-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(replay): Merge packages together & ensure bundles are built #11552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
92142c5
Revert "ref(feedback): Create stub integrations for feedback modal & …
mydea a71249d
Add to bundles
mydea 1134eb0
generate CDN bundles
mydea 7f84d3b
fix size limit
mydea 67ebd91
add to lazy load list
mydea 7fcb281
keep tests
mydea 6740b5d
better tests for bundle etc.
mydea 31e742e
fix for feedback bundle
mydea 7cd982a
update selector
mydea 4bc8457
make test less flaky
mydea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import { sentryTest } from '../../../utils/fixtures'; | ||
import { envelopeRequestParser, getEnvelopeType } from '../../../utils/helpers'; | ||
import { envelopeRequestParser, getEnvelopeType, shouldSkipFeedbackTest } from '../../../utils/helpers'; | ||
|
||
sentryTest('should capture feedback (@sentry-internal/feedback import)', async ({ getLocalTestPath, page }) => { | ||
if (process.env.PW_BUNDLE) { | ||
sentryTest('should capture feedback', async ({ getLocalTestPath, page }) => { | ||
if (shouldSkipFeedbackTest()) { | ||
sentryTest.skip(); | ||
} | ||
|
||
|
@@ -39,7 +39,7 @@ sentryTest('should capture feedback (@sentry-internal/feedback import)', async ( | |
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(); | ||
await page.locator('[data-sentry-feedback] .btn--primary').click(); | ||
|
||
const feedbackEvent = envelopeRequestParser((await feedbackRequestPromise).request()); | ||
expect(feedbackEvent).toEqual({ | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -5,7 +5,7 @@ window.Sentry = Sentry; | |
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
replaysOnErrorSampleRate: 1.0, | ||
replaysSessionSampleRate: 0, | ||
replaysSessionSampleRate: 1.0, | ||
integrations: [ | ||
Sentry.replayIntegration({ | ||
flushMinDelay: 200, | ||
|
198 changes: 101 additions & 97 deletions
198
...es/browser-integration-tests/suites/feedback/captureFeedbackAndReplay/hasSampling/test.ts
This file contains hidden or 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 |
---|---|---|
@@ -1,107 +1,111 @@ | ||
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 ({ forceFlushReplay, getLocalTestPath, page }) => { | ||
if (process.env.PW_BUNDLE) { | ||
sentryTest.skip(); | ||
import { envelopeRequestParser, getEnvelopeType, shouldSkipFeedbackTest } from '../../../../utils/helpers'; | ||
import { | ||
collectReplayRequests, | ||
getReplayBreadcrumbs, | ||
shouldSkipReplayTest, | ||
waitForReplayRequest, | ||
} from '../../../../utils/replayHelpers'; | ||
|
||
sentryTest('should capture feedback', async ({ forceFlushReplay, getLocalTestPath, page }) => { | ||
if (shouldSkipFeedbackTest() || shouldSkipReplayTest()) { | ||
sentryTest.skip(); | ||
} | ||
|
||
const reqPromise0 = waitForReplayRequest(page, 0); | ||
|
||
const feedbackRequestPromise = page.waitForResponse(res => { | ||
const req = res.request(); | ||
|
||
const postData = req.postData(); | ||
if (!postData) { | ||
return false; | ||
} | ||
|
||
const reqPromise0 = waitForReplayRequest(page, 0); | ||
const reqPromise1 = waitForReplayRequest(page, 1); | ||
const reqPromise2 = waitForReplayRequest(page, 2); | ||
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; | ||
} | ||
}); | ||
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' }), | ||
}); | ||
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 }); | ||
|
||
const [, , replayReq0] = await Promise.all([page.goto(url), page.getByText('Report a Bug').click(), reqPromise0]); | ||
|
||
// Inputs are slow, these need to be serial | ||
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'); | ||
|
||
// Force flush here, as inputs are slow and can cause click event to be in unpredictable segments | ||
await Promise.all([forceFlushReplay(), reqPromise1]); | ||
|
||
const [, feedbackResp, replayReq2] = await Promise.all([ | ||
page.getByLabel('Send Bug Report').click(), | ||
feedbackRequestPromise, | ||
reqPromise2, | ||
]); | ||
|
||
const feedbackEvent = envelopeRequestParser(feedbackResp.request()); | ||
const replayEvent = getReplayEvent(replayReq0); | ||
// Feedback breadcrumb is on second segment because we flush when "Report a Bug" is clicked | ||
// And then the breadcrumb is sent when feedback form is submitted | ||
const { breadcrumbs } = getCustomRecordingEvents(replayReq2); | ||
|
||
expect(breadcrumbs).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ | ||
category: 'sentry.feedback', | ||
data: { feedbackId: expect.any(String) }, | ||
timestamp: expect.any(Number), | ||
type: 'default', | ||
}), | ||
]), | ||
); | ||
|
||
expect(feedbackEvent).toEqual({ | ||
type: 'feedback', | ||
breadcrumbs: expect.any(Array), | ||
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: { | ||
const url = await getLocalTestPath({ testDir: __dirname }); | ||
|
||
await Promise.all([page.goto(url), page.getByText('Report a Bug').click(), reqPromise0]); | ||
|
||
const replayRequestPromise = collectReplayRequests(page, recordingEvents => { | ||
return getReplayBreadcrumbs(recordingEvents).some(breadcrumb => breadcrumb.category === 'sentry.feedback'); | ||
}); | ||
|
||
// Inputs are slow, these need to be serial | ||
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'); | ||
|
||
// Force flush here, as inputs are slow and can cause click event to be in unpredictable segments | ||
await Promise.all([forceFlushReplay()]); | ||
|
||
const [, feedbackResp] = await Promise.all([ | ||
page.locator('[data-sentry-feedback] .btn--primary').click(), | ||
feedbackRequestPromise, | ||
]); | ||
|
||
const { replayEvents, replayRecordingSnapshots } = await replayRequestPromise; | ||
const breadcrumbs = getReplayBreadcrumbs(replayRecordingSnapshots); | ||
|
||
const replayEvent = replayEvents[0]; | ||
const feedbackEvent = envelopeRequestParser(feedbackResp.request()); | ||
|
||
expect(breadcrumbs).toEqual( | ||
expect.arrayContaining([ | ||
expect.objectContaining({ | ||
category: 'sentry.feedback', | ||
data: { feedbackId: expect.any(String) }, | ||
timestamp: expect.any(Number), | ||
type: 'default', | ||
}), | ||
]), | ||
); | ||
|
||
expect(feedbackEvent).toEqual({ | ||
type: 'feedback', | ||
breadcrumbs: expect.any(Array), | ||
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'), | ||
headers: { | ||
'User-Agent': expect.stringContaining(''), | ||
}, | ||
}, | ||
platform: 'javascript', | ||
}); | ||
}, | ||
); | ||
}, | ||
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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was intentional to make sure that replay is captured when in buffering mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is not actually doing this today, I believe? At least the test failed 🤔 I merged this in now so we are unblocked, we can revert/tweak this a bit in a follow up!