-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(analytics): Use custom user agent in all Analytics providers (#1…
- Loading branch information
Showing
8 changed files
with
98 additions
and
10 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
packages/analytics/__tests__/Providers/CustomUserAgent.test.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { | ||
AmazonPersonalizeProvider, | ||
AWSKinesisFirehoseProvider, | ||
AWSKinesisProvider, | ||
AWSPinpointProvider, | ||
} from '../../src/Providers'; | ||
|
||
describe('Each provider client is configured with the custom user client', () => { | ||
describe('AmazonPersonalizeProvider', () => { | ||
test('received the custom user client', () => { | ||
const provider = new AmazonPersonalizeProvider(); | ||
// Run init to setup the client | ||
provider['_init']({ region: 'us-east-1' }, {}); | ||
|
||
expect( | ||
provider['_personalize']['config']['customUserAgent'] | ||
).toMatchObject([ | ||
['aws-amplify', expect.any(String)], | ||
['analytics', '1'], | ||
['framework', '0'], | ||
]); | ||
}); | ||
}); | ||
|
||
describe('AWSKinesisFirehoseProvider', () => { | ||
test('received the custom user client', () => { | ||
const provider = new AWSKinesisFirehoseProvider(); | ||
// Run init to setup the client | ||
provider['_init']({ region: 'us-east-1' }, {}); | ||
|
||
expect( | ||
provider['_kinesisFirehose']['config']['customUserAgent'] | ||
).toMatchObject([ | ||
['aws-amplify', expect.any(String)], | ||
['analytics', '1'], | ||
['framework', '0'], | ||
]); | ||
}); | ||
}); | ||
|
||
describe('AWSKinesisProvider', () => { | ||
test('received the custom user client', () => { | ||
const provider = new AWSKinesisProvider(); | ||
// Run init to setup the client | ||
provider['_init']({ region: 'us-east-1' }, {}); | ||
|
||
expect(provider['_kinesis']['config']['customUserAgent']).toMatchObject([ | ||
['aws-amplify', expect.any(String)], | ||
['analytics', '1'], | ||
['framework', '0'], | ||
]); | ||
}); | ||
}); | ||
|
||
describe('AWSPinpointProvider', () => { | ||
test('received the custom user client', () => { | ||
const provider = new AWSPinpointProvider({ region: 'us-east-1' }); | ||
// Run init to setup the client | ||
provider['_initClients']({}); | ||
|
||
expect( | ||
provider['pinpointClient']['config']['customUserAgent'] | ||
).toMatchObject([ | ||
['aws-amplify', expect.any(String)], | ||
['analytics', '1'], | ||
['framework', '0'], | ||
]); | ||
}); | ||
}); | ||
}); |
This file contains 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { | ||
AnalyticsAction, | ||
Category, | ||
getAmplifyUserAgent, | ||
} from '@aws-amplify/core'; | ||
|
||
export function getAnalyticsUserAgent() { | ||
return getAmplifyUserAgent({ | ||
category: Category.Analytics, | ||
action: AnalyticsAction.Record, | ||
}); | ||
} |
This file contains 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 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