Customer privacy utilities occasionally returning false positives
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.1k
- Forks
- 442
- Avg merge
- 4d 19h
- Merged PRs (30d)
- 24
Description
What is the location of your example repository?
No response
Which package or tool is having this issue?
Hydrogen
What version of that package or tool are you using?
"@shopify/hydrogen": "2026.4.0",
What version of React Router 7 are you using?
"react-router": "7.14.0",
Steps to Reproduce
I am trying to prevent some scripts from firing before consent has been given, but the utilities given to check if consent is given are sometimes returning true before consent has been given. It seems to be a bit flaky and doesn't happen all the time. I'm using the default Shopify cookie banner. I've tried using canTrack and customerPrivacy returned from useAnalytics(), as well as calling window methods directly. These specifically:
window.Shopify?.customerPrivacy.analyticsProcessingAllowed()customerPrivacy?.analyticsProcessingAllowed()canTrack()
Steps to reproduce:
- Log the result of those ☝️ invocations on page load
- Load a page, before having accepted cookies
- You might see them return
true(might take a few reloads)
Expected Behavior
The utilities should return false, since no consent has been given
Actual Behavior
The utilities [sometimes] return true:
If I then call the window method directly (without reloading or giving consent), it correctly returns false.
If I refresh the page (still without giving consent), the utilities correctly return true:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the useAnalytics customerPrivacy and canTrack entry points, then compare their page-load results with window.Shopify.customerPrivacy.analyticsProcessingAllowed() while using the default Shopify cookie banner. Reproduce the intermittent pre-consent true result across reloads; done when all utility paths consistently return false before consent and the existing behavior remains correct afterward.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100