mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## Problem kb has no cookie consent banner, so PostHog pageviews have to wait. Part of GROWTH-1352. ## Solution - `ConsentIsland` mounts the www/docs consent toast as a `client:only` island. - Shared consent code reads `process.env.NEXT_PUBLIC_*`, which Vite doesn't provide in the browser, so `astro.config.mjs` defines it for the client only. - `consent.tsx`, `ConsentToast`, and `PrivacySettings` import specific `common` modules instead of the barrel, which cuts the island from 652 KB to 96 KB. - A footer Privacy Settings link opens the same dialog, like docs. <img width="400" height="150" alt="kb-consent-banner" src="https://github.com/user-attachments/assets/c32a57ce-89e9-4842-89e4-67d03dafcd7c" /> kb previews auto-accept consent like www and docs (`NEXT_PUBLIC_ENVIRONMENT=staging`). Production needs `NEXT_PUBLIC_IS_PLATFORM` and `NEXT_PUBLIC_USERCENTRICS_RULESET_ID` before the banner shows. Testing: on `astro dev` (toast forced on), the banner renders, and Privacy settings opens from both the toast and the footer. Accept and opt out are unverified until production. ## Review instructions 1. The kb, www, and docs previews load with no console errors. 2. On the kb preview, the footer Privacy Settings link opens the dialog. ## Checklist Check all before review: - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [x] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
17 lines
713 B
TypeScript
17 lines
713 B
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
|
|
describe('astro.config', () => {
|
|
it('inlines only NEXT_PUBLIC_* vars, and only into the client build', async () => {
|
|
vi.stubEnv('NEXT_PUBLIC_IS_PLATFORM', 'true')
|
|
vi.stubEnv('SUPABASE_SERVICE_ROLE_KEY', 'secret')
|
|
const { default: config } = await import('./astro.config.mjs')
|
|
|
|
expect(config.vite?.define).toBeUndefined()
|
|
expect(config.vite?.environments?.ssr?.define).toBeUndefined()
|
|
|
|
const inlined = JSON.parse(config.vite?.environments?.client?.define?.['process.env'])
|
|
expect(inlined.NEXT_PUBLIC_IS_PLATFORM).toBe('true')
|
|
expect(Object.keys(inlined).every((key) => key.startsWith('NEXT_PUBLIC_'))).toBe(true)
|
|
}, 30_000)
|
|
})
|