Skip to content

Commit 192212d

Browse files
committed
clean up sample code sent to segment
1 parent 1a2e976 commit 192212d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/js/07-copy-to-clipboard.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@
5252
copy.addEventListener('click', function () {
5353
var text = code.innerText.replace(TRAILING_SPACE_RX, '')
5454
if (code.dataset.lang === 'console' && text.startsWith('$ ')) text = extractCommands(text)
55-
var codeSample = text.slice(0, 50).trim()
5655
writeToClipboard(text, copy)
57-
trackCopy(code.dataset.lang, title?.childNodes[0]?.nodeValue, codeSample)
56+
trackCopy(code.dataset.lang, title?.childNodes[0]?.nodeValue, text)
5857
})
5958
content.prepend(toolbox)
6059
}
@@ -92,8 +91,9 @@
9291
)
9392
}
9493

95-
function trackCopy (language, title, sample) {
94+
function trackCopy (language, title, text) {
9695
if (window.analytics) {
96+
var sample = text.slice(0, 50).replace(/\s+/g, ' ').trim()
9797
window.analytics.track('Code Snippet Copied', {
9898
snippetLanguage: language,
9999
snippetTitle: title,

0 commit comments

Comments
 (0)