Skip to content

feat: instrument the delegation funnel with Vercel Web Analytics - #809

Open
Jipperism wants to merge 1 commit into
livepeer:mainfrom
Jipperism:feat/722-Implement-Instrumentation-Plan
Open

Jipperism wants to merge 1 commit into
livepeer:mainfrom
Jipperism:feat/722-Implement-Instrumentation-Plan

Conversation

@Jipperism

Copy link
Copy Markdown
Contributor

Closes #722

Summary

  • Adds @vercel/analytics (<Analytics /> in _app.tsx) and a typed trackVercelAnalyticsEvent() helper in lib/analytics.ts. Event properties stay non-identifying: no addresses, ENS names, tx hashes or error text.
  • Instruments 11 of the 13 funnel events from the plan: Orchestrators nav click (desktop + mobile drawer), Orchestrators page view, orchestrator detail view, wallet connect (with a coarse surface property), delegation form start, delegation tx submitted/confirmed/failed, Delegating tab view, redelegation started, and unbonding started.
  • All transaction events go through useHandleTransaction. A "Move Delegated Stake" bond counts as redelegation_started only, so it stays out of the delegation submitted → confirmed/failed conversion.
  • delegation_form_started fires once per widget mount, on the first clean → dirty transition.
  • Not implemented: earn_entry_point_clicked and delegation_review_opened, because the UI they depend on doesn't exist yet.

Test plan

  • pnpm typecheck, pnpm lint, pnpm test pass
  • In dev (Vercel Analytics debug mode), confirmed each of these fires once: nav click, Orchestrators page view, orchestrator detail view, form start (including after clearing and re-entering an amount), Delegating tab view
  • Wallet connect and the transaction events (delegate, undelegate, redelegate, and "Move Delegated Stake" → redelegation_started) still need a check with a real wallet
  • After deploy, check that custom events show up in the Vercel Analytics dashboard

🤖 Generated with Claude Code

@vercel

vercel Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

@Jipperism is attempting to deploy a commit to the Livepeer Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@Jipperism
Jipperism force-pushed the feat/722-Implement-Instrumentation-Plan branch 6 times, most recently from 51c5db2 to b6b8be9 Compare September 19, 2026 01:47
Adds custom events for the delegation funnel (nav click, page views,
wallet connect, form start, transaction submit/confirm/fail) per the
instrumentation plan in livepeer#722, so delegator UX changes can be measured
against a baseline instead of guessed at.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Jipperism
Jipperism force-pushed the feat/722-Implement-Instrumentation-Plan branch from b6b8be9 to cb374a4 Compare September 19, 2026 02:06
@Jipperism
Jipperism marked this pull request as ready for review September 19, 2026 02:10
Copilot AI lite review requested due to automatic review settings September 19, 2026 02:10
@Jipperism

Copy link
Copy Markdown
Contributor Author

@ECWireless ready for review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

There are a couple of confirmed instrumentation correctness/data-quality gaps (notably route hydration causing double-fires and missing surface property on wallet_connected despite the PR description) that should be fixed before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 3 Medium severity · 1 Low severity

Open (4)
What changed in this PR

Adds Vercel Web Analytics to instrument the Explorer delegation funnel, including a typed analytics helper and event emission from key UI surfaces (nav, orchestrator pages, wallet connect, form start, and transaction lifecycle).

Changes:

  • Added @vercel/analytics with <Analytics beforeSend={...} /> and a new lib/analytics.ts helper to centralize event tracking/redaction.
  • Instrumented funnel events across Orchestrators pages, Account tabs, wallet connect, delegation form start, and transaction stages via useHandleTransaction.
  • Extended transaction args to flag “Move Delegated Stake” (transfer-stake) so it maps to redelegation events.
File Description
package.json Adds @vercel/analytics dependency.
pnpm-lock.yaml Locks @vercel/analytics and related dependency updates.
pages/​_app.tsx Mounts Vercel <Analytics /> and applies URL redaction via beforeSend.
lib/​analytics.ts Introduces typed funnel event names, tracking helpers, URL redaction, and transaction→event mapping.
layouts/​main.tsx Instruments wallet connect and Orchestrators nav click (desktop + drawer item).
pages/​orchestrators.tsx Tracks Orchestrators index page view.
pages/​accounts/​[account]/​orchestrating.tsx Tracks orchestrator detail view once per account per session.
pages/​accounts/​[account]/​delegating.tsx Tracks “Delegating” tab view once for the connected user’s account.
components/​Drawer/​index.tsx Wires drawer item onClick for nav click instrumentation.
components/​DelegatingWidget/​index.tsx Tracks delegation form start on first clean→dirty transition per mount.
components/​DelegatingWidget/​Delegate.tsx Passes isTransferStake into tx args for redelegation classification.
hooks/​useExplorerStore.tsx Adds isTransferStake?: boolean to transaction input data.
hooks/​useHandleTransaction.tsx Routes submitted/confirmed/failed stages into analytics transaction tracking.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread layouts/main.tsx
Comment on lines +274 to +285
onConnect: ({ isReconnected }) => {
// Outside of migration and governance, connecting a wallet is taken as
// delegation intent. Reconnects restore a previous session, so they
// don't count.
const isNonDelegationPage = NON_DELEGATION_PATHS.some((path) =>
asPath.startsWith(path)
);
if (!isReconnected && !isNonDelegationPage) {
trackVercelAnalyticsEvent("wallet_connected");
}
},
});
Comment on lines +28 to +38
const { query } = useRouter();
const viewedAccount = String(query.account);

useEffect(() => {
if (!hadError) {
trackVercelAnalyticsEventOnce(
"orchestrator_detail_viewed",
viewedAccount
);
}
}, [hadError, viewedAccount]);
Comment thread pages/orchestrators.tsx
Comment on lines +47 to +49
useEffect(() => {
trackVercelAnalyticsEvent("orchestrators_page_viewed");
}, []);
Comment thread lib/analytics.ts
Comment on lines +56 to +63
type TransactionEvents = Partial<
Record<TransactionStage, DelegationFunnelEvent>
>;

const REDELEGATION_EVENTS: TransactionEvents = {
submitted: "redelegation_started",
};

@vercel

vercel Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
explorer-arbitrum-one Ready Ready Preview Sep 19, 2026 1:17pm UTC

Request Review

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.

Implement Instrumentation Plan

2 participants