mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-02 15:30:50 -05:00
f0b3d8a26a
[misc] submit events and prepare roll-out for pdf caching w/ split test GitOrigin-RevId: a7b7af65e1adf5bf003b65d96f1641a343b4b09c
19 lines
448 B
JavaScript
19 lines
448 B
JavaScript
import { postJSON } from './fetch-json'
|
|
|
|
export function send(category, action, label, value) {
|
|
if (typeof window.ga === 'function') {
|
|
window.ga('send', 'event', category, action, label, value)
|
|
}
|
|
}
|
|
|
|
export function sendMB(key, body = {}) {
|
|
postJSON(`/event/${key}`, { body }).catch(() => {
|
|
// ignore errors
|
|
})
|
|
}
|
|
|
|
export function sendMBSampled(key, body = {}, rate = 0.01) {
|
|
if (Math.random() < rate) {
|
|
sendMB(key, body)
|
|
}
|
|
}
|