Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send multiple events with logEvent #23

Open
nvuillam opened this issue Sep 1, 2020 · 9 comments
Open

Send multiple events with logEvent #23

nvuillam opened this issue Sep 1, 2020 · 9 comments

Comments

@nvuillam
Copy link

nvuillam commented Sep 1, 2020

Summary

Send multiple events with logEvent

Motivations

Avoid multiple HTTP calls :)

@nvuillam
Copy link
Author

nvuillam commented Sep 1, 2020

mmmm I see that this package looks much more advanced, and already provides requested feature ....

https://github.com/geoffdutton/amplitude

I'll try to use it and tell here if i still need the enhancement ! ( i started to do it but npm install fails because package @amplitude/utils is not available on npm registry )

@kelvin-lu
Copy link
Contributor

Sorry for the inconvenience @nvuillam - we'll work rightaway to get the @amplitude/utils onto the registry. As for the multiple http calls, we're looking to use the batch endpoint as the default on an open pr (along with some logic for retrying events in the correct order).

@nvuillam
Copy link
Author

nvuillam commented Sep 1, 2020

I made some tests using amplitude npm package, it seems to work for now :)
But as your library seems more lightweight, I may switch back to it once you publish an update :)

@kelvin-lu
Copy link
Contributor

kelvin-lu commented Sep 18, 2020

Thanks @nvuillam ! We're looking forward to having an update soon. While we are discussing having mutliple events being sent in logEvent, it's also good to note that logEvent by default (in the new version) waits until the next event loop to batch and send all the events its collected - so as to avoid many many http calls. You can also set the option for it to wait even longer for the batch time to increase and send more events at a time.

@kelvin-lu
Copy link
Contributor

Hi @nvuillam - the 1.0.2 behavior is for events to be batched by logEvent and not be sent until a certain amount of time passes, or flush is called - I think this might be a suitable solution for your use?

@nvuillam
Copy link
Author

nvuillam commented Oct 1, 2020

Is the HTTP request done by a separate node instance ? If not, it could be not ok for CLIs , because it wouldn't exit until such batch is processed

@kelvin-lu
Copy link
Contributor

@nvuillam apologies for the late response!
It's using setTimeout to wait some number of seconds in the same node instance, so the concern here is valid. We're adding optioning to make the timings of these waits more configurable - what do you think? We'll also start looking into putting some of this logic in separate node instances.

also, the base optioning is to wait 0 ms - to the next event loop.

@Vadorequest
Copy link

Is there any example/doc about how to use this feature? (multiple events in one HTTP call)

@viqueen
Copy link

viqueen commented May 30, 2022

While logEvent does batching under the hood, it's a little bit counter intuitive when we actually care about the response body.
My understanding it calls this API https://developers.amplitude.com/docs/batch-event-upload-api , which makes my response handlers a little bit confusing to write

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants