-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsession-replay-browser.ts
More file actions
156 lines (136 loc) · 4.8 KB
/
Copy pathsession-replay-browser.ts
File metadata and controls
156 lines (136 loc) · 4.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import type * as SessionReplay from '../generated/browserSessionReplay'
export * from '../generated/browserSessionReplay'
/**
* For backward compatibility reasons, `undefined` should be accepted as a possible value for Browser segments, too.
**/
export const BrowserSource = {
Browser: 'browser',
} as const
export type BrowserSource = (typeof BrowserSource)[keyof typeof BrowserSource]
export const RecordType: {
FullSnapshot: SessionReplay.BrowserFullSnapshotRecord['type']
IncrementalSnapshot: SessionReplay.BrowserIncrementalSnapshotRecord['type']
Meta: SessionReplay.MetaRecord['type']
Focus: SessionReplay.FocusRecord['type']
ViewEnd: SessionReplay.ViewEndRecord['type']
VisualViewport: SessionReplay.VisualViewportRecord['type']
FrustrationRecord: SessionReplay.FrustrationRecord['type']
Change: SessionReplay.BrowserChangeRecord['type']
} = {
FullSnapshot: 2,
IncrementalSnapshot: 3,
Meta: 4,
Focus: 6,
ViewEnd: 7,
VisualViewport: 8,
FrustrationRecord: 9,
Change: 12,
} as const
export type RecordType = (typeof RecordType)[keyof typeof RecordType]
export const NodeType: {
Document: SessionReplay.DocumentNode['type']
DocumentType: SessionReplay.DocumentTypeNode['type']
Element: SessionReplay.ElementNode['type']
Text: SessionReplay.TextNode['type']
CDATA: SessionReplay.CDataNode['type']
DocumentFragment: SessionReplay.DocumentFragmentNode['type']
} = {
Document: 0,
DocumentType: 1,
Element: 2,
Text: 3,
CDATA: 4,
DocumentFragment: 11,
} as const
export type NodeType = (typeof NodeType)[keyof typeof NodeType]
export const IncrementalSource: {
Mutation: SessionReplay.BrowserMutationData['source']
MouseMove: Exclude<SessionReplay.MousemoveData['source'], 6>
MouseInteraction: SessionReplay.MouseInteractionData['source']
Scroll: SessionReplay.ScrollData['source']
ViewportResize: SessionReplay.ViewportResizeData['source']
Input: SessionReplay.InputData['source']
TouchMove: Exclude<SessionReplay.MousemoveData['source'], 1>
MediaInteraction: SessionReplay.MediaInteractionData['source']
StyleSheetRule: SessionReplay.StyleSheetRuleData['source']
PointerInteraction: SessionReplay.PointerInteractionData['source']
} = {
Mutation: 0,
MouseMove: 1,
MouseInteraction: 2,
Scroll: 3,
ViewportResize: 4,
Input: 5,
TouchMove: 6,
MediaInteraction: 7,
StyleSheetRule: 8,
PointerInteraction: 9,
// Font : 10,
} as const
export type IncrementalSource = (typeof IncrementalSource)[keyof typeof IncrementalSource]
export const MouseInteractionType = {
MouseUp: 0,
MouseDown: 1,
Click: 2,
ContextMenu: 3,
DblClick: 4,
Focus: 5,
Blur: 6,
TouchStart: 7,
TouchEnd: 9,
} as const
export type MouseInteractionType = (typeof MouseInteractionType)[keyof typeof MouseInteractionType]
export const MediaInteractionType = {
Play: 0,
Pause: 1,
} as const
export type MediaInteractionType = (typeof MediaInteractionType)[keyof typeof MediaInteractionType]
// ChangeTypeId evaluates to Id if [Id, ...Data[]] is a valid variant of Change;
// otherwise, it triggers a compile-time error.
type ChangeTypeId<Id, Data> = [Id, ...Data[]] extends SessionReplay.Change ? Id : never
export const ChangeType: {
AddString: ChangeTypeId<0, SessionReplay.AddStringChange>
AddNode: ChangeTypeId<1, SessionReplay.AddNodeChange>
RemoveNode: ChangeTypeId<2, SessionReplay.RemoveNodeChange>
Attribute: ChangeTypeId<3, SessionReplay.AttributeChange>
Text: ChangeTypeId<4, SessionReplay.TextChange>
Size: ChangeTypeId<5, SessionReplay.SizeChange>
ScrollPosition: ChangeTypeId<6, SessionReplay.ScrollPositionChange>
AddStyleSheet: ChangeTypeId<7, SessionReplay.AddStyleSheetChange>
AttachedStyleSheets: ChangeTypeId<8, SessionReplay.AttachedStyleSheetsChange>
MediaPlaybackState: ChangeTypeId<9, SessionReplay.MediaPlaybackStateChange>
VisualViewport: ChangeTypeId<10, SessionReplay.VisualViewportChange>
AddStringNamespace: ChangeTypeId<11, SessionReplay.AddStringNamespaceChange>
AddNamespacedString: ChangeTypeId<12, SessionReplay.AddNamespacedStringChange>
} = {
AddString: 0,
AddNode: 1,
RemoveNode: 2,
Attribute: 3,
Text: 4,
Size: 5,
ScrollPosition: 6,
AddStyleSheet: 7,
AttachedStyleSheets: 8,
MediaPlaybackState: 9,
VisualViewport: 10,
AddStringNamespace: 11,
AddNamespacedString: 12,
} as const
export type ChangeType = (typeof ChangeType)[keyof typeof ChangeType]
export const PlaybackState: {
Playing: SessionReplay.PlaybackStatePlaying
Paused: SessionReplay.PlaybackStatePaused
} = {
Playing: 0,
Paused: 1,
} as const
export type PlaybackState = (typeof PlaybackState)[keyof typeof PlaybackState]
export const SnapshotFormat: {
V1: SessionReplay.SnapshotFormatV1
Change: SessionReplay.SnapshotFormatChange
} = {
V1: 0,
Change: 1,
} as const
export type SnapshotFormat = (typeof SnapshotFormat)[keyof typeof SnapshotFormat]