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

fix: integration test opting out #959

Merged
merged 8 commits into from
Jan 22, 2024
Merged

Conversation

pauldambra
Copy link
Member

@pauldambra pauldambra commented Jan 12, 2024

@neilkakkar and I were answering questions about what the library does if started in opted out state

Things are complicated enough that it's hard to read the code and be sure we're giving good advice

It turns out that if you opt out we drop messages at capture, so even if areas of posthog-js start running they can't send events.

But that also means that for e.g. we lazy load the entire JS bundle, track DOM mutations, and then drop any snapshot events.

We should not start session recording until we're asked to...

This PR:

  • adds integration tests for session recording opted out state
  • doesn't download the recorder bundle when opted out
  • removes given from Cypress tests
  • converts Cypress tests to typescript

Copy link

github-actions bot commented Jan 12, 2024

Size Change: +464 B (0%)

Total Size: 758 kB

Filename Size Change
dist/array.full.js 178 kB +116 B (0%)
dist/array.js 119 kB +116 B (0%)
dist/es.js 119 kB +116 B (0%)
dist/module.js 119 kB +116 B (0%)
ℹ️ View Unchanged
Filename Size
dist/exception-autocapture.js 12 kB
dist/recorder-v2.js 104 kB
dist/recorder.js 58.4 kB
dist/surveys.js 48.7 kB

compressed-size-action

@marandaneto
Copy link
Member

FWIW Android does the same, Replay calls capture always, and then capture checks the optOut flag and bails out if needed.

We should not start session recording until we're asked to...

Android is different because you can only hook up early in the app lifecycle (using the AppContext), so we have to hook up to the observers and not capture anything when it's triggered, it's less overhead than observing everything but more overhead than not doing anything.

@pauldambra pauldambra marked this pull request as ready for review January 22, 2024 08:32
@pauldambra pauldambra requested a review from a team January 22, 2024 08:32
@pauldambra pauldambra merged commit 9fef5f6 into master Jan 22, 2024
13 checks passed
@pauldambra pauldambra deleted the fix/integration-test-opting-out branch January 22, 2024 12:21
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.

3 participants