Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

[Full changelog](https://github.com/mozilla/glean.js/compare/v0.15.0...main)

* [#399](https://github.com/mozilla/glean.js/pull/399): Check if there are ping data before attempting to delete it.
* This change lowers the amount of log messages related to attempting to delete inexistent data.

# v0.15.0 (2021-06-03)

[Full changelog](https://github.com/mozilla/glean.js/compare/v0.14.1...v0.15.0)
Expand Down
1 change: 1 addition & 0 deletions glean/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ dist
venv
node_modules
qt.js
tests/integration/schema/generated
2 changes: 1 addition & 1 deletion glean/src/core/metrics/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class MetricsDatabase {
const pingData = await this.getAndValidatePingData(ping, Lifetime.Ping);
const appData = await this.getAndValidatePingData(ping, Lifetime.Application);

if (clearPingLifetimeData) {
if (clearPingLifetimeData && Object.keys(pingData).length > 0) {
await this.clear(Lifetime.Ping, ping);
}

Expand Down
2 changes: 1 addition & 1 deletion glean/src/core/metrics/events_database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class EventsDatabase {
async getPingEvents(ping: string, clearPingLifetimeData: boolean): Promise<JSONArray | undefined> {
const pingData = await this.getAndValidatePingData(ping);

if (clearPingLifetimeData) {
if (clearPingLifetimeData && Object.keys(pingData).length > 0) {
await this.eventsStore.delete([ping]);
}

Expand Down
2 changes: 1 addition & 1 deletion glean/src/core/storage/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export function deleteKeyFromNestedObject(obj: JSONObject, index: StorageIndex):
for (const key of index.slice(0, index.length - 1)) {
const value = target[key];
if (!isObject(value)) {
throw Error("Attempted to delete an entry from an invalid index.");
throw Error(`Attempted to delete an entry from an inexistent index: ${JSON.stringify(index)}.`);
} else {
target = value;
}
Expand Down