posthog-node 4.4.0 → 4.4.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.
@@ -130,3 +130,4 @@ export type PostHogFlagsAndPayloadsResponse = {
130
130
  export type JsonType = string | number | boolean | null | {
131
131
  [key: string]: JsonType;
132
132
  } | Array<JsonType>;
133
+ export type FetchLike = (url: string, options: PostHogFetchOptions) => Promise<PostHogFetchResponse>;
@@ -1,3 +1,4 @@
1
+ import { FetchLike } from './types';
1
2
  export declare function assert(truthyValue: any, message: string): void;
2
3
  export declare function removeTrailingSlash(url: string): string;
3
4
  export interface RetriableOptions {
@@ -10,3 +11,4 @@ export declare function currentTimestamp(): number;
10
11
  export declare function currentISOTime(): string;
11
12
  export declare function safeSetTimeout(fn: () => void, timeout: number): any;
12
13
  export declare const isPromise: (obj: any) => obj is Promise<any>;
14
+ export declare function getFetch(): FetchLike | undefined;
@@ -6,7 +6,6 @@
6
6
  * This is currently solved by using the global fetch if available instead.
7
7
  * See https://github.com/PostHog/posthog-js-lite/issues/127 for more info
8
8
  */
9
- import { PostHogFetchOptions, PostHogFetchResponse } from 'posthog-core/src';
10
- type FetchLike = (url: string, options: PostHogFetchOptions) => Promise<PostHogFetchResponse>;
9
+ import { FetchLike } from 'posthog-core/src';
11
10
  declare const _default: FetchLike;
12
11
  export default _default;
@@ -3,6 +3,7 @@ import { EventMessage, GroupIdentifyMessage, IdentifyMessage, PostHogNodeV1 } fr
3
3
  export type PostHogOptions = PostHogCoreOptions & {
4
4
  persistence?: 'memory';
5
5
  personalApiKey?: string;
6
+ privacyMode?: boolean;
6
7
  featureFlagsPollingInterval?: number;
7
8
  maxCacheSize?: number;
8
9
  fetch?: (url: string, options: PostHogFetchOptions) => Promise<PostHogFetchResponse>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "posthog-node",
3
- "version": "4.4.0",
3
+ "version": "4.4.1",
4
4
  "description": "PostHog Node.js integration",
5
5
  "repository": {
6
6
  "type": "git",
package/src/fetch.ts CHANGED
@@ -7,14 +7,10 @@
7
7
  * See https://github.com/PostHog/posthog-js-lite/issues/127 for more info
8
8
  */
9
9
 
10
- import { PostHogFetchOptions, PostHogFetchResponse } from 'posthog-core/src'
10
+ import { FetchLike, PostHogFetchOptions, PostHogFetchResponse } from 'posthog-core/src'
11
+ import { getFetch } from 'posthog-core/src/utils'
11
12
 
12
- type FetchLike = (url: string, options: PostHogFetchOptions) => Promise<PostHogFetchResponse>
13
-
14
- let _fetch: FetchLike | undefined =
15
- // eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
16
- // @ts-ignore
17
- typeof fetch !== 'undefined' ? fetch : typeof global.fetch !== 'undefined' ? global.fetch : undefined
13
+ let _fetch: FetchLike | undefined = getFetch()
18
14
 
19
15
  if (!_fetch) {
20
16
  // eslint-disable-next-line @typescript-eslint/no-var-requires
@@ -18,6 +18,7 @@ import fetch from './fetch'
18
18
  export type PostHogOptions = PostHogCoreOptions & {
19
19
  persistence?: 'memory'
20
20
  personalApiKey?: string
21
+ privacyMode?: boolean
21
22
  // The interval in milliseconds between polls for refreshing feature flag definitions. Defaults to 30 seconds.
22
23
  featureFlagsPollingInterval?: number
23
24
  // Maximum size of cache that deduplicates $feature_flag_called calls per user.