-
-
Notifications
You must be signed in to change notification settings - Fork 364
Add UserFeedback #2486
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add UserFeedback #2486
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a92e87a
Add UserFeedback draft
d9b0aab
Add user feedback to the sample
cdd4f01
Fix user feedback sample ui
e945ae3
Add headers to user feedback
dac2a92
Add user feedback integration test
590e007
Merge branch 'main' into krystofwoldrich/addUserFeedback
5ed2138
Update changelog
d8eca88
Fix lint
f15f49a
Move user feedback to sdk.tsx
47b0837
Merge branch 'main' into krystofwoldrich/addUserFeedback
krystofwoldrich 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| import React, { useState } from 'react'; | ||
| import { View, Modal, StyleSheet, Text, TouchableOpacity, TextInput, Image } from 'react-native'; | ||
| import * as Sentry from '@sentry/react-native'; | ||
| import { UserFeedback } from '@sentry/react-native'; | ||
| import { styles as homeScreenStyles } from '../screens/HomeScreen'; | ||
|
|
||
| export const DEFAULT_COMMENTS = `It's broken again! Please fix it.`; | ||
|
|
||
| export function UserFeedbackModal() { | ||
| const [comments, onChangeComments] = React.useState(DEFAULT_COMMENTS); | ||
| const [modalVisible, setModalVisible] = useState(false); | ||
| const clearComments = () => onChangeComments(DEFAULT_COMMENTS); | ||
|
|
||
| return ( | ||
| <View> | ||
| <Modal | ||
| animationType="slide" | ||
| transparent={true} | ||
| visible={modalVisible} | ||
| onRequestClose={() => { | ||
| setModalVisible(!modalVisible); | ||
| }} | ||
| > | ||
| <View style={styles.centeredView}> | ||
| <View style={styles.modalView}> | ||
| <Image | ||
| source={require('../assets/sentry-announcement.png')} | ||
| style={styles.modalImage} | ||
| /> | ||
| <Text style={styles.modalText}>Whoops, what happened?</Text> | ||
| <TextInput | ||
| style={styles.input} | ||
| onChangeText={onChangeComments} | ||
| value={comments} | ||
| multiline={true} | ||
| numberOfLines={4} | ||
| /> | ||
| <TouchableOpacity | ||
| onPress={async () => { | ||
| setModalVisible(!modalVisible); | ||
|
|
||
| const sentryId = Sentry.captureMessage('Message that needs user feedback'); | ||
|
|
||
| const userFeedback: UserFeedback = { | ||
| event_id: sentryId, | ||
| name: 'John Doe', | ||
| email: 'john@doe.com', | ||
| comments, | ||
| }; | ||
|
|
||
| Sentry.captureUserFeedback(userFeedback); | ||
| clearComments(); | ||
| }}> | ||
| <Text style={homeScreenStyles.buttonText}>Send feedback</Text> | ||
| </TouchableOpacity> | ||
| <TouchableOpacity | ||
| onPress={async () => { | ||
| setModalVisible(!modalVisible); | ||
| }}> | ||
| <Text style={homeScreenStyles.buttonText}>Close</Text> | ||
| </TouchableOpacity> | ||
| </View> | ||
| </View> | ||
| </Modal> | ||
| <TouchableOpacity | ||
| onPress={async () => { | ||
| setModalVisible(true); | ||
| }}> | ||
| <Text style={homeScreenStyles.buttonText}>Send user feedback</Text> | ||
| </TouchableOpacity> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| centeredView: { | ||
| flex: 1, | ||
| justifyContent: "center", | ||
| alignItems: "center", | ||
| }, | ||
| modalView: { | ||
| margin: 5, | ||
| backgroundColor: "white", | ||
| borderRadius: 6, | ||
| padding: 25, | ||
| alignItems: "center", | ||
| shadowColor: "#000", | ||
| shadowOffset: { | ||
| width: 0, | ||
| height: 2 | ||
| }, | ||
| shadowOpacity: 0.25, | ||
| shadowRadius: 4, | ||
| elevation: 5 | ||
| }, | ||
| input: { | ||
| margin: 12, | ||
| marginBottom: 20, | ||
| borderWidth: 0.5, | ||
| borderColor: '#c6becf', | ||
| padding: 15, | ||
| borderRadius: 6, | ||
| height: 100, | ||
| width: 250, | ||
| textAlignVertical: 'top', | ||
| }, | ||
| modalText: { | ||
| marginBottom: 15, | ||
| textAlign: "center", | ||
| fontSize: 18, | ||
| }, | ||
| modalImage: { | ||
| marginBottom: 20, | ||
| width: 80, | ||
| height: 80, | ||
| } | ||
| }); |
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
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 |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import { | ||
| BaseEnvelopeHeaders, | ||
| DsnComponents, | ||
| EventEnvelope, | ||
| EventEnvelopeHeaders, | ||
| SdkMetadata, | ||
| UserFeedback, | ||
| UserFeedbackItem, | ||
| } from '@sentry/types'; | ||
| import { createEnvelope, dsnToString } from '@sentry/utils'; | ||
|
|
||
| /** | ||
| * Creates an envelope from a user feedback. | ||
| */ | ||
| export function createUserFeedbackEnvelope( | ||
| feedback: UserFeedback, | ||
| { | ||
| metadata, | ||
| tunnel, | ||
| dsn, | ||
| }: { | ||
| metadata: SdkMetadata | undefined, | ||
| tunnel: string | undefined, | ||
| dsn: DsnComponents | undefined, | ||
| }, | ||
| ): EventEnvelope { | ||
| // TODO: Use EventEnvelope[0] when JS sdk fix is released | ||
| const headers: EventEnvelopeHeaders & BaseEnvelopeHeaders = { | ||
| event_id: feedback.event_id, | ||
| sent_at: new Date().toISOString(), | ||
| ...(metadata && metadata.sdk && { sdk: metadata.sdk }), | ||
| ...(!!tunnel && !!dsn && { dsn: dsnToString(dsn) }), | ||
| }; | ||
| const item = createUserFeedbackEnvelopeItem(feedback); | ||
|
|
||
| return createEnvelope(headers, [item]); | ||
| } | ||
|
|
||
| function createUserFeedbackEnvelopeItem( | ||
| feedback: UserFeedback | ||
| ): UserFeedbackItem { | ||
| const feedbackHeaders: UserFeedbackItem[0] = { | ||
| type: 'user_report', | ||
| }; | ||
| return [feedbackHeaders, feedback]; | ||
| } | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.