-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(analytics): send level field in the setup call
- Loading branch information
1 parent
0ebf396
commit 0f82ac0
Showing
5 changed files
with
71 additions
and
8 deletions.
There are no files selected for viewing
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,5 @@ | ||
--- | ||
'@adyen/adyen-web': patch | ||
--- | ||
|
||
Send `level` field to the analytic `setup` call. If analytics is `enabled`, we send `level` value `all`, otherwise we send `initial`. |
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,47 @@ | ||
import Analytics from './Analytics'; | ||
import collectId from '../Services/analytics/collect-id'; | ||
|
||
jest.mock('../Services/analytics/collect-id'); | ||
|
||
const mockedCollectId = collectId as jest.Mock; | ||
|
||
describe('Analytics setup call', () => { | ||
const mockCollectIdPromise: jest.Mock = jest.fn(); | ||
|
||
beforeEach(() => { | ||
mockCollectIdPromise.mockResolvedValue(null); | ||
mockedCollectId.mockImplementation(() => mockCollectIdPromise); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should send "initial" value for the level field', async () => { | ||
const analytics = Analytics({ | ||
amount: undefined, | ||
bundleType: '', | ||
clientKey: undefined, | ||
loadingContext: undefined, | ||
locale: undefined, | ||
analytics: { | ||
enabled: false | ||
} | ||
}); | ||
|
||
await analytics.setUp({ component: '', containerWidth: 0, flavor: '' }); | ||
expect(mockCollectIdPromise).toHaveBeenCalledWith(expect.objectContaining({ level: 'initial' })); | ||
}); | ||
|
||
it('should send "all" value for the level field', async () => { | ||
await Analytics({ | ||
amount: undefined, | ||
bundleType: '', | ||
clientKey: undefined, | ||
loadingContext: undefined, | ||
locale: undefined | ||
}).setUp({ component: '', containerWidth: 0, flavor: '' }); | ||
|
||
expect(mockCollectIdPromise).toHaveBeenCalledWith(expect.objectContaining({ level: 'all' })); | ||
}); | ||
}); |
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