Skip to content

Amplitude: add granular explore_* events#639

Draft
hdprajwal wants to merge 1 commit into
masterfrom
feat/amplitude-explore-events
Draft

Amplitude: add granular explore_* events#639
hdprajwal wants to merge 1 commit into
masterfrom
feat/amplitude-explore-events

Conversation

@hdprajwal

Copy link
Copy Markdown
Contributor

Fixes #638

Summary: Splits user interactions on /data out of the catch-all page_viewed event into seven dedicated explore_* events so they can be sliced cleanly in Amplitude. page_viewed now fires only on pathname change.

Changes

  • Logical changes
    • New useAmplitudeParamEvents hook mounted in AmplitudeTracker (src/app/App.tsx).
    • Seven new events sharing a path / view / entity base: explore_entity_switched, explore_view_switched, explore_sort_changed, explore_search_typed, explore_filter_changed (per-key, with filter_action), explore_detail_viewed, explore_detail_switched. Full event taxonomy is in the linked issue.
    • page_viewed dedupe in src/shared/lib/amplitude.ts now keyed on pathname only.
    • Initial-mount and pathname-change guards in the hook prevent spurious events on deep links and route transitions.
    • data_exported enriched with the same path / view / entity base for consistency. Breaking: object_type is renamed to entity on this event.
  • Refactors
    • FILTER_PARAM_KEYS, deriveFilterAction, areFilterValuesEqual extracted in amplitudeFormat.ts; resolveEnumValue exported so numeric-enum filters emit readable strings.

Test Plan

  1. npm run dev, accept consent, open DevTools then Network and filter for amplitude.com.
  2. Navigate to /data. Confirm one page_viewed.
  3. Run through each interaction: search (Enter, then clear), filter (territory + writing system in one update should emit two events), view switch, entity switch, sort change, open a card (explore_detail_viewed), click a different card (explore_detail_switched), close the panel (no event).
  4. Deep-link /data?searchString=Spanish&territoryFilter=ES&view=Table. Confirm one page_viewed and zero explore_* events.
  5. Navigate /data, /about, /data. Confirm one page_viewed per route change, no spurious explore_*.
  6. Decline consent in the Cookie settings banner; confirm no Amplitude requests fire for any of the above.

No visual changes; screenshots not applicable.

Checklist

Summary

  • Clear description of what and why
  • Scope kept focused; follow-ups noted in the issue
  • Set yourself as assignee
  • Mention the issue (Fixes #638 )

Testing

  • npm run lint
  • npm run build
  • npm run test (tests added for changed logic)
  • npm run dev - manual walkthrough per the test plan above

@hdprajwal hdprajwal self-assigned this May 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Cloudflare Pages preview

@LuoZihYuan

Copy link
Copy Markdown

Issues & Enhancements

explore_entity_switched

  1. Adjust properties {entity, from_entity, to_entity} to simply {entity, previous_entity}
  2. Events involving the switch from the Language entity should always have the property previous_entity.

explore_view_switched

  1. Adjust event properties {view, from_view, to_view} to simply {view, previous_view}
  2. Events involving the switch from the default Cards view should always have the property previous_view.

explore_sort_changed

  1. Should have included the entity property to tell which entity is currently being sorted.
  2. Adjust event properties {changed_keys, sort_by, secondary_sort_by} to simply {sort}.
  3. sort is now an array of variable strings representing the sorting keys. For example, sorting primarily by "Population" in descending order, and secondarily by "Name" in ascending order, should have the value ["population_desc", "name_asc"].

explore_filter_changed

  1. Should have included the entity property to tell which entity is currently being filtered.
  2. Decode the value of the property filter_value to the original strings for better understanding.

explore_search_typed

  1. Should have included the entity property to tell which entity is currently being searched.
  2. Should have included the result_count property to quickly tell if we have the data the user is searching for.
  3. Add triggering logic: "Clicking on search suggestions".

explore_detail_viewed

  1. Should have included the entity property to tell which entity the object belongs to.

explore_detail_switched

  1. Should have included the entity property to tell which entity the object belongs to.
  2. Adjust event properties {from_object_id, to_object_id} to {object, previous_object} to follow previous naming convention.

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.

Amplitude: Replace catch-all page_viewed with granular explore_* events

3 participants