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

Support for push report metrics endpoint. #98

Merged
merged 5 commits into from
Feb 7, 2022
Merged

Conversation

lisaah
Copy link
Contributor

@lisaah lisaah commented Feb 1, 2022

The base url for this endpoint doesn't seem to obey the api/v1 standard of the rest.

Copy link
Collaborator

@mike-engel mike-engel left a comment

Choose a reason for hiding this comment

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

Thanks @lisaah for this PR! Just a few notes for types and backwards compatibility

lib/regions.ts Outdated

constructor(trackUrl: string, apiUrl: string) {
constructor(trackUrl: string, apiUrl: string, trackPushUrl: string) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

To maintain backwards compatibility, this should be optional. I doubt anyone is creating their own Regions, but just in case!

lib/track.ts Outdated
@@ -20,6 +20,7 @@ export class TrackClient {
request: Request;
trackRoot: string;
apiRoot: string;
trackPushRoot: string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similarly, this should be optional

lib/track.ts Outdated
@@ -98,6 +100,10 @@ export class TrackClient {
});
}

trackPush(data: RequestData = {}) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

A few things here:

  • data should be more strongly typed. According to the api docs, there are only four valid parameters. A type or interface should be created for trackPush to only allow those four (requried) parameters
  • There should be special handling if this.trackPushRoot is undefined. Probably a MissingParamError or a new Error subclass

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 Added the typing, can make it required but the docs don't seem to annotate them as required like it does for name in regular events.

@lisaah lisaah requested a review from mike-engel February 2, 2022 17:31
@mike-engel
Copy link
Collaborator

@lisaah thanks for the updates! I'm sorry about the back and forth, but after you opened this PR I had a chat with the team about why the push metrics endpoint was different, and we all agreed it was a bit weird. We've made a change in production that adds /api/v1/push/metrics, so I think the extra handling for the push URL can be removed (but you can leave the PushRequestData and trackPush code in!)

@lisaah
Copy link
Contributor Author

lisaah commented Feb 3, 2022

@lisaah thanks for the updates! I'm sorry about the back and forth, but after you opened this PR I had a chat with the team about why the push metrics endpoint was different, and we all agreed it was a bit weird. We've made a change in production that adds /api/v1/push/metrics, so I think the extra handling for the push URL can be removed (but you can leave the PushRequestData and trackPush code in!)

Sure, think it makes the code cleaner that way anyways.

@mike-engel mike-engel merged commit 089c570 into customerio:main Feb 7, 2022
@mike-engel
Copy link
Collaborator

Thanks again @lisaah, this has been published with 3.2.0!

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