Skip to content

Commit f7363ca

Browse files
committed
Bug 1851698 - Update default maxEvents to 1
changelog - set the default `maxEvents` number to 1 - update existing tests that rely on having more than 1 event - update comments in `pings.yaml`
1 parent f4c9b0e commit f7363ca

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[Full changelog](https://github.com/mozilla/glean.js/compare/v2.0.1...main)
44

55
* [#1755](https://github.com/mozilla/glean.js/pull/1755): Add sync check to `set` function for the URL metric.
6+
* [#1766](https://github.com/mozilla/glean.js/pull/1766): Update default `maxEvents` count to 1. This means an events ping will be sent after each recorded event unless the `maxEvents` count is explicitly set to a larger number.
67

78
# v2.0.1 (2023-08-11)
89

glean/src/core/config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import { Context } from "./context.js";
1111

1212
const LOG_TAG = "core.Config";
1313

14-
// The default maximum number of events Glean will store before submitting the events ping.
15-
// If the maximum is hit, the events ping is sent immediately.
16-
const DEFAULT_MAX_EVENTS = 500;
14+
// By default we want to send the events ping after every event is recorded. Unless the user
15+
// explicitly sets a higher value, we will send the events ping after every event.
16+
const DEFAULT_MAX_EVENTS = 1;
1717

1818
/**
1919
* Lists Glean's debug options.

glean/src/pings.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ events:
4141
from the previous application run in storage.
4242
It is also sent when maximum capacity is hit
4343
i.e. when a given number of events is in storage.
44-
Maximum capacity defaults to 500,
44+
Maximum capacity defaults to 1,
4545
but may be changed through the `maxEvents` configuration option.
4646
include_client_id: true
4747
bugs:
@@ -56,7 +56,7 @@ events:
5656
The events ping is always sent if there are any pending events at startup,
5757
because event timestamps are not as reliable across application runs.
5858
max_capacity: |
59-
The maximum number of events was reached (default 500 events).
59+
The maximum number of events was reached (default 1 event).
6060
inactive: |
6161
The ping was submitted when becoming inactive. In earlier versions, this
6262
was called `background`.

glean/tests/unit/core/metrics/events_database.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ describe("EventsDatabase", function() {
755755
// Restore timer APIs for WaitableUploader to work
756756
clock.restore();
757757

758+
await testResetGlean(testAppId, true, { maxEvents: 500 });
759+
758760
const event = new EventMetricType({
759761
category: "test",
760762
name: "event",
@@ -780,6 +782,8 @@ describe("EventsDatabase", function() {
780782
// Restore timer APIs for WaitableUploader to work
781783
clock.restore();
782784

785+
await testResetGlean(testAppId, true, { maxEvents: 500 });
786+
783787
const previousRunEvent = new EventMetricType({
784788
category: "test",
785789
name: "previousRun",
@@ -809,7 +813,7 @@ describe("EventsDatabase", function() {
809813
const httpClient = new WaitableUploader();
810814
const waitForEventsPings = httpClient.waitForBatchPingSubmission(EVENTS_PING_NAME, 2);
811815
// Initialization should trigger a startup ping
812-
await testInitializeGlean(testAppId, true, { httpClient });
816+
await testInitializeGlean(testAppId, true, { httpClient, maxEvents: 500 });
813817
// Send another 'events' ping after init, it should contain the preInit events
814818
await Context.corePings.events.submitUndispatched();
815819

0 commit comments

Comments
 (0)