question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Only first event logged / sent to server

See original GitHub issue

I 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:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:28 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
blazzycommented, Nov 28, 2018

@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.

2reactions
blazzycommented, Nov 28, 2018

@FunkyloverOne, If you are using the amplitude snippet to load amplitude, you need to invoke amplitude.getInstance() every time you call logEvent.

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Only first event logged / sent to server · Issue #18 - GitHub
I noticed the _q property of the amplitude object is correctly appended w/ new event data after the first one.
Read more >
How to start a Server-Sent Event "only once" inside a ...
var shWorker = new SharedWorker('woker.js'); shWorker.port.onmessage = function (e) { console.log('Message received from worker'); setmsj(e.
Read more >
Server Sent Events - The Modern JavaScript Tutorial
The Server-Sent Events specification describes a built-in class EventSource , that keeps ... One-directional: only server sends data.
Read more >
What Server-Sent Events is - and how and when to implement it
In a nutshell, a server-sent event is when updates are pushed (rather than pulled, or requested) from a server to a browser.
Read more >
Event ID 41 The system has rebooted without cleanly shutting ...
Scenario 3: The computer is unresponsive or randomly restarts, and Event ID 41 isn't logged or the Event ID 41 entry lists error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found