-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(feedback): Add
level
and remove breadcrumbs from feedback event (
#9533) Also adds a browser integration test as well
- Loading branch information
Showing
13 changed files
with
311 additions
and
81 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
packages/browser-integration-tests/suites/feedback/captureFeedback/init.js
This file contains 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,9 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
import { Feedback } from '@sentry-internal/feedback'; | ||
|
||
window.Sentry = Sentry; | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
integrations: [new Feedback()], | ||
}); |
7 changes: 7 additions & 0 deletions
7
packages/browser-integration-tests/suites/feedback/captureFeedback/template.html
This file contains 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,7 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
</head> | ||
<body></body> | ||
</html> |
74 changes: 74 additions & 0 deletions
74
packages/browser-integration-tests/suites/feedback/captureFeedback/test.ts
This file contains 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,74 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { sentryTest } from '../../../utils/fixtures'; | ||
import { envelopeRequestParser, getEnvelopeType } from '../../../utils/helpers'; | ||
|
||
sentryTest('should capture feedback (@sentry-internal/feedback import)', async ({ getLocalTestPath, page }) => { | ||
if (process.env.PW_BUNDLE) { | ||
sentryTest.skip(); | ||
} | ||
|
||
const feedbackRequestPromise = page.waitForResponse(res => { | ||
const req = res.request(); | ||
|
||
const postData = req.postData(); | ||
if (!postData) { | ||
return false; | ||
} | ||
|
||
try { | ||
return getEnvelopeType(req) === 'feedback'; | ||
} catch (err) { | ||
return false; | ||
} | ||
}); | ||
|
||
await page.route('https://dsn.ingest.sentry.io/**/*', route => { | ||
return route.fulfill({ | ||
status: 200, | ||
contentType: 'application/json', | ||
body: JSON.stringify({ id: 'test-id' }), | ||
}); | ||
}); | ||
|
||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
|
||
await page.goto(url); | ||
await page.getByText('Report a Bug').click(); | ||
expect(await page.locator(':visible:text-is("Report a Bug")').count()).toEqual(1); | ||
await page.locator('[name="name"]').fill('Jane Doe'); | ||
await page.locator('[name="email"]').fill('[email protected]'); | ||
await page.locator('[name="message"]').fill('my example feedback'); | ||
await page.getByLabel('Send Bug Report').click(); | ||
|
||
const feedbackEvent = envelopeRequestParser((await feedbackRequestPromise).request()); | ||
expect(feedbackEvent).toEqual({ | ||
type: 'feedback', | ||
contexts: { | ||
feedback: { | ||
contact_email: '[email protected]', | ||
message: 'my example feedback', | ||
name: 'Jane Doe', | ||
source: 'widget', | ||
url: expect.stringContaining('/dist/index.html'), | ||
}, | ||
}, | ||
level: 'info', | ||
timestamp: expect.any(Number), | ||
event_id: expect.stringMatching(/\w{32}/), | ||
environment: 'production', | ||
sdk: { | ||
integrations: expect.arrayContaining(['Feedback']), | ||
version: expect.any(String), | ||
name: 'sentry.javascript.browser', | ||
packages: expect.anything(), | ||
}, | ||
request: { | ||
url: expect.stringContaining('/dist/index.html'), | ||
headers: { | ||
'User-Agent': expect.stringContaining(''), | ||
}, | ||
}, | ||
platform: 'javascript', | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
packages/browser-integration-tests/suites/feedback/captureFeedbackAndReplay/init.js
This file contains 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,18 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
import { Feedback } from '@sentry-internal/feedback'; | ||
|
||
window.Sentry = Sentry; | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
replaysOnErrorSampleRate: 1.0, | ||
replaysSessionSampleRate: 0, | ||
integrations: [ | ||
new Sentry.Replay({ | ||
flushMinDelay: 200, | ||
flushMaxDelay: 200, | ||
minReplayDuration: 0, | ||
}), | ||
new Feedback(), | ||
], | ||
}); |
7 changes: 7 additions & 0 deletions
7
packages/browser-integration-tests/suites/feedback/captureFeedbackAndReplay/template.html
This file contains 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,7 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
</head> | ||
<body></body> | ||
</html> |
90 changes: 90 additions & 0 deletions
90
packages/browser-integration-tests/suites/feedback/captureFeedbackAndReplay/test.ts
This file contains 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,90 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { sentryTest } from '../../../utils/fixtures'; | ||
import { envelopeRequestParser, getEnvelopeType } from '../../../utils/helpers'; | ||
import { getCustomRecordingEvents, getReplayEvent, waitForReplayRequest } from '../../../utils/replayHelpers'; | ||
|
||
sentryTest('should capture feedback (@sentry-internal/feedback import)', async ({ getLocalTestPath, page }) => { | ||
if (process.env.PW_BUNDLE) { | ||
sentryTest.skip(); | ||
} | ||
|
||
const reqPromise0 = waitForReplayRequest(page, 0); | ||
const feedbackRequestPromise = page.waitForResponse(res => { | ||
const req = res.request(); | ||
|
||
const postData = req.postData(); | ||
if (!postData) { | ||
return false; | ||
} | ||
|
||
try { | ||
return getEnvelopeType(req) === 'feedback'; | ||
} catch (err) { | ||
return false; | ||
} | ||
}); | ||
|
||
await page.route('https://dsn.ingest.sentry.io/**/*', route => { | ||
return route.fulfill({ | ||
status: 200, | ||
contentType: 'application/json', | ||
body: JSON.stringify({ id: 'test-id' }), | ||
}); | ||
}); | ||
|
||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
|
||
await page.goto(url); | ||
await page.getByText('Report a Bug').click(); | ||
await page.locator('[name="name"]').fill('Jane Doe'); | ||
await page.locator('[name="email"]').fill('[email protected]'); | ||
await page.locator('[name="message"]').fill('my example feedback'); | ||
await page.getByLabel('Send Bug Report').click(); | ||
|
||
const [feedbackResp, replayReq] = await Promise.all([feedbackRequestPromise, reqPromise0]); | ||
|
||
const feedbackEvent = envelopeRequestParser(feedbackResp.request()); | ||
const replayEvent = getReplayEvent(replayReq); | ||
const { breadcrumbs } = getCustomRecordingEvents(replayReq); | ||
|
||
expect(breadcrumbs).toEqual( | ||
expect.arrayContaining([ | ||
{ | ||
category: 'sentry.feedback', | ||
data: { feedbackId: expect.any(String) }, | ||
}, | ||
]), | ||
); | ||
|
||
expect(feedbackEvent).toEqual({ | ||
type: 'feedback', | ||
contexts: { | ||
feedback: { | ||
contact_email: '[email protected]', | ||
message: 'my example feedback', | ||
name: 'Jane Doe', | ||
replay_id: replayEvent.event_id, | ||
source: 'widget', | ||
url: expect.stringContaining('/dist/index.html'), | ||
}, | ||
}, | ||
level: 'info', | ||
timestamp: expect.any(Number), | ||
event_id: expect.stringMatching(/\w{32}/), | ||
environment: 'production', | ||
sdk: { | ||
integrations: expect.arrayContaining(['Feedback']), | ||
version: expect.any(String), | ||
name: 'sentry.javascript.browser', | ||
packages: expect.anything(), | ||
}, | ||
request: { | ||
url: expect.stringContaining('/dist/index.html'), | ||
headers: { | ||
'User-Agent': expect.stringContaining(''), | ||
}, | ||
}, | ||
platform: 'javascript', | ||
}); | ||
}); |
This file contains 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 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 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 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.