Skip to content

Commit

Permalink
repo sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Octomerger authored Oct 23, 2020
2 parents 53eae61 + 09cb922 commit d87ac23
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions javascripts/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export function sendEvent ({
survey_email,
experiment_name,
experiment_variation,
experiment_success
experiment_success,
clipboard_operation
}) {
const body = {
_csrf: getCsrf(),
Expand Down Expand Up @@ -107,7 +108,10 @@ export function sendEvent ({
// Experiment event
experiment_name,
experiment_variation,
experiment_success
experiment_success,

// Clipboard event
clipboard_operation
}
const blob = new Blob([JSON.stringify(body)], { type: 'application/json' })
navigator.sendBeacon('/events', blob)
Expand Down Expand Up @@ -170,6 +174,13 @@ export default function initializeEvents () {
page_render_duration: render
})

// Clipboard event
;['copy', 'cut', 'paste'].forEach(verb => {
document.documentElement.addEventListener(verb, () => {
sendEvent({ type: 'clipboard', clipboard_operation: verb })
})
})

// Link event
document.documentElement.addEventListener('click', evt => {
const link = evt.target.closest('a[href^="http"]')
Expand Down

0 comments on commit d87ac23

Please sign in to comment.