Skip to content

feat(discover): Discover v2 card and section analytics#7557

Open
DanielSinclair wants to merge 6 commits into
daniel/chore-placements-v1-legacy-component-cleanupfrom
daniel/discover-v2-analytics
Open

feat(discover): Discover v2 card and section analytics#7557
DanielSinclair wants to merge 6 commits into
daniel/chore-placements-v1-legacy-component-cleanupfrom
daniel/discover-v2-analytics

Conversation

@DanielSinclair
Copy link
Copy Markdown
Contributor

@DanielSinclair DanielSinclair commented Jun 4, 2026

What changed

  • Section layouts own analytics emission — card press, "see all" press, tab press, and carousel scroll are tracked from the layout, not individual cards.
  • Cards report market metadata up through a shared CardPressHandler (predictions via an OrderPressHandler) passed into each renderItem.
  • The layout contract moves from onPressSeeAll + surface to onPress + placement + section + surfaceId.
  • Carousel scroll tracking is debounced (500ms trailing), flushed on unmount.
  • Sections with no placement use no-op handlers, so tracking only fires for placement-backed content.
  • Retires the unused PlacementItemAnalyticsMetadata type; tightens surfaceId props to SurfaceId.

@DanielSinclair DanielSinclair changed the title feat(discover): declare discover analytics events feat(discover): Discover v2 card and section analytics Jun 4, 2026
Copy link
Copy Markdown
Contributor Author

DanielSinclair commented Jun 4, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add the label merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@DanielSinclair DanielSinclair marked this pull request as ready for review June 4, 2026 10:37
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 74422c8. Configure here.

outcome: order.outcome,
});
}
: noopOrderPress;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Analytics handler construction duplicated across three layout files

Medium Severity

The onCardPress and onOrderPress handler construction — including the discoverCardPressed tracking, trackPlacementInteraction call, discoverPredictionOrderPressed tracking, and the noopCardPress/noopOrderPress fallbacks — is copy-pasted nearly identically across MarketCarousel, MarketGrid, and MarketList. A future change to the tracking payload (e.g. adding a field to discoverCardPressed) would need to be applied in three places, risking inconsistency. This ~40-line block could be extracted into a shared factory function.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 74422c8. Configure here.

@DanielSinclair DanielSinclair force-pushed the daniel/chore-placements-v1-legacy-component-cleanup branch from e1c8e71 to c88a9f0 Compare June 4, 2026 11:03
@DanielSinclair DanielSinclair force-pushed the daniel/discover-v2-analytics branch from 74422c8 to 53e9246 Compare June 4, 2026 11:03
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

Launch in simulator or device for 920a172

Copy link
Copy Markdown
Contributor

@i1skn i1skn left a comment

Choose a reason for hiding this comment

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

left some comments, mainly to remove code duplication


import { ShowMoreButton, ShowMoreCellEnterAnimation } from './ShowMoreButton';

function noopCardPress(): undefined {
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.

nit: I think we can just have single noopPress here

const listItem = <View>{renderItem(item)}</View>;
const onCardPress: CardPressHandler = placement
? metadata => {
analytics.track(event.discoverCardPressed, {
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.

I see we repeat it here, I think we can move it to something like trackCardPress to encapsulate these two large calls there inside

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.

This is also going to break any downstream component memoization, creating these functions inline

Comment thread src/features/discover/components/markets/layouts/MarketGrid.tsx Outdated
@i1skn i1skn removed the request for review from christianbaroni June 4, 2026 12:24
@DanielSinclair DanielSinclair force-pushed the daniel/discover-v2-analytics branch from 53e9246 to 6c25cf5 Compare June 4, 2026 16:58
@DanielSinclair DanielSinclair force-pushed the daniel/chore-placements-v1-legacy-component-cleanup branch from c88a9f0 to 455bcd4 Compare June 4, 2026 16:58
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

Launch in simulator or device for f77be26

Copy link
Copy Markdown
Contributor

@i1skn i1skn left a comment

Choose a reason for hiding this comment

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

approving this, as none of my comments are critical, but please take a look on them

Comment thread src/features/discover/components/MarketSection.tsx

const HORIZONTAL_PADDING = 12;
const CARD_GAP = HORIZONTAL_PADDING;
const SCROLL_DEBOUNCE_MS = time.ms(500);
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.

This seem too frequent. This is effectively tracking every scroll interaction.

@DanielSinclair DanielSinclair force-pushed the daniel/discover-v2-analytics branch from 6c25cf5 to 0b43bb6 Compare June 4, 2026 20:30
@DanielSinclair DanielSinclair force-pushed the daniel/chore-placements-v1-legacy-component-cleanup branch from 455bcd4 to 27a223e Compare June 4, 2026 20:30
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

Launch in simulator or device for 308f9ae

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7fe26ebb0a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

marketId: row.market.id,
marketName: row.market.question,
marketSlug: row.market.slug,
outcome: row.title,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Report the selected market outcome

For multi-market prediction widgets, row.title is the display label derived from groupItemTitle/question in getOutcomeRows, not the actual selected outcome at row.outcomeIndex. In those cases the order analytics records labels like the threshold/team row instead of the outcome being bought, while the navigation uses outcomeIndex to open the order sheet for row.market.outcomes[row.outcomeIndex]; this corrupts discover.prediction_order_pressed outcome data for those widgets.

Useful? React with 👍 / 👎.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

Launch in simulator or device for 848ed03

@DanielSinclair DanielSinclair force-pushed the daniel/discover-v2-analytics branch from 7fe26eb to 702b335 Compare June 5, 2026 04:20
@DanielSinclair DanielSinclair force-pushed the daniel/chore-placements-v1-legacy-component-cleanup branch from 27a223e to 5a2337d Compare June 5, 2026 04:20
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

Launch in simulator or device for 84938e8

@DanielSinclair DanielSinclair force-pushed the daniel/discover-v2-analytics branch from 702b335 to def7421 Compare June 5, 2026 18:45
@DanielSinclair DanielSinclair force-pushed the daniel/chore-placements-v1-legacy-component-cleanup branch 2 times, most recently from 1d29e79 to c5e9d50 Compare June 6, 2026 00:45
@DanielSinclair DanielSinclair force-pushed the daniel/discover-v2-analytics branch from def7421 to 36a2091 Compare June 6, 2026 00:45
The card and order press handlers each fell back to a separate no-op
(noopCardPress / noopOrderPress) when a section had no placement. Both are
zero-arg `(): undefined` functions, so a single shared `noopPress` satisfies
the CardPressHandler and OrderPressHandler fallbacks in all three layouts
(carousel, grid, list), per i1skn's review.
@DanielSinclair DanielSinclair force-pushed the daniel/chore-placements-v1-legacy-component-cleanup branch from c5e9d50 to ef8527e Compare June 6, 2026 01:02
@DanielSinclair DanielSinclair force-pushed the daniel/discover-v2-analytics branch from 36a2091 to 1a1bc50 Compare June 6, 2026 01:02
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 6, 2026

Launch in simulator or device for 23ac50a

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