From eeece912f0fc9d85ab937afdc24448a52f6e7c75 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 28 May 2024 10:39:59 +0200 Subject: [PATCH 1/2] feat(js): Add docs for new `captureFeedback` method And streamline this for browser & node. --- .../javascript/common/user-feedback/index.mdx | 4 +- .../sdk-api-example/javascript.mdx | 37 +++++++++---------- .../sdk-api-example/javascript.node.mdx | 16 -------- 3 files changed, 21 insertions(+), 36 deletions(-) delete mode 100644 platform-includes/user-feedback/sdk-api-example/javascript.node.mdx diff --git a/docs/platforms/javascript/common/user-feedback/index.mdx b/docs/platforms/javascript/common/user-feedback/index.mdx index 9d55c8b67eb42..a8b3335b0d30e 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, without requiring an error event to occur. The [Crash-Report Modal](#crash-report-modal) feature still exists to handle user feedback associated with an error event. + +Note that if you are 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 support for feedback 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..7e6e82b67dd6a 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 second argument, 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); -``` From 557ce31ff3c3943c8e903da219328e2a0a5df4a6 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 29 May 2024 09:05:49 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Liza Mock --- docs/platforms/javascript/common/user-feedback/index.mdx | 4 ++-- .../user-feedback/sdk-api-example/javascript.mdx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/platforms/javascript/common/user-feedback/index.mdx b/docs/platforms/javascript/common/user-feedback/index.mdx index a8b3335b0d30e..0d5c447f61a9d 100644 --- a/docs/platforms/javascript/common/user-feedback/index.mdx +++ b/docs/platforms/javascript/common/user-feedback/index.mdx @@ -4,9 +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. 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 are 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 support for feedback functionality. +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 7e6e82b67dd6a..8943f0b863387 100644 --- a/platform-includes/user-feedback/sdk-api-example/javascript.mdx +++ b/platform-includes/user-feedback/sdk-api-example/javascript.mdx @@ -13,7 +13,7 @@ const userFeedback = { Sentry.captureFeedback(userFeedback); ``` -You can also attach further data to the feedback event by passing a hint as second argument, similar to other `capture` methods: +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.captureFeedback(