-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
116 additions
and
14 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 |
---|---|---|
|
@@ -10,22 +10,32 @@ | |
|
||
### Features | ||
|
||
- Adds new `captureFeedback` and deprecates the `captureUserFeedback` API ([#4320](https://github.com/getsentry/sentry-react-native/pull/4320)) | ||
- Adds new `captureFeedback` and deprecates the `captureUserFeedback` API ([#4320](https://github.com/getsentry/sentry-react-native/pull/4320), [#4322](https://github.com/getsentry/sentry-react-native/pull/4322)) | ||
|
||
```jsx | ||
import * as Sentry from "@sentry/react-native"; | ||
import { SendFeedbackParams } from "@sentry/react-native"; | ||
import * as Sentry from '@sentry/react-native'; | ||
import { SendFeedbackParams } from '@sentry/react-native'; | ||
|
||
const eventId = Sentry.captureMessage("My Message"); | ||
const eventId = Sentry.captureMessage('My Message'); | ||
// OR: const eventId = Sentry.lastEventId(); | ||
|
||
const userFeedback: SendFeedbackParams = { | ||
name: "John Doe", | ||
email: "[email protected]", | ||
message: "Hello World!", | ||
name: 'John Doe', | ||
email: '[email protected]', | ||
message: 'Hello World!', | ||
associatedEventId: eventId,// Optional | ||
}; | ||
Sentry.captureFeedback(userFeedback); | ||
Sentry.captureFeedback(userFeedback, { | ||
captureContext: { | ||
tags: { 'tag-key': 'tag-value' }, | ||
}, | ||
attachments: [ | ||
{ | ||
filename: 'screenshot.png', | ||
data: 'base64-encoded-image', | ||
}, | ||
], | ||
}); | ||
``` | ||
|
||
### Fixes | ||
|
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 |
---|---|---|
|
@@ -313,7 +313,40 @@ describe('Tests ReactNativeClient', () => { | |
|
||
client.captureFeedback(feedback); | ||
|
||
expect(captureFeedbackApi).toHaveBeenCalledWith(feedback); | ||
expect(captureFeedbackApi).toHaveBeenCalledWith(feedback, undefined); | ||
}); | ||
|
||
test('sends UserFeedback with hint', () => { | ||
const client = new ReactNativeClient({ | ||
...DEFAULT_OPTIONS, | ||
dsn: EXAMPLE_DSN, | ||
}); | ||
jest.mock('@sentry/browser', () => ({ | ||
captureFeedback: jest.fn(), | ||
})); | ||
|
||
const feedback: SendFeedbackParams = { | ||
message: 'Test Comments', | ||
email: '[email protected]', | ||
name: 'Test User', | ||
associatedEventId: 'testEvent123', | ||
}; | ||
|
||
const hint = { | ||
captureContext: { | ||
tags: { testtag: 'testvalue' }, | ||
}, | ||
attachments: [ | ||
{ | ||
filename: 'screenshot.png', | ||
data: 'base64Image', | ||
}, | ||
], | ||
}; | ||
|
||
client.captureFeedback(feedback, hint); | ||
|
||
expect(captureFeedbackApi).toHaveBeenCalledWith(feedback, hint); | ||
}); | ||
}); | ||
|
||
|
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 |
---|---|---|
|
@@ -65,6 +65,36 @@ export function UserFeedbackModal(props: { onDismiss: () => void }) { | |
}} | ||
/> | ||
<View style={styles.buttonSpacer} /> | ||
<Button | ||
title="Send feedback with attachment and tags" | ||
color="#6C5FC7" | ||
onPress={async () => { | ||
onDismiss(); | ||
|
||
const base64Image = | ||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/wcAAgUBA+kZYq8AAAAASUVORK5CYII='; | ||
|
||
const userFeedback: SendFeedbackParams = { | ||
message: comments, | ||
name: 'John Doe', | ||
email: '[email protected]', | ||
}; | ||
|
||
Sentry.captureFeedback(userFeedback, { | ||
captureContext: { | ||
tags: { testtag: 'testvalue' }, | ||
}, | ||
attachments: [ | ||
{ | ||
filename: 'screenshot.png', | ||
data: base64Image, | ||
}, | ||
], | ||
}); | ||
clearComments(); | ||
}} | ||
/> | ||
<View style={styles.buttonSpacer} /> | ||
<Button | ||
title="Close" | ||
color="#6C5FC7" | ||
|
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 |
---|---|---|
|
@@ -65,6 +65,35 @@ export function UserFeedbackModal(props: { onDismiss: () => void }) { | |
}} | ||
/> | ||
<View style={styles.buttonSpacer} /> | ||
<Button | ||
title="Send feedback with attachment and tags" | ||
color="#6C5FC7" | ||
onPress={async () => { | ||
onDismiss(); | ||
|
||
const base64Image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/wcAAgUBA+kZYq8AAAAASUVORK5CYII='; | ||
|
||
const userFeedback: SendFeedbackParams = { | ||
message: comments, | ||
name: 'John Doe', | ||
email: '[email protected]', | ||
}; | ||
|
||
Sentry.captureFeedback(userFeedback, { | ||
captureContext: { | ||
tags: { testtag: 'testvalue' }, | ||
}, | ||
attachments: [ | ||
{ | ||
filename: 'screenshot.png', | ||
data: base64Image, | ||
}, | ||
], | ||
}); | ||
clearComments(); | ||
}} | ||
/> | ||
<View style={styles.buttonSpacer} /> | ||
<Button | ||
title="Close" | ||
color="#6C5FC7" | ||
|