Repository navigation
Add OpenPanel analytics adapter - #388
jamiedavenport wants to merge 1 commit into
Conversation
`openpanel({ clientId })` renders OpenPanel's script tag install: the
`window.op` queue stub and init call, then the op1.js tracker. Every other
option is forwarded to init verbatim, with trackScreenViews,
trackOutgoingLinks, and trackAttributes on by default to match the official
snippet (the tracker leaves each off unless it is `true`). `scriptUrl`
points the tracker at a proxy or self-hosted instance.
The tracker wraps pushState and listens for popstate itself, so client
router navigations need no Blume hook. Blume's custom events reach
OpenPanel through `window.op("track", event, props)`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 7964362 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
🔇 Additional comments: 12
packages/blume/test/analytics-providers.test.ts: 2
499-500: Thenew Functionhint is a false positive here.The input is the adapter's own generated snippet, not untrusted data. The
oxlint-disablecomment documents the intent. No change is needed.
32-43: LGTM!Also applies to: 68-78, 109-109, 129-144, 162-162, 464-507
packages/blume/src/analytics/schema.ts: 1
19-19: LGTM!Also applies to: 45-45
packages/blume/src/analytics/index.ts: 1
64-65: LGTM!packages/blume/src/analytics/head.ts: 1
17-17: LGTM!Also applies to: 106-108
apps/docs/content/docs/configuration/analytics.mdx: 1
54-54: LGTM!Also applies to: 229-254, 462-464, 484-484
apps/docs/pages/guides/documentation-search-analytics.astro: 1
111-111: LGTM!.changeset/openpanel-analytics.md: 1
1-5: LGTM!packages/blume/src/components/layout/analytics-client.ts: 1
40-40: LGTM!Also applies to: 91-91
packages/blume/test/analytics-client.test.ts: 1
33-33: LGTM!Also applies to: 84-84, 107-107, 135-135
apps/docs/pages/guides/documentation-feedback-analytics.astro: 1
150-150: LGTM!packages/blume/src/analytics/openpanel.ts: 1
84-91: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.Remove or justify
defertogether withasyncon the tracker script.The tracker script sets both
async: trueanddefer: true. In HTML,asynctakes precedence on a modern browser, sodeferhas no effect there. The attribute is harmless, but it implies an ordering that does not exist.The inline init script at Line 80 is parser-inserted and runs synchronously. It already runs before the tracker, because the tracker is an external async script that loads later. Drop
deferto avoid confusion.♻️ Proposed change
attributes: { async: true, - defer: true, src: scriptUrl ?? OPENPANEL_SCRIPT_SRC, },The tests at
analytics-providers.test.tsLines 478 would need the same update.
ℹ️ Review info
⚙️ Run configuration
- Configuration used: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
f1f0a06e-f12d-4087-9dcc-da2496e37e0b
📒 Files selected for processing: 11
.changeset/openpanel-analytics.mdapps/docs/content/docs/configuration/analytics.mdxapps/docs/pages/guides/documentation-feedback-analytics.astroapps/docs/pages/guides/documentation-search-analytics.astropackages/blume/src/analytics/head.tspackages/blume/src/analytics/index.tspackages/blume/src/analytics/openpanel.tspackages/blume/src/analytics/schema.tspackages/blume/src/components/layout/analytics-client.tspackages/blume/test/analytics-client.test.tspackages/blume/test/analytics-providers.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
Description
Blume sites can now configure OpenPanel with
analytics: [openpanel({ clientId: "YOUR_CLIENT_ID" })]. Until now an OpenPanel site had to hand-write the queue stub and tracker as twoscript()adapters.The adapter renders OpenPanel's script tag install: the
window.opqueue stub andinitcall, thenop1.js.clientIdis mapped. Every other option (apiUrl,trackHashChanges,sessionReplay, …) is forwarded towindow.op("init")verbatim, following the PostHog/Amplitude passthrough pattern.trackScreenViews,trackOutgoingLinks, andtrackAttributesdefault totrue, as in OpenPanel's snippet. The web SDK only enables each when it is explicitlytrue, so without these defaults nothing would be tracked automatically. Any of them can be set tofalse.scriptUrl(the name OpenPanel's own Astro component uses) loads the tracker from a proxy or self-hosted instance.trackScreenViewson, the tracker wrapspushStateand listens forpopstateitself.window.op("track", event, props). The queue stub exists from first paint, so early events are queued until the tracker loads.Docs: a new OpenPanel section, plus rows in the adapter and options tables, in
configuration/analytics.mdx. OpenPanel is also added to the custom-event provider lists there and in the feedback and search analytics guides. Translated pages are left for the translation run.Validation
bun run check— passedbun run typecheck— passedbun run build— passedbun run test:coverage— 6361 pass, 0 fail;src/analytics/openpanel.tsat 100% lines/functionswindow. They assert the queue shapeop1.jsreplays (initfirst, then queuedtrackcalls).openpanel({ clientId, trackHashChanges: true })and confirmeddist/index.htmlcontains the stub, the merged init options, and<script async defer src="https://openpanel.dev/op1.js">in that order.Checklist
🤖 Generated with Claude Code
Summary by CodeRabbit