Skip to content

Commit 7ca4409

Browse files
authored
analytics: allow tldraw.dev without www (tldraw#6978)
### Change type - [ ] `bugfix` - [ ] `improvement` - [ ] `feature` - [ ] `api` - [x] `other` <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds `https://tldraw.dev` to CORS allowlists and mocks the consent service in e2e tests for deterministic banner behavior. > > - **Workers/CORS**: > - Allow exact origin `https://tldraw.dev` in `apps/analytics-worker/src/worker.ts` and `packages/worker-shared/src/origins.ts`. > - **Tests**: > - In `apps/dotcom/client/e2e/tests/cookie-consent.spec.ts`, mock `https://consent.tldraw.xyz` to always return `{ requires_consent: true, country_code: 'TEST' }` to ensure the banner displays during tests. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit b8b83c4. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 03d244d commit 7ca4409

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

apps/analytics-worker/src/worker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function isAllowedOrigin(origin: string | null): string | undefined {
1515
if (origin === 'http://localhost:3000') return origin
1616
if (origin === 'http://localhost:5420') return origin
1717
if (origin === 'https://meet.google.com') return origin
18+
if (origin === 'https://tldraw.dev') return origin
1819
if (origin.endsWith('.tldraw.com')) return origin
1920
if (origin.endsWith('.tldraw.dev')) return origin
2021
if (origin.endsWith('.tldraw.club')) return origin

apps/dotcom/client/e2e/tests/cookie-consent.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ test.use({ storageState: { cookies: [], origins: [] } })
77

88
test.describe('cookie consent banner', () => {
99
test.beforeEach(async ({ page }) => {
10+
// Mock the consent check to always require consent
11+
await page.route('https://consent.tldraw.xyz', async (route) => {
12+
await route.fulfill({
13+
status: 200,
14+
contentType: 'application/json',
15+
body: JSON.stringify({ requires_consent: true, country_code: 'TEST' }),
16+
})
17+
})
18+
1019
await page.evaluate((key) => {
1120
// eslint-disable-next-line no-restricted-syntax
1221
window.localStorage.removeItem(key)

packages/worker-shared/src/origins.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export function isAllowedOrigin(origin: string) {
2121
if (origin === 'http://localhost:3000') return origin
2222
if (origin === 'http://localhost:5420') return origin
2323
if (origin === 'https://meet.google.com') return origin
24+
if (origin === 'https://tldraw.dev') return origin
2425
if (origin.endsWith('.tldraw.com')) return origin
2526
if (origin.endsWith('.tldraw.dev')) return origin
2627
if (origin.endsWith('.tldraw.club')) return origin

0 commit comments

Comments
 (0)