-
Notifications
You must be signed in to change notification settings - Fork 141
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
Consent - Do not load segment/send events unneccessarily #1001
Conversation
🦋 Changeset detectedLatest commit: 69bf193 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Will not? |
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.
Looks good to me!
@@ -13,7 +13,7 @@ | |||
"!**/test-helpers/**" | |||
], | |||
"scripts": { | |||
".": "yarn run -T turbo run --filter=@segment/analytics-consent-tools", | |||
".": "yarn run -T turbo run --filter=@segment/analytics-consent-tools...", |
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.
Just curious, when is this script run?
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's just a helper for local development. I think I wrote about in the docs under development. This makes it useful for "yarn . watch" (watch this and all of its dependencies).
Also, ...package-name watches dependents -- which might also be a useful alias. e.g "yarn ... watch"
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.
Actually, I take that back about local development: we do use this in CI to lazily build specific packages. :-)
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.
A couple minor comments, non blocking
const isDisabled = ( | ||
cdnSettings: CDNSettings, | ||
initialCategories: Categories, | ||
disableOpt: InitOptions['disable'] | undefined |
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.
Should we have this shortcircuit before everything? As in, if disable
is true
then bypass all the cdnsettings function
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 actually was in the process of refactoring this when you wrote this comment =)
import { segmentShouldBeDisabled } from '../disable-segment' | ||
|
||
describe('segmentShouldBeDisabled', () => { | ||
it('should be disabled if user has only consented to irrelevant vategories', () => { |
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.
nit: typo categories
See changeset.
This will not cause any problems for recent older versions of analytics that don't have "disabled" -- they just won't get this feature.