Comments (9)
Also, the UX on the server isn't great, because you're making either device_id or user_id required, but most of the time I don't know what's the device (it's an API call, there is no device) and sometimes I have no way to know who's the user either.
I think none of those fields should be required for server-side usage. They should both be optional.
from amplitude-node.
Okay, so it looks like it was because the call worked (200 response) but eventsIngested
was 0
.
And this is because of the user/device issue. I had to specify a device_id
value even though I'm on a server and don't know what value to use. Should I rather use a dynamically generated value for every call?
from amplitude-node.
I've fixed it at 815ff95
(#374)
But this doesn't seem great, Amplitude now believes all events are related to the same user, which isn't really the case. So I'll rather use a dynamic UUID value as default user_id to counter this behavior.
I wish this had been explained in the README, I've lost a whole day on this.
from amplitude-node.
I'd like to know if it's necessary to await the flush()
on Next.js API endpoints, I believe it is but that'd be great to have a confirmation. 😄
from amplitude-node.
Hi @Vadorequest, great to hear you solved the problem on your own.
- The Amplitude-Node will call our Amplitude HTTP v2 API, the device_id and the user_id are semi-required there. So it cannot be all optional. If a device_id is not sent with the event, it will be set to a hashed version of the user_id. So you can set a dynamic UUID as default user_id when you don't know what's the user_id is and don't pass the device_id during logEvent.
- In Amplitude-Node, the flush() function is async and will return a promise. So, yes, if you need to do something with the response you need to await it.
from amplitude-node.
In Amplitude-Node, the flush() function is async and will return a promise. So, yes, you need to await it.
I was asking in relation to https://vercel.com/docs/platform/limits#streaming-responses. I understand I need to await it if I want to do anything with the Response
, but do I need to await it to make sure the event is sent in the context of AWS Lambda? If I don't await logEvent()
but simply logEvent()
, do I take the risk of the event not being processed? That's what a bit uncertain at the moment.
Ideally, I'd rather not await when calling logEvent
, because I don't want to make any of my own API endpoints slower.
from amplitude-node.
@Vadorequest
To clarify your question,
You are using Vercel as the framework. And you are curious if Vercel does not support streaming responses will affect how you use Amplitude-Node and if you must add await when calling flush or logEvent?
cc: @ajhorst
from amplitude-node.
from amplitude-node.
I've opened a related issue on Next.js to try to figure out the pros/cons and best practices regarding all of this. vercel/next.js#26523
from amplitude-node.
Related Issues (20)
- Not compatible with Webpack 5 (Next.js 11) 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.