Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as Sentry from '@sentry/browser';

window.Sentry = Sentry;

Sentry.init({
dsn: 'https://[email protected]/1337',
beforeSend(event) {
Sentry.captureUserFeedback({
event_id: event.event_id,
name: 'John Doe',
email: '[email protected]',
comments: 'This feedback should be attached associated with the captured error',
});
return event;
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sentry.captureException(new Error('Error with Feedback'));
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { expect } from '@playwright/test';
import type { Event, UserFeedback } from '@sentry/types';

import { sentryTest } from '../../../../utils/fixtures';
import { getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers';

sentryTest('capture user feedback when captureException is called', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });

const data = (await getMultipleSentryEnvelopeRequests(page, 2, { url })) as (Event | UserFeedback)[];

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;

expect(feedback).toEqual({
comments: 'This feedback should be attached associated with the captured error',
email: '[email protected]',
event_id: errorEvent.event_id,
name: 'John Doe',
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as Sentry from '@sentry/browser';

window.Sentry = Sentry;

Sentry.init({
dsn: 'https://[email protected]/1337',
beforeSend(event) {
Sentry.captureUserFeedback({
event_id: event.event_id,
name: 'John Doe',
email: '[email protected]',
comments: 'This feedback should be attached associated with the captured message',
});
return event;
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sentry.captureMessage('Message with Feedback');
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { expect } from '@playwright/test';
import type { Event, UserFeedback } from '@sentry/types';

import { sentryTest } from '../../../../utils/fixtures';
import { getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers';

sentryTest('capture user feedback when captureMessage is called', async ({ getLocalTestPath, page }) => {
const url = await getLocalTestPath({ testDir: __dirname });

const data = (await getMultipleSentryEnvelopeRequests(page, 2, { url })) as (Event | UserFeedback)[];

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;

expect(feedback).toEqual({
comments: 'This feedback should be attached associated with the captured message',
email: '[email protected]',
event_id: errorEvent.event_id,
name: 'John Doe',
});
});