diff --git a/dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/init.js b/dev-packages/browser-integration-tests/suites/public-api/captureFeedback/init.js similarity index 100% rename from dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/init.js rename to dev-packages/browser-integration-tests/suites/public-api/captureFeedback/init.js diff --git a/dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/simple_feedback/subject.js b/dev-packages/browser-integration-tests/suites/public-api/captureFeedback/simple_feedback/subject.js similarity index 56% rename from dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/simple_feedback/subject.js rename to dev-packages/browser-integration-tests/suites/public-api/captureFeedback/simple_feedback/subject.js index 035199ab42f1..950b7701a043 100644 --- a/dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/simple_feedback/subject.js +++ b/dev-packages/browser-integration-tests/suites/public-api/captureFeedback/simple_feedback/subject.js @@ -1,6 +1,6 @@ -Sentry.captureUserFeedback({ +Sentry.captureFeedback({ eventId: 'test_event_id', email: 'test_email', - comments: 'test_comments', + message: 'test_comments', name: 'test_name', }); diff --git a/dev-packages/browser-integration-tests/suites/public-api/captureFeedback/simple_feedback/test.ts b/dev-packages/browser-integration-tests/suites/public-api/captureFeedback/simple_feedback/test.ts new file mode 100644 index 000000000000..acf97eba586f --- /dev/null +++ b/dev-packages/browser-integration-tests/suites/public-api/captureFeedback/simple_feedback/test.ts @@ -0,0 +1,21 @@ +import { expect } from '@playwright/test'; +import type { FeedbackEvent } from '@sentry/core'; + +import { sentryTest } from '../../../../utils/fixtures'; +import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; + +sentryTest('should capture simple user feedback', async ({ getLocalTestUrl, page }) => { + const url = await getLocalTestUrl({ testDir: __dirname }); + + const eventData = await getFirstSentryEnvelopeRequest(page, url); + + expect(eventData.contexts).toMatchObject( + expect.objectContaining({ + feedback: { + contact_email: 'test_email', + message: 'test_comments', + name: 'test_name', + }, + }), + ); +}); diff --git a/dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/withCaptureMessage/init.js b/dev-packages/browser-integration-tests/suites/public-api/captureFeedback/withCaptureException/init.js similarity index 61% rename from dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/withCaptureMessage/init.js rename to dev-packages/browser-integration-tests/suites/public-api/captureFeedback/withCaptureException/init.js index 805d6adc2e1e..099425cd3f2f 100644 --- a/dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/withCaptureMessage/init.js +++ b/dev-packages/browser-integration-tests/suites/public-api/captureFeedback/withCaptureException/init.js @@ -5,11 +5,11 @@ window.Sentry = Sentry; Sentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1337', beforeSend(event) { - Sentry.captureUserFeedback({ - event_id: event.event_id, + Sentry.captureFeedback({ + associatedEventId: event.event_id, name: 'John Doe', email: 'john@doe.com', - comments: 'This feedback should be attached associated with the captured message', + message: 'This feedback should be attached associated with the captured error', }); return event; }, diff --git a/dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/withCaptureException/subject.js b/dev-packages/browser-integration-tests/suites/public-api/captureFeedback/withCaptureException/subject.js similarity index 100% rename from dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/withCaptureException/subject.js rename to dev-packages/browser-integration-tests/suites/public-api/captureFeedback/withCaptureException/subject.js diff --git a/dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/withCaptureException/test.ts b/dev-packages/browser-integration-tests/suites/public-api/captureFeedback/withCaptureException/test.ts similarity index 58% rename from dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/withCaptureException/test.ts rename to dev-packages/browser-integration-tests/suites/public-api/captureFeedback/withCaptureException/test.ts index aa7bc8f7aa17..24a2664154f5 100644 --- a/dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/withCaptureException/test.ts +++ b/dev-packages/browser-integration-tests/suites/public-api/captureFeedback/withCaptureException/test.ts @@ -1,5 +1,5 @@ import { expect } from '@playwright/test'; -import type { Event, UserFeedback } from '@sentry/core'; +import type { Event, FeedbackEvent } from '@sentry/core'; import { sentryTest } from '../../../../utils/fixtures'; import { getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers'; @@ -7,17 +7,21 @@ import { getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers'; sentryTest('capture user feedback when captureException is called', async ({ getLocalTestUrl, page }) => { const url = await getLocalTestUrl({ testDir: __dirname }); - const data = (await getMultipleSentryEnvelopeRequests(page, 2, { url })) as (Event | UserFeedback)[]; + const data = (await getMultipleSentryEnvelopeRequests(page, 2, { url })) as (Event | FeedbackEvent)[]; expect(data).toHaveLength(2); const errorEvent = ('exception' in data[0] ? data[0] : data[1]) as Event; - const feedback = ('exception' in data[0] ? data[1] : data[0]) as UserFeedback; + const feedback = ('exception' in data[0] ? data[1] : data[0]) as FeedbackEvent; - expect(feedback).toEqual({ - comments: 'This feedback should be attached associated with the captured error', - email: 'john@doe.com', - event_id: errorEvent.event_id, - name: 'John Doe', - }); + expect(feedback.contexts).toEqual( + expect.objectContaining({ + feedback: { + associated_event_id: errorEvent.event_id, + message: 'This feedback should be attached associated with the captured error', + contact_email: 'john@doe.com', + name: 'John Doe', + }, + }), + ); }); diff --git a/dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/withCaptureException/init.js b/dev-packages/browser-integration-tests/suites/public-api/captureFeedback/withCaptureMessage/init.js similarity index 60% rename from dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/withCaptureException/init.js rename to dev-packages/browser-integration-tests/suites/public-api/captureFeedback/withCaptureMessage/init.js index 866263273351..b1cc371e5ec6 100644 --- a/dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/withCaptureException/init.js +++ b/dev-packages/browser-integration-tests/suites/public-api/captureFeedback/withCaptureMessage/init.js @@ -5,11 +5,11 @@ window.Sentry = Sentry; Sentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1337', beforeSend(event) { - Sentry.captureUserFeedback({ - event_id: event.event_id, + Sentry.captureFeedback({ + associatedEventId: event.event_id, name: 'John Doe', email: 'john@doe.com', - comments: 'This feedback should be attached associated with the captured error', + message: 'This feedback should be attached associated with the captured message', }); return event; }, diff --git a/dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/withCaptureMessage/subject.js b/dev-packages/browser-integration-tests/suites/public-api/captureFeedback/withCaptureMessage/subject.js similarity index 100% rename from dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/withCaptureMessage/subject.js rename to dev-packages/browser-integration-tests/suites/public-api/captureFeedback/withCaptureMessage/subject.js diff --git a/dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/withCaptureMessage/test.ts b/dev-packages/browser-integration-tests/suites/public-api/captureFeedback/withCaptureMessage/test.ts similarity index 57% rename from dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/withCaptureMessage/test.ts rename to dev-packages/browser-integration-tests/suites/public-api/captureFeedback/withCaptureMessage/test.ts index 019a5d4a0326..2ae261759767 100644 --- a/dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/withCaptureMessage/test.ts +++ b/dev-packages/browser-integration-tests/suites/public-api/captureFeedback/withCaptureMessage/test.ts @@ -1,5 +1,5 @@ import { expect } from '@playwright/test'; -import type { Event, UserFeedback } from '@sentry/core'; +import type { Event, FeedbackEvent } from '@sentry/core'; import { sentryTest } from '../../../../utils/fixtures'; import { getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers'; @@ -7,17 +7,21 @@ import { getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers'; sentryTest('capture user feedback when captureMessage is called', async ({ getLocalTestUrl, page }) => { const url = await getLocalTestUrl({ testDir: __dirname }); - const data = (await getMultipleSentryEnvelopeRequests(page, 2, { url })) as (Event | UserFeedback)[]; + const data = (await getMultipleSentryEnvelopeRequests(page, 2, { url })) as (Event | FeedbackEvent)[]; expect(data).toHaveLength(2); const errorEvent = ('exception' in data[0] ? data[0] : data[1]) as Event; - const feedback = ('exception' in data[0] ? data[1] : data[0]) as UserFeedback; + const feedback = ('exception' in data[0] ? data[1] : data[0]) as FeedbackEvent; - expect(feedback).toEqual({ - comments: 'This feedback should be attached associated with the captured message', - email: 'john@doe.com', - event_id: errorEvent.event_id, - name: 'John Doe', - }); + expect(feedback.contexts).toEqual( + expect.objectContaining({ + feedback: { + message: 'This feedback should be attached associated with the captured message', + contact_email: 'john@doe.com', + associated_event_id: errorEvent.event_id, + name: 'John Doe', + }, + }), + ); }); diff --git a/dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/simple_feedback/test.ts b/dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/simple_feedback/test.ts deleted file mode 100644 index 3d1253910e3d..000000000000 --- a/dev-packages/browser-integration-tests/suites/public-api/captureUserFeedback/simple_feedback/test.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { expect } from '@playwright/test'; -import type { UserFeedback } from '@sentry/core'; - -import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; - -sentryTest('should capture simple user feedback', async ({ getLocalTestUrl, page }) => { - const url = await getLocalTestUrl({ testDir: __dirname }); - - const eventData = await getFirstSentryEnvelopeRequest(page, url); - - expect(eventData).toMatchObject({ - eventId: 'test_event_id', - email: 'test_email', - comments: 'test_comments', - name: 'test_name', - }); -}); diff --git a/docs/migration/v8-to-v9.md b/docs/migration/v8-to-v9.md index ae2f68bb0e38..77f1607e9169 100644 --- a/docs/migration/v8-to-v9.md +++ b/docs/migration/v8-to-v9.md @@ -72,6 +72,10 @@ Sentry.init({ - When `skipOpenTelemetrySetup: true` is configured, `httpIntegration({ spans: false })` will be configured by default. This means that you no longer have to specify this yourself in this scenario. With this change, no spans are emitted once `skipOpenTelemetrySetup: true` is configured, without any further configuration being needed. +### `@sentry/browser` + +- The `captureUserFeedback` method has been removed. Use `captureFeedback` instead and update the `comments` field to `message`. + ### Uncategorized (TODO) TODO @@ -128,6 +132,10 @@ Sentry.init({ - The `urlEncode` method has been removed. There is no replacement. - The `getDomElement` method has been removed. There is no replacement. +### `@sentry/browser` + +- The `captureUserFeedback` method has been removed. Use `captureFeedback` instead and update the `comments` field to `message`. + ### `@sentry/nestjs` - Removed `WithSentry` decorator. Use `SentryExceptionCaptured` instead. diff --git a/packages/browser/src/client.ts b/packages/browser/src/client.ts index 2ce5c7dfece6..c6945289284a 100644 --- a/packages/browser/src/client.ts +++ b/packages/browser/src/client.ts @@ -8,14 +8,11 @@ import type { ParameterizedString, Scope, SeverityLevel, - UserFeedback, } from '@sentry/core'; -import { BaseClient, applySdkMetadata, getSDKSource, logger } from '@sentry/core'; -import { DEBUG_BUILD } from './debug-build'; +import { BaseClient, applySdkMetadata, getSDKSource } from '@sentry/core'; import { eventFromException, eventFromMessage } from './eventbuilder'; import { WINDOW } from './helpers'; import type { BrowserTransportOptions } from './transports/types'; -import { createUserFeedbackEnvelope } from './userfeedback'; /** * Configuration options for the Sentry Browser SDK. @@ -105,28 +102,6 @@ export class BrowserClient extends BaseClient { return eventFromMessage(this._options.stackParser, message, level, hint, this._options.attachStacktrace); } - /** - * Sends user feedback to Sentry. - * - * @deprecated Use `captureFeedback` instead. - */ - public captureUserFeedback(feedback: UserFeedback): void { - if (!this._isEnabled()) { - DEBUG_BUILD && logger.warn('SDK not enabled, will not capture user feedback.'); - return; - } - - const envelope = createUserFeedbackEnvelope(feedback, { - metadata: this.getSdkMetadata(), - dsn: this.getDsn(), - tunnel: this.getOptions().tunnel, - }); - - // sendEnvelope should not throw - // eslint-disable-next-line @typescript-eslint/no-floating-promises - this.sendEnvelope(envelope); - } - /** * @inheritDoc */ diff --git a/packages/browser/src/exports.ts b/packages/browser/src/exports.ts index 295e6daa36cc..f34bad9c5aa7 100644 --- a/packages/browser/src/exports.ts +++ b/packages/browser/src/exports.ts @@ -27,6 +27,7 @@ export { addIntegration, captureException, captureEvent, + captureFeedback, captureMessage, close, createTransport, @@ -92,8 +93,6 @@ export { init, onLoad, showReportDialog, - // eslint-disable-next-line deprecation/deprecation - captureUserFeedback, } from './sdk'; export { breadcrumbsIntegration } from './integrations/breadcrumbs'; diff --git a/packages/browser/src/sdk.ts b/packages/browser/src/sdk.ts index 425212015455..163e17b014d7 100644 --- a/packages/browser/src/sdk.ts +++ b/packages/browser/src/sdk.ts @@ -2,7 +2,6 @@ import { consoleSandbox, dedupeIntegration, functionToStringIntegration, - getClient, getCurrentScope, getIntegrationsToSetup, getReportDialogEndpoint, @@ -13,7 +12,7 @@ import { stackParserFromStackParserOptions, supportsFetch, } from '@sentry/core'; -import type { Client, DsnLike, Integration, Options, UserFeedback } from '@sentry/core'; +import type { Client, DsnLike, Integration, Options } from '@sentry/core'; import type { BrowserClientOptions, BrowserOptions } from './client'; import { BrowserClient } from './client'; import { DEBUG_BUILD } from './debug-build'; @@ -307,16 +306,3 @@ export function forceLoad(): void { export function onLoad(callback: () => void): void { callback(); } - -/** - * Captures user feedback and sends it to Sentry. - * - * @deprecated Use `captureFeedback` instead. - */ -export function captureUserFeedback(feedback: UserFeedback): void { - const client = getClient(); - if (client) { - // eslint-disable-next-line deprecation/deprecation - client.captureUserFeedback(feedback); - } -}