Skip to content

Add OpenPanel analytics adapter - #388

Open
jamiedavenport wants to merge 1 commit into
haydenbleasel:mainfrom
jamiedavenport:openpanel-analytics
Open

jamiedavenport wants to merge 1 commit into
haydenbleasel:mainfrom
jamiedavenport:openpanel-analytics

Conversation

@jamiedavenport

@jamiedavenport jamiedavenport commented Oct 19, 2026 •

Copy link
Copy Markdown

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 two script() adapters.

The adapter renders OpenPanel's script tag install: the window.op queue stub and init call, then op1.js.

  • clientId is mapped. Every other option (apiUrl, trackHashChanges, sessionReplay, …) is forwarded to window.op("init") verbatim, following the PostHog/Amplitude passthrough pattern.
  • trackScreenViews, trackOutgoingLinks, and trackAttributes default to true, as in OpenPanel's snippet. The web SDK only enables each when it is explicitly true, so without these defaults nothing would be tracked automatically. Any of them can be set to false.
  • scriptUrl (the name OpenPanel's own Astro component uses) loads the tracker from a proxy or self-hosted instance.
  • Client-router navigations need no Blume hook. With trackScreenViews on, the tracker wraps pushState and listens for popstate itself.
  • Blume's custom events (feedback, search, assistant, narration) reach OpenPanel through 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 — passed
  • bun run typecheck — passed
  • bun run build — passed
  • bun run test:coverage — 6361 pass, 0 fail; src/analytics/openpanel.ts at 100% lines/functions
  • New tests run the emitted stub against a fake window. They assert the queue shape op1.js replays (init first, then queued track calls).
  • Built a minimal site with openpanel({ clientId, trackHashChanges: true }) and confirmed dist/index.html contains the stub, the merged init options, and <script async defer src="https://openpanel.dev/op1.js"> in that order.

Checklist

  • I've reviewed my code
  • I've written tests
  • I've generated a change set file
  • I've updated the docs, if necessary

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added OpenPanel as an analytics provider, with support for screen views, outgoing links, tracked attributes, client-side navigation, and custom events.
    • Added options to configure the client ID, tracker URL, and other provider settings.
    • Added OpenPanel to the analytics provider lists in the documentation.

`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-bot

changeset-bot Bot commented Oct 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7964362

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
blume Patch

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

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

📝 Walkthrough

Blume adds an OpenPanel analytics adapter with validated options, generated initialization and tracker scripts, and custom-event forwarding. The analytics documentation and tests cover adapter configuration, tracking defaults, tracker URL overrides, and event delivery.

Changes: OpenPanel integration

Layer / File(s) Summary
Adapter configuration and tracker setup
packages/blume/src/analytics/openpanel.ts, packages/blume/src/analytics/schema.ts, packages/blume/src/analytics/head.ts, packages/blume/src/analytics/index.ts, packages/blume/test/analytics-providers.test.ts, apps/docs/content/docs/configuration/analytics.mdx, apps/docs/pages/guides/documentation-search-analytics.astro, .changeset/openpanel-analytics.md
Adds and registers the OpenPanel adapter. Its options require a nonempty clientId; the tracker URL defaults to OpenPanel Cloud. Generated scripts initialize the tracker with screen-view, outgoing-link, and attribute tracking enabled by default. Tests cover validation, option passthrough, script generation, and queued initialization. Documentation describes configuration and URL overrides.
Custom-event forwarding
packages/blume/src/components/layout/analytics-client.ts, packages/blume/test/analytics-client.test.ts, apps/docs/pages/guides/documentation-feedback-analytics.astro
Adds the OpenPanel op global to event fan-out. The client calls op("track", event, props) through attempt. Tests verify the call arguments, and the feedback guide lists OpenPanel among adapters receiving full feedback properties.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant AnalyticsConfiguration
  participant openpanelHead
  participant Browser
  participant OpenPanelTracker
  participant AnalyticsClient
  AnalyticsConfiguration->>openpanelHead: OpenPanel options
  openpanelHead->>Browser: Initialization stub and tracker script
  Browser->>OpenPanelTracker: Load tracker script asynchronously
  OpenPanelTracker->>Browser: Replay queued initialization call
  AnalyticsClient->>Browser: Track event and properties through window.op
Loading

Suggested reviewers: p-essonam, haydenbleasel

Merge Risk: ⚪ Minimal · up to 79643

The OpenPanel adapter appears ready to merge after normal checks; no actionable merge-blocking issue was established.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: adding an OpenPanel analytics adapter.
Description check Passed The description provides a detailed change summary, validation results, test coverage, documentation updates, and a completed checklist. It omits the Related Issues section, but the description is oth…
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 7…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description provides a detailed change summary, validation results, test coverage, documentation updates, and a completed checklist. It omits the Related Issues section, but the description is otherwise complete and relevant.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 7 files. (4 skipped: 4 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔇 Additional comments: 12
packages/blume/test/analytics-providers.test.ts: 2

499-500: The new Function hint is a false positive here.

The input is the adapter's own generated snippet, not untrusted data. The oxlint-disable comment 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 defer together with async on the tracker script.

The tracker script sets both async: true and defer: true. In HTML, async takes precedence on a modern browser, so defer has 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 defer to avoid confusion.

♻️ Proposed change
       attributes: {
         async: true,
-        defer: true,
         src: scriptUrl ?? OPENPANEL_SCRIPT_SRC,
       },

The tests at analytics-providers.test.ts Lines 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
📥 Commits

Reviewing files that changed from the base of the PR and between 8d84df3 and 7964362.

📒 Files selected for processing: 11
  • .changeset/openpanel-analytics.md
  • apps/docs/content/docs/configuration/analytics.mdx
  • apps/docs/pages/guides/documentation-feedback-analytics.astro
  • apps/docs/pages/guides/documentation-search-analytics.astro
  • packages/blume/src/analytics/head.ts
  • packages/blume/src/analytics/index.ts
  • packages/blume/src/analytics/openpanel.ts
  • packages/blume/src/analytics/schema.ts
  • packages/blume/src/components/layout/analytics-client.ts
  • packages/blume/test/analytics-client.test.ts
  • packages/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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant