From 6f670da8d6b18605772c3b883e99b8dcffad2a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=20Rodr=C3=ADguez?= Date: Mon, 26 Aug 2024 10:12:36 +0200 Subject: [PATCH] Add analytic query param to videos#find_by_id Whenever the user comes to a video page by using the shortlink URL (/v/1234), there will be an extra analytic parameter as ?ref=shortlink so that I can see in Plausible the usage of the shortlink feature to analyze the performance of the links that I usually place at the video description in YouTube. --- app/controllers/videos_controller.rb | 2 +- spec/features/videos/video_find_by_id_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/videos_controller.rb b/app/controllers/videos_controller.rb index 822aead1..a0da916f 100644 --- a/app/controllers/videos_controller.rb +++ b/app/controllers/videos_controller.rb @@ -25,7 +25,7 @@ def show def find_by_id @video = Video.find_by!(youtube_id: params[:id]) - redirect_to playlist_video_path(@video, playlist_id: @video.playlist) + redirect_to playlist_video_path(@video, playlist_id: @video.playlist, ref: 'shortlink') end def early diff --git a/spec/features/videos/video_find_by_id_spec.rb b/spec/features/videos/video_find_by_id_spec.rb index 03bd89da..ef71fe1c 100644 --- a/spec/features/videos/video_find_by_id_spec.rb +++ b/spec/features/videos/video_find_by_id_spec.rb @@ -9,7 +9,7 @@ describe 'when the correct video is found' do it 'redirects to the correct video page' do visit "/v/#{video.youtube_id}" - expect(page).to have_current_path playlist_video_path(video, playlist_id: playlist) + expect(page).to have_current_path playlist_video_path(video, playlist_id: playlist, ref: 'shortlink') end end