mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
27 lines
613 B
CoffeeScript
27 lines
613 B
CoffeeScript
|
define [], () ->
|
||
|
chooseOption = (testName, option1, option2, callback = (error, option) ->) ->
|
||
|
if Math.random() < 0.5
|
||
|
option = option1
|
||
|
else
|
||
|
option = option2
|
||
|
|
||
|
loaded = false
|
||
|
do initTest = ->
|
||
|
return if loaded
|
||
|
if mixpanel?.get_property?
|
||
|
attributes = {}
|
||
|
attributes[testName] = option
|
||
|
mixpanel?.register_once( attributes )
|
||
|
mixpanel?.people.set( attributes )
|
||
|
loaded = true
|
||
|
callback null, mixpanel?.get_property( testName )
|
||
|
else
|
||
|
setTimeout(initTest, 300)
|
||
|
|
||
|
fallback = () ->
|
||
|
return if loaded
|
||
|
loaded = true
|
||
|
callback null, option1
|
||
|
setTimeout fallback, 1500
|
||
|
|