Skip to content

Conversation

@alaister
Copy link
Member

Addresses FE-1601, FE-1602 (indirectly) and FE-1603 (directly).

Testing

Non-EU:

  • Open docs/www/studio and ensure page events are being sent and no consent popup is shown

EU:

Open docs/www/studio and ensure:

  • Page events are not sent
  • Consent toast appears
  • After accepting, page events are sent
  • After denying, page events are not sent
  • After accepting or denying, no consent toast should be shown on subsequent visits

You can use a VPN to swap into Europe. Make sure to clear local storage in between changes.

@alaister alaister requested review from a team as code owners April 30, 2025 14:28
@vercel
Copy link

vercel bot commented Apr 30, 2025

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

Name Status Preview Comments Updated (UTC)
design-system ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 2, 2025 0:50am
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 2, 2025 0:50am
studio-self-hosted ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 2, 2025 0:50am
studio-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 2, 2025 0:50am
ui-library ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 2, 2025 0:50am
zone-www-dot-com ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 2, 2025 0:50am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio ⬜️ Ignored (Inspect) Visit Preview May 2, 2025 0:50am

@supabase
Copy link

supabase bot commented Apr 30, 2025

This pull request has been ignored for the connected project xguihxuzqibwxjnimxev because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

? 'https://frontend-assets.supabase.green'
: 'https://frontend-assets.supabase.com'

const USERCENTRICS_URLS = 'https://*.usercentrics.eu'
Copy link
Member

Choose a reason for hiding this comment

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

@pamelachia
Copy link
Contributor

some tests:

no VPN go www

  • no banner shown
  • consent settings all accepted
  • privacy settings button show right settings
  • pageviews are being sent to posthog
  • events are not being sent to posthog
  • when change in privacy settings off analytics, pageviews are not sent to posthog
    VPN to france www
  • banner shown
  • change “We use first-party cookies to improve our services.” remove first-party
  • remove console logs

docs VPN and no VPN same functionality as www

  • the banner shows but it takes quite long to load…? like a good 10 seconds

studio VPN does not show banner and can’t change privacy settings
no VPN also can’t change privacy settings

{
    "errorMessage": "Unable to find available languages using given settingsId and version.",
    "statusCode": 403
}
and
GET https://api.usercentrics.eu/settings//latest/languages.json 403 (Forbidden)

Fixes we need:

  • fix studio errors so banner shows and can't change settings at account/me
  • sendTelemetryEvent should work the same as pageview event sending and rely on the same usercentrics privacy setttings

@pamelachia
Copy link
Contributor

Tested docs and www and studio

  • SG location
    • no banner shown, telemetry auto accepted and pageview and events get sent
    • turned off analytics in privacy settings, events and pageviews dont get sent
    • turning it back on sends it as usual
  • VPN to France
    • banner shown, clicked around and nothing got sent
    • click accept and pageviews and events get sent
    • turning it off and on works correctly

Should be last fixes needed:

  • when in SG and auto accepted, first pageview is not being sent, only next ones are
  • UI lib does not show banner not send any events

@pamelachia
Copy link
Contributor

pamelachia commented May 1, 2025

ok the first pageview works now and tested the referrer shows t.co when i went from twitter to www homepage for in and out of EU. When in EU, I clicked to another page, clicked accept banner, then another page, and the new sent event still showed referrer as t.co

I get 500 errors for UI lib preview. Code looks right though.
Need someone else to test for UI Lib and more additional testing by frontend.

If it looks good let's merge this ASAP so we can get some early data to roll in over the weekend when our traffic is low.

Copy link
Member

@jordienr jordienr left a comment

Choose a reason for hiding this comment

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

tested in docs and studio preview and looks good. Brave seems to block everything anyway but chrome sends the events after accepting the toast.

// Although this is "technically" breaking the rules of hooks
// IS_PLATFORM never changes within a session, so this won't cause any issues
// eslint-disable-next-line react-hooks/rules-of-hooks
const { hasAcceptedConsent } = IS_PLATFORM ? useConsentToast() : { hasAcceptedConsent: true }
Copy link
Member

Choose a reason for hiding this comment

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

you could use an { enabled: bool } argument in the hook to enable/disable it conditionally without breaking the hook law

useConsentToast({ enabled: IS_PLATFORM })

@pamelachia pamelachia merged commit 2b419c7 into master May 5, 2025
20 checks passed
@pamelachia pamelachia deleted the chore/usercentrics branch May 5, 2025 05:18
seanoliver added a commit that referenced this pull request Nov 7, 2025
Fixes bug where App Router pages (docs, www/blog) only tracked the
initial page load but not subsequent navigations.

The issue was introduced in PR #35384 which inverted the logic for
the App Router telemetry tracking. The condition checked
`!hasSentInitialPageTelemetryRef.current` which prevented tracking
after the initial page view was sent.

Changed to match Pages Router behavior: wait until initial page view
is sent, then track all subsequent pathname changes.

Before: Only first page view tracked
After: All page navigations tracked (like Pages Router)

Affects: docs app, www app (blog pages)
seanoliver added a commit that referenced this pull request Nov 7, 2025
Fixes bug where App Router pages (docs, www/blog) only tracked the
initial page load but not subsequent navigations.

The issue was introduced in PR #35384 which inverted the logic for
App Router telemetry tracking. The condition used a boolean flag
that prevented tracking after the initial page view.

The root cause: useEffect with [appPathname] dependency fires both
on initial mount AND on pathname changes. The flag-based approach
couldn't differentiate between these two cases.

Solution: Track the previous pathname to detect actual changes.
- Initial mount: previousAppPathnameRef is null, skip (initial effect handles it)
- Navigation: previousAppPathnameRef !== appPathname, send telemetry

Before: Only first page view tracked
After: All page navigations tracked (like Pages Router)

Affects: docs app, www app (blog pages)
seanoliver added a commit that referenced this pull request Nov 7, 2025
Fixes bug where App Router pages (docs, www/blog) only tracked the
initial page load but not subsequent navigations.

The issue was introduced in PR #35384 which inverted the logic for
App Router telemetry tracking. The condition used a boolean flag
that prevented tracking after the initial page view.

The root cause: useEffect with [appPathname] dependency fires both
on initial mount AND on pathname changes. The flag-based approach
couldn't differentiate between these two cases.

Solution: Track the previous pathname to detect actual changes.
- Initial mount: previousAppPathnameRef is null, skip (initial effect handles it)
- Navigation: previousAppPathnameRef !== appPathname, send telemetry

Before: Only first page view tracked
After: All page navigations tracked (like Pages Router)

Affects: docs app, www app (blog pages)
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.

6 participants