Comments (10)
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.
@BeatrizFerreira @axelvaindal this is now available in 1.0.3 - see the response type to see what logEvent and flush return
from amplitude-node.
@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.
@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.
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.
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.
-
buffer execution time will be decided by the threshold you set, like every 30 sec etc.
-
Batch will be automatic and it can be forced to flush too
-
Yes, single promise.
from amplitude-node.
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.
@BeatrizFerreira Thanks for your feedback! We will definitely consider to keep that API with returning a Promise!
cc: @kelvin-lu
from amplitude-node.
@haoliu-amp that is great! Looking forward to the new version with this change!
from amplitude-node.
Related Issues (20)
- Not compatible with Webpack 5 (Next.js 11) HOT 9
- Doesn't work with Next.js in APIs (events seem sent but aren't available on Amplitude dashboard) HOT 9
- Identify event taking too long to resolve HOT 3
- Node.js example has a bug for ES5 HOT 1
- requestTimeoutMillis breaks 1.8.0 -> 1.8.1 HOT 5
- How should I generate the device ID ? HOT 6
- User properties inheritance HOT 6
- UnhandledRejection when amplitude server is unavailable
- includeUtm HOT 1
- ChainAlert: new npm maintainer has published version 1.10.0 of package @amplitude/utils
- ChainAlert: new npm maintainer has published version 1.10.0 of package @amplitude/types
- Getting host verification error while installation npm install amplitude/node HOT 1
- Where can I see the event log in amplitude? HOT 1
- Can we send batch/bulk events at once HOT 1
- 📣 Introducing NEW Amplitude SDK for Node.js [BETA]
- Not compatible with Webpack 5 (Next.js 11) (fix)
- maj tslib to next major HOT 5
- How to track revenue? HOT 3
- insert_id parameter in amplitude android sdk
- Test Issue ticket creation in AMP
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amplitude-node.