Skip to content
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

test(replay): Add integration test for privacy #7055

Merged
merged 20 commits into from
Feb 10, 2023

Conversation

billyvg
Copy link
Member

@billyvg billyvg commented Feb 3, 2023

Adds an integration test for default privacy settings.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 20.07 KB (-0.02% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 62.2 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.7 KB (-0.02% 🔽)
@sentry/browser - ES6 CDN Bundle (minified) 55.34 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 20.43 KB (0%)
@sentry/browser - Webpack (minified) 66.78 KB (0%)
@sentry/react - Webpack (gzipped + minified) 20.46 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 47.85 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.98 KB (-0.01% 🔽)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.24 KB (-0.02% 🔽)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 42.27 KB (-0.01% 🔽)
@sentry/replay - Webpack (gzipped + minified) 36.7 KB (0%)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 59.93 KB (-0.01% 🔽)
@sentry/browser + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 53.49 KB (-0.01% 🔽)

'childNodes': [
{
'id': 16,
'textContent': 'This should be unmasked due to data attribute',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should break when we merge and release getsentry/rrweb#40

@@ -1 +1,3 @@
export { Replay } from './integration';

export type {RecordingEvent} from './types'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't sure the best way to expose this type for the test

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I was also struggling with this and opted to duplicate the type in #7052. If we're comfortable exposing this as public API, I think exporting it is fine and I'll also switch to it in my PR.
The one reason against exporting it would be breaking changes in rrweb 2.x, if any? But considering how far off it seems that we're upgrading, I'd say it's negligible. WDYT?

@billyvg billyvg changed the title feat(replay): Add integration test for privacy test(replay): Add integration test for privacy Feb 6, 2023
@billyvg billyvg requested a review from Lms24 February 6, 2023 16:37
@billyvg billyvg marked this pull request as ready for review February 6, 2023 16:37
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice test! Heads-up, in case #7052 is merged first, I added a bunch of helper functions that might be helpful here.

@@ -1 +1,3 @@
export { Replay } from './integration';

export type {RecordingEvent} from './types'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I was also struggling with this and opted to duplicate the type in #7052. If we're comfortable exposing this as public API, I think exporting it is fine and I'll also switch to it in my PR.
The one reason against exporting it would be breaking changes in rrweb 2.x, if any? But considering how far off it seems that we're upgrading, I'd say it's negligible. WDYT?

@@ -17,8 +17,8 @@ export const envelopeParser = (request: Request | null): unknown[] => {
});
};

export const envelopeRequestParser = (request: Request | null): Event => {
return envelopeParser(request)[2] as Event;
export const envelopeRequestParser = <T = Event>(request: Request | null, index = 2): T => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thought in #7052 😅

packages/integration-tests/suites/replay/privacy/test.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,18 @@
import * as Sentry from '@sentry/browser';
import { Replay } from '@sentry/replay';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, so these tests were breaking from es6 bundles when I did not use Replay from @sentry/replay (e.g. I was usin Sentry.Replay). Any ideas @Lms24?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, this was how we currently still differ between injecting the addon replay CDN bundle in addition to the CDN bundle (w/o replay) vs. testing the NPM @sentry/browser export.
I'm trying to get #7096 merged today which will get rid of relying on imports here. Going forward, we'll drop testing the addon bundle but instead additionally test against the two bundle variants that include Replay directly.

@@ -0,0 +1,236 @@
{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT about using snapshots here @Lms24 -- It's cumbersome trying to update these by hand.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially thought it'd be good to use snapshots in such situations. In #7082, it turned out though, that Playwright needs to have a snapshot for each platform+browser combination, meaning we'd likely end up with 12+ snapshot files per snapshot. The problem here is that this temporarily breaks tests on CI as well as for other folks running them locally and they'd need to contribute their newly made snapshots to the repo. We opted to therefore stay away from snapshots.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Lms24 Yeah I noticed that too, I was able to find a way to disable the platform, so now it's only by browser. This makes it possible to update snapshots locally, you just have to run --update-snapshots with --browser="all". Does that make it more reasonable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing snapshots for now so I can merge this in now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice, didn't know this worked. Then sure, snapshots would be okay, too. Actually that's good to know for my tests as well!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I'll make a new PR for it

@billyvg billyvg enabled auto-merge (squash) February 10, 2023 14:10
@billyvg billyvg merged commit 17c3132 into develop Feb 10, 2023
@billyvg billyvg deleted the feat-replay-add-privacy-test branch February 10, 2023 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants