* Move site search to use an endpoint * Update browser.js * Update search.js * Update lib/search/versions.js Co-authored-by: James M. Greene <JamesMGreene@github.com> * Fix URLs Co-authored-by: James M. Greene <JamesMGreene@github.com>
29 lines
747 B
JavaScript
29 lines
747 B
JavaScript
import murmur from 'imurmurhash'
|
|
import { getUserEventsId, sendEvent } from './events'
|
|
// import h from './hyperscript'
|
|
|
|
const TREATMENT = 'TREATMENT'
|
|
const CONTROL = 'CONTROL'
|
|
|
|
export function bucket (test) {
|
|
const id = getUserEventsId()
|
|
const hash = murmur(test).hash(id).result()
|
|
return hash % 2 ? TREATMENT : CONTROL
|
|
}
|
|
|
|
export async function sendSuccess (test) {
|
|
return sendEvent({
|
|
type: 'experiment',
|
|
experiment_name: test,
|
|
experiment_variation: bucket(test).toLowerCase(),
|
|
experiment_success: true
|
|
})
|
|
}
|
|
|
|
export default function () {
|
|
// const testName = '$test-name$'
|
|
// const xbucket = bucket(testName)
|
|
// if (xbucket === TREATMENT) { ... }
|
|
// x.addEventListener('click', () => { sendSuccess(testName) })
|
|
}
|