posthog-node 4.8.1 → 4.9.0

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,8 +1,8 @@
1
1
  import { PostHogFetchOptions, PostHogFetchResponse, PostHogAutocaptureElement, PostHogDecideResponse, PostHogCoreOptions, PostHogEventProperties, PostHogPersistedProperty, PostHogCaptureOptions, JsonType } from './types';
2
2
  import { RetriableOptions } from './utils';
3
- export * as utils from './utils';
4
3
  import { LZString } from './lz-string';
5
4
  import { SimpleEventEmitter } from './eventemitter';
5
+ export * as utils from './utils';
6
6
  export declare abstract class PostHogCoreStateless {
7
7
  readonly apiKey: string;
8
8
  readonly host: string;
@@ -64,10 +64,10 @@ export declare abstract class PostHogCoreStateless {
64
64
  protected getDecide(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, extraPayload?: Record<string, any>): Promise<PostHogDecideResponse | undefined>;
65
65
  protected getFeatureFlagStateless(key: string, distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean): Promise<boolean | string | undefined>;
66
66
  protected getFeatureFlagPayloadStateless(key: string, distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean): Promise<JsonType | undefined>;
67
- protected getFeatureFlagPayloadsStateless(distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean): Promise<PostHogDecideResponse['featureFlagPayloads'] | undefined>;
67
+ protected getFeatureFlagPayloadsStateless(distinctId: string, groups?: Record<string, string>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean, flagKeysToEvaluate?: string[]): Promise<PostHogDecideResponse['featureFlagPayloads'] | undefined>;
68
68
  protected _parsePayload(response: any): any;
69
- protected getFeatureFlagsStateless(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean): Promise<PostHogDecideResponse['featureFlags'] | undefined>;
70
- protected getFeatureFlagsAndPayloadsStateless(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean): Promise<{
69
+ protected getFeatureFlagsStateless(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean, flagKeysToEvaluate?: string[]): Promise<PostHogDecideResponse['featureFlags'] | undefined>;
70
+ protected getFeatureFlagsAndPayloadsStateless(distinctId: string, groups?: Record<string, string | number>, personProperties?: Record<string, string>, groupProperties?: Record<string, Record<string, string>>, disableGeoip?: boolean, flagKeysToEvaluate?: string[]): Promise<{
71
71
  flags: PostHogDecideResponse['featureFlags'] | undefined;
72
72
  payloads: PostHogDecideResponse['featureFlagPayloads'] | undefined;
73
73
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-node",
3
- "version": "4.8.1",
3
+ "version": "4.9.0",
4
4
  "description": "PostHog Node.js integration",
5
5
  "repository": {
6
6
  "type": "git",
@@ -2,10 +2,10 @@
2
2
  // Uncomment below line while developing to not compile code everytime
3
3
  import { PostHog as PostHog, PostHogOptions } from '../src/posthog-node'
4
4
  import { matchProperty, InconclusiveMatchError, relativeDateParseForFeatureFlagMatching } from '../src/feature-flags'
5
- jest.mock('../src/fetch')
6
5
  import fetch from '../src/fetch'
7
6
  import { anyDecideCall, anyLocalEvalCall, apiImplementation } from './test-utils'
8
7
  import { waitForPromises } from 'posthog-core/test/test-utils/test-utils'
8
+ jest.mock('../src/fetch')
9
9
 
10
10
  jest.spyOn(console, 'debug').mockImplementation()
11
11
 
@@ -360,6 +360,7 @@ describe('local evaluation', () => {
360
360
  },
361
361
  group_properties: {},
362
362
  geoip_disable: true,
363
+ flag_keys_to_evaluate: ['complex-flag'],
363
364
  }),
364
365
  })
365
366
  )
@@ -379,6 +380,7 @@ describe('local evaluation', () => {
379
380
  person_properties: { distinct_id: 'some-distinct-id', doesnt_matter: '1' },
380
381
  group_properties: {},
381
382
  geoip_disable: true,
383
+ flag_keys_to_evaluate: ['complex-flag'],
382
384
  }),
383
385
  })
384
386
  )
@@ -1180,6 +1180,7 @@ describe('PostHog Node.js', () => {
1180
1180
  instance: { $group_key: 'app.posthog.com' },
1181
1181
  },
1182
1182
  geoip_disable: true,
1183
+ flag_keys_to_evaluate: ['random_key'],
1183
1184
  }),
1184
1185
  })
1185
1186
  )
@@ -1208,6 +1209,7 @@ describe('PostHog Node.js', () => {
1208
1209
  instance: { $group_key: 'app.posthog.com' },
1209
1210
  },
1210
1211
  geoip_disable: true,
1212
+ flag_keys_to_evaluate: ['random_key'],
1211
1213
  }),
1212
1214
  })
1213
1215
  )
@@ -1279,6 +1281,7 @@ describe('PostHog Node.js', () => {
1279
1281
  },
1280
1282
  group_properties: {},
1281
1283
  geoip_disable: true,
1284
+ flag_keys_to_evaluate: ['random_key'],
1282
1285
  }),
1283
1286
  })
1284
1287
  )
@@ -1300,6 +1303,7 @@ describe('PostHog Node.js', () => {
1300
1303
  },
1301
1304
  group_properties: {},
1302
1305
  geoip_disable: true,
1306
+ flag_keys_to_evaluate: ['random_key'],
1303
1307
  }),
1304
1308
  })
1305
1309
  )