Skip to content

Commit d87ac23

Browse files
authored
repo sync
2 parents 53eae61 + 09cb922 commit d87ac23

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

javascripts/events.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ export function sendEvent ({
4646
survey_email,
4747
experiment_name,
4848
experiment_variation,
49-
experiment_success
49+
experiment_success,
50+
clipboard_operation
5051
}) {
5152
const body = {
5253
_csrf: getCsrf(),
@@ -107,7 +108,10 @@ export function sendEvent ({
107108
// Experiment event
108109
experiment_name,
109110
experiment_variation,
110-
experiment_success
111+
experiment_success,
112+
113+
// Clipboard event
114+
clipboard_operation
111115
}
112116
const blob = new Blob([JSON.stringify(body)], { type: 'application/json' })
113117
navigator.sendBeacon('/events', blob)
@@ -170,6 +174,13 @@ export default function initializeEvents () {
170174
page_render_duration: render
171175
})
172176

177+
// Clipboard event
178+
;['copy', 'cut', 'paste'].forEach(verb => {
179+
document.documentElement.addEventListener(verb, () => {
180+
sendEvent({ type: 'clipboard', clipboard_operation: verb })
181+
})
182+
})
183+
173184
// Link event
174185
document.documentElement.addEventListener('click', evt => {
175186
const link = evt.target.closest('a[href^="http"]')

0 commit comments

Comments
 (0)