Skip to content
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

Merged
merged 12 commits into from
Feb 3, 2021

Conversation

Dexterp37
Copy link
Contributor

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.

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.
@Dexterp37 Dexterp37 self-assigned this Feb 2, 2021
private eventsStore: Store;

constructor() {
this.eventsStore = new WeakStore("unused");
Copy link
Contributor Author

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

Copy link
Contributor

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 :)

Copy link
Contributor

@brizental brizental left a 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.

package.json Outdated Show resolved Hide resolved
src/metrics/index.ts Outdated Show resolved Hide resolved
src/metrics/events_database.ts Outdated Show resolved Hide resolved
src/metrics/events_database.ts Outdated Show resolved Hide resolved
src/metrics/events_database.ts Outdated Show resolved Hide resolved
src/metrics/events_database.ts Outdated Show resolved Hide resolved
src/metrics/events_database.ts Outdated Show resolved Hide resolved
src/metrics/types/event.ts Outdated Show resolved Hide resolved
src/metrics/types/event.ts Outdated Show resolved Hide resolved
src/metrics/types/event.ts Outdated Show resolved Hide resolved
private eventsStore: Store;

constructor() {
this.eventsStore = new WeakStore("unused");
Copy link
Contributor

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 :)

): Promise<RecordedEvent[] | undefined> {
const events = await this.getAndValidatePingData(ping);
if (events.length === 0) {
return undefined;
Copy link
Contributor

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.

Copy link
Contributor

@brizental brizental left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+wc!

@@ -91,7 +81,7 @@ class EventsDatabase {
private eventsStore: Store;

constructor() {
this.eventsStore = new WeakStore("unused");
this.eventsStore = new PersistentStore("unused");
Copy link
Contributor

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"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants