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

feat: standardize user agent value #1775

Merged
merged 18 commits into from
Dec 19, 2020
Merged

Conversation

AllanZhengYP
Copy link
Contributor

The purpose of this change is to standardize the user agent behavior across the AWS tools. A brief summary is:

  1. Only basic version information will be sent with User-Agent header: aws-sdk-js/[version];
  2. More tracking metrics are sent with x-amz-user-agent header
  3. User specified user agent prefix are prepended onto both headers.
  4. Include required tool id and version: aws-sdk-js/[version],
  5. Include required language identifier and version: lang/js,
  6. Include optional language metadata: md/nodejs/[version] or md/browser/[version] or md/rn/[version]
  7. Include required OS info: os/[name]/[version]
  8. include optional modular SDK module version: api/[serviceId]/[version]
  9. include optional client config like: cfg/retry-mode/[mode]

Here's an example UA string:
aws-sdk-js/3.0.0-rc.9 os/linux/4.14.200-155.322.amzn2.x86_64 lang/js md/nodejs/12.14.0 api/iam/3.0.0-rc.9 cfg/retry-mode/standard

In browser, I introduced bowser to make best effort infer the OS and browser version from the UA string. This is so far the best choice considering downloads, size, and GH activities.

TODO: bellows are features to be addressed in following PR:

  1. Paginator, waiter and lib-storage has limitation of adding ft/[paginator, waiter, s3-transfer] ua to these requests. We need to address the issues with these features before we can add user agent for them.

A noteworthy change in this PR is that I added a UserAgent abstraction. So users don't need to deal with the string concatenation, instead they can just put the tuple by context.userAgent.push(["foo-api", "1.0.0"])

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

codegen/.vscode/settings.json Outdated Show resolved Hide resolved
packages/util-user-agent-browser/src/index.ts Outdated Show resolved Hide resolved
packages/util-user-agent-browser/src/index.native.ts Outdated Show resolved Hide resolved
packages/util-user-agent-node/src/index.ts Outdated Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented Dec 15, 2020

Codecov Report

Merging #1775 (0d861f7) into master (de75f7e) will decrease coverage by 0.49%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1775      +/-   ##
==========================================
- Coverage   79.77%   79.28%   -0.50%     
==========================================
  Files         325      367      +42     
  Lines       12087    15118    +3031     
  Branches     2553     3221     +668     
==========================================
+ Hits         9643    11987    +2344     
- Misses       2444     3131     +687     
Impacted Files Coverage Δ
protocol_tests/aws-json/models/models_0.ts 79.36% <0.00%> (-20.64%) ⬇️
packages/util-user-agent-node/src/index.ts 88.88% <0.00%> (-11.12%) ⬇️
protocol_tests/aws-restjson/models/models_0.ts 89.43% <0.00%> (-10.57%) ⬇️
...rotocol_tests/aws-restxml/protocols/Aws_restXml.ts 64.10% <0.00%> (-2.15%) ⬇️
...ackages/node-http-handler/src/node-http-handler.ts 98.00% <0.00%> (-2.00%) ⬇️
packages/middleware-sdk-sqs/src/send-message.ts 86.66% <0.00%> (-0.84%) ⬇️
protocol_tests/aws-query/protocols/Aws_query.ts 66.34% <0.00%> (-0.38%) ⬇️
...kages/middleware-sdk-sqs/src/send-message-batch.ts 92.30% <0.00%> (-0.29%) ⬇️
...kages/fetch-http-handler/src/fetch-http-handler.ts 9.30% <0.00%> (-0.23%) ⬇️
protocol_tests/aws-ec2/protocols/Aws_ec2.ts 66.93% <0.00%> (-0.01%) ⬇️
... and 187 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e151aee...0d861f7. Read the comment docs.

@AllanZhengYP AllanZhengYP marked this pull request as ready for review December 15, 2020 01:52
@github-actions
Copy link

github-actions bot commented Jan 8, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 8, 2021
@trivikr
Copy link
Member

trivikr commented Jun 25, 2021

Revisiting this PR to check User Agent values before and after:

Node.js:

  • Before: aws-sdk-nodejs-v3-@aws-sdk/client-dynamodb/1.0.0-rc.10 darwin/v14.17.1
  • After: aws-sdk-js/3.1.0 os/darwin/20.5.0 lang/js md/nodejs/14.17.1 api/dynamodb/3.1.0

Browser:

  • Before: aws-sdk-js-v3-@aws-sdk/client-dynamodb/1.0.0-rc.10 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36
  • After: aws-sdk-js/3.1.0 os/macOS/10.15.7 lang/js md/browser/Chrome_91.0.4472.114 api/dynamodb/3.1.0

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

Successfully merging this pull request may close these issues.

None yet

3 participants