From 2201488456c2888ff983b0136de123f1f5f6c242 Mon Sep 17 00:00:00 2001 From: lassenordahl Date: Thu, 8 Feb 2024 15:09:13 -0500 Subject: [PATCH] customscripts: add download segment event 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 --- src/current/js/customscripts.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/current/js/customscripts.js b/src/current/js/customscripts.js index 61db3f55256..9f597e97001 100755 --- a/src/current/js/customscripts.js +++ b/src/current/js/customscripts.js @@ -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 => { @@ -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();