diff --git a/docs/platforms/javascript/common/user-feedback/index.mdx b/docs/platforms/javascript/common/user-feedback/index.mdx index 9d55c8b67eb42..0d5c447f61a9d 100644 --- a/docs/platforms/javascript/common/user-feedback/index.mdx +++ b/docs/platforms/javascript/common/user-feedback/index.mdx @@ -4,7 +4,9 @@ description: "Learn how to enable User Feedback in your app." sidebar_order: 6000 --- -The User Feedback feature allows you to collect user feedback from anywhere inside your application, without requiring an error event to occur. This requires a minimum SDK version of [7.85.0](https://github.com/getsentry/sentry-javascript/releases/tag/7.85.0). The [Crash-Report Modal](#crash-report-modal) feature still exists to handle user feedback associated with an error event. +The User Feedback feature allows you to collect user feedback from anywhere inside your application at any time, without needing an error event to occur first. The [Crash-Report Modal](#crash-report-modal) feature, on the other hand, lets you prompt for user feedback when an error event occurs. + +Note that if you're using a self-hosted Sentry instance, you'll need to be on version 24.4.2 or higher in order to use the full functionality of the User Feedback feature. Lower versions may have limited functionality. diff --git a/platform-includes/user-feedback/sdk-api-example/javascript.mdx b/platform-includes/user-feedback/sdk-api-example/javascript.mdx index 1142677911f85..8943f0b863387 100644 --- a/platform-includes/user-feedback/sdk-api-example/javascript.mdx +++ b/platform-includes/user-feedback/sdk-api-example/javascript.mdx @@ -1,5 +1,3 @@ -_Requires JS SDK version v7.47.0 or higher._ - ```javascript import * as Sentry from "@sentry/browser"; @@ -7,29 +5,30 @@ const eventId = Sentry.captureMessage("User Feedback"); // OR: const eventId = Sentry.lastEventId(); const userFeedback = { - event_id: eventId, name: "John Doe", email: "john@doe.com", - comments: "I really like your App, thanks!", + message: "I really like your App, thanks!", + associatedEventId: eventId, }; -Sentry.captureUserFeedback(userFeedback); +Sentry.captureFeedback(userFeedback); ``` -You could also collect feedback and send it when an error occurs via the SDK's `beforeSend` callback: - - +You can also attach further data to the feedback event by passing a hint as a second argument. This is similar to other `capture` methods: ```javascript -Sentry.init({ - dsn: '___PUBLIC_DSN___', - beforeSend: event => { - const userFeedback = collectYourUserFeedback(); - const feedback = { - ...userFeedback, - event_id: event.event_id, - } - Sentry.captureUserFeedback(feedback); - return event; +Sentry.captureFeedback( + { message: "I really like your App, thanks!" }, + { + captureContext: { + tags: { key: "value" }, + extra: { key: "value" }, + }, + attachments: [ + { + filename: "screenshot.png", + data: "base64-encoded-image", + }, + ], } -}) +); ``` diff --git a/platform-includes/user-feedback/sdk-api-example/javascript.node.mdx b/platform-includes/user-feedback/sdk-api-example/javascript.node.mdx deleted file mode 100644 index ccafca10813fa..0000000000000 --- a/platform-includes/user-feedback/sdk-api-example/javascript.node.mdx +++ /dev/null @@ -1,16 +0,0 @@ -_Requires JS SDK version v7.47.0 or higher._ - -```javascript -import * as Sentry from "@sentry/node"; - -const eventId = Sentry.captureMessage("User Feedback"); -// OR: const eventId = Sentry.lastEventId(); - -const userFeedback = { - event_id: eventId, - name: "John Doe", - email: "john@doe.com", - comments: "I really like your App, thanks!", -}; -Sentry.captureUserFeedback(userFeedback); -```