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

feat: Refactor GDPR stuff into a more readable consent class #1176

Merged
merged 11 commits into from
May 28, 2024

Conversation

benjackwhite
Copy link
Collaborator

@benjackwhite benjackwhite commented May 9, 2024

Changes

The "GDPR" opt in/out code was reaaaaaallly messy. Been wanting to refactor it for a while but didn't have a strong need until recently (other PR where I was potentially modifying some bits).

  • Creates a new ConsentManager class to encapsulate the logic
  • Removes the spaghetti of gdpr functions from before
  • Fairly sure it works as before and hopefully enough tests to prove it
  • Removes a few weird code paths such as the localStorage+cookie (which never would have got stored in the cookie)
  • Changes the params given to the opt in functions so you can't choose the persistence type - should now always be done via the config and it is now deterministic

Checklist

  • Tests for new code (see advice on the tests we use)
  • Accounted for the impact of any changes across different browsers
  • Accounted for backwards compatibility of any changes (no breaking changes in posthog-js!)

Copy link

vercel bot commented May 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
posthog-js 🛑 Canceled (Inspect) May 28, 2024 11:03am

@benjackwhite benjackwhite marked this pull request as ready for review May 9, 2024 15:10
@benjackwhite benjackwhite added the bump minor Bump minor version when this PR gets merged label May 9, 2024
Copy link

github-actions bot commented May 9, 2024

Size Change: -4.41 kB (-0.45%)

Total Size: 973 kB

Filename Size Change
dist/array.full.js 234 kB -1.11 kB (-0.47%)
dist/array.js 131 kB -1.1 kB (-0.84%)
dist/es.js 131 kB -1.1 kB (-0.83%)
dist/module.js 131 kB -1.1 kB (-0.83%)
ℹ️ View Unchanged
Filename Size
dist/exception-autocapture.js 12.2 kB
dist/recorder-v2.js 108 kB
dist/recorder.js 108 kB
dist/surveys-module-previews.js 57.8 kB
dist/surveys.js 59.5 kB

compressed-size-action

Copy link
Member

@pauldambra pauldambra left a comment

Choose a reason for hiding this comment

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

This looks great!

I messed around with the cypress tests for this a few months ago so I'm relatively confident that they cover this well (although I was focussed on replay consent)

src/__tests__/consent.test.ts Show resolved Hide resolved
src/__tests__/extensions/replay/sessionrecording.test.ts Outdated Show resolved Hide resolved
src/consent.ts Show resolved Hide resolved
@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@grahamc
Copy link

grahamc commented Nov 26, 2024

Hey folks, I just wanted to raise awareness to the folks involved in this PR that I think it broke the SDK and has exposed users who were GDRP compliant, to being non-compliant with GDPR: #1547

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump minor Bump minor version when this PR gets merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants