-
Notifications
You must be signed in to change notification settings - Fork 633
feat(middleware-user-agent): add client config for userAgentAppId #6524
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
Merged
Merged
Changes from 17 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
2afbfb5
feat(codegen): add codegen for userAgentAppId
siddsriv c973314
chore(codegen): comment update
siddsriv 70f7722
fix(codegen): formatting fixes
siddsriv 11fb1b9
fix(codegen): correct appId type
siddsriv 86b6c2d
chore(codegen): comments
siddsriv df70919
chore(codegen): comment update
siddsriv d731ec6
chore(codegen): merge appId codegen into existing UA codegen
siddsriv b9e9e19
chore(codegen): update typescript integration for codegen change in p…
siddsriv 22dd421
chore(codegen): keep codegen style consistent for runtimeConfigs
siddsriv 49e3086
chore(codegen): style/comment update
siddsriv ad89eac
feat(middleware-user-agent): appId config resolvers and accompanying …
siddsriv b47f801
fix(middleware-user-agent): add smithy core in deps
siddsriv a067a37
test(middleware-user-agent): add case for appId
siddsriv 1c079c5
test(middleware-user-agent): case for long appId
siddsriv 9e0ed22
feat(util-user-agent-browser): add appId collection
siddsriv 919f209
test(util-user-agent-node): add appId case
siddsriv 8707e8d
test(util-user-agent-node): test update for mock env
siddsriv ce01280
chore(middleware-user-agent): formatting fixes
siddsriv bceeb93
docs(supplemental-docs): add userAgentAppId in CLIENTS
siddsriv 79cf144
docs(supplemental-docs): correct example
siddsriv efd2bae
chore(clients): codege
siddsriv 1b7cb36
test(util-user-agent-node): unit test update to mock before import
siddsriv 1b8c57a
Merge branch 'main' into feat/UAAppId
siddsriv 51edd2d
chore(util-user-agent-node): remove explicit return type
siddsriv 6b97cc8
chore(private): add userAgentAppId explicitly for interface test fix
siddsriv 7d656b0
chore(middleware-user-agent): deps update
siddsriv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,50 @@ | ||
import { defaultUserAgent } from "."; | ||
import { defaultUserAgent, PreviouslyResolved } from "."; | ||
|
||
const ua = | ||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36"; | ||
|
||
it("should populate metrics", async () => { | ||
jest.spyOn(window.navigator, "userAgent", "get").mockReturnValue(ua); | ||
const userAgent = await defaultUserAgent({ serviceId: "s3", clientVersion: "0.1.0" })(); | ||
expect(userAgent[0]).toEqual(["aws-sdk-js", "0.1.0"]); | ||
expect(userAgent[1]).toEqual(["ua", "2.0"]); | ||
expect(userAgent[2]).toEqual(["os/macOS", "10.15.7"]); | ||
expect(userAgent[3]).toEqual(["lang/js"]); | ||
expect(userAgent[4]).toEqual(["md/browser", "Chrome_86.0.4240.111"]); | ||
expect(userAgent[5]).toEqual(["api/s3", "0.1.0"]); | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it("should populate metrics when service id not available", async () => { | ||
jest.spyOn(window.navigator, "userAgent", "get").mockReturnValue(ua); | ||
const userAgent = await defaultUserAgent({ serviceId: undefined, clientVersion: "0.1.0" })(); | ||
expect(userAgent).not.toContainEqual(["api/s3", "0.1.0"]); | ||
jest.clearAllMocks(); | ||
}); | ||
const mockConfig: PreviouslyResolved = { | ||
userAgentAppId: jest.fn().mockResolvedValue(undefined), | ||
}; | ||
|
||
describe("defaultUserAgent", () => { | ||
beforeEach(() => { | ||
jest.spyOn(window.navigator, "userAgent", "get").mockReturnValue(ua); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it("should populate metrics", async () => { | ||
const userAgent = await defaultUserAgent({ serviceId: "s3", clientVersion: "0.1.0" })(mockConfig); | ||
expect(userAgent[0]).toEqual(["aws-sdk-js", "0.1.0"]); | ||
expect(userAgent[1]).toEqual(["ua", "2.0"]); | ||
expect(userAgent[2]).toEqual(["os/macOS", "10.15.7"]); | ||
expect(userAgent[3]).toEqual(["lang/js"]); | ||
expect(userAgent[4]).toEqual(["md/browser", "Chrome_86.0.4240.111"]); | ||
expect(userAgent[5]).toEqual(["api/s3", "0.1.0"]); | ||
expect(userAgent.length).toBe(6); | ||
}); | ||
|
||
it("should populate metrics when service id not available", async () => { | ||
const userAgent = await defaultUserAgent({ serviceId: undefined, clientVersion: "0.1.0" })(mockConfig); | ||
expect(userAgent).not.toContainEqual(["api/s3", "0.1.0"]); | ||
expect(userAgent.length).toBe(5); | ||
}); | ||
|
||
it("should include appId when provided", async () => { | ||
const configWithAppId: PreviouslyResolved = { | ||
userAgentAppId: jest.fn().mockResolvedValue("test-app-id"), | ||
}; | ||
const userAgent = await defaultUserAgent({ serviceId: "s3", clientVersion: "0.1.0" })(configWithAppId); | ||
expect(userAgent[6]).toEqual(["app/test-app-id"]); | ||
expect(userAgent.length).toBe(7); | ||
}); | ||
|
||
it("should not include appId when not provided", async () => { | ||
const userAgent = await defaultUserAgent({ serviceId: "s3", clientVersion: "0.1.0" })(mockConfig); | ||
expect(userAgent).not.toContainEqual(expect.arrayContaining(["app/"])); | ||
expect(userAgent.length).toBe(6); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.