Commit 713761f
authored
* fix(analytics): restore Mixpanel IIFE syntax broken in PR #5
PR #5 (Rocket Loader bypass) accidentally introduced a typo in the Mixpanel
bootstrap IIFE: a[c[0]]= became a=c[0]]=, which is a JS SyntaxError
(Unexpected token ']'). The whole <script> block fails to parse, so
mixpanel.init() never runs and no events are sent — the Rocket Loader fix was
correct but got masked by this regression.
Confirmed via `node --check` on the extracted <script> block: SyntaxError on
the merged code, OK after this fix.
Reported by Codex (P1) and Copilot review on PR #5.
Only the two bytes a[ → a= are changed; nothing else.
* fix(analytics): replace corrupted Mixpanel stub with official snippet
The bootstrap IIFE shipped since 7c95a83 was a hand-edited variant with a
structurally broken init stub: it called b._q.push(...) but only ever
initialized b._i (never b._q), so every mixpanel.init(...) threw
'TypeError: Cannot read properties of undefined (reading push') before any
tracking method (track/identify/people.set/...) could be stubbed onto the
object. Result: zero events, even with a valid SDK URL and Rocket Loader bypass.
PR #6 fixed one symptom (the a=c[0]] syntax typo from #5), but the underlying
_q/_i logic bug remained — flagged again as P1 by Codex review on #6.
Fix: replace the whole IIFE with Mixpanel's official snippet verbatim from
https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript. The official
stub stubs out all methods (track, identify, people.*, ...) and records the
init call via b._i.push([...]) — matching the SDK's own contract.
Verified by executing the extracted <script> block in Node with a DOM mock:
- mixpanel._i receives the init call
- mixpanel.track / identify / people.set are all functions
- No TypeError, no SyntaxError
Same snippet in site/index.html and web/index.html. data-cfasync="false"
and the existing mixpanel.init(...) config line are preserved.
1 parent d32aa63 commit 713761f
2 files changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
210 | | - | |
| 210 | + | |
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
210 | | - | |
| 210 | + | |
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| |||
0 commit comments