segmentio / analytics-node

The hassle-free way to integrate analytics into any node application.

Home Page:https://segment.com/libraries/node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

5.1.0 no data is sent to segment

renanbronchart opened this issue · comments

Hello, I've connected well my analytic.

But I don't receive any data.

const Analytics = require('analytics-node')
const client = new Analytics(my-key)


  const plop = await client.track({
    event: 'success/backend/signUp',
    userId: 'myUserId'
  })

@renanbronchart Thanks for your inquiry, we will be looking into this shortly. Thanks

This is probably an issue with your implementation.
Maybe make sure that the setup code is actually being executed? That the writeKey is correct?

Hey @pbassut, thanks for reply.
Yes, my writeKey is good. I've copied from segment dashboard.

But there is still (No recent data on my dashboard)
I've installed "analytics-node": "4.0.1",

@pbassut @nd4p90x
This is my analytic response when I console.log(plop) :

INFO	Analytics {
  queue: [ { message: [Object], callback: [Function: noop] } ],
  writeKey: '#########dSZAGc1TdyrEWIy',
  host: 'https://api.segment.io',
  path: '/v1/batch',
  axiosInstance: [Function: wrap] {
    request: [Function: wrap],
    getUri: [Function: wrap],
    delete: [Function: wrap],
    get: [Function: wrap],
    head: [Function: wrap],
    options: [Function: wrap],
    post: [Function: wrap],
    put: [Function: wrap],
    patch: [Function: wrap],
    defaults: {
      headers: [Object],
      transformRequest: [Array],
      transformResponse: [Array],
      timeout: 0,
      adapter: [Function: httpAdapter],
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxContentLength: -1,
      maxBodyLength: -1,
      validateStatus: [Function: validateStatus],
      transitional: [Object]
    },
    interceptors: { request: [InterceptorManager], response: [InterceptorManager] }
  },
  timeout: false,
  flushAt: 20,
  flushInterval: 10000,
  flushed: true,
  enable: true,
  timer: Timeout {
    _idleTimeout: 10000,
    _idlePrev: [TimersList],
    _idleNext: [TimersList],
    _idleStart: 1073,
    _onTimeout: [Function: bound flush],
    _timerArgs: undefined,
    _repeat: null,
    _destroyed: false,
    [Symbol(refed)]: true,
    [Symbol(kHasPrimitive)]: false,
    [Symbol(asyncId)]: 22,
    [Symbol(triggerId)]: 0
  }
}

can you setup callbacks and check if they're called? enqueue method can receive a callback as it's third parameter, and so is every other method(track, identify, group, etc, as their second parameter).

Just do a console log and see if it does anything. Please post the code here.

Oh, also, make sure the number of messages in the queue hits flushAt(default 20) or flushInterval(default 10 secs) has elapsed.

@renanbronchart Hey, did you figure it out?

Hi @renanbronchart, sorry for the late reply, I join in with what @pbassut says. It's probably a problem with your implementation since I just tested this in the lastest version (5.1.2) of consent manager and everything works correctly.

The easiest way to test it is by using the snippet found in the documentation to see if it is correctly configured. But it should we pretty straightforward.
https://github.com/segmentio/analytics-node#usage

On the other hand we will be closing this issue, I hope my answer has been useful to you and any other problem feel free to open a new issue.

Greetings, segment team.