snowplow-javascript-tracker icon indicating copy to clipboard operation
snowplow-javascript-tracker copied to clipboard

Consider returning a promise from flush method in node tracker

Open adatzer opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe. Currently gotEmitter's flush method is not async and returns void instead of a promise. This makes it harder to use in environments where a promise is needed to ensure all async tasks complete before exiting (e.g. AWS Lambda async handlers).

Describe the solution you'd like flush is async/returns a promise.

Describe alternatives you've considered At the moment the way to ensure flush completes in such environments is to wrap the emitter in a promise, and configure it with a callback that resolves and rejects that promise.

adatzer avatar Aug 19 '22 04:08 adatzer

I've often pondered if we should "promisify" the whole tracker...

paulboocock avatar Aug 19 '22 08:08 paulboocock