Skip to content

feat: Guided Tours Completion Metrics#2412

Open
camielvs wants to merge 1 commit into
06-10-feat_guided_tour_-_secretsfrom
06-11-feat_guided_tours_completion_metrics
Open

feat: Guided Tours Completion Metrics#2412
camielvs wants to merge 1 commit into
06-10-feat_guided_tour_-_secretsfrom
06-11-feat_guided_tours_completion_metrics

Conversation

@camielvs

@camielvs camielvs commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Description

Tours can now be marked as completed and restarted, and we capture progression telemetry so we can see how tours are used and where people bounce off.

Completion state is persisted per user on the backend via /api/users/me/settings (key: completed_tours) — read with TanStack Query and updated with a read-modify-write PATCH, so it survives across sessions/devices and sits alongside any other user settings without overwriting them. There is no local-storage layer: when no backend is available (e.g. offline / GitHub Pages) completion state simply doesn't surface, which is acceptable for this low-stakes feature and can be revisited later.

We deliberately do not resume partially-finished tours — restarting always begins from the first step — so no in-progress state is surfaced.

User-facing

  • Completed tours show a "Completed" badge and their action relabels to "Restart" (in both the Tours library and Featured tours).
  • Restarting starts the tour fresh.

Telemetry (analytics events, independent of the settings store)

  • learning_hub.tours.start — now carries is_restart to distinguish redos from first runs.
  • learning_hub.tours.step_viewed — fired once per step reached (step_index, step_count, interaction); gives a step-by-step drop-off funnel.
  • learning_hub.tours.completed — on reaching the final step (step_count, completion_count, previously_completed, duration_ms).
  • learning_hub.tours.exited — on leaving before completion (furthest_step, percent_complete, duration_ms, previously_completed) — the "bounce" signal.

Together these cover issue 640's item 2 (how many started/completed, and how far users get before exiting).

Related Issue and Pull requests

Closes https://github.com/Shopify/oasis-frontend/issues/640

Note

Cross-device persistence depends on the backend /api/users/me/settings route doing a key-level merge of the settings dict (confirmed) so completed_tours is appended alongside other keys rather than replacing them.

Type of Change

  • New feature

Checklist

  • I have tested this does not break current pipelines / runs functionality
  • I have tested the changes on staging

Screenshots (if applicable)

image.png

Test Instructions

  1. With a backend configured, go to Learning Hub → Guided Tours and complete a tour through to the final step.
  2. Return to the library: the tour shows a Completed badge and a Restart button.
  3. Reload the page — completion persists (it's read from /api/users/me/settings). In DevTools, the GET .../api/users/me/settings?setting_names=completed_tours returns the completed_tours map; completing a tour fires a PATCH that includes the full map under settings.completed_tours.
  4. Start a tour and navigate away before finishing → a learning_hub.tours.exited event fires with furthest_step. Walk a tour to the end → learning_hub.tours.completed fires; each step emits step_viewed.
  5. (Offline / no backend) Tours still run; completion badges just don't surface — nothing errors.

Additional Comments

completed_tours write is last-write-wins against the cached map within a session — a completion added by another tab/device between our GET and PATCH could be missed. Negligible here; true per-entry safety would require the backend to deep-merge completed_tours.

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

🎩 Preview

A preview build has been created at: 06-11-feat_guided_tours_completion_metrics/3bfbe19

camielvs commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator Author

@camielvs camielvs mentioned this pull request Jun 12, 2026
3 tasks
@camielvs camielvs added the #gsd:50583 Learning Hub label Jun 12, 2026 — with Graphite App
@camielvs camielvs force-pushed the 06-11-feat_guided_tours_completion_metrics branch 2 times, most recently from 2cfbe6e to 586e87d Compare June 12, 2026 18:00
@camielvs camielvs mentioned this pull request Jun 12, 2026
3 tasks
@camielvs camielvs force-pushed the 06-10-feat_guided_tour_-_secrets branch from 61e99a7 to e5de95e Compare June 12, 2026 23:36
@camielvs camielvs force-pushed the 06-11-feat_guided_tours_completion_metrics branch from 586e87d to 6bffb2c Compare June 12, 2026 23:36
Comment thread src/components/Learn/FeaturedTours.tsx
Comment thread src/components/Learn/ToursLibrary.tsx
Comment thread src/providers/TourProvider/TourTelemetryBridge.tsx
@camielvs camielvs force-pushed the 06-10-feat_guided_tour_-_secrets branch from e5de95e to 9551233 Compare June 15, 2026 17:55
@camielvs camielvs force-pushed the 06-11-feat_guided_tours_completion_metrics branch from 6bffb2c to 18c2dd3 Compare June 15, 2026 17:55
@camielvs camielvs mentioned this pull request Jun 15, 2026
3 tasks
@camielvs camielvs force-pushed the 06-10-feat_guided_tour_-_secrets branch from 9551233 to 1e6793c Compare June 15, 2026 18:47
@camielvs camielvs force-pushed the 06-11-feat_guided_tours_completion_metrics branch from 18c2dd3 to 0e1b241 Compare June 15, 2026 18:47
@camielvs camielvs force-pushed the 06-10-feat_guided_tour_-_secrets branch from 1e6793c to f89c2a4 Compare June 15, 2026 18:59
@camielvs camielvs force-pushed the 06-11-feat_guided_tours_completion_metrics branch from 0e1b241 to 7f552ac Compare June 15, 2026 18:59
@camielvs camielvs force-pushed the 06-10-feat_guided_tour_-_secrets branch from f89c2a4 to c487762 Compare June 15, 2026 19:21
@camielvs camielvs force-pushed the 06-11-feat_guided_tours_completion_metrics branch 2 times, most recently from 3b6725f to cf9670d Compare June 15, 2026 19:32
@camielvs camielvs force-pushed the 06-10-feat_guided_tour_-_secrets branch 2 times, most recently from 46e18c1 to e3b0dd6 Compare June 15, 2026 19:49
@camielvs camielvs force-pushed the 06-10-feat_guided_tour_-_secrets branch from 72758f7 to 076c6dd Compare June 19, 2026 21:48
Comment thread src/providers/TourProvider/TourTelemetryBridge.tsx
@camielvs camielvs force-pushed the 06-10-feat_guided_tour_-_secrets branch from 076c6dd to 9195f97 Compare June 26, 2026 00:20
@camielvs camielvs force-pushed the 06-11-feat_guided_tours_completion_metrics branch 2 times, most recently from 96f0bf2 to 1632bef Compare June 26, 2026 00:37
@camielvs camielvs force-pushed the 06-10-feat_guided_tour_-_secrets branch from 9195f97 to 4fd1034 Compare June 26, 2026 00:53
@camielvs camielvs force-pushed the 06-11-feat_guided_tours_completion_metrics branch from 1632bef to 19bac1e Compare June 26, 2026 00:53
Comment thread react-compiler.config.js
Comment thread src/providers/TourProvider/tourCompletion.ts
@camielvs camielvs force-pushed the 06-10-feat_guided_tour_-_secrets branch from 4fd1034 to c1d1d2e Compare June 26, 2026 17:20
@camielvs camielvs force-pushed the 06-11-feat_guided_tours_completion_metrics branch from 19bac1e to 0d1cd7a Compare June 26, 2026 17:20
@camielvs camielvs force-pushed the 06-10-feat_guided_tour_-_secrets branch from c1d1d2e to 8e73648 Compare June 26, 2026 19:28
@camielvs camielvs force-pushed the 06-11-feat_guided_tours_completion_metrics branch from 0d1cd7a to 3f17435 Compare June 26, 2026 19:28
@camielvs camielvs force-pushed the 06-10-feat_guided_tour_-_secrets branch from 8e73648 to 4f37373 Compare June 26, 2026 19:49
@camielvs camielvs force-pushed the 06-11-feat_guided_tours_completion_metrics branch 2 times, most recently from 4f4db72 to dd06708 Compare June 26, 2026 20:52
@camielvs camielvs force-pushed the 06-10-feat_guided_tour_-_secrets branch from 09b89a1 to db0230b Compare June 26, 2026 21:10
@camielvs camielvs force-pushed the 06-11-feat_guided_tours_completion_metrics branch from dd06708 to 893f173 Compare June 26, 2026 21:10
@camielvs camielvs force-pushed the 06-10-feat_guided_tour_-_secrets branch from db0230b to edb2a50 Compare June 26, 2026 21:13
@camielvs camielvs force-pushed the 06-11-feat_guided_tours_completion_metrics branch 2 times, most recently from 745d62c to 893a662 Compare June 26, 2026 21:28
@camielvs camielvs force-pushed the 06-10-feat_guided_tour_-_secrets branch 2 times, most recently from df55905 to 3ae4c3b Compare June 26, 2026 21:29
@camielvs camielvs force-pushed the 06-11-feat_guided_tours_completion_metrics branch 2 times, most recently from 21b6c60 to 4e5942b Compare June 26, 2026 21:30
@camielvs camielvs force-pushed the 06-10-feat_guided_tour_-_secrets branch from 3ae4c3b to d5e8d45 Compare June 26, 2026 21:30
@camielvs camielvs force-pushed the 06-11-feat_guided_tours_completion_metrics branch from 4e5942b to 3bfbe19 Compare June 26, 2026 21:50
},
});

return (tourId: string): RecordedCompletion => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 This is an AI-generated code review comment.

useRecordTourCompletion returns completionCount and previouslyCompleted from the current React Query cache before the mutation fetches and merges the authoritative settings map. When the cache is cold, stale, or still loading, TourTelemetryBridge immediately emits learning_hub.tours.completed with completion_count: 1 and previously_completed: false even if the server record already has prior completions. The PATCH later writes the correct merged count, but the analytics event for this completion is already wrong.

Suggestion: Make recording return the authoritative result used by the mutation (for example, expose an async mutateAsync/recordCompletion that resolves after ensureQueryData, then track completed from that result), or synchronously seed/update the cache before building the analytics payload so the emitted metrics match the persisted value.

Rule: tangle-ui-review: General quality / proper server-state handling for user-facing analytics

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

Labels

#gsd:50583 Learning Hub

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants