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

improvement(core): include user-agent for internal rpc calls #204

Merged
merged 3 commits into from
Apr 24, 2020

Conversation

xavdid
Copy link
Contributor

@xavdid xavdid commented Apr 23, 2020

This helps us identify these calls internally. Hopefully will help prevent things like this.

Also cleaned up some promise code while I was in there.

@xavdid xavdid requested a review from eliangcs as a code owner April 23, 2020 22:43
@xavdid
Copy link
Contributor Author

xavdid commented Apr 23, 2020

I'm OOO friday, so if this looks good and you still plan on cutting 9.4.0, then kindly merge this before you release.

also given that there's no API-level changes (that is, the surface of the code didn't change at all), it's probably better as 9.3.1. NBD either way though!

module.exports = {
DEFAULT_LOGGING_HTTP_API_KEY,
DEFAULT_LOGGING_HTTP_ENDPOINT,
HYDRATE_DIRECTIVE_HOIST,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorting

Copy link
Member

@eliangcs eliangcs left a comment

Choose a reason for hiding this comment

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

I have a suggestion about the User-Agent header format. If you agree, feel free to merge once you adopt the suggested change. If you don't, let me know what you think.

also given that there's no API-level changes (that is, the surface of the code didn't change at all), it's probably better as 9.3.1.

There's one actually: #195 adds an allowGetBody option to the z.request API. I kind of consider it a public API change, even though we don't encourage using it.

I'll hold on to 9.4.0 release until this PR is merged.

const { url: fetchUrl, ...fetchOptions } = options;

fetchOptions.headers = {
'user-agent': `${PACKAGE_NAME} v${PACKAGE_VERSION} (via node-fetch)`,
Copy link
Member

Choose a reason for hiding this comment

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

Should we make the format consistent with the CLI?

'User-Agent': `${constants.PACKAGE_NAME}/${constants.PACKAGE_VERSION}`,

I'd also suggest removing the (via node-fetch) part. Two reasons: 1) zapier-platform-core/<version> alone can already help us infer the underlying HTTP client library we use. 2) Minor, but it's easy to forget to update it if we were to replace node-fetch with something else.

So the suggested change would be:

Suggested change
'user-agent': `${PACKAGE_NAME} v${PACKAGE_VERSION} (via node-fetch)`,
'user-agent': `${PACKAGE_NAME}/${PACKAGE_VERSION}`,

@xavdid
Copy link
Contributor Author

xavdid commented Apr 24, 2020 via email

@eliangcs eliangcs merged commit f1fa3a4 into master Apr 24, 2020
@eliangcs eliangcs deleted the add-internal-user-agent branch April 24, 2020 09:25
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.

None yet

2 participants