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

Is there a way to batch events and send them manually? #452

Open
emathew80 opened this issue Jun 21, 2023 · 7 comments
Open

Is there a way to batch events and send them manually? #452

emathew80 opened this issue Jun 21, 2023 · 7 comments
Labels
question Further information is requested

Comments

@emathew80
Copy link

Summary

We want to be able to batch events prior to login and after login, we can see if the user has opted out of amplitude reporting. If the user has opted out of reporting then we want to flush the batch and if the user has agreed to amplitude tracking, we want to send that batch immediately and continue sending events through the user journey. Ideas?

@emathew80 emathew80 added the question Further information is requested label Jun 21, 2023
@Mercy811
Copy link
Contributor

Hi @emathew80, events are batched by default. You can configure the batch behavior by setting eventUploadPeriodSeconds, eventUploadThreshold, eventUploadMaxBatchSize and eventMaxCount

Learn more about configurations.

@emathew80
Copy link
Author

emathew80 commented Jun 22, 2023

@Mercy811, ideally, I would want a way for the SDK to collect events and only send to amplitude when I call a function on the SDK to send events to the amplitude server.

The usecase here is that we do not know the user/client preference until login. If the user/client preference is not to send events, we cannot send events that are collected prior to login and will need to flush those events collected prior to login. If the user/client pref is that we are allowed to send events, we want to be able to batch and send the events that happen prior to login all at once at that time.

Ive looked already at the suggestions above, but none of them give the app the control on when exactly to send a batch of events. The batch size could potentially be 3 or 30. The period seconds is variable based on the user and activity prior to login, etc.

We would like to be able to collect a batch of events and then at some specific user action (ie successful login and policy eval) call the amplitude sdk to send/dispatch the batch.

@Mercy811
Copy link
Contributor

Hi @emathew80, thanks for your clarification.

If the user/client preference is not to send events, we cannot send events that are collected prior to login and will need to flush those events collected prior to login.
Is any typo here? "we cannot send events that are collected prior to login" and "will need to flush those events collected prior to login" seem to be conflicted.

We would like to be able to collect a batch of events and then at some specific user action (ie successful login and policy eval) call the amplitude sdk to send/dispatch the batch.

setOffline can achieve this (definition/comments, test code snippet)

  • setting it to true
  • setting it to false once user consent/login and then flush

@emathew80
Copy link
Author

emathew80 commented Jun 22, 2023

Ah interesting so.... if I setOfline to true in the beginning of the app launch and then I log, say, 10 events... then set setOffline to false once the user/client logs in, the SDK should send those 10 events at that time? It seems that way, but I just wanted to be sure!

@Mercy811
Copy link
Contributor

Yes it does!

@emathew80
Copy link
Author

Amazing, thank you so much!

@jhiat00
Copy link

jhiat00 commented Jul 12, 2023

@Mercy811 You mentioned an ability to flush. Is there documentation on that?

@emathew80 emathew80 reopened this Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants