-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug 1688902 - Create the events metric type #36
Conversation
This introduces the `test:unit` npm script, which quickly runs all the unit tests.
This field is required, but it can be an empty string.
This is modeled after the events database in the Glean SDK (without the append-only file).
This is the primary API for dealing with events.
Change the payload structure to declare them as an array instead of an object.
src/metrics/events_database.ts
Outdated
private eventsStore: Store; | ||
|
||
constructor() { | ||
this.eventsStore = new WeakStore("unused"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably use the persistent storage :-P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, I think this one was missed :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approach looks fine for me overall. Left a bunch of comments but most of them are nits.
My main concern is the liberal usage of as
to bypass the type checker.
src/metrics/events_database.ts
Outdated
private eventsStore: Store; | ||
|
||
constructor() { | ||
this.eventsStore = new WeakStore("unused"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, I think this one was missed :)
src/metrics/events_database.ts
Outdated
): Promise<RecordedEvent[] | undefined> { | ||
const events = await this.getAndValidatePingData(ping); | ||
if (events.length === 0) { | ||
return undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uber nit: If you change the return type to Promise<RecordedEvent[] | void>
you can do just return;
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r+wc!
src/metrics/events_database.ts
Outdated
@@ -91,7 +81,7 @@ class EventsDatabase { | |||
private eventsStore: Store; | |||
|
|||
constructor() { | |||
this.eventsStore = new WeakStore("unused"); | |||
this.eventsStore = new PersistentStore("unused"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"unused"
may not the most descriptive storage name. Maybe "events"
?
See the individual commit messages descriptions for easier review.
This exclusively adds the metric type, it doesn't take care of adding the 'events' ping.