Giter Club home page Giter Club logo

Comments (10)

BeatrizFerreira avatar BeatrizFerreira commented on August 20, 2024 4

Firstly, thanks for the new SDK for Node :)
I was about to open a new issue, but I guess this issue is exactly the problem we have. We want to log some events on Amplitude by executing a cloud function (google cloud function) written in node. The thing is: when the cloud function is invoked, one instance of it is created, executed and, when it finishes, the instance is destructed by GCP and we won't be able to check if the request was successful or not. I believe having a Promise as the return from the logEvent method would help to prevent loss of events by resending them or logging the error when it happens.

Is there any way of returning a Promise from logEvent method?!

I've seen your team already have an idea of a new architecture solution that would be great for sending lots of events in one roll, but I'd suggest having also the possibility of sending only one event ( that would be very useful for simple log events using node on server-side).

Thanks in advance.

from amplitude-node.

kelvin-lu avatar kelvin-lu commented on August 20, 2024 2

@BeatrizFerreira @axelvaindal this is now available in 1.0.3 - see the response type to see what logEvent and flush return

from amplitude-node.

haoliu-amp avatar haoliu-amp commented on August 20, 2024

@axelvaindal Glad to hear that you're using our Node SDK. Are you trying to know if an event was successfully submitted to our sever?

from amplitude-node.

axelvaindal avatar axelvaindal commented on August 20, 2024

@haoliu-amp Indeed, this is what I'm trying to do. More specifically, I would like to get the success status if it's okay or the error message to help me debug the current logEvent request if it's not.

from amplitude-node.

haoliu-amp avatar haoliu-amp commented on August 20, 2024

We're thinking changing current design. Instead of triggering a network call whenever submitting one event. We wanna buffer events and then create a batch request instead over all these events.

So when you log an event, there won't be any errors since it's just putting it to a buffer.

However, when batch request happens, we can expose a promise that time, and you can listen to that. Do you think that will help?

from amplitude-node.

axelvaindal avatar axelvaindal commented on August 20, 2024

When exactly will the buffer be executed ?
Are you thinking about providing something like that:

client.logEvent(); // this push inside an internal buffer
client.logEvent(); // this push inside an internal buffer
await client.sendEvents(); // This send the batch request with all the events in the buffer

Or do you think the batch send will be handled automatically based on a specific trigger ?

Considering there may be multiple events in that batch, I assume you could expose a single Promise, which either return a success status (or whatever) if the batch request went well, or the array of errors description for each event that went wrong 🤔

from amplitude-node.

haoliu-amp avatar haoliu-amp commented on August 20, 2024
  1. buffer execution time will be decided by the threshold you set, like every 30 sec etc.

  2. Batch will be automatic and it can be forced to flush too

  3. Yes, single promise.

from amplitude-node.

axelvaindal avatar axelvaindal commented on August 20, 2024

Alright, things are clear thanks.

Not sure if I will ever need to batch event sending, but if you feel this is needed to avoid spamming your service with single calls, it's fine for me.
In our current usage, we simply log a single event when something occurs in our server, so the call will never contain multiple events, but perhaps there may be some cases when someone would like to log multiple times in the same server side process.

from amplitude-node.

haoliu-amp avatar haoliu-amp commented on August 20, 2024

@BeatrizFerreira Thanks for your feedback! We will definitely consider to keep that API with returning a Promise!

cc: @kelvin-lu

from amplitude-node.

BeatrizFerreira avatar BeatrizFerreira commented on August 20, 2024

@haoliu-amp that is great! Looking forward to the new version with this change!

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.