Skip to content

feat: lucky button experiment#6013

Open
rebelchris wants to merge 3 commits intomainfrom
feat/lucky-button
Open

feat: lucky button experiment#6013
rebelchris wants to merge 3 commits intomainfrom
feat/lucky-button

Conversation

@rebelchris
Copy link
Copy Markdown
Contributor

@rebelchris rebelchris commented May 8, 2026

Summary

Experiment that adds a Sparkle "lucky" button to the main feed SearchControlHeader (gated by hasFeedActions, same as IntroQuest / AchievementTracker). On click it fetches a random trending post via the existing randomTrendingPosts(first: 1) resolver and navigates to it.

  • Experiment flag: featureLuckyButton (GrowthBook). Off by default in production; gated via useConditionalFeature so it only evaluates when auth is ready.
  • Backend: no changes — reuses the existing randomPostsResolver pattern.
  • Animation: Sparkle icon rotates + scales on hover, spins while fetching.
  • Tracking: LogEvent.Click with target_type: 'lucky button' fires immediately on click (before the network call).
  • Navigation: uses window.location.assign since commentsPermalink is a full URL — router.push(fullUrl) was the silent-click bug.
  • Errors: useMutation + toast ("Bad luck — try again in a moment.") so failed fetches are visible.

The existing (no-op) "I'm feeling lucky" CTA in BestDiscussions is intentionally untouched.

Test plan

  • Enable lucky_button flag → Sparkle button appears on My Feed / Custom feed (desktop).
  • Disable flag → button hidden.
  • Click → tracking event fires, then navigates to a random trending post.
  • Repeat clicks → land on different posts.
  • Hover → icon rotates and scales.
  • Loading state → icon spins, button disabled.
  • Error state (e.g. resolver returns empty) → toast appears.

🤖 Generated with Claude Code

Preview domain

https://feat-lucky-button.preview.app.daily.dev

Adds a Sparkle-icon button in the main feed control header that fetches a
random trending post via the existing randomTrendingPosts resolver and
navigates to it. Reuses the same backend random-post logic that powers the
"I'm feeling lucky" CTA in BestDiscussions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 8, 2026

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

Project Deployment Actions Updated (UTC)
daily-webapp Ready Ready Preview May 8, 2026 2:50pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
storybook Ignored Ignored May 8, 2026 2:50pm

Request Review

- Add featureLuckyButton GrowthBook flag (off by default)
- Fix click navigation: commentsPermalink is a full URL, so router.push
  was failing silently; switch to window.location.assign
- Move click tracking to fire immediately on click (event_name: Click,
  target_type: 'lucky button'), not after fetch
- Use TanStack useMutation with toast on error so failures are visible
- Add hover animation: sparkle rotates and scales on hover, spins while
  fetching

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rebelchris rebelchris changed the title feat: add lucky button to feed header feat: lucky button experiment May 8, 2026
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.

1 participant