-
Notifications
You must be signed in to change notification settings - Fork 64
[Fix] attributeEncoders are not registered nor called #1441
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 all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,9 +22,10 @@ import { DdRumUserInteractionTracking } from '../rum/instrumentation/interaction | |
| import { DdRumResourceTracking } from '../rum/instrumentation/resourceTracking/DdRumResourceTracking'; | ||
| import { PropagatorType, RumActionType } from '../rum/types'; | ||
| import { AttributesSingleton } from '../sdk/AttributesSingleton/AttributesSingleton'; | ||
| import { NativeDdSdk } from '../sdk/DdSdkInternal'; | ||
| import { DdSdkWrapper } from '../sdk/DdSdkInternal'; | ||
| import { GlobalState } from '../sdk/GlobalState/GlobalState'; | ||
| import { UserInfoSingleton } from '../sdk/UserInfoSingleton/UserInfoSingleton'; | ||
| import NativeDdSdkSpec from '../specs/NativeDdSdk'; | ||
| import type { LogEvent } from '../types'; | ||
| import { ErrorSource } from '../types'; | ||
| import { version as sdkVersion } from '../version'; | ||
|
|
@@ -1184,8 +1185,8 @@ describe('DdSdkReactNative', () => { | |
| await DdSdkReactNative.addAttribute(key, value); | ||
|
|
||
| // THEN | ||
| expect(NativeDdSdk.addAttribute).toHaveBeenCalledTimes(1); | ||
| expect(NativeDdSdk.addAttribute).toHaveBeenCalledWith(key, { | ||
| expect(NativeDdSdkSpec.addAttribute).toHaveBeenCalledTimes(1); | ||
| expect(NativeDdSdkSpec.addAttribute).toHaveBeenCalledWith(key, { | ||
| value | ||
| }); | ||
| expect(AttributesSingleton.getInstance().getAttribute(key)).toEqual( | ||
|
|
@@ -1205,8 +1206,8 @@ describe('DdSdkReactNative', () => { | |
| await DdSdkReactNative.removeAttribute(key); | ||
|
|
||
| // THEN | ||
| expect(NativeDdSdk.removeAttribute).toHaveBeenCalledTimes(1); | ||
| expect(NativeDdSdk.removeAttribute).toHaveBeenCalledWith(key); | ||
| expect(NativeDdSdkSpec.removeAttribute).toHaveBeenCalledTimes(1); | ||
| expect(NativeDdSdkSpec.removeAttribute).toHaveBeenCalledWith(key); | ||
| expect(AttributesSingleton.getInstance().getAttribute(key)).toEqual( | ||
| undefined | ||
| ); | ||
|
|
@@ -1223,8 +1224,10 @@ describe('DdSdkReactNative', () => { | |
| await DdSdkReactNative.addAttributes(attributes); | ||
|
|
||
| // THEN | ||
| expect(NativeDdSdk.addAttributes).toHaveBeenCalledTimes(1); | ||
| expect(NativeDdSdk.addAttributes).toHaveBeenCalledWith(attributes); | ||
| expect(NativeDdSdkSpec.addAttributes).toHaveBeenCalledTimes(1); | ||
| expect(NativeDdSdkSpec.addAttributes).toHaveBeenCalledWith( | ||
| attributes | ||
| ); | ||
| expect(AttributesSingleton.getInstance().getAttributes()).toEqual({ | ||
| foo: 'bar' | ||
| }); | ||
|
|
@@ -1241,8 +1244,8 @@ describe('DdSdkReactNative', () => { | |
| await DdSdkReactNative.removeAttributes(['foo', 'baz']); | ||
|
|
||
| // THEN | ||
| expect(NativeDdSdk.removeAttributes).toHaveBeenCalledTimes(1); | ||
| expect(NativeDdSdk.removeAttributes).toHaveBeenCalledWith([ | ||
| expect(NativeDdSdkSpec.removeAttributes).toHaveBeenCalledTimes(1); | ||
| expect(NativeDdSdkSpec.removeAttributes).toHaveBeenCalledWith([ | ||
| 'foo', | ||
| 'baz' | ||
| ]); | ||
|
|
@@ -1268,8 +1271,8 @@ describe('DdSdkReactNative', () => { | |
| await DdSdkReactNative.setUserInfo(userInfo); | ||
|
|
||
| // THEN | ||
| expect(NativeDdSdk.setUserInfo).toHaveBeenCalledTimes(1); | ||
| expect(NativeDdSdk.setUserInfo).toHaveBeenCalledWith(userInfo); | ||
| expect(NativeDdSdkSpec.setUserInfo).toHaveBeenCalledTimes(1); | ||
| expect(NativeDdSdkSpec.setUserInfo).toHaveBeenCalledWith(userInfo); | ||
| expect(UserInfoSingleton.getInstance().getUserInfo()).toEqual( | ||
| userInfo | ||
| ); | ||
|
|
@@ -1289,8 +1292,8 @@ describe('DdSdkReactNative', () => { | |
| await DdSdkReactNative.addUserExtraInfo(extraInfo); | ||
|
|
||
| // THEN | ||
| expect(NativeDdSdk.addUserExtraInfo).toHaveBeenCalledTimes(1); | ||
| expect(NativeDdSdk.addUserExtraInfo).toHaveBeenCalledWith( | ||
| expect(NativeDdSdkSpec.addUserExtraInfo).toHaveBeenCalledTimes(1); | ||
| expect(NativeDdSdkSpec.addUserExtraInfo).toHaveBeenCalledWith( | ||
| extraInfo | ||
| ); | ||
| expect(UserInfoSingleton.getInstance().getUserInfo()).toEqual({ | ||
|
|
@@ -1310,7 +1313,7 @@ describe('DdSdkReactNative', () => { | |
| await DdSdkReactNative.addUserExtraInfo(extraInfo); | ||
|
|
||
| // THEN | ||
| expect(NativeDdSdk.addUserExtraInfo).toHaveBeenCalledWith( | ||
| expect(NativeDdSdkSpec.addUserExtraInfo).toHaveBeenCalledWith( | ||
| extraInfo | ||
| ); | ||
| expect(UserInfoSingleton.getInstance().getUserInfo()).toEqual({ | ||
|
|
@@ -1339,8 +1342,8 @@ describe('DdSdkReactNative', () => { | |
| await DdSdkReactNative.clearUserInfo(); | ||
|
|
||
| // THEN | ||
| expect(NativeDdSdk.clearUserInfo).toHaveBeenCalledTimes(1); | ||
| expect(NativeDdSdk.setUserInfo).toHaveBeenCalled(); | ||
| expect(NativeDdSdkSpec.clearUserInfo).toHaveBeenCalledTimes(1); | ||
| expect(NativeDdSdkSpec.setUserInfo).toHaveBeenCalled(); | ||
| expect( | ||
| UserInfoSingleton.getInstance().getUserInfo() | ||
| ).toBeUndefined(); | ||
|
|
@@ -1357,8 +1360,8 @@ describe('DdSdkReactNative', () => { | |
| DdSdkReactNative.setTrackingConsent(consent); | ||
|
|
||
| // THEN | ||
| expect(NativeDdSdk.setTrackingConsent).toHaveBeenCalledTimes(1); | ||
| expect(NativeDdSdk.setTrackingConsent).toHaveBeenCalledWith( | ||
| expect(NativeDdSdkSpec.setTrackingConsent).toHaveBeenCalledTimes(1); | ||
| expect(NativeDdSdkSpec.setTrackingConsent).toHaveBeenCalledWith( | ||
| consent | ||
| ); | ||
| }); | ||
|
|
@@ -1370,7 +1373,7 @@ describe('DdSdkReactNative', () => { | |
| DdSdkReactNative.clearAllData(); | ||
|
|
||
| // THEN | ||
| expect(NativeDdSdk.clearAllData).toHaveBeenCalledTimes(1); | ||
| expect(NativeDdSdkSpec.clearAllData).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); | ||
|
|
||
|
|
@@ -1500,4 +1503,121 @@ describe('DdSdkReactNative', () => { | |
| }); | ||
| } | ||
| ); | ||
| describe('routing through DdSdkWrapper', () => { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This new set of tests make sure that the |
||
| it('DdSdkReactNative.addAttribute reaches the native spec via the wrapper', async () => { | ||
| const spy = jest.spyOn(DdSdkWrapper.prototype, 'addAttribute'); | ||
|
|
||
| await DdSdkReactNative.addAttribute('key', 'value'); | ||
|
|
||
| expect(spy).toHaveBeenCalled(); | ||
| spy.mockRestore(); | ||
| }); | ||
|
|
||
| it('DdSdkReactNative.removeAttribute reaches the native spec via the wrapper', async () => { | ||
| const spy = jest.spyOn(DdSdkWrapper.prototype, 'removeAttribute'); | ||
|
|
||
| await DdSdkReactNative.removeAttribute('key'); | ||
|
|
||
| expect(spy).toHaveBeenCalled(); | ||
| spy.mockRestore(); | ||
| }); | ||
|
|
||
| it('DdSdkReactNative.addAttributes reaches the native spec via the wrapper', async () => { | ||
| const spy = jest.spyOn(DdSdkWrapper.prototype, 'addAttributes'); | ||
|
|
||
| await DdSdkReactNative.addAttributes({ key: 'value' }); | ||
|
|
||
| expect(spy).toHaveBeenCalled(); | ||
| spy.mockRestore(); | ||
| }); | ||
|
|
||
| it('DdSdkReactNative.removeAttributes reaches the native spec via the wrapper', async () => { | ||
| const spy = jest.spyOn(DdSdkWrapper.prototype, 'removeAttributes'); | ||
|
|
||
| await DdSdkReactNative.removeAttributes(['key']); | ||
|
|
||
| expect(spy).toHaveBeenCalled(); | ||
| spy.mockRestore(); | ||
| }); | ||
|
|
||
| it('DdSdkReactNative.setUserInfo reaches the native spec via the wrapper', async () => { | ||
| const spy = jest.spyOn(DdSdkWrapper.prototype, 'setUserInfo'); | ||
|
|
||
| await DdSdkReactNative.setUserInfo({ id: 'user-id' }); | ||
|
|
||
| expect(spy).toHaveBeenCalled(); | ||
| spy.mockRestore(); | ||
| }); | ||
|
|
||
| it('DdSdkReactNative.clearUserInfo reaches the native spec via the wrapper', async () => { | ||
| const spy = jest.spyOn(DdSdkWrapper.prototype, 'clearUserInfo'); | ||
|
|
||
| await DdSdkReactNative.clearUserInfo(); | ||
|
|
||
| expect(spy).toHaveBeenCalled(); | ||
| spy.mockRestore(); | ||
| }); | ||
|
|
||
| it('DdSdkReactNative.addUserExtraInfo reaches the native spec via the wrapper', async () => { | ||
| const spy = jest.spyOn(DdSdkWrapper.prototype, 'addUserExtraInfo'); | ||
|
|
||
| await DdSdkReactNative.addUserExtraInfo({ role: 'admin' }); | ||
|
|
||
| expect(spy).toHaveBeenCalled(); | ||
| spy.mockRestore(); | ||
| }); | ||
|
|
||
| it('DdSdkReactNative.setAccountInfo reaches the native spec via the wrapper', async () => { | ||
| const spy = jest.spyOn(DdSdkWrapper.prototype, 'setAccountInfo'); | ||
|
|
||
| await DdSdkReactNative.setAccountInfo({ id: 'account-id' }); | ||
|
|
||
| expect(spy).toHaveBeenCalled(); | ||
| spy.mockRestore(); | ||
| }); | ||
|
|
||
| it('DdSdkReactNative.clearAccountInfo reaches the native spec via the wrapper', async () => { | ||
| const spy = jest.spyOn(DdSdkWrapper.prototype, 'clearAccountInfo'); | ||
|
|
||
| await DdSdkReactNative.clearAccountInfo(); | ||
|
|
||
| expect(spy).toHaveBeenCalled(); | ||
| spy.mockRestore(); | ||
| }); | ||
|
|
||
| it('DdSdkReactNative.addAccountExtraInfo reaches the native spec via the wrapper', async () => { | ||
| // addAccountExtraInfo bails out early unless an account ID is set. | ||
| await DdSdkReactNative.setAccountInfo({ id: 'account-id' }); | ||
| const spy = jest.spyOn( | ||
| DdSdkWrapper.prototype, | ||
| 'addAccountExtraInfo' | ||
| ); | ||
|
|
||
| await DdSdkReactNative.addAccountExtraInfo({ tier: 'premium' }); | ||
|
|
||
| expect(spy).toHaveBeenCalled(); | ||
| spy.mockRestore(); | ||
| }); | ||
|
|
||
| it('DdSdkReactNative.setTrackingConsent reaches the native spec via the wrapper', async () => { | ||
| const spy = jest.spyOn( | ||
| DdSdkWrapper.prototype, | ||
| 'setTrackingConsent' | ||
| ); | ||
|
|
||
| await DdSdkReactNative.setTrackingConsent(TrackingConsent.GRANTED); | ||
|
|
||
| expect(spy).toHaveBeenCalled(); | ||
| spy.mockRestore(); | ||
| }); | ||
|
|
||
| it('DdSdkReactNative.clearAllData reaches the native spec via the wrapper', async () => { | ||
| const spy = jest.spyOn(DdSdkWrapper.prototype, 'clearAllData'); | ||
|
|
||
| await DdSdkReactNative.clearAllData(); | ||
|
|
||
| expect(spy).toHaveBeenCalled(); | ||
| spy.mockRestore(); | ||
| }); | ||
| }); | ||
| }); | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These mocks were missing.