Skip to content
This repository was archived by the owner on Feb 13, 2024. It is now read-only.
This repository was archived by the owner on Feb 13, 2024. It is now read-only.

Track call fails when property has bigint attribute #375

Description

@rgaino

Package version is latest: "@segment/analytics-node": "^1.1.3".

The segment node package fails to send events when any of the properties attributes are of the bigint type. There's no type error, and no error returned in the callback, but the track() calls returns immediately.

import { Analytics } from '@segment/analytics-node';

const analytics = new Analytics({ writeKey: process.env.SEGMENT_WRITE_KEY });

const start = new Date();
const timeElapsedInMs = () => new Date().getTime() - start.getTime();

analytics.track(
	{
		userId: 'test@test.com',
		event: 'NoBigInt event',
		properties: {
			someInt: 1,
		},
	},
	(err) => console.log('err1:', err, 'timeElapsedInMs:', timeElapsedInMs()),
);

analytics.track(
	{
		userId: 'test@test.com',
		event: 'BigInt event',
		properties: {
			someInt: 2,
			someBigInt: BigInt(1234567890),
		},
	},
	(err) => console.log('err2:', err, 'timeElapsedInMs:', timeElapsedInMs()),
);

output:

err2: undefined timeElapsedInMs: 302
err1: undefined timeElapsedInMs: 11033

I'm not quite sure what the behaviour should be here, but it took me some digging to figure out what was going on. On my app, I added a type check because I have a wrapper and use TypeScript, so now I'm covered. I think at a minimum the library should not allow bigint types, because currently the type is Record<string, any> (see https://github.com/segmentio/analytics-next/blob/master/packages/core/src/events/interfaces.ts#L22C50-L22C50), or the callback should return an error, or both.

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions