Skip to content

Commit

Permalink
Implement context tracking with the beacon API
Browse files Browse the repository at this point in the history
This means less code to deal with ourselves
  • Loading branch information
jcoyne committed Feb 9, 2024
1 parent 990c9fd commit 8f9e662
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 57 deletions.
7 changes: 5 additions & 2 deletions app/helpers/blacklight/url_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ def session_tracking_params document, counter, per_page: search_session['per_pag
path = session_tracking_path(document, path_params)
return {} if path.nil?

context_method = blacklight_config.track_search_session.storage == 'client' ? 'get' : 'post'
{ data: { context_href: path, context_method: context_method } }
if blacklight_config.track_search_session.storage == 'client'
{ data: { context_href: path, context_method: 'get' } }
else
{ onclick: "navigator.sendBeacon('#{path}')"}
end
end

##
Expand Down
2 changes: 0 additions & 2 deletions app/javascript/blacklight/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
import BookmarkToggle from './bookmark_toggle.js'
import ButtonFocus from './button_focus.js'
import Modal from './modal.js'
import SearchContext from './search_context.js'
import Core from './core.js'


export default {
BookmarkToggle,
ButtonFocus,
Modal,
SearchContext,
Core,
onLoad: Core.onLoad
}
53 changes: 0 additions & 53 deletions app/javascript/blacklight/search_context.js

This file was deleted.

0 comments on commit 8f9e662

Please sign in to comment.