amplitude / amplitude/Amplitude-Node

Doesn't work with Next.js in APIs (events seem sent but aren't available on Amplitude dashboard)

Ouverte
#123 9 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
bug
Langage dominant
TypeScript
Étoiles
73
Forks
20
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

## Expected Behavior
Event sent using @amplitude/node should be available on the Amplitude Dashboard

## Current Behavior
Events aren't available in Amplitude, as if they were never received.

Logs:
```
info - ready on http://localhost:8888
2021-06-22T18:09:53.157Z [modules/core/amplitude/amplitudeServerClient] Logging Amplitude event "api-invoked" with properties: { apiEndpoint: 'status' }
2021-06-22T18:09:53.157Z [modules/core/amplitude/amplitudeServerClient] NodeClient {
_events: [],
_responseListeners: [],
_flushTimer: null,
_apiKey: '5ea02d86a6840c165fcc01377131fa13',
_options: {
serverUrl: 'https://api2.amplitude.com/2/httpapi',
debug: true,
maxCachedEvents: 16000,
logLevel: 3,
optOut: false,
retryTimeouts: [
100, 100, 200, 200,
400, 400, 800, 800,
1600, 1600, 3200, 3200
],
retryClass: null,
transportClass: null,
uploadIntervalInSec: 0,
minIdLength: null
},
_transportWithRetry: RetryHandler {
_apiKey: '5ea02d86a6840c165fcc01377131fa13',
_options: {
serverUrl: 'https://api2.amplitude.com/2/httpapi',
debug: true,
maxCachedEvents: 16000,
logLevel: 3,
optOut: false,
retryTimeouts: [Array],
retryClass: null,
transportClass: null,
uploadIntervalInSec: 0,
minIdLength: null
},
_transport: HTTPTransport {
options: [Object],
_uploadInProgress: false,
_requestQueue: [AsyncQueue],
module: [Object]
},
_idToBuffer: Map(0) {},
_eventsInRetry: 0
}
} 5ea02d86a6840c165fcc01377131fa13

response {
status: 'success',
statusCode: 200,
body: {
eventsIngested: 0,
payloadSizeBytes: 58,
serverUploadTime: 1624385394010
}
}

```

The API key is defined, the response is sent and awaited for, the result is a success, but there are no data in the Amplitude Dashboard. The `@amplitude/react-amplitude` package works fine on the browser, though.

It doesn't work locally, and it doesn't work on Vercel either.

![image](https://user-images.githubusercontent.com/3807458/122980732-4cfc6b00-d399-11eb-9f46-692a86300552.png)

![image](https://user-images.githubusercontent.com/3807458/122980781-5b4a8700-d399-11eb-9a3f-4847c7df3333.png)

I'm not sure what's wrong.

## Possible Solution
Potentially related to flushing and https://vercel.com/docs/platform/limits#streaming-responses, but I've flushed and awaited for the flush to avoid any issue. Also, it doesn't even work locally.

## Steps to Reproduce

1. `git clone git@github.com:UnlyEd/next-right-now.git nrn-refactor-amplitude && cd nrn-refactor-amplitude && git checkout refactor-amplitude && cp .env.local.example .env.local && yarn && yarn start`
2. Go to `localhost:8888/api/status` and look at the server console

## Environment
- SDK Version: "@amplitude/node": "1.6.1",
- Node version: v14

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.