posthog-js
Advanced tools
Comparing version 1.29.1 to 1.29.2
@@ -0,1 +1,5 @@ | ||
## 1.29.2 - 2022-08-25 | ||
- fix(typing): rrweb types (#441) | ||
## 1.29.1 - 2022-08-23 | ||
@@ -2,0 +6,0 @@ |
@@ -1,6 +0,93 @@ | ||
import { MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot'; | ||
import { record } from 'rrweb'; | ||
import { listenerHandler, eventWithTime } from 'rrweb/typings/types'; | ||
import { Integration, EventProcessor, Hub } from '@sentry/types'; | ||
declare enum NodeType { | ||
Document = 0, | ||
DocumentType = 1, | ||
Element = 2, | ||
Text = 3, | ||
CDATA = 4, | ||
Comment = 5 | ||
} | ||
declare type documentNode = { | ||
type: NodeType.Document; | ||
childNodes: serializedNodeWithId[]; | ||
compatMode?: string; | ||
}; | ||
declare type documentTypeNode = { | ||
type: NodeType.DocumentType; | ||
name: string; | ||
publicId: string; | ||
systemId: string; | ||
}; | ||
declare type attributes = { | ||
[key: string]: string | number | boolean; | ||
}; | ||
declare type elementNode = { | ||
type: NodeType.Element; | ||
tagName: string; | ||
attributes: attributes; | ||
childNodes: serializedNodeWithId[]; | ||
isSVG?: true; | ||
needBlock?: boolean; | ||
}; | ||
declare type textNode = { | ||
type: NodeType.Text; | ||
textContent: string; | ||
isStyle?: true; | ||
}; | ||
declare type cdataNode = { | ||
type: NodeType.CDATA; | ||
textContent: ''; | ||
}; | ||
declare type commentNode = { | ||
type: NodeType.Comment; | ||
textContent: string; | ||
}; | ||
declare type serializedNode = (documentNode | documentTypeNode | elementNode | textNode | cdataNode | commentNode) & { | ||
rootId?: number; | ||
isShadowHost?: boolean; | ||
isShadow?: boolean; | ||
}; | ||
declare type serializedNodeWithId = serializedNode & { | ||
id: number; | ||
}; | ||
interface INode extends Node { | ||
__sn: serializedNodeWithId; | ||
} | ||
declare type idNodeMap = { | ||
[key: number]: INode; | ||
}; | ||
declare type MaskInputOptions = Partial<{ | ||
color: boolean; | ||
date: boolean; | ||
'datetime-local': boolean; | ||
email: boolean; | ||
month: boolean; | ||
number: boolean; | ||
range: boolean; | ||
search: boolean; | ||
tel: boolean; | ||
text: boolean; | ||
time: boolean; | ||
url: boolean; | ||
week: boolean; | ||
textarea: boolean; | ||
select: boolean; | ||
password: boolean; | ||
}>; | ||
declare type SlimDOMOptions = Partial<{ | ||
script: boolean; | ||
comment: boolean; | ||
headFavicon: boolean; | ||
headWhitespace: boolean; | ||
headMetaDescKeywords: boolean; | ||
headMetaSocial: boolean; | ||
headMetaRobots: boolean; | ||
headMetaHttpEquiv: boolean; | ||
headMetaAuthorship: boolean; | ||
headMetaVerification: boolean; | ||
}>; | ||
declare type MaskTextFn = (text: string) => string; | ||
declare type MaskInputFn = (text: string) => string; | ||
declare class CaptureMetrics { | ||
@@ -339,2 +426,339 @@ enabled: boolean; | ||
declare type PackFn = (event: eventWithTime) => string; | ||
declare enum EventType { | ||
DomContentLoaded = 0, | ||
Load = 1, | ||
FullSnapshot = 2, | ||
IncrementalSnapshot = 3, | ||
Meta = 4, | ||
Custom = 5, | ||
Plugin = 6 | ||
} | ||
declare type domContentLoadedEvent = { | ||
type: EventType.DomContentLoaded; | ||
data: {}; | ||
}; | ||
declare type loadedEvent = { | ||
type: EventType.Load; | ||
data: {}; | ||
}; | ||
declare type fullSnapshotEvent = { | ||
type: EventType.FullSnapshot; | ||
data: { | ||
node: serializedNodeWithId; | ||
initialOffset: { | ||
top: number; | ||
left: number; | ||
}; | ||
}; | ||
}; | ||
declare type incrementalSnapshotEvent = { | ||
type: EventType.IncrementalSnapshot; | ||
data: incrementalData; | ||
}; | ||
declare type metaEvent = { | ||
type: EventType.Meta; | ||
data: { | ||
href: string; | ||
width: number; | ||
height: number; | ||
}; | ||
}; | ||
declare type customEvent<T = unknown> = { | ||
type: EventType.Custom; | ||
data: { | ||
tag: string; | ||
payload: T; | ||
}; | ||
}; | ||
declare type pluginEvent<T = unknown> = { | ||
type: EventType.Plugin; | ||
data: { | ||
plugin: string; | ||
payload: T; | ||
}; | ||
}; | ||
declare enum IncrementalSource { | ||
Mutation = 0, | ||
MouseMove = 1, | ||
MouseInteraction = 2, | ||
Scroll = 3, | ||
ViewportResize = 4, | ||
Input = 5, | ||
TouchMove = 6, | ||
MediaInteraction = 7, | ||
StyleSheetRule = 8, | ||
CanvasMutation = 9, | ||
Font = 10, | ||
Log = 11, | ||
Drag = 12, | ||
StyleDeclaration = 13 | ||
} | ||
declare type mutationData = { | ||
source: IncrementalSource.Mutation; | ||
} & mutationCallbackParam; | ||
declare type mousemoveData = { | ||
source: IncrementalSource.MouseMove | IncrementalSource.TouchMove | IncrementalSource.Drag; | ||
positions: mousePosition[]; | ||
}; | ||
declare type mouseInteractionData = { | ||
source: IncrementalSource.MouseInteraction; | ||
} & mouseInteractionParam; | ||
declare type scrollData = { | ||
source: IncrementalSource.Scroll; | ||
} & scrollPosition; | ||
declare type viewportResizeData = { | ||
source: IncrementalSource.ViewportResize; | ||
} & viewportResizeDimension; | ||
declare type inputData = { | ||
source: IncrementalSource.Input; | ||
id: number; | ||
} & inputValue; | ||
declare type mediaInteractionData = { | ||
source: IncrementalSource.MediaInteraction; | ||
} & mediaInteractionParam; | ||
declare type styleSheetRuleData = { | ||
source: IncrementalSource.StyleSheetRule; | ||
} & styleSheetRuleParam; | ||
declare type styleDeclarationData = { | ||
source: IncrementalSource.StyleDeclaration; | ||
} & styleDeclarationParam; | ||
declare type canvasMutationData = { | ||
source: IncrementalSource.CanvasMutation; | ||
} & canvasMutationParam; | ||
declare type fontData = { | ||
source: IncrementalSource.Font; | ||
} & fontParam; | ||
declare type incrementalData = mutationData | mousemoveData | mouseInteractionData | scrollData | viewportResizeData | inputData | mediaInteractionData | styleSheetRuleData | canvasMutationData | fontData | styleDeclarationData; | ||
declare type event = domContentLoadedEvent | loadedEvent | fullSnapshotEvent | incrementalSnapshotEvent | metaEvent | customEvent | pluginEvent; | ||
declare type eventWithTime = event & { | ||
timestamp: number; | ||
delay?: number; | ||
}; | ||
declare type blockClass = string | RegExp; | ||
declare type maskTextClass = string | RegExp; | ||
declare type SamplingStrategy = Partial<{ | ||
mousemove: boolean | number; | ||
mousemoveCallback: number; | ||
mouseInteraction: boolean | Record<string, boolean | undefined>; | ||
scroll: number; | ||
media: number; | ||
input: 'all' | 'last'; | ||
}>; | ||
declare type RecordPlugin<TOptions = unknown> = { | ||
name: string; | ||
observer?: (cb: Function, win: IWindow, options: TOptions) => listenerHandler; | ||
eventProcessor?: <TExtend>(event: eventWithTime) => eventWithTime & TExtend; | ||
options: TOptions; | ||
}; | ||
declare type recordOptions<T> = { | ||
emit?: (e: T, isCheckout?: boolean) => void; | ||
checkoutEveryNth?: number; | ||
checkoutEveryNms?: number; | ||
blockClass?: blockClass; | ||
blockSelector?: string; | ||
ignoreClass?: string; | ||
maskTextClass?: maskTextClass; | ||
maskTextSelector?: string; | ||
maskAllInputs?: boolean; | ||
maskInputOptions?: MaskInputOptions; | ||
maskInputFn?: MaskInputFn; | ||
maskTextFn?: MaskTextFn; | ||
slimDOMOptions?: SlimDOMOptions | 'all' | true; | ||
inlineStylesheet?: boolean; | ||
hooks?: hooksParam; | ||
packFn?: PackFn; | ||
sampling?: SamplingStrategy; | ||
recordCanvas?: boolean; | ||
userTriggeredOnInput?: boolean; | ||
collectFonts?: boolean; | ||
inlineImages?: boolean; | ||
plugins?: RecordPlugin[]; | ||
mousemoveWait?: number; | ||
keepIframeSrcFn?: KeepIframeSrcFn; | ||
}; | ||
declare type hooksParam = { | ||
mutation?: mutationCallBack; | ||
mousemove?: mousemoveCallBack; | ||
mouseInteraction?: mouseInteractionCallBack; | ||
scroll?: scrollCallback; | ||
viewportResize?: viewportResizeCallback; | ||
input?: inputCallback; | ||
mediaInteaction?: mediaInteractionCallback; | ||
styleSheetRule?: styleSheetRuleCallback; | ||
styleDeclaration?: styleDeclarationCallback; | ||
canvasMutation?: canvasMutationCallback; | ||
font?: fontCallback; | ||
}; | ||
declare type textMutation = { | ||
id: number; | ||
value: string | null; | ||
}; | ||
declare type styleAttributeValue = { | ||
[key: string]: styleValueWithPriority | string | false; | ||
}; | ||
declare type styleValueWithPriority = [string, string]; | ||
declare type attributeMutation = { | ||
id: number; | ||
attributes: { | ||
[key: string]: string | styleAttributeValue | null; | ||
}; | ||
}; | ||
declare type removedNodeMutation = { | ||
parentId: number; | ||
id: number; | ||
isShadow?: boolean; | ||
}; | ||
declare type addedNodeMutation = { | ||
parentId: number; | ||
previousId?: number | null; | ||
nextId: number | null; | ||
node: serializedNodeWithId; | ||
}; | ||
declare type mutationCallbackParam = { | ||
texts: textMutation[]; | ||
attributes: attributeMutation[]; | ||
removes: removedNodeMutation[]; | ||
adds: addedNodeMutation[]; | ||
isAttachIframe?: true; | ||
}; | ||
declare type mutationCallBack = (m: mutationCallbackParam) => void; | ||
declare type mousemoveCallBack = (p: mousePosition[], source: IncrementalSource.MouseMove | IncrementalSource.TouchMove | IncrementalSource.Drag) => void; | ||
declare type mousePosition = { | ||
x: number; | ||
y: number; | ||
id: number; | ||
timeOffset: number; | ||
}; | ||
declare enum MouseInteractions { | ||
MouseUp = 0, | ||
MouseDown = 1, | ||
Click = 2, | ||
ContextMenu = 3, | ||
DblClick = 4, | ||
Focus = 5, | ||
Blur = 6, | ||
TouchStart = 7, | ||
TouchMove_Departed = 8, | ||
TouchEnd = 9, | ||
TouchCancel = 10 | ||
} | ||
declare enum CanvasContext { | ||
'2D' = 0, | ||
WebGL = 1, | ||
WebGL2 = 2 | ||
} | ||
declare type mouseInteractionParam = { | ||
type: MouseInteractions; | ||
id: number; | ||
x: number; | ||
y: number; | ||
}; | ||
declare type mouseInteractionCallBack = (d: mouseInteractionParam) => void; | ||
declare type scrollPosition = { | ||
id: number; | ||
x: number; | ||
y: number; | ||
}; | ||
declare type scrollCallback = (p: scrollPosition) => void; | ||
declare type styleSheetAddRule = { | ||
rule: string; | ||
index?: number | number[]; | ||
}; | ||
declare type styleSheetDeleteRule = { | ||
index: number | number[]; | ||
}; | ||
declare type styleSheetRuleParam = { | ||
id: number; | ||
removes?: styleSheetDeleteRule[]; | ||
adds?: styleSheetAddRule[]; | ||
}; | ||
declare type styleSheetRuleCallback = (s: styleSheetRuleParam) => void; | ||
declare type styleDeclarationParam = { | ||
id: number; | ||
index: number[]; | ||
set?: { | ||
property: string; | ||
value: string | null; | ||
priority: string | undefined; | ||
}; | ||
remove?: { | ||
property: string; | ||
}; | ||
}; | ||
declare type styleDeclarationCallback = (s: styleDeclarationParam) => void; | ||
declare type canvasMutationCommand = { | ||
property: string; | ||
args: Array<unknown>; | ||
setter?: true; | ||
}; | ||
declare type canvasMutationParam = { | ||
id: number; | ||
type: CanvasContext; | ||
commands: canvasMutationCommand[]; | ||
} | ({ | ||
id: number; | ||
type: CanvasContext; | ||
} & canvasMutationCommand); | ||
declare type canvasMutationCallback = (p: canvasMutationParam) => void; | ||
declare type fontParam = { | ||
family: string; | ||
fontSource: string; | ||
buffer: boolean; | ||
descriptors?: FontFaceDescriptors; | ||
}; | ||
declare type fontCallback = (p: fontParam) => void; | ||
declare type viewportResizeDimension = { | ||
width: number; | ||
height: number; | ||
}; | ||
declare type viewportResizeCallback = (d: viewportResizeDimension) => void; | ||
declare type inputValue = { | ||
text: string; | ||
isChecked: boolean; | ||
userTriggered?: boolean; | ||
}; | ||
declare type inputCallback = (v: inputValue & { | ||
id: number; | ||
}) => void; | ||
declare const enum MediaInteractions { | ||
Play = 0, | ||
Pause = 1, | ||
Seeked = 2, | ||
VolumeChange = 3 | ||
} | ||
declare type mediaInteractionParam = { | ||
type: MediaInteractions; | ||
id: number; | ||
currentTime?: number; | ||
volume?: number; | ||
muted?: boolean; | ||
}; | ||
declare type mediaInteractionCallback = (p: mediaInteractionParam) => void; | ||
declare type Mirror = { | ||
map: idNodeMap; | ||
getId: (n: INode) => number; | ||
getNode: (id: number) => INode | null; | ||
removeNodeFromMap: (n: INode) => void; | ||
has: (id: number) => boolean; | ||
reset: () => void; | ||
}; | ||
declare type listenerHandler = () => void; | ||
declare type KeepIframeSrcFn = (src: string) => boolean; | ||
declare global { | ||
interface Window { | ||
FontFace: typeof FontFace; | ||
} | ||
} | ||
declare type IWindow = Window & typeof globalThis; | ||
declare function record<T = eventWithTime>(options?: recordOptions<T>): listenerHandler | undefined; | ||
declare namespace record { | ||
var addCustomEvent: <T>(tag: string, payload: T) => void; | ||
var freezePage: () => void; | ||
var takeFullSnapshot: (isCheckout?: boolean | undefined) => void; | ||
var mirror: Mirror; | ||
} | ||
declare class SessionRecording { | ||
@@ -341,0 +765,0 @@ instance: PostHog; |
{ | ||
"name": "posthog-js", | ||
"version": "1.29.1", | ||
"version": "1.29.2", | ||
"description": "Posthog-js allows you to automatically capture usage and send events to PostHog.", | ||
@@ -11,4 +11,14 @@ "repository": "https://github.com/PostHog/posthog-js", | ||
"build": "yarn build-rollup && yarn build-react", | ||
"build-rollup": "tsc -b && rollup -c", | ||
"build-rollup": "yarn build:prepare-types && rollup -c", | ||
"build-react": "cd react; yarn; yarn build;", | ||
"build:prepare-types": "yarn build:prepare-types:tsc && yarn build:prepare-types:copy && yarn build:prepare-types:fix && yarn build:prepare-types:rename-1 && yarn build:prepare-types:rename-2 && yarn build:prepare-types:rename-3 && yarn build:prepare-types:rename-4 && yarn build:prepare-types:rename-5 && yarn build:prepare-types:rename-6", | ||
"build:prepare-types:tsc": "rm -rf lib && tsc -b", | ||
"build:prepare-types:copy": "rm -rf lib/rrweb && rm -rf lib/rrweb-snapshot && cp -a node_modules/rrweb lib/rrweb; cp -a node_modules/rrweb-snapshot/typings lib/rrweb-snapshot", | ||
"build:prepare-types:fix": "cd lib/rrweb/typings/replay && cat index.d.ts |grep -v 'styles/style.css' > x && mv x index.d.ts", | ||
"build:prepare-types:rename-1": "cd lib/rrweb/typings/record && sed 's/rrweb-snapshot/..\\/..\\/..\\/rrweb-snapshot/g' iframe-manager.d.ts > x && mv x iframe-manager.d.ts", | ||
"build:prepare-types:rename-2": "cd lib/rrweb/typings/replay && sed 's/rrweb-snapshot/..\\/..\\/..\\/rrweb-snapshot/g' virtual-styles.d.ts > x && mv x virtual-styles.d.ts", | ||
"build:prepare-types:rename-3": "cd lib/rrweb/typings && sed 's/rrweb-snapshot/..\\/..\\/rrweb-snapshot/g' types.d.ts > x && mv x types.d.ts", | ||
"build:prepare-types:rename-4": "cd lib/rrweb/typings && sed 's/rrweb-snapshot/..\\/..\\/rrweb-snapshot/g' utils.d.ts > x && mv x utils.d.ts", | ||
"build:prepare-types:rename-5": "cd lib/src/extensions && sed 's/rrweb\\/typings/..\\/..\\/rrweb\\/typings/g' sessionrecording.d.ts > x && mv x sessionrecording.d.ts", | ||
"build:prepare-types:rename-6": "cd lib/src && sed 's/rrweb-snapshot/..\\/rrweb-snapshot/g' types.d.ts > x && mv x types.d.ts", | ||
"lint": "eslint ./src/**/*.{ts,js}", | ||
@@ -15,0 +25,0 @@ "prettier": "prettier --write src/**/*", |
{ | ||
"name": "posthog-js", | ||
"version": "1.29.1", | ||
"version": "1.29.2", | ||
"description": "Posthog-js allows you to automatically capture usage and send events to PostHog.", | ||
@@ -11,4 +11,14 @@ "repository": "https://github.com/PostHog/posthog-js", | ||
"build": "yarn build-rollup && yarn build-react", | ||
"build-rollup": "tsc -b && rollup -c", | ||
"build-rollup": "yarn build:prepare-types && rollup -c", | ||
"build-react": "cd react; yarn; yarn build;", | ||
"build:prepare-types": "yarn build:prepare-types:tsc && yarn build:prepare-types:copy && yarn build:prepare-types:fix && yarn build:prepare-types:rename-1 && yarn build:prepare-types:rename-2 && yarn build:prepare-types:rename-3 && yarn build:prepare-types:rename-4 && yarn build:prepare-types:rename-5 && yarn build:prepare-types:rename-6", | ||
"build:prepare-types:tsc": "rm -rf lib && tsc -b", | ||
"build:prepare-types:copy": "rm -rf lib/rrweb && rm -rf lib/rrweb-snapshot && cp -a node_modules/rrweb lib/rrweb; cp -a node_modules/rrweb-snapshot/typings lib/rrweb-snapshot", | ||
"build:prepare-types:fix": "cd lib/rrweb/typings/replay && cat index.d.ts |grep -v 'styles/style.css' > x && mv x index.d.ts", | ||
"build:prepare-types:rename-1": "cd lib/rrweb/typings/record && sed 's/rrweb-snapshot/..\\/..\\/..\\/rrweb-snapshot/g' iframe-manager.d.ts > x && mv x iframe-manager.d.ts", | ||
"build:prepare-types:rename-2": "cd lib/rrweb/typings/replay && sed 's/rrweb-snapshot/..\\/..\\/..\\/rrweb-snapshot/g' virtual-styles.d.ts > x && mv x virtual-styles.d.ts", | ||
"build:prepare-types:rename-3": "cd lib/rrweb/typings && sed 's/rrweb-snapshot/..\\/..\\/rrweb-snapshot/g' types.d.ts > x && mv x types.d.ts", | ||
"build:prepare-types:rename-4": "cd lib/rrweb/typings && sed 's/rrweb-snapshot/..\\/..\\/rrweb-snapshot/g' utils.d.ts > x && mv x utils.d.ts", | ||
"build:prepare-types:rename-5": "cd lib/src/extensions && sed 's/rrweb\\/typings/..\\/..\\/rrweb\\/typings/g' sessionrecording.d.ts > x && mv x sessionrecording.d.ts", | ||
"build:prepare-types:rename-6": "cd lib/src && sed 's/rrweb-snapshot/..\\/rrweb-snapshot/g' types.d.ts > x && mv x types.d.ts", | ||
"lint": "eslint ./src/**/*.{ts,js}", | ||
@@ -15,0 +25,0 @@ "prettier": "prettier --write src/**/*", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
2178502
14624