posthog-js 1.63.1 → 1.63.3

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.
package/dist/module.d.ts CHANGED
@@ -1,6 +1,66 @@
1
- import { record } from 'rrweb2/typings';
2
- import { listenerHandler, eventWithTime } from '@rrweb/types';
3
-
1
+ declare enum NodeType {
2
+ Document = 0,
3
+ DocumentType = 1,
4
+ Element = 2,
5
+ Text = 3,
6
+ CDATA = 4,
7
+ Comment = 5
8
+ }
9
+ declare type documentNode = {
10
+ type: NodeType.Document;
11
+ childNodes: serializedNodeWithId[];
12
+ compatMode?: string;
13
+ };
14
+ declare type documentTypeNode = {
15
+ type: NodeType.DocumentType;
16
+ name: string;
17
+ publicId: string;
18
+ systemId: string;
19
+ };
20
+ declare type attributes = {
21
+ [key: string]: string | number | true | null;
22
+ };
23
+ declare type elementNode = {
24
+ type: NodeType.Element;
25
+ tagName: string;
26
+ attributes: attributes;
27
+ childNodes: serializedNodeWithId[];
28
+ isSVG?: true;
29
+ needBlock?: boolean;
30
+ };
31
+ declare type textNode = {
32
+ type: NodeType.Text;
33
+ textContent: string;
34
+ isStyle?: true;
35
+ };
36
+ declare type cdataNode = {
37
+ type: NodeType.CDATA;
38
+ textContent: '';
39
+ };
40
+ declare type commentNode = {
41
+ type: NodeType.Comment;
42
+ textContent: string;
43
+ };
44
+ declare type serializedNode = (documentNode | documentTypeNode | elementNode | textNode | cdataNode | commentNode) & {
45
+ rootId?: number;
46
+ isShadowHost?: boolean;
47
+ isShadow?: boolean;
48
+ };
49
+ declare type serializedNodeWithId = serializedNode & {
50
+ id: number;
51
+ };
52
+ interface IMirror<TNode> {
53
+ getId(n: TNode | undefined | null): number;
54
+ getNode(id: number): TNode | null;
55
+ getIds(): number[];
56
+ getMeta(n: TNode): serializedNodeWithId | null;
57
+ removeNodeFromMap(n: TNode): void;
58
+ has(id: number): boolean;
59
+ hasNode(node: TNode): boolean;
60
+ add(n: TNode, meta: serializedNodeWithId): void;
61
+ replace(id: number, n: TNode): void;
62
+ reset(): void;
63
+ }
4
64
  declare type MaskInputOptions = Partial<{
5
65
  color: boolean;
6
66
  date: boolean;
@@ -31,6 +91,27 @@ declare type SlimDOMOptions = Partial<{
31
91
  headMetaAuthorship: boolean;
32
92
  headMetaVerification: boolean;
33
93
  }>;
94
+ declare type DataURLOptions = Partial<{
95
+ type: string;
96
+ quality: number;
97
+ }>;
98
+ declare type MaskTextFn = (text: string) => string;
99
+ declare type MaskInputFn = (text: string, element: HTMLElement) => string;
100
+
101
+ declare class Mirror implements IMirror<Node> {
102
+ private idNodeMap;
103
+ private nodeMetaMap;
104
+ getId(n: Node | undefined | null): number;
105
+ getNode(id: number): Node | null;
106
+ getIds(): number[];
107
+ getMeta(n: Node): serializedNodeWithId | null;
108
+ removeNodeFromMap(n: Node): void;
109
+ has(id: number): boolean;
110
+ hasNode(node: Node): boolean;
111
+ add(n: Node, meta: serializedNodeWithId): void;
112
+ replace(id: number, n: Node): void;
113
+ reset(): void;
114
+ }
34
115
 
35
116
  declare class CaptureMetrics {
36
117
  enabled: boolean;
@@ -112,7 +193,6 @@ interface PostHogConfig {
112
193
  ui_host: string | null;
113
194
  token: string;
114
195
  autocapture: boolean | AutocaptureConfig;
115
- autocapture_exceptions: boolean;
116
196
  rageclick: boolean;
117
197
  cross_subdomain_cookie: boolean;
118
198
  persistence: 'localStorage' | 'cookie' | 'memory' | 'localStorage+cookie' | 'sessionStorage';
@@ -491,6 +571,385 @@ declare class PostHogFeatureFlags {
491
571
  resetGroupPropertiesForFlags(group_type?: string): void;
492
572
  }
493
573
 
574
+ declare enum EventType {
575
+ DomContentLoaded = 0,
576
+ Load = 1,
577
+ FullSnapshot = 2,
578
+ IncrementalSnapshot = 3,
579
+ Meta = 4,
580
+ Custom = 5,
581
+ Plugin = 6
582
+ }
583
+ declare type domContentLoadedEvent = {
584
+ type: EventType.DomContentLoaded;
585
+ data: unknown;
586
+ };
587
+ declare type loadedEvent = {
588
+ type: EventType.Load;
589
+ data: unknown;
590
+ };
591
+ declare type fullSnapshotEvent = {
592
+ type: EventType.FullSnapshot;
593
+ data: {
594
+ node: serializedNodeWithId;
595
+ initialOffset: {
596
+ top: number;
597
+ left: number;
598
+ };
599
+ };
600
+ };
601
+ declare type incrementalSnapshotEvent = {
602
+ type: EventType.IncrementalSnapshot;
603
+ data: incrementalData;
604
+ };
605
+ declare type metaEvent = {
606
+ type: EventType.Meta;
607
+ data: {
608
+ href: string;
609
+ width: number;
610
+ height: number;
611
+ };
612
+ };
613
+ declare type customEvent<T = unknown> = {
614
+ type: EventType.Custom;
615
+ data: {
616
+ tag: string;
617
+ payload: T;
618
+ };
619
+ };
620
+ declare type pluginEvent<T = unknown> = {
621
+ type: EventType.Plugin;
622
+ data: {
623
+ plugin: string;
624
+ payload: T;
625
+ };
626
+ };
627
+ declare enum IncrementalSource {
628
+ Mutation = 0,
629
+ MouseMove = 1,
630
+ MouseInteraction = 2,
631
+ Scroll = 3,
632
+ ViewportResize = 4,
633
+ Input = 5,
634
+ TouchMove = 6,
635
+ MediaInteraction = 7,
636
+ StyleSheetRule = 8,
637
+ CanvasMutation = 9,
638
+ Font = 10,
639
+ Log = 11,
640
+ Drag = 12,
641
+ StyleDeclaration = 13,
642
+ Selection = 14,
643
+ AdoptedStyleSheet = 15
644
+ }
645
+ declare type mutationData = {
646
+ source: IncrementalSource.Mutation;
647
+ } & mutationCallbackParam;
648
+ declare type mousemoveData = {
649
+ source: IncrementalSource.MouseMove | IncrementalSource.TouchMove | IncrementalSource.Drag;
650
+ positions: mousePosition[];
651
+ };
652
+ declare type mouseInteractionData = {
653
+ source: IncrementalSource.MouseInteraction;
654
+ } & mouseInteractionParam;
655
+ declare type scrollData = {
656
+ source: IncrementalSource.Scroll;
657
+ } & scrollPosition;
658
+ declare type viewportResizeData = {
659
+ source: IncrementalSource.ViewportResize;
660
+ } & viewportResizeDimension;
661
+ declare type inputData = {
662
+ source: IncrementalSource.Input;
663
+ id: number;
664
+ } & inputValue;
665
+ declare type mediaInteractionData = {
666
+ source: IncrementalSource.MediaInteraction;
667
+ } & mediaInteractionParam;
668
+ declare type styleSheetRuleData = {
669
+ source: IncrementalSource.StyleSheetRule;
670
+ } & styleSheetRuleParam;
671
+ declare type styleDeclarationData = {
672
+ source: IncrementalSource.StyleDeclaration;
673
+ } & styleDeclarationParam;
674
+ declare type canvasMutationData = {
675
+ source: IncrementalSource.CanvasMutation;
676
+ } & canvasMutationParam;
677
+ declare type fontData = {
678
+ source: IncrementalSource.Font;
679
+ } & fontParam;
680
+ declare type selectionData = {
681
+ source: IncrementalSource.Selection;
682
+ } & selectionParam;
683
+ declare type adoptedStyleSheetData = {
684
+ source: IncrementalSource.AdoptedStyleSheet;
685
+ } & adoptedStyleSheetParam;
686
+ declare type incrementalData = mutationData | mousemoveData | mouseInteractionData | scrollData | viewportResizeData | inputData | mediaInteractionData | styleSheetRuleData | canvasMutationData | fontData | selectionData | styleDeclarationData | adoptedStyleSheetData;
687
+ declare type event = domContentLoadedEvent | loadedEvent | fullSnapshotEvent | incrementalSnapshotEvent | metaEvent | customEvent | pluginEvent;
688
+ declare type eventWithTime = event & {
689
+ timestamp: number;
690
+ delay?: number;
691
+ };
692
+ declare type blockClass = string | RegExp;
693
+ declare type maskTextClass = string | RegExp;
694
+ declare type SamplingStrategy = Partial<{
695
+ mousemove: boolean | number;
696
+ mousemoveCallback: number;
697
+ mouseInteraction: boolean | Record<string, boolean | undefined>;
698
+ scroll: number;
699
+ media: number;
700
+ input: 'all' | 'last';
701
+ canvas: 'all' | number;
702
+ }>;
703
+ interface ICrossOriginIframeMirror {
704
+ getId(iframe: HTMLIFrameElement, remoteId: number, parentToRemoteMap?: Map<number, number>, remoteToParentMap?: Map<number, number>): number;
705
+ getIds(iframe: HTMLIFrameElement, remoteId: number[]): number[];
706
+ getRemoteId(iframe: HTMLIFrameElement, parentId: number, map?: Map<number, number>): number;
707
+ getRemoteIds(iframe: HTMLIFrameElement, parentId: number[]): number[];
708
+ reset(iframe?: HTMLIFrameElement): void;
709
+ }
710
+ declare type RecordPlugin<TOptions = unknown> = {
711
+ name: string;
712
+ observer?: (cb: (...args: Array<unknown>) => void, win: IWindow, options: TOptions) => listenerHandler;
713
+ eventProcessor?: <TExtend>(event: eventWithTime) => eventWithTime & TExtend;
714
+ getMirror?: (mirrors: {
715
+ nodeMirror: Mirror;
716
+ crossOriginIframeMirror: ICrossOriginIframeMirror;
717
+ crossOriginIframeStyleMirror: ICrossOriginIframeMirror;
718
+ }) => void;
719
+ options: TOptions;
720
+ };
721
+ declare type hooksParam = {
722
+ mutation?: mutationCallBack;
723
+ mousemove?: mousemoveCallBack;
724
+ mouseInteraction?: mouseInteractionCallBack;
725
+ scroll?: scrollCallback;
726
+ viewportResize?: viewportResizeCallback;
727
+ input?: inputCallback;
728
+ mediaInteaction?: mediaInteractionCallback;
729
+ styleSheetRule?: styleSheetRuleCallback;
730
+ styleDeclaration?: styleDeclarationCallback;
731
+ canvasMutation?: canvasMutationCallback;
732
+ font?: fontCallback;
733
+ selection?: selectionCallback;
734
+ };
735
+ declare type textMutation = {
736
+ id: number;
737
+ value: string | null;
738
+ };
739
+ declare type styleAttributeValue = {
740
+ [key: string]: styleValueWithPriority | string | false;
741
+ };
742
+ declare type styleValueWithPriority = [string, string];
743
+ declare type attributeMutation = {
744
+ id: number;
745
+ attributes: {
746
+ [key: string]: string | styleAttributeValue | null;
747
+ };
748
+ };
749
+ declare type removedNodeMutation = {
750
+ parentId: number;
751
+ id: number;
752
+ isShadow?: boolean;
753
+ };
754
+ declare type addedNodeMutation = {
755
+ parentId: number;
756
+ previousId?: number | null;
757
+ nextId: number | null;
758
+ node: serializedNodeWithId;
759
+ };
760
+ declare type mutationCallbackParam = {
761
+ texts: textMutation[];
762
+ attributes: attributeMutation[];
763
+ removes: removedNodeMutation[];
764
+ adds: addedNodeMutation[];
765
+ isAttachIframe?: true;
766
+ };
767
+ declare type mutationCallBack = (m: mutationCallbackParam) => void;
768
+ declare type mousemoveCallBack = (p: mousePosition[], source: IncrementalSource.MouseMove | IncrementalSource.TouchMove | IncrementalSource.Drag) => void;
769
+ declare type mousePosition = {
770
+ x: number;
771
+ y: number;
772
+ id: number;
773
+ timeOffset: number;
774
+ };
775
+ declare enum MouseInteractions {
776
+ MouseUp = 0,
777
+ MouseDown = 1,
778
+ Click = 2,
779
+ ContextMenu = 3,
780
+ DblClick = 4,
781
+ Focus = 5,
782
+ Blur = 6,
783
+ TouchStart = 7,
784
+ TouchMove_Departed = 8,
785
+ TouchEnd = 9,
786
+ TouchCancel = 10
787
+ }
788
+ declare enum PointerTypes {
789
+ Mouse = 0,
790
+ Pen = 1,
791
+ Touch = 2
792
+ }
793
+ declare enum CanvasContext {
794
+ '2D' = 0,
795
+ WebGL = 1,
796
+ WebGL2 = 2
797
+ }
798
+ declare type mouseInteractionParam = {
799
+ type: MouseInteractions;
800
+ id: number;
801
+ x: number;
802
+ y: number;
803
+ pointerType?: PointerTypes;
804
+ };
805
+ declare type mouseInteractionCallBack = (d: mouseInteractionParam) => void;
806
+ declare type scrollPosition = {
807
+ id: number;
808
+ x: number;
809
+ y: number;
810
+ };
811
+ declare type scrollCallback = (p: scrollPosition) => void;
812
+ declare type styleSheetAddRule = {
813
+ rule: string;
814
+ index?: number | number[];
815
+ };
816
+ declare type styleSheetDeleteRule = {
817
+ index: number | number[];
818
+ };
819
+ declare type styleSheetRuleParam = {
820
+ id?: number;
821
+ styleId?: number;
822
+ removes?: styleSheetDeleteRule[];
823
+ adds?: styleSheetAddRule[];
824
+ replace?: string;
825
+ replaceSync?: string;
826
+ };
827
+ declare type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;
828
+ declare type adoptedStyleSheetParam = {
829
+ id: number;
830
+ styles?: {
831
+ styleId: number;
832
+ rules: styleSheetAddRule[];
833
+ }[];
834
+ styleIds: number[];
835
+ };
836
+ declare type styleDeclarationParam = {
837
+ id?: number;
838
+ styleId?: number;
839
+ index: number[];
840
+ set?: {
841
+ property: string;
842
+ value: string | null;
843
+ priority: string | undefined;
844
+ };
845
+ remove?: {
846
+ property: string;
847
+ };
848
+ };
849
+ declare type styleDeclarationCallback = (s: styleDeclarationParam) => void;
850
+ declare type canvasMutationCommand = {
851
+ property: string;
852
+ args: Array<unknown>;
853
+ setter?: true;
854
+ };
855
+ declare type canvasMutationParam = {
856
+ id: number;
857
+ type: CanvasContext;
858
+ commands: canvasMutationCommand[];
859
+ } | ({
860
+ id: number;
861
+ type: CanvasContext;
862
+ } & canvasMutationCommand);
863
+ declare type canvasMutationCallback = (p: canvasMutationParam) => void;
864
+ declare type fontParam = {
865
+ family: string;
866
+ fontSource: string;
867
+ buffer: boolean;
868
+ descriptors?: FontFaceDescriptors;
869
+ };
870
+ declare type fontCallback = (p: fontParam) => void;
871
+ declare type viewportResizeDimension = {
872
+ width: number;
873
+ height: number;
874
+ };
875
+ declare type viewportResizeCallback = (d: viewportResizeDimension) => void;
876
+ declare type inputValue = {
877
+ text: string;
878
+ isChecked: boolean;
879
+ userTriggered?: boolean;
880
+ };
881
+ declare type inputCallback = (v: inputValue & {
882
+ id: number;
883
+ }) => void;
884
+ declare const enum MediaInteractions {
885
+ Play = 0,
886
+ Pause = 1,
887
+ Seeked = 2,
888
+ VolumeChange = 3,
889
+ RateChange = 4
890
+ }
891
+ declare type mediaInteractionParam = {
892
+ type: MediaInteractions;
893
+ id: number;
894
+ currentTime?: number;
895
+ volume?: number;
896
+ muted?: boolean;
897
+ playbackRate?: number;
898
+ };
899
+ declare type mediaInteractionCallback = (p: mediaInteractionParam) => void;
900
+ declare type SelectionRange = {
901
+ start: number;
902
+ startOffset: number;
903
+ end: number;
904
+ endOffset: number;
905
+ };
906
+ declare type selectionParam = {
907
+ ranges: Array<SelectionRange>;
908
+ };
909
+ declare type selectionCallback = (p: selectionParam) => void;
910
+ declare type listenerHandler = () => void;
911
+ declare type KeepIframeSrcFn = (src: string) => boolean;
912
+ declare global {
913
+ interface Window {
914
+ FontFace: typeof FontFace;
915
+ }
916
+ }
917
+ declare type IWindow = Window & typeof globalThis;
918
+
919
+ declare type rrwebRecord = {
920
+ (options: recordOptions<eventWithTime>): listenerHandler;
921
+ addCustomEvent: (tag: string, payload: any) => void;
922
+ takeFullSnapshot: () => void;
923
+ };
924
+ declare type recordOptions<T> = {
925
+ emit?: (e: T, isCheckout?: boolean) => void;
926
+ checkoutEveryNth?: number;
927
+ checkoutEveryNms?: number;
928
+ blockClass?: blockClass;
929
+ blockSelector?: string;
930
+ ignoreClass?: string;
931
+ maskTextClass?: maskTextClass;
932
+ maskTextSelector?: string;
933
+ maskAllInputs?: boolean;
934
+ maskInputOptions?: MaskInputOptions;
935
+ maskInputFn?: MaskInputFn;
936
+ maskTextFn?: MaskTextFn;
937
+ slimDOMOptions?: SlimDOMOptions | 'all' | true;
938
+ ignoreCSSAttributes?: Set<string>;
939
+ inlineStylesheet?: boolean;
940
+ hooks?: hooksParam;
941
+ sampling?: SamplingStrategy;
942
+ dataURLOptions?: DataURLOptions;
943
+ recordCanvas?: boolean;
944
+ recordCrossOriginIframes?: boolean;
945
+ recordAfter?: 'DOMContentLoaded' | 'load';
946
+ userTriggeredOnInput?: boolean;
947
+ collectFonts?: boolean;
948
+ inlineImages?: boolean;
949
+ plugins?: RecordPlugin[];
950
+ mousemoveWait?: number;
951
+ keepIframeSrcFn?: KeepIframeSrcFn;
952
+ };
494
953
  declare class SessionRecording {
495
954
  instance: PostHog;
496
955
  captureStarted: boolean;
@@ -501,7 +960,7 @@ declare class SessionRecording {
501
960
  windowId: string | null;
502
961
  sessionId: string | null;
503
962
  receivedDecide: boolean;
504
- rrwebRecord: typeof record | undefined;
963
+ rrwebRecord: rrwebRecord | undefined;
505
964
  recorderVersion?: string;
506
965
  lastActivityTimestamp: number;
507
966
  isIdle: boolean;
@@ -644,19 +1103,18 @@ declare class ExceptionObserver {
644
1103
  private originalOnErrorHandler;
645
1104
  private originalOnUnhandledRejectionHandler;
646
1105
  constructor(instance: PostHog);
647
- startObservingIfEnabled(): void;
648
1106
  startCapturing(): void;
649
1107
  stopCapturing(): void;
650
1108
  isCapturing(): boolean;
651
1109
  isEnabled(): boolean;
652
1110
  afterDecideResponse(response: DecideResponse): void;
1111
+ captureException(args: ErrorEventArgs, properties?: Properties): void;
653
1112
  /**
654
1113
  * :TRICKY: Make sure we batch these requests
655
1114
  */
656
1115
  sendExceptionEvent(properties: {
657
1116
  [key: string]: any;
658
1117
  }): void;
659
- captureException(args: ErrorEventArgs, properties?: Properties): void;
660
1118
  }
661
1119
 
662
1120
  /**