Skip to content

Commit

Permalink
customscripts: add download segment event
Browse files Browse the repository at this point in the history
This PR adds a segment event for copy downloads across docs pages. The event
text will be sent as a property, along with the URL and version in order to
differentiate what users are looking at.

Release note: None
  • Loading branch information
lassenordahl committed Feb 20, 2024
1 parent 3cefb06 commit 2201488
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/current/js/customscripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,8 @@ $(function() {
// find the filter set with this scope
$('[data-scope].current').each(function(index) {
// console.log("data-scope is: " + $(this).attr('data-scope'));
// if the target scope is in the same group as the current scope for that
// if the target scope is in the same group as the current scope for that
// group, remove the current class

const sectionScopes = $(this).attr('data-scope').split(" ");
// multiple scopes can be set, so try each scope, but stop after removing current
sectionScopes.every(v => {
Expand Down Expand Up @@ -442,7 +441,16 @@ $(function() {

clipboard.on('success', function(e) {
$(e.trigger).addClass('copy-clipboard--copied');
// $(e.trigger).find('.copy-clipboard__text').text('copied');
$(e.trigger).find('.copy-clipboard__text').text('copied');

try {
window.analytics.track("copied_core_download_link", {
text: e.text, // The copied text is sent as a property.
url: window.location.href,
});
} catch (e) {
console.error("Error submitting event", e);
}
});

$('[data-tooltip]').tooltip();
Expand Down

0 comments on commit 2201488

Please sign in to comment.