Commit 397466a
committed
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 c71a98f commit 397466a
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