rawls238 / PlanOut.js

A JavaScript port of Facebook's PlanOut Experimentation Framework
MIT License
308 stars 52 forks source link

Call async/await inside log and previouslyLogged #73

Open paulinetheitgirl opened 6 years ago

paulinetheitgirl commented 6 years ago

If I call my own API inside the log() and previouslyLogged(), is it possible to use Promises or async/await to get the result of the API call? For example if I want to have an endpoint that writes the event to an external log inside log(), and then another endpoint that reads the log to determine if the event was previouslyLogged().

thethomaseffect commented 5 years ago

You probably long figured this out but yes and no. If you're manually calling log then there's nothing stopping you but if you use stuff like logExposure then your log function will be called without await and thus no way to handle errors. I'd take a look at the code in experiment.js and write your own logExposureAsync based on what's there for now.