posthog-js 1.121.3 → 1.121.4

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,27 +1,22 @@
1
1
  import RageClick from './extensions/rageclick';
2
- import { AutocaptureConfig, AutoCaptureCustomProperty, DecideResponse, Properties } from './types';
2
+ import { DecideResponse } from './types';
3
3
  import { PostHog } from './posthog-core';
4
- declare const autocapture: {
5
- _initializedTokens: string[];
4
+ export declare class Autocapture {
5
+ instance: PostHog;
6
+ _initialized: boolean;
6
7
  _isDisabledServerSide: boolean | null;
7
- _isAutocaptureEnabled: boolean;
8
- _setIsAutocaptureEnabled: (instance: PostHog) => void;
9
- _previousElementSibling: (el: Element) => Element | null;
10
- _getAugmentPropertiesFromElement: (elem: Element) => Properties;
11
- _getPropertiesFromElement: (elem: Element, maskInputs: boolean, maskText: boolean) => Properties;
12
- _getDefaultProperties: (eventType: string) => Properties;
13
- _extractCustomPropertyValue: (customProperty: AutoCaptureCustomProperty) => string;
14
- _getCustomProperties: (targetElementList: Element[]) => Properties;
15
- _getEventTarget: (e: Event) => Element | null;
16
- _captureEvent: (e: Event, instance: PostHog, eventName?: string, extraProps?: Properties) => boolean | void;
17
- _navigate: (href: string) => void;
18
- _addDomEventHandlers: (instance: PostHog) => void;
19
- _customProperties: AutoCaptureCustomProperty[];
20
- rageclicks: RageClick | null;
21
- config: AutocaptureConfig | undefined;
22
- init: (instance: PostHog) => void;
23
- afterDecideResponse: (response: DecideResponse, instance: PostHog) => void;
24
- enabledForProject: (token: string | null | undefined, numBuckets: number, numEnabledBuckets: number) => boolean;
25
- isBrowserSupported: () => boolean;
26
- };
27
- export { autocapture };
8
+ rageclicks: RageClick;
9
+ _elementsChainAsString: boolean;
10
+ constructor(instance: PostHog);
11
+ private get config();
12
+ private _addDomEventHandlers;
13
+ afterDecideResponse(response: DecideResponse): void;
14
+ get isEnabled(): boolean;
15
+ private _previousElementSibling;
16
+ private _getAugmentPropertiesFromElement;
17
+ private _getPropertiesFromElement;
18
+ private _getDefaultProperties;
19
+ private _getEventTarget;
20
+ private _captureEvent;
21
+ isBrowserSupported(): boolean;
22
+ }
@@ -4,7 +4,6 @@ export default class RageClick {
4
4
  y: number;
5
5
  timestamp: number;
6
6
  }[];
7
- enabled: boolean;
8
- constructor(enabled: boolean);
7
+ constructor();
9
8
  isRageClick(x: number, y: number, timestamp: number): boolean;
10
9
  }
@@ -6,13 +6,14 @@ import { RequestQueue } from './request-queue';
6
6
  import { RetryQueue } from './retry-queue';
7
7
  import { SessionIdManager } from './sessionid';
8
8
  import { RequestRouter } from './utils/request-router';
9
- import { AutocaptureConfig, CaptureOptions, CaptureResult, Compression, DecideResponse, EarlyAccessFeatureCallback, GDPROptions, IsFeatureEnabledOptions, JsonType, OptInOutCapturingOptions, PostHogConfig, Properties, Property, QueuedRequestOptions, RequestCallback, SessionIdChangedCallback, SnippetArrayItem, ToolbarParams } from './types';
9
+ import { CaptureOptions, CaptureResult, Compression, DecideResponse, EarlyAccessFeatureCallback, GDPROptions, IsFeatureEnabledOptions, JsonType, OptInOutCapturingOptions, PostHogConfig, Properties, Property, QueuedRequestOptions, RequestCallback, SessionIdChangedCallback, SnippetArrayItem, ToolbarParams } from './types';
10
10
  import { SentryIntegration } from './extensions/sentry-integration';
11
11
  import { PageViewManager } from './page-view';
12
12
  import { PostHogSurveys } from './posthog-surveys';
13
13
  import { RateLimiter } from './rate-limiter';
14
14
  import { SurveyCallback } from './posthog-surveys-types';
15
15
  import { SessionPropsManager } from './session-props';
16
+ import { Autocapture } from './autocapture';
16
17
  type OnlyValidKeys<T, Shape> = T extends Shape ? (Exclude<keyof T, keyof Shape> extends never ? T : never) : never;
17
18
  export declare const defaultConfig: () => PostHogConfig;
18
19
  declare class DeprecatedWebPerformanceObserver {
@@ -37,6 +38,7 @@ export declare class PostHog {
37
38
  sessionManager?: SessionIdManager;
38
39
  sessionPropsManager?: SessionPropsManager;
39
40
  requestRouter: RequestRouter;
41
+ autocapture?: Autocapture;
40
42
  _requestQueue?: RequestQueue;
41
43
  _retryQueue?: RetryQueue;
42
44
  sessionRecording?: SessionRecording;
@@ -45,10 +47,8 @@ export declare class PostHog {
45
47
  compression?: Compression;
46
48
  __captureHooks: ((eventName: string) => void)[];
47
49
  __request_queue: QueuedRequestOptions[];
48
- __autocapture: boolean | AutocaptureConfig | undefined;
49
50
  decideEndpointWasHit: boolean;
50
51
  analyticsDefaultEndpoint: string;
51
- elementsChainAsString: boolean;
52
52
  SentryIntegration: typeof SentryIntegration;
53
53
  segmentIntegration: () => any;
54
54
  /** DEPRECATED: We keep this to support existing usage but now one should just call .setPersonProperties */
@@ -224,10 +224,6 @@ export type FlagVariant = {
224
224
  };
225
225
  export interface DecideResponse {
226
226
  supportedCompression: Compression[];
227
- config: {
228
- enable_collect_everything: boolean;
229
- };
230
- custom_properties: AutoCaptureCustomProperty[];
231
227
  featureFlags: Record<string, string | boolean>;
232
228
  featureFlagPayloads: Record<string, JsonType>;
233
229
  errorsWhileComputingFlags: boolean;
@@ -265,11 +261,6 @@ export interface DecideResponse {
265
261
  export type FeatureFlagsCallback = (flags: string[], variants: Record<string, string | boolean>, context?: {
266
262
  errorsLoading?: boolean;
267
263
  }) => void;
268
- export interface AutoCaptureCustomProperty {
269
- name: string;
270
- css_selector: string;
271
- event_selectors: string[];
272
- }
273
264
  export interface GDPROptions {
274
265
  capture?: (event: string, properties: Properties, options: CaptureOptions) => void; /** function used for capturing a PostHog event to record the opt-in action */
275
266
  captureEventName?: string; /** event name to be used for capturing the opt-in action */
@@ -1,6 +1,5 @@
1
1
  import { Breaker, EventHandler, Properties } from '../types';
2
2
  export declare const _trim: (str: string) => string;
3
- export declare const _bind_instance_methods: (obj: Record<string, any>) => void;
4
3
  export declare function _eachArray<E = any>(obj: E[] | null | undefined, iterator: (value: E, key: number) => void | Breaker, thisArg?: any): void;
5
4
  /**
6
5
  * @param {*=} obj
@@ -23,7 +22,6 @@ export declare const _formatDate: (d: Date) => string;
23
22
  export declare const _try: <T>(fn: () => T) => T | undefined;
24
23
  export declare const _safewrap: <F extends (...args: any[]) => any = (...args: any[]) => any>(f: F) => F;
25
24
  export declare const _safewrap_class: (klass: Function, functions: string[]) => void;
26
- export declare const _safewrap_instance_methods: (obj: Record<string, any>) => void;
27
25
  export declare const _strip_empty_properties: (p: Properties) => Properties;
28
26
  export declare const _strip_leading_dollar: (s: string) => string;
29
27
  export declare function _copyAndTruncateStrings<T extends Record<string, any> = Record<string, any>>(object: T, maxStringLength: number | null): T;
package/dist/module.d.ts CHANGED
@@ -305,10 +305,6 @@ type FlagVariant = {
305
305
  };
306
306
  interface DecideResponse {
307
307
  supportedCompression: Compression[];
308
- config: {
309
- enable_collect_everything: boolean;
310
- };
311
- custom_properties: AutoCaptureCustomProperty[];
312
308
  featureFlags: Record<string, string | boolean>;
313
309
  featureFlagPayloads: Record<string, JsonType>;
314
310
  errorsWhileComputingFlags: boolean;
@@ -346,11 +342,6 @@ interface DecideResponse {
346
342
  type FeatureFlagsCallback = (flags: string[], variants: Record<string, string | boolean>, context?: {
347
343
  errorsLoading?: boolean;
348
344
  }) => void;
349
- interface AutoCaptureCustomProperty {
350
- name: string;
351
- css_selector: string;
352
- event_selectors: string[];
353
- }
354
345
  interface GDPROptions {
355
346
  capture?: (event: string, properties: Properties, options: CaptureOptions) => void; /** function used for capturing a PostHog event to record the opt-in action */
356
347
  captureEventName?: string; /** event name to be used for capturing the opt-in action */
@@ -1262,6 +1253,36 @@ declare class SessionPropsManager {
1262
1253
  };
1263
1254
  }
1264
1255
 
1256
+ declare class RageClick {
1257
+ clicks: {
1258
+ x: number;
1259
+ y: number;
1260
+ timestamp: number;
1261
+ }[];
1262
+ constructor();
1263
+ isRageClick(x: number, y: number, timestamp: number): boolean;
1264
+ }
1265
+
1266
+ declare class Autocapture {
1267
+ instance: PostHog;
1268
+ _initialized: boolean;
1269
+ _isDisabledServerSide: boolean | null;
1270
+ rageclicks: RageClick;
1271
+ _elementsChainAsString: boolean;
1272
+ constructor(instance: PostHog);
1273
+ private get config();
1274
+ private _addDomEventHandlers;
1275
+ afterDecideResponse(response: DecideResponse): void;
1276
+ get isEnabled(): boolean;
1277
+ private _previousElementSibling;
1278
+ private _getAugmentPropertiesFromElement;
1279
+ private _getPropertiesFromElement;
1280
+ private _getDefaultProperties;
1281
+ private _getEventTarget;
1282
+ private _captureEvent;
1283
+ isBrowserSupported(): boolean;
1284
+ }
1285
+
1265
1286
  type OnlyValidKeys<T, Shape> = T extends Shape ? (Exclude<keyof T, keyof Shape> extends never ? T : never) : never;
1266
1287
  declare class DeprecatedWebPerformanceObserver {
1267
1288
  get _forceAllowLocalhost(): boolean;
@@ -1285,6 +1306,7 @@ declare class PostHog {
1285
1306
  sessionManager?: SessionIdManager;
1286
1307
  sessionPropsManager?: SessionPropsManager;
1287
1308
  requestRouter: RequestRouter;
1309
+ autocapture?: Autocapture;
1288
1310
  _requestQueue?: RequestQueue;
1289
1311
  _retryQueue?: RetryQueue;
1290
1312
  sessionRecording?: SessionRecording;
@@ -1293,10 +1315,8 @@ declare class PostHog {
1293
1315
  compression?: Compression;
1294
1316
  __captureHooks: ((eventName: string) => void)[];
1295
1317
  __request_queue: QueuedRequestOptions[];
1296
- __autocapture: boolean | AutocaptureConfig | undefined;
1297
1318
  decideEndpointWasHit: boolean;
1298
1319
  analyticsDefaultEndpoint: string;
1299
- elementsChainAsString: boolean;
1300
1320
  SentryIntegration: typeof SentryIntegration;
1301
1321
  segmentIntegration: () => any;
1302
1322
  /** DEPRECATED: We keep this to support existing usage but now one should just call .setPersonProperties */
@@ -1959,4 +1979,4 @@ declare class PostHog {
1959
1979
 
1960
1980
  declare const posthog: PostHog;
1961
1981
 
1962
- export { type AutoCaptureCustomProperty, type AutocaptureCompatibleElement, type AutocaptureConfig, type BasicSurveyQuestion, type BootstrapConfig, type Breaker, type CaptureOptions, type CaptureResult, type CapturedNetworkRequest, Compression, type DecideResponse, type DomAutocaptureEvents, type EarlyAccessFeature, type EarlyAccessFeatureCallback, type EarlyAccessFeatureResponse, type EventHandler, type FeatureFlagsCallback, type FlagVariant, type GDPROptions, type Headers, type InitiatorType, type IsFeatureEnabledOptions, type JsonType, type LinkSurveyQuestion, type MultipleSurveyQuestion, type NetworkRecordOptions, type NetworkRequest, type OptInOutCapturingOptions, type PersistentStore, PostHog, type PostHogConfig, type Properties, type Property, type QueuedRequestOptions, type RatingSurveyQuestion, type RequestCallback, type RequestOptions, type RequestResponse, type RetriableRequestOptions, type SessionIdChangedCallback, type SessionRecordingOptions, type SnippetArrayItem, type Survey, type SurveyAppearance, type SurveyCallback, type SurveyQuestion, SurveyQuestionType, type SurveyResponse, SurveyType, type SurveyUrlMatchType, type ToolbarParams, type ToolbarSource, type ToolbarUserIntent, type ToolbarVersion, posthog as default, posthog };
1982
+ export { type AutocaptureCompatibleElement, type AutocaptureConfig, type BasicSurveyQuestion, type BootstrapConfig, type Breaker, type CaptureOptions, type CaptureResult, type CapturedNetworkRequest, Compression, type DecideResponse, type DomAutocaptureEvents, type EarlyAccessFeature, type EarlyAccessFeatureCallback, type EarlyAccessFeatureResponse, type EventHandler, type FeatureFlagsCallback, type FlagVariant, type GDPROptions, type Headers, type InitiatorType, type IsFeatureEnabledOptions, type JsonType, type LinkSurveyQuestion, type MultipleSurveyQuestion, type NetworkRecordOptions, type NetworkRequest, type OptInOutCapturingOptions, type PersistentStore, PostHog, type PostHogConfig, type Properties, type Property, type QueuedRequestOptions, type RatingSurveyQuestion, type RequestCallback, type RequestOptions, type RequestResponse, type RetriableRequestOptions, type SessionIdChangedCallback, type SessionRecordingOptions, type SnippetArrayItem, type Survey, type SurveyAppearance, type SurveyCallback, type SurveyQuestion, SurveyQuestionType, type SurveyResponse, SurveyType, type SurveyUrlMatchType, type ToolbarParams, type ToolbarSource, type ToolbarUserIntent, type ToolbarVersion, posthog as default, posthog };