Skip to main content

I recently implemented @amplitude/analytics-browser package in my react application. I have initialized the app and then I am using the track() method to send the events to amplitude. However, I noticed there's a lot of duplication. When I load the app, it will place a request to https://api2.amplitude.com/2/httpapi with the request object firing the load event. When I click a button, it will again make a similar request but now it contains the load event as well as the click event. I was assuming that it will only send one event at a time but it looks like it keeps clubbing up the events and sends them to the server. Every time I perform an action, it clubs up with the previous events and sends it to the server. 

 

How can I prevent it from sending all the events all over again and again? Can I not send one event at a time?

Thanks.

Thanks for reaching out here @asharma. This related thread might help as you work out the next steps. 

To prevent this behavior and send events immediately to Amplitude, you can disable event queuing by setting the batchEvents option to false when initializing the Amplitude object. Alternatively, you can use the logEvent() method instead of track() to send individual events without queueing.


I have tried both `batchEvents` set to “false” and using `logEvent()`, but it still sends events in batches. Here’s an example of the network request. You can see how the httpapi request contains multiple events in a single payload:

 

How do I stop it from doing this? 


Thanks for trying that @asharma. I’ll escalate this to our support team for further investigation.


@asharma Happy to help!

 

Please share the following information:

  1. How is the SDK being initialized? Can you provide a screenshot(removing the API Key and any other PII).
  2. The SDK and version being ran.
  3. Is there a website where this SDK is being ran on that you can provide a URL to?

Hope to hear from you soon!


Reply