Skip to content

Commit

Permalink
Add analytic query param to videos#find_by_id
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
danirod committed Aug 26, 2024
1 parent 68c62eb commit 6f670da
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/videos_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/features/videos/video_find_by_id_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 6f670da

Please sign in to comment.