Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repo sync #757

Merged
merged 2 commits into from
Oct 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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