Only first event logged / sent to server
See original GitHub issueI integrated amplitude-javascript into my Angular/Ionic app using this method: https://github.com/mounibec/angular-amplitude.
I’m experiencing a strange behavior: if I turn on the $locationChangeStart
listener, the first event (first route change) is correctly sent to the server (I’m monitoring api.amplitude.com
calls). But all subsequent events are not sent (no errors). If I turn off the listener and send some events manually, same behavior: only the first logEvent
is logged.
I noticed the _q
property of the amplitude
object is correctly appended w/ new event data after the first one. In local storage, amplitude_unsent
stays empty and amplitude_lastEventId
stays the same.
FIY I’m using the same integration on another angular app (w/o Ionic though) and it’s working fine with the $locationChangeStart
listener.
Any idea as to why or how to debug this?
Thanks.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:28 (7 by maintainers)
@janbalaz The callback status here is misleading. Your events are being sent. This is just a dumb callback API.
Even though the callback gets invoked right away with
(0, 'No request sent' '{reason: "Request already in progress"}')
, the subsequent events are still being sent immediately after the first event is sent.The subsequent events get batched together in a single request to amplitude. If you examine the network requests going out you’ll see the the calls to
https://api.amplitude.com
A more sensible version of the SDK would only invoke the callback after it attempted to send the event. The fact that the following events are queued for a second after the first event goes out is meaningless.
@FunkyloverOne, If you are using the amplitude snippet to load amplitude, you need to invoke
amplitude.getInstance()
every time you calllogEvent
.When you use the snippet, the initial instance you get would just be a stubbed out version of an instance because the amplitude analytics script hasn’t been fetched and loaded yet. That stubbed out version just queues up calls to
logEvent
and the like until the the amplitude library fully loads and runs through the queue.