diff --git a/app/controllers/daily_rolls_controller.rb b/app/controllers/daily_rolls_controller.rb index fe5f8c758..ef1982412 100644 --- a/app/controllers/daily_rolls_controller.rb +++ b/app/controllers/daily_rolls_controller.rb @@ -49,6 +49,7 @@ def leaderboard @viewer_rank = @viewer_date_roll.rank @viewer_page = ((@viewer_rank - 1) / PAGE_SIZE) + 1 end + @lookout_banner_origin = lookout_banner_origin else @anonymous_roll = AnonymousRoll.new(cookies).today end @@ -101,6 +102,22 @@ def roll_for_anonymous locals: { roll: roll, just_rolled: just_rolled, anonymous: true }) ] end + # Re-engagement: the daily roll pulls even people who never track time back + # here, so signed-in viewers who haven't linked Hackatime get a banner nudging + # them toward Lookout. Returns where /auth/hackatime should send them afterward + # (their most recent project, so the on-project record flow is one click away), + # or nil when the banner shouldn't show. Kept cheap on purpose — keyed off the + # identity association, never a live Hackatime sync, which would add an API call + # to this hot path. Broadening to "linked but 0 hours" needs a cached hours + # signal first. + def lookout_banner_origin + return unless Flipper.enabled?(:lookout, current_user) + return if current_user.hackatime_identity.present? + + recent_project = current_user.projects.order(created_at: :desc).first + recent_project ? project_path(recent_project) : rng_path + end + # rng ships with the week 2 release; until then it 404s for everyone. def require_week_2_release head :not_found unless Flipper.enabled?(:week_2_release, current_user) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index a930eb696..49594183c 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -106,6 +106,7 @@ <% end %>