Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

Commit

The analytics loader starts once every module has loaded (Part of #204)

With the plan's routes, the bundler put lib/analytics-consent.ts in a chunk that reaches lib/analytics.client.ts's chunk back through four others, so the loader subscribed to consent before the consent module had made its listeners: every route threw as it loaded (CI Build, load-check). It now starts in a microtask, after the whole module graph has run. Checked: react-router build, then scripts/load-check.mjs (every route loads, 281) and scripts/deploy-check.mjs; npm run typecheck; npm test.

G1t-Session:
ses_01m5bgsckce7gt943v64h219yy
syntaqxcommitted Parent6012ffdBrowse files
1 file+6−20/1 viewed
+6−2
4141 else window.addEventListener("load", idle, { once: true });
4242 }
4343
44−if (analyticsHere()) {
44+// Once every module has loaded: the bundler may put the consent module in
45+// a chunk that imports this one back, and then it is not ready while this
46+// one runs.
47+queueMicrotask(() => {
48+ if (!analyticsHere()) return;
4549 if (allowed()) whenIdle(() => void load());
4650 // A choice made on the banner, or changed from the footer.
4751 onChoice(() => {
4953 if (choice() === "yes") void load().then((analytics) => analytics.optInCapturing());
5054 else if (sdk) void sdk.then((analytics) => analytics.optOutCapturing());
5155 });
52−}
56+});
5357
5458 /** Who is signed in, by account id only; null after signing out. */
5559 export function identify(userId: string | null, previous: string | null) {

Comments

Sign in to comment.