posthog-node 3.5.0 → 3.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { PostHogFetchOptions, PostHogFetchResponse, PostHogAutocaptureElement, PostHogDecideResponse, PosthogCoreOptions, PostHogEventProperties, PostHogPersistedProperty, PosthogCaptureOptions, JsonType } from './types';
1
+ import { PostHogFetchOptions, PostHogFetchResponse, PostHogAutocaptureElement, PostHogDecideResponse, PosthogCoreOptions, PostHogEventProperties, PostHogPersistedProperty, PostHogCaptureOptions, JsonType } from './types';
2
2
  import { RetriableOptions } from './utils';
3
3
  export * as utils from './utils';
4
4
  import { LZString } from './lz-string';
@@ -36,17 +36,17 @@ export declare abstract class PostHogCoreStateless {
36
36
  /***
37
37
  *** TRACKING
38
38
  ***/
39
- protected identifyStateless(distinctId: string, properties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
39
+ protected identifyStateless(distinctId: string, properties?: PostHogEventProperties, options?: PostHogCaptureOptions): this;
40
40
  protected captureStateless(distinctId: string, event: string, properties?: {
41
41
  [key: string]: any;
42
- }, options?: PosthogCaptureOptions): this;
42
+ }, options?: PostHogCaptureOptions): this;
43
43
  protected aliasStateless(alias: string, distinctId: string, properties?: {
44
44
  [key: string]: any;
45
- }, options?: PosthogCaptureOptions): this;
45
+ }, options?: PostHogCaptureOptions): this;
46
46
  /***
47
47
  *** GROUPS
48
48
  ***/
49
- protected groupIdentifyStateless(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PosthogCaptureOptions, distinctId?: string, eventProperties?: PostHogEventProperties): this;
49
+ protected groupIdentifyStateless(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PostHogCaptureOptions, distinctId?: string, eventProperties?: PostHogEventProperties): this;
50
50
  /***
51
51
  *** FEATURE FLAGS
52
52
  ***/
@@ -63,7 +63,7 @@ export declare abstract class PostHogCoreStateless {
63
63
  /***
64
64
  *** QUEUEING AND FLUSHING
65
65
  ***/
66
- protected enqueue(type: string, _message: any, options?: PosthogCaptureOptions): void;
66
+ protected enqueue(type: string, _message: any, options?: PostHogCaptureOptions): void;
67
67
  flushAsync(): Promise<any>;
68
68
  flush(callback?: (err?: any, data?: any) => void): void;
69
69
  private fetchWithRetry;
@@ -101,20 +101,20 @@ export declare abstract class PostHogCore extends PostHogCoreStateless {
101
101
  /***
102
102
  *** TRACKING
103
103
  ***/
104
- identify(distinctId?: string, properties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
104
+ identify(distinctId?: string, properties?: PostHogEventProperties, options?: PostHogCaptureOptions): this;
105
105
  capture(event: string, properties?: {
106
106
  [key: string]: any;
107
- }, options?: PosthogCaptureOptions): this;
107
+ }, options?: PostHogCaptureOptions): this;
108
108
  alias(alias: string): this;
109
- autocapture(eventType: string, elements: PostHogAutocaptureElement[], properties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
109
+ autocapture(eventType: string, elements: PostHogAutocaptureElement[], properties?: PostHogEventProperties, options?: PostHogCaptureOptions): this;
110
110
  /***
111
111
  *** GROUPS
112
112
  ***/
113
113
  groups(groups: {
114
114
  [type: string]: string | number;
115
115
  }): this;
116
- group(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
117
- groupIdentify(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PosthogCaptureOptions): this;
116
+ group(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PostHogCaptureOptions): this;
117
+ groupIdentify(groupType: string, groupKey: string | number, groupProperties?: PostHogEventProperties, options?: PostHogCaptureOptions): this;
118
118
  /***
119
119
  * PROPERTIES
120
120
  ***/
@@ -45,7 +45,10 @@ export declare type PostHogFetchOptions = {
45
45
  body?: string;
46
46
  signal?: AbortSignal;
47
47
  };
48
- export declare type PosthogCaptureOptions = {
48
+ export declare type PostHogCaptureOptions = {
49
+ /** If provided overrides the auto-generated event ID */
50
+ uuid?: string;
51
+ /** If provided overrides the auto-generated timestamp */
49
52
  timestamp?: Date;
50
53
  disableGeoip?: boolean;
51
54
  };
@@ -1,5 +1,5 @@
1
1
  import { JsonType, PosthogCoreOptions, PostHogCoreStateless, PostHogFetchOptions, PostHogFetchResponse, PosthogFlagsAndPayloadsResponse, PostHogPersistedProperty } from '../../posthog-core/src';
2
- import { EventMessageV1, GroupIdentifyMessage, IdentifyMessageV1, PostHogNodeV1 } from './types';
2
+ import { EventMessage, GroupIdentifyMessage, IdentifyMessage, PostHogNodeV1 } from './types';
3
3
  export declare type PostHogOptions = PosthogCoreOptions & {
4
4
  persistence?: 'memory';
5
5
  personalApiKey?: string;
@@ -24,8 +24,8 @@ export declare class PostHog extends PostHogCoreStateless implements PostHogNode
24
24
  enable(): void;
25
25
  disable(): void;
26
26
  debug(enabled?: boolean): void;
27
- capture({ distinctId, event, properties, groups, sendFeatureFlags, timestamp, disableGeoip }: EventMessageV1): void;
28
- identify({ distinctId, properties, disableGeoip }: IdentifyMessageV1): void;
27
+ capture({ distinctId, event, properties, groups, sendFeatureFlags, timestamp, disableGeoip, uuid, }: EventMessage): void;
28
+ identify({ distinctId, properties, disableGeoip }: IdentifyMessage): void;
29
29
  alias(data: {
30
30
  distinctId: string;
31
31
  alias: string;
@@ -1,14 +1,15 @@
1
1
  import { JsonType } from '../../posthog-core/src';
2
- export interface IdentifyMessageV1 {
2
+ export interface IdentifyMessage {
3
3
  distinctId: string;
4
4
  properties?: Record<string | number, any>;
5
5
  disableGeoip?: boolean;
6
6
  }
7
- export interface EventMessageV1 extends IdentifyMessageV1 {
7
+ export interface EventMessage extends IdentifyMessage {
8
8
  event: string;
9
9
  groups?: Record<string, string | number>;
10
10
  sendFeatureFlags?: boolean;
11
11
  timestamp?: Date;
12
+ uuid?: string;
12
13
  }
13
14
  export interface GroupIdentifyMessage {
14
15
  groupType: string;
@@ -67,7 +68,7 @@ export declare type PostHogNodeV1 = {
67
68
  * @param groups OPTIONAL | object of what groups are related to this event, example: { company: 'id:5' }. Can be used to analyze companies instead of users.
68
69
  * @param sendFeatureFlags OPTIONAL | Used with experiments. Determines whether to send feature flag values with the event.
69
70
  */
70
- capture({ distinctId, event, properties, groups, sendFeatureFlags }: EventMessageV1): void;
71
+ capture({ distinctId, event, properties, groups, sendFeatureFlags }: EventMessage): void;
71
72
  /**
72
73
  * @description Identify lets you add metadata on your users so you can more easily identify who they are in PostHog,
73
74
  * and even do things like segment users by these properties.
@@ -75,7 +76,7 @@ export declare type PostHogNodeV1 = {
75
76
  * @param distinctId which uniquely identifies your user
76
77
  * @param properties with a dict with any key: value pairs
77
78
  */
78
- identify({ distinctId, properties }: IdentifyMessageV1): void;
79
+ identify({ distinctId, properties }: IdentifyMessage): void;
79
80
  /**
80
81
  * @description To marry up whatever a user does before they sign up or log in with what they do after you need to make an alias call.
81
82
  * This will allow you to answer questions like "Which marketing channels leads to users churning after a month?"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-node",
3
- "version": "3.5.0",
3
+ "version": "3.6.1",
4
4
  "description": "PostHog Node.js integration",
5
5
  "repository": {
6
6
  "type": "git",
@@ -532,13 +532,9 @@ function matchProperty(
532
532
  }
533
533
  }
534
534
  case 'is_date_after':
535
- case 'is_date_before':
536
- case 'is_relative_date_before':
537
- case 'is_relative_date_after': {
538
- let parsedDate = null
539
- if (['is_relative_date_before', 'is_relative_date_after'].includes(operator)) {
540
- parsedDate = relativeDateParseForFeatureFlagMatching(String(value))
541
- } else {
535
+ case 'is_date_before': {
536
+ let parsedDate = relativeDateParseForFeatureFlagMatching(String(value))
537
+ if (parsedDate == null) {
542
538
  parsedDate = convertToDateTime(value)
543
539
  }
544
540
 
@@ -546,7 +542,7 @@ function matchProperty(
546
542
  throw new InconclusiveMatchError(`Invalid date: ${value}`)
547
543
  }
548
544
  const overrideDate = convertToDateTime(overrideValue)
549
- if (['is_date_before', 'is_relative_date_before'].includes(operator)) {
545
+ if (['is_date_before'].includes(operator)) {
550
546
  return overrideDate < parsedDate
551
547
  }
552
548
  return overrideDate > parsedDate
@@ -691,7 +687,7 @@ function convertToDateTime(value: string | number | (string | number)[] | Date):
691
687
  }
692
688
 
693
689
  function relativeDateParseForFeatureFlagMatching(value: string): Date | null {
694
- const regex = /^(?<number>[0-9]+)(?<interval>[a-z])$/
690
+ const regex = /^-?(?<number>[0-9]+)(?<interval>[a-z])$/
695
691
  const match = value.match(regex)
696
692
  const parsedDt = new Date(new Date().toISOString())
697
693
 
@@ -10,7 +10,7 @@ import {
10
10
  PostHogPersistedProperty,
11
11
  } from '../../posthog-core/src'
12
12
  import { PostHogMemoryStorage } from '../../posthog-core/src/storage-memory'
13
- import { EventMessageV1, GroupIdentifyMessage, IdentifyMessageV1, PostHogNodeV1 } from './types'
13
+ import { EventMessage, GroupIdentifyMessage, IdentifyMessage, PostHogNodeV1 } from './types'
14
14
  import { FeatureFlagsPoller } from './feature-flags'
15
15
  import fetch from './fetch'
16
16
 
@@ -100,9 +100,18 @@ export class PostHog extends PostHogCoreStateless implements PostHogNodeV1 {
100
100
  this.featureFlagsPoller?.debug(enabled)
101
101
  }
102
102
 
103
- capture({ distinctId, event, properties, groups, sendFeatureFlags, timestamp, disableGeoip }: EventMessageV1): void {
104
- const _capture = (props: EventMessageV1['properties']): void => {
105
- super.captureStateless(distinctId, event, props, { timestamp, disableGeoip })
103
+ capture({
104
+ distinctId,
105
+ event,
106
+ properties,
107
+ groups,
108
+ sendFeatureFlags,
109
+ timestamp,
110
+ disableGeoip,
111
+ uuid,
112
+ }: EventMessage): void {
113
+ const _capture = (props: EventMessage['properties']): void => {
114
+ super.captureStateless(distinctId, event, props, { timestamp, disableGeoip, uuid })
106
115
  }
107
116
 
108
117
  // :TRICKY: If we flush, or need to shut down, to not lose events we want this promise to resolve before we flush
@@ -155,7 +164,7 @@ export class PostHog extends PostHogCoreStateless implements PostHogNodeV1 {
155
164
  this.addPendingPromise(capturePromise)
156
165
  }
157
166
 
158
- identify({ distinctId, properties, disableGeoip }: IdentifyMessageV1): void {
167
+ identify({ distinctId, properties, disableGeoip }: IdentifyMessage): void {
159
168
  // Catch properties passed as $set and move them to the top level
160
169
  const personProperties = properties?.$set || properties
161
170
 
@@ -451,7 +460,7 @@ export class PostHog extends PostHogCoreStateless implements PostHogNodeV1 {
451
460
  personProperties?: Record<string, string>,
452
461
  groupProperties?: Record<string, Record<string, string>>
453
462
  ): { allPersonProperties: Record<string, string>; allGroupProperties: Record<string, Record<string, string>> } {
454
- const allPersonProperties = { $current_distinct_id: distinctId, ...(personProperties || {}) }
463
+ const allPersonProperties = { distinct_id: distinctId, ...(personProperties || {}) }
455
464
 
456
465
  const allGroupProperties: Record<string, Record<string, string>> = {}
457
466
  if (groups) {
package/src/types.ts CHANGED
@@ -1,16 +1,17 @@
1
1
  import { JsonType } from '../../posthog-core/src'
2
2
 
3
- export interface IdentifyMessageV1 {
3
+ export interface IdentifyMessage {
4
4
  distinctId: string
5
5
  properties?: Record<string | number, any>
6
6
  disableGeoip?: boolean
7
7
  }
8
8
 
9
- export interface EventMessageV1 extends IdentifyMessageV1 {
9
+ export interface EventMessage extends IdentifyMessage {
10
10
  event: string
11
11
  groups?: Record<string, string | number> // Mapping of group type to group id
12
12
  sendFeatureFlags?: boolean
13
13
  timestamp?: Date
14
+ uuid?: string
14
15
  }
15
16
 
16
17
  export interface GroupIdentifyMessage {
@@ -75,7 +76,7 @@ export type PostHogNodeV1 = {
75
76
  * @param groups OPTIONAL | object of what groups are related to this event, example: { company: 'id:5' }. Can be used to analyze companies instead of users.
76
77
  * @param sendFeatureFlags OPTIONAL | Used with experiments. Determines whether to send feature flag values with the event.
77
78
  */
78
- capture({ distinctId, event, properties, groups, sendFeatureFlags }: EventMessageV1): void
79
+ capture({ distinctId, event, properties, groups, sendFeatureFlags }: EventMessage): void
79
80
 
80
81
  /**
81
82
  * @description Identify lets you add metadata on your users so you can more easily identify who they are in PostHog,
@@ -84,7 +85,7 @@ export type PostHogNodeV1 = {
84
85
  * @param distinctId which uniquely identifies your user
85
86
  * @param properties with a dict with any key: value pairs
86
87
  */
87
- identify({ distinctId, properties }: IdentifyMessageV1): void
88
+ identify({ distinctId, properties }: IdentifyMessage): void
88
89
 
89
90
  /**
90
91
  * @description To marry up whatever a user does before they sign up or log in with what they do after you need to make an alias call.
@@ -146,6 +146,7 @@ describe('PostHogSentryIntegration', () => {
146
146
  library: 'posthog-node',
147
147
  library_version: '1.2.3',
148
148
  timestamp: expect.any(String),
149
+ uuid: expect.any(String),
149
150
  },
150
151
  ])
151
152
  })
@@ -354,7 +354,7 @@ describe('local evaluation', () => {
354
354
  distinct_id: 'some-distinct-id_outside_rollout?',
355
355
  groups: {},
356
356
  person_properties: {
357
- $current_distinct_id: 'some-distinct-id_outside_rollout?',
357
+ distinct_id: 'some-distinct-id_outside_rollout?',
358
358
  region: 'USA',
359
359
  email: 'a@b.com',
360
360
  },
@@ -376,7 +376,7 @@ describe('local evaluation', () => {
376
376
  token: 'TEST_API_KEY',
377
377
  distinct_id: 'some-distinct-id',
378
378
  groups: {},
379
- person_properties: { $current_distinct_id: 'some-distinct-id', doesnt_matter: '1' },
379
+ person_properties: { distinct_id: 'some-distinct-id', doesnt_matter: '1' },
380
380
  group_properties: {},
381
381
  geoip_disable: true,
382
382
  }),
@@ -2054,7 +2054,7 @@ describe('match properties', () => {
2054
2054
  it('with relative date operators', () => {
2055
2055
  jest.setSystemTime(new Date('2022-05-01'))
2056
2056
 
2057
- const property_a = { key: 'key', value: '6h', operator: 'is_relative_date_before' }
2057
+ const property_a = { key: 'key', value: '-6h', operator: 'is_date_before' }
2058
2058
  expect(matchProperty(property_a, { key: '2022-03-01' })).toBe(true)
2059
2059
  expect(matchProperty(property_a, { key: '2022-04-30' })).toBe(true)
2060
2060
 
@@ -2073,58 +2073,53 @@ describe('match properties', () => {
2073
2073
  // however js understands numbers as date offsets from utc epoch
2074
2074
  expect(() => matchProperty(property_a, { key: 1 })).not.toThrow(InconclusiveMatchError)
2075
2075
 
2076
- const property_b = { key: 'key', value: '1h', operator: 'is_relative_date_after' }
2076
+ const property_b = { key: 'key', value: '1h', operator: 'is_date_after' }
2077
2077
  expect(matchProperty(property_b, { key: '2022-05-02' })).toBe(true)
2078
2078
  expect(matchProperty(property_b, { key: '2022-05-30' })).toBe(true)
2079
2079
  expect(matchProperty(property_b, { key: new Date(2022, 4, 30) })).toBe(true)
2080
2080
  expect(matchProperty(property_b, { key: new Date('2022-05-30') })).toBe(true)
2081
2081
  expect(matchProperty(property_b, { key: '2022-04-30' })).toBe(false)
2082
2082
 
2083
- // # Invalid flag property
2084
- const property_c = { key: 'key', value: 1234, operator: 'is_relative_date_after' }
2085
- expect(() => matchProperty(property_c, { key: '2022-05-30' })).toThrow(InconclusiveMatchError)
2086
- expect(() => matchProperty(property_c, { key: 1 })).toThrow(InconclusiveMatchError)
2087
-
2088
2083
  // # Try all possible relative dates
2089
- const property_e = { key: 'key', value: '1h', operator: 'is_relative_date_before' }
2084
+ const property_e = { key: 'key', value: '1h', operator: 'is_date_before' }
2090
2085
  expect(matchProperty(property_e, { key: '2022-05-01 00:00:00' })).toBe(false)
2091
2086
  expect(matchProperty(property_e, { key: '2022-04-30 22:00:00' })).toBe(true)
2092
2087
 
2093
- const property_f = { key: 'key', value: '1d', operator: 'is_relative_date_before' }
2088
+ const property_f = { key: 'key', value: '-1d', operator: 'is_date_before' }
2094
2089
  expect(matchProperty(property_f, { key: '2022-04-29 23:59:00 GMT' })).toBe(true)
2095
2090
  expect(matchProperty(property_f, { key: '2022-04-30 00:00:01 GMT' })).toBe(false)
2096
2091
 
2097
- const property_g = { key: 'key', value: '1w', operator: 'is_relative_date_before' }
2092
+ const property_g = { key: 'key', value: '1w', operator: 'is_date_before' }
2098
2093
  expect(matchProperty(property_g, { key: '2022-04-23 00:00:00 GMT' })).toBe(true)
2099
2094
  expect(matchProperty(property_g, { key: '2022-04-24 00:00:00 GMT' })).toBe(false)
2100
2095
  expect(matchProperty(property_g, { key: '2022-04-24 00:00:01 GMT' })).toBe(false)
2101
2096
 
2102
- const property_h = { key: 'key', value: '1m', operator: 'is_relative_date_before' }
2097
+ const property_h = { key: 'key', value: '1m', operator: 'is_date_before' }
2103
2098
  expect(matchProperty(property_h, { key: '2022-03-01 00:00:00 GMT' })).toBe(true)
2104
2099
  expect(matchProperty(property_h, { key: '2022-04-05 00:00:00 GMT' })).toBe(false)
2105
2100
 
2106
- const property_i = { key: 'key', value: '1y', operator: 'is_relative_date_before' }
2101
+ const property_i = { key: 'key', value: '-1y', operator: 'is_date_before' }
2107
2102
  expect(matchProperty(property_i, { key: '2021-04-28 00:00:00 GMT' })).toBe(true)
2108
2103
  expect(matchProperty(property_i, { key: '2021-05-01 00:00:01 GMT' })).toBe(false)
2109
2104
 
2110
- const property_j = { key: 'key', value: '122h', operator: 'is_relative_date_after' }
2105
+ const property_j = { key: 'key', value: '122h', operator: 'is_date_after' }
2111
2106
  expect(matchProperty(property_j, { key: '2022-05-01 00:00:00 GMT' })).toBe(true)
2112
2107
  expect(matchProperty(property_j, { key: '2022-04-23 01:00:00 GMT' })).toBe(false)
2113
2108
 
2114
- const property_k = { key: 'key', value: '2d', operator: 'is_relative_date_after' }
2109
+ const property_k = { key: 'key', value: '2d', operator: 'is_date_after' }
2115
2110
  expect(matchProperty(property_k, { key: '2022-05-01 00:00:00 GMT' })).toBe(true)
2116
2111
  expect(matchProperty(property_k, { key: '2022-04-29 00:00:01 GMT' })).toBe(true)
2117
2112
  expect(matchProperty(property_k, { key: '2022-04-29 00:00:00 GMT' })).toBe(false)
2118
2113
 
2119
- const property_l = { key: 'key', value: '02w', operator: 'is_relative_date_after' }
2114
+ const property_l = { key: 'key', value: '02w', operator: 'is_date_after' }
2120
2115
  expect(matchProperty(property_l, { key: '2022-05-01 00:00:00 GMT' })).toBe(true)
2121
2116
  expect(matchProperty(property_l, { key: '2022-04-16 00:00:00 GMT' })).toBe(false)
2122
2117
 
2123
- const property_m = { key: 'key', value: '1m', operator: 'is_relative_date_after' }
2118
+ const property_m = { key: 'key', value: '-1m', operator: 'is_date_after' }
2124
2119
  expect(matchProperty(property_m, { key: '2022-04-01 00:00:01 GMT' })).toBe(true)
2125
2120
  expect(matchProperty(property_m, { key: '2022-04-01 00:00:00 GMT' })).toBe(false)
2126
2121
 
2127
- const property_n = { key: 'key', value: '1y', operator: 'is_relative_date_after' }
2122
+ const property_n = { key: 'key', value: '1y', operator: 'is_date_after' }
2128
2123
  expect(matchProperty(property_n, { key: '2022-05-01 00:00:00 GMT' })).toBe(true)
2129
2124
  expect(matchProperty(property_n, { key: '2021-05-01 00:00:01 GMT' })).toBe(true)
2130
2125
  expect(matchProperty(property_n, { key: '2021-05-01 00:00:00 GMT' })).toBe(false)
@@ -4,6 +4,7 @@ jest.mock('../src/fetch')
4
4
  import fetch from '../src/fetch'
5
5
  import { anyDecideCall, anyLocalEvalCall, apiImplementation } from './feature-flags.spec'
6
6
  import { waitForPromises, wait } from '../../posthog-core/test/test-utils/test-utils'
7
+ import { generateUUID } from 'posthog-core/src/utils'
7
8
 
8
9
  jest.mock('../package.json', () => ({ version: '1.2.3' }))
9
10
 
@@ -66,6 +67,7 @@ describe('PostHog Node.js', () => {
66
67
  $lib: 'posthog-node',
67
68
  $lib_version: '1.2.3',
68
69
  },
70
+ uuid: expect.any(String),
69
71
  timestamp: expect.any(String),
70
72
  type: 'capture',
71
73
  library: 'posthog-node',
@@ -185,6 +187,24 @@ describe('PostHog Node.js', () => {
185
187
  distinct_id: '123',
186
188
  timestamp: '2021-02-03T00:00:00.000Z',
187
189
  event: 'custom-time',
190
+ uuid: expect.any(String),
191
+ },
192
+ ])
193
+ })
194
+
195
+ it('should allow overriding uuid', async () => {
196
+ expect(mockedFetch).toHaveBeenCalledTimes(0)
197
+ const uuid = generateUUID()
198
+ posthog.capture({ event: 'custom-time', distinctId: '123', uuid })
199
+ await waitForPromises()
200
+ jest.runOnlyPendingTimers()
201
+ const batchEvents = getLastBatchEvents()
202
+ expect(batchEvents).toMatchObject([
203
+ {
204
+ distinct_id: '123',
205
+ timestamp: expect.any(String),
206
+ event: 'custom-time',
207
+ uuid: uuid,
188
208
  },
189
209
  ])
190
210
  })
@@ -1015,7 +1035,7 @@ describe('PostHog Node.js', () => {
1015
1035
  distinct_id: 'some_id',
1016
1036
  groups: { company: 'id:5', instance: 'app.posthog.com' },
1017
1037
  person_properties: {
1018
- $current_distinct_id: 'some_id',
1038
+ distinct_id: 'some_id',
1019
1039
  x1: 'y1',
1020
1040
  },
1021
1041
  group_properties: {
@@ -1031,7 +1051,7 @@ describe('PostHog Node.js', () => {
1031
1051
 
1032
1052
  await posthog.getFeatureFlag('random_key', 'some_id', {
1033
1053
  groups: { company: 'id:5', instance: 'app.posthog.com' },
1034
- personProperties: { $current_distinct_id: 'override' },
1054
+ personProperties: { distinct_id: 'override' },
1035
1055
  groupProperties: { company: { $group_key: 'group_override' } },
1036
1056
  })
1037
1057
  jest.runOnlyPendingTimers()
@@ -1044,7 +1064,7 @@ describe('PostHog Node.js', () => {
1044
1064
  distinct_id: 'some_id',
1045
1065
  groups: { company: 'id:5', instance: 'app.posthog.com' },
1046
1066
  person_properties: {
1047
- $current_distinct_id: 'override',
1067
+ distinct_id: 'override',
1048
1068
  },
1049
1069
  group_properties: {
1050
1070
  company: { $group_key: 'group_override' },
@@ -1074,7 +1094,7 @@ describe('PostHog Node.js', () => {
1074
1094
  distinct_id: 'some_id',
1075
1095
  groups: {},
1076
1096
  person_properties: {
1077
- $current_distinct_id: 'some_id',
1097
+ distinct_id: 'some_id',
1078
1098
  },
1079
1099
  group_properties: {},
1080
1100
  geoip_disable: true,
@@ -1098,7 +1118,7 @@ describe('PostHog Node.js', () => {
1098
1118
  distinct_id: 'some_id',
1099
1119
  groups: { company: 'id:5' },
1100
1120
  person_properties: {
1101
- $current_distinct_id: 'some_id',
1121
+ distinct_id: 'some_id',
1102
1122
  },
1103
1123
  group_properties: { company: { $group_key: 'id:5' } },
1104
1124
  geoip_disable: true,
@@ -1118,7 +1138,7 @@ describe('PostHog Node.js', () => {
1118
1138
  distinct_id: 'some_id',
1119
1139
  groups: {},
1120
1140
  person_properties: {
1121
- $current_distinct_id: 'some_id',
1141
+ distinct_id: 'some_id',
1122
1142
  },
1123
1143
  group_properties: {},
1124
1144
  geoip_disable: true,
@@ -1139,7 +1159,7 @@ describe('PostHog Node.js', () => {
1139
1159
  distinct_id: 'some_id',
1140
1160
  groups: {},
1141
1161
  person_properties: {
1142
- $current_distinct_id: 'some_id',
1162
+ distinct_id: 'some_id',
1143
1163
  },
1144
1164
  group_properties: {},
1145
1165
  geoip_disable: true,