Skip to content

feat(analytics): add tools event tracking and shared event constants#664

Open
kjmitchelljr wants to merge 11 commits intomainfrom
feat/663-tools-analytics-events
Open

feat(analytics): add tools event tracking and shared event constants#664
kjmitchelljr wants to merge 11 commits intomainfrom
feat/663-tools-analytics-events

Conversation

@kjmitchelljr
Copy link
Copy Markdown
Collaborator

@kjmitchelljr kjmitchelljr commented Apr 15, 2026

PR Description

Focuses on TOOLS_EVENTS coverage for issue #663

What's changed

  • Added shared analytics event constants package
  • Implemented tools_* tracking for:
    • main tools page view
    • tool card clicks
    • wallet connected/disconnected
    • profile saved
    • script generated
    • settings changed
    • generated tag (link_tag)

Notes

  • tools_settings_changed currently fires on successful save paths
  • Questions:
    • revshare “generated vs copied” semantics - should we track just on generation or perhaps when user copies the tag?
    • whether to add field-level diff payload for settings_changed - in this PR do we want to track the fields the user changed for the profile?
    • whether to add explicit copy events for scripts/tags - should there be event tracking for when a user copies scripts or tags to clipboard or is that overhead not needed?

Apart of #625

@kjmitchelljr kjmitchelljr marked this pull request as ready for review April 15, 2026 19:25
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 15, 2026

Deployment results

Worker Alias URL Outcome
API - staging success
CDN - staging success
App - 9b12c45a success

Logs #24726480127

Comment thread frontend/app/hooks/useSaveProfile.tsx Outdated
Comment thread frontend/app/routes/_index.tsx Outdated
Comment thread frontend/app/routes/_index.tsx Outdated
Copy link
Copy Markdown
Member

@sidvishnoi sidvishnoi left a comment

Choose a reason for hiding this comment

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

Consider creating a map (like object) of event name and its expected custom event data (can be undefined/never).
Then instead of exporting each constant, we just let our frontend analytics lib know the possible events, and when we call trackEvent, it'll be correctly typed (and we get to keep all events info in one place too).
Like:

type Events = {
  eventA: undefined,
  eventB: { tool: ToolName, walletProvider: string }
}

Also instead of shared package, start by adding it in frontend only (where do you expect frontend event map to be used for it to be a shared package?)

@kjmitchelljr
Copy link
Copy Markdown
Collaborator Author

Consider creating a map (like object) of event name and its expected custom event data (can be undefined/never). Then instead of exporting each constant, we just let our frontend analytics lib know the possible events, and when we call trackEvent, it'll be correctly typed (and we get to keep all events info in one place too). Like:

type Events = {
  eventA: undefined,
  eventB: { tool: ToolName, walletProvider: string }
}

Also instead of shared package, start by adding it in frontend only (where do you expect frontend event map to be used for it to be a shared package?)

Can do. I don't expect frontend event map to be used, but based on the doc I know I'll be soon adding events in CDN and API as well. The thinking was to have it shared across there, however could keep it all separate.

@sidvishnoi
Copy link
Copy Markdown
Member

Given CDN & frontend won't be sharing event names (like CDN ones will have a prefix for sure), I don't think they need to be in a shared package.

I'm not sure we need Umami events in API - we've different kind of technical instrumentation there from Cloudflare already; and as CDN/embed is calling the API, we'll have user-facing events from embeds, not "API called" events.

@kjmitchelljr kjmitchelljr self-assigned this Apr 16, 2026
@DarianM
Copy link
Copy Markdown
Member

DarianM commented Apr 17, 2026

I'm not sure we need Umami events in API -

Are you suggesting we shouldn’t use Umami in the API for things like tool_embed_render? If so, that could mean our events are no longer in one place dashboard.
I thought the right place to track tool render is in our api, on GET api/profile

@kjmitchelljr
Copy link
Copy Markdown
Collaborator Author

I'm not sure we need Umami events in API -

Are you suggesting we shouldn’t use Umami in the API for things like tool_embed_render? If so, that could mean our events are no longer in one place dashboard. I thought the right place to track tool render is in our api, on GET api/profile

@sidvishnoi I was basing this off the doc where it mentions Count GET /profile{tool} on /api module per what Darian was saying above. Could you help me understand?

@sidvishnoi
Copy link
Copy Markdown
Member

Can we discuss tracking the API when we come to it, and here focus on the frontend?

Comment thread frontend/app/lib/analytics-events.ts
Comment thread frontend/app/stores/banner-store.ts Outdated
Comment thread frontend/app/stores/banner-store.ts Outdated
Comment thread frontend/app/hooks/useSaveProfile.tsx Outdated
@kjmitchelljr kjmitchelljr requested a review from sidvishnoi April 21, 2026 14:02
Comment on lines +57 to +62
trackEvent('script_generated', {
tool: toolState.currentToolType,
})
openDialog(<ScriptDialog wallet={wallet} />)
} else {
trackEvent('profile_saved', {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need two separate events for this? What if we pass an action in event data to tell whether it was save or script?

const validatedPointer = await validateAndConfirmPointer(pointerInput)
setParsedLinkTag(htmlEncodePointer(validatedPointer))
setShowCodeBox(true)
trackEvent('generated_tag', { tag_type: 'link_tag' })
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we use the same save /submit event here from other tools and pass tool: "link_tag" with it?

if (result.success) {
actions.commitProfile()

trackEvent('settings_changed', {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's remove this event for now - this one here is fired even if settings aren't changed.

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.

3 participants