-
Notifications
You must be signed in to change notification settings - Fork 31
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
CommercialMetrics includes ad blocker use #3446
Conversation
Size Change: +11 B (0%) Total Size: 949 kB
ℹ️ View Unchanged
|
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 it would be better to replace this promise with useAdBlockInUse
.
Having async calls which set state at the root of react components is likely to cause race conditions because you're fighting with React's re-rendering lifecycle rather than using it
Thanks for the feedback, @oliverlloyd ! |
Ah, I see. Yes, that's true, it doesn't handle the use case where an action is required when no ad blocker is in use
I agree. It currently only changes state in the positive case purely as a micro optimisation based on the assumption we would only ever want to use this logic to decide to do things when an ad blocker is detected. This is illustraighted with the WhenAdBlockInUse component. But it seems that assumption has been proven wrong! |
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.
Scratch my comment about needing useOnce
. @zekehuntergreen rightly pointed out the sentCommercialMetrics
state prevents double submission so the use of useOnce
is only needed for the nice here, not as an absolute.
What does this change?
sendCommercialMetrics
so that it accepts an optional parameteradBlockerInUse
sendCommercialMetrics
Why?
We'd like to collect data on our readers' use of ad blockers
frontend
→ guardian/frontend#24191