-
-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only deprecate client captureUserFeedback
- Loading branch information
Showing
3 changed files
with
71 additions
and
2 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
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 |
---|---|---|
|
@@ -19,6 +19,7 @@ import { | |
envelopeItems, | ||
firstArg, | ||
getMockSession, | ||
getMockUserFeedback, | ||
getSyncPromiseRejectOnFirstCall, | ||
} from './testutils'; | ||
|
||
|
@@ -186,6 +187,15 @@ describe('Tests ReactNativeClient', () => { | |
expect(mockTransport.send).not.toBeCalled(); | ||
}); | ||
|
||
test('captureUserFeedback does not call transport when enabled false', () => { | ||
const mockTransport = createMockTransport(); | ||
const client = createDisabledClientWith(mockTransport); | ||
|
||
client.captureUserFeedback(getMockUserFeedback()); | ||
|
||
expect(mockTransport.send).not.toBeCalled(); | ||
}); | ||
|
||
function createDisabledClientWith(transport: Transport) { | ||
return new ReactNativeClient({ | ||
...DEFAULT_OPTIONS, | ||
|
@@ -279,6 +289,38 @@ describe('Tests ReactNativeClient', () => { | |
}); | ||
}); | ||
|
||
describe('UserFeedback', () => { | ||
test('sends UserFeedback to native Layer', () => { | ||
const mockTransportSend: jest.Mock = jest.fn(() => Promise.resolve()); | ||
const client = new ReactNativeClient({ | ||
...DEFAULT_OPTIONS, | ||
dsn: EXAMPLE_DSN, | ||
transport: () => ({ | ||
send: mockTransportSend, | ||
flush: jest.fn(), | ||
}), | ||
}); | ||
|
||
client.captureUserFeedback({ | ||
comments: 'Test Comments', | ||
email: '[email protected]', | ||
name: 'Test User', | ||
event_id: 'testEvent123', | ||
}); | ||
|
||
expect(mockTransportSend.mock.calls[0][firstArg][envelopeHeader].event_id).toEqual('testEvent123'); | ||
expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemHeader].type).toEqual( | ||
'user_report', | ||
); | ||
expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload]).toEqual({ | ||
comments: 'Test Comments', | ||
email: '[email protected]', | ||
name: 'Test User', | ||
event_id: 'testEvent123', | ||
}); | ||
}); | ||
}); | ||
|
||
describe('attachStacktrace', () => { | ||
let mockTransportSend: jest.Mock; | ||
let client: ReactNativeClient; | ||
|
@@ -375,6 +417,11 @@ describe('Tests ReactNativeClient', () => { | |
client.captureSession(getMockSession()); | ||
expect(getSdkInfoFrom(mockTransportSend)).toStrictEqual(expectedSdkInfo); | ||
}); | ||
|
||
test('send SdkInfo in the user feedback envelope header', () => { | ||
client.captureUserFeedback(getMockUserFeedback()); | ||
expect(getSdkInfoFrom(mockTransportSend)).toStrictEqual(expectedSdkInfo); | ||
}); | ||
}); | ||
|
||
describe('event data enhancement', () => { | ||
|
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