Giter Club home page Giter Club logo

Comments (3)

ajhorst avatar ajhorst commented on July 1, 2024

@florian-milky the skipped response should only be returned from flush when either there are no events remaining in the buffer, or the events are incorrectly formatted. Where is it that you notice events are missing? Are they not appearing on the amplitude website?

from amplitude-node.

florian-milky avatar florian-milky commented on July 1, 2024

@ajhorst I log something when the promise is resolved. So I got like 13 logs right before logEvents, and then I got like 10 logs that the promise resolved. Then the flush resolves. On amplitude website I don't see events that didn't resolve.

Now I double checked my code and I realise I expected the promise to throw because I was using async/await, but when I stopped awaiting the logEvent, I removed the async/await which means the code is not gonna throw anymore 🤦

So I'll handle that and check why it is throwing.

Edit: ok obviously not fully awake yet. I am not catching the promise so it would fail if one of them would throw.

Some code:

export function logMetrics(metrics) {
  console.log(`Logging metrics into ${process.env.ENV}`, metrics);
  client
    .logEvent({
      event_type: 'KPI - PageSpeed audit',
      user_id: 'lambda-lighthouse',
      event_properties: metrics,
    })
    .then((r) => console.log(metrics.target, r));
}
   // iterating over some stuff and calling logMetrics

    console.log('Flushing metrics to amplitude');
    const response = await flush();
    if (response.status !== Status.Success && response.status !== Status.Skipped) {
      console.log('Flushing did not work', response);
      throw new Error('Could not flush amplitude events');
    }
    console.log('Flushed', { status: response.status });

from amplitude-node.

ajhorst avatar ajhorst commented on July 1, 2024

@florian-milky are there any console warnings in your browser window when you try this?

from amplitude-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.