clarity-decode 0.6.23
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/README.md +26 -0
- package/build/clarity.decode.js +677 -0
- package/build/clarity.decode.min.js +1 -0
- package/build/clarity.decode.module.js +673 -0
- package/package.json +61 -0
- package/rollup.config.ts +30 -0
- package/src/clarity.ts +195 -0
- package/src/data.ts +87 -0
- package/src/diagnostic.ts +34 -0
- package/src/global.ts +9 -0
- package/src/index.ts +1 -0
- package/src/interaction.ts +80 -0
- package/src/layout.ts +163 -0
- package/src/performance.ts +38 -0
- package/tsconfig.json +20 -0
- package/tslint.json +33 -0
- package/types/core.d.ts +8 -0
- package/types/data.d.ts +84 -0
- package/types/diagnostic.d.ts +9 -0
- package/types/index.d.ts +10 -0
- package/types/interaction.d.ts +23 -0
- package/types/layout.d.ts +29 -0
- package/types/performance.d.ts +8 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Data, Performance } from "clarity-js";
|
|
2
|
+
import { PerformanceEvent } from "../types/performance";
|
|
3
|
+
|
|
4
|
+
export function decode(tokens: Data.Token[]): PerformanceEvent {
|
|
5
|
+
let time = tokens[0] as number;
|
|
6
|
+
let event = tokens[1] as Data.Event;
|
|
7
|
+
switch (event) {
|
|
8
|
+
case Data.Event.Connection:
|
|
9
|
+
let connectionData: Performance.ConnectionData = {
|
|
10
|
+
downlink: tokens[2] as number,
|
|
11
|
+
rtt: tokens[3] as number,
|
|
12
|
+
saveData: tokens[4] as number,
|
|
13
|
+
type: tokens[5] as string
|
|
14
|
+
};
|
|
15
|
+
return { time, event, data: connectionData };
|
|
16
|
+
case Data.Event.Navigation:
|
|
17
|
+
let navigationData: Performance.NavigationData = {
|
|
18
|
+
fetchStart: tokens[2] as number,
|
|
19
|
+
connectStart: tokens[3] as number,
|
|
20
|
+
connectEnd: tokens[4] as number,
|
|
21
|
+
requestStart: tokens[5] as number,
|
|
22
|
+
responseStart: tokens[6] as number,
|
|
23
|
+
responseEnd: tokens[7] as number,
|
|
24
|
+
domInteractive: tokens[8] as number,
|
|
25
|
+
domComplete: tokens[9] as number,
|
|
26
|
+
loadEventStart: tokens[10] as number,
|
|
27
|
+
loadEventEnd: tokens[11] as number,
|
|
28
|
+
redirectCount: tokens[12] as number,
|
|
29
|
+
size: tokens[13] as number,
|
|
30
|
+
type: tokens[14] as string,
|
|
31
|
+
protocol: tokens[15] as string,
|
|
32
|
+
encodedSize: tokens[16] as number,
|
|
33
|
+
decodedSize: tokens[17] as number
|
|
34
|
+
};
|
|
35
|
+
return { time, event, data: navigationData };
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "esnext",
|
|
4
|
+
"target": "es5",
|
|
5
|
+
"lib": ["es6", "dom", "es2016", "es2017"],
|
|
6
|
+
"moduleResolution": "node",
|
|
7
|
+
"forceConsistentCasingInFileNames": true,
|
|
8
|
+
"noImplicitReturns": true,
|
|
9
|
+
"noUnusedLocals": true,
|
|
10
|
+
"noUnusedParameters": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"baseUrl": ".",
|
|
13
|
+
"paths": {
|
|
14
|
+
"@src/*": ["src/*"],
|
|
15
|
+
"@clarity-types/*": ["types/*"]
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"include":["src/**/*.ts","types/**/*.d.ts"],
|
|
19
|
+
"exclude": ["node_modules", "build"]
|
|
20
|
+
}
|
package/tslint.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "tslint:recommended",
|
|
3
|
+
"rules": {
|
|
4
|
+
"max-line-length": [
|
|
5
|
+
true,
|
|
6
|
+
140
|
|
7
|
+
],
|
|
8
|
+
"no-console": [
|
|
9
|
+
false
|
|
10
|
+
],
|
|
11
|
+
"no-string-literal": false,
|
|
12
|
+
"prefer-const": false,
|
|
13
|
+
"prefer-for-of": false,
|
|
14
|
+
"object-literal-sort-keys": false,
|
|
15
|
+
"one-variable-per-declaration": false,
|
|
16
|
+
"trailing-comma": [
|
|
17
|
+
false
|
|
18
|
+
],
|
|
19
|
+
"variable-name": false,
|
|
20
|
+
"interface-name": false,
|
|
21
|
+
"interface-over-type-literal": false,
|
|
22
|
+
"only-arrow-functions": false,
|
|
23
|
+
"typedef": [
|
|
24
|
+
true,
|
|
25
|
+
"call-signature",
|
|
26
|
+
"parameter",
|
|
27
|
+
"property-declaration",
|
|
28
|
+
"member-variable-declaration",
|
|
29
|
+
"object-destructuring",
|
|
30
|
+
"array-destructuring"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
}
|
package/types/core.d.ts
ADDED
package/types/data.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Data } from "clarity-js";
|
|
2
|
+
import { DiagnosticEvent, ImageErrorEvent, LogEvent, ScriptErrorEvent } from "./diagnostic";
|
|
3
|
+
import { ClickEvent, InputEvent, InteractionEvent, PointerEvent, ResizeEvent } from "./interaction";
|
|
4
|
+
import { ScrollEvent, SelectionEvent, TimelineEvent, UnloadEvent, VisibilityEvent } from "./interaction";
|
|
5
|
+
import { BoxEvent, DocumentEvent, DomEvent, LayoutEvent, RegionEvent } from "./layout";
|
|
6
|
+
import { ConnectionEvent, NavigationEvent, PerformanceEvent } from "./performance";
|
|
7
|
+
import { PartialEvent } from "./core";
|
|
8
|
+
|
|
9
|
+
/* Redeclare enums */
|
|
10
|
+
export import Envelope = Data.Envelope;
|
|
11
|
+
export import Code = Data.Code;
|
|
12
|
+
export import Dimension = Data.Dimension;
|
|
13
|
+
export import Event = Data.Event;
|
|
14
|
+
export import Metric = Data.Metric;
|
|
15
|
+
export import Payload = Data.Payload;
|
|
16
|
+
export import BooleanFlag = Data.BooleanFlag;
|
|
17
|
+
export import Constant = Data.Constant;
|
|
18
|
+
export import Setting = Data.Setting;
|
|
19
|
+
|
|
20
|
+
/* Data Events */
|
|
21
|
+
export interface BaselineEvent extends PartialEvent { data: Data.BaselineData; }
|
|
22
|
+
export interface DimensionEvent extends PartialEvent { data: Data.DimensionData; }
|
|
23
|
+
export interface MetricEvent extends PartialEvent { data: Data.MetricData; }
|
|
24
|
+
export interface CustomEvent extends PartialEvent { data: Data.CustomData; }
|
|
25
|
+
export interface VariableEvent extends PartialEvent { data: Data.VariableData; }
|
|
26
|
+
export interface PingEvent extends PartialEvent { data: Data.PingData; }
|
|
27
|
+
export interface LimitEvent extends PartialEvent { data: Data.LimitData; }
|
|
28
|
+
export interface SummaryEvent extends PartialEvent { data: Data.SummaryData; }
|
|
29
|
+
export interface UpgradeEvent extends PartialEvent { data: Data.UpgradeData; }
|
|
30
|
+
export interface UploadEvent extends PartialEvent { data: Data.UploadData; }
|
|
31
|
+
export interface DataEvent extends PartialEvent {
|
|
32
|
+
data: Data.BaselineData |
|
|
33
|
+
Data.DimensionData |
|
|
34
|
+
Data.MetricData |
|
|
35
|
+
Data.CustomData |
|
|
36
|
+
Data.VariableData |
|
|
37
|
+
Data.PingData |
|
|
38
|
+
Data.LimitData |
|
|
39
|
+
Data.SummaryData |
|
|
40
|
+
Data.UpgradeData |
|
|
41
|
+
Data.UploadData;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type DecodedEvent = DataEvent | DiagnosticEvent | InteractionEvent | LayoutEvent | PerformanceEvent;
|
|
45
|
+
|
|
46
|
+
export interface DecodedPayload {
|
|
47
|
+
timestamp: number;
|
|
48
|
+
envelope: Data.Envelope;
|
|
49
|
+
metric?: MetricEvent[];
|
|
50
|
+
dimension?: DimensionEvent[];
|
|
51
|
+
ping?: PingEvent[];
|
|
52
|
+
limit?: LimitEvent[];
|
|
53
|
+
image?: ImageErrorEvent[];
|
|
54
|
+
script?: ScriptErrorEvent[];
|
|
55
|
+
input?: InputEvent[];
|
|
56
|
+
pointer?: PointerEvent[];
|
|
57
|
+
click?: ClickEvent[];
|
|
58
|
+
resize?: ResizeEvent[];
|
|
59
|
+
scroll?: ScrollEvent[];
|
|
60
|
+
selection?: SelectionEvent[];
|
|
61
|
+
summary?: SummaryEvent[];
|
|
62
|
+
timeline?: TimelineEvent[];
|
|
63
|
+
unload?: UnloadEvent[];
|
|
64
|
+
upgrade?: UpgradeEvent[];
|
|
65
|
+
upload?: UploadEvent[];
|
|
66
|
+
visibility?: VisibilityEvent[];
|
|
67
|
+
box?: BoxEvent[];
|
|
68
|
+
region?: RegionEvent[];
|
|
69
|
+
dom?: DomEvent[];
|
|
70
|
+
doc?: DocumentEvent[];
|
|
71
|
+
connection?: ConnectionEvent[];
|
|
72
|
+
navigation?: NavigationEvent[];
|
|
73
|
+
log?: LogEvent[];
|
|
74
|
+
baseline?: BaselineEvent[];
|
|
75
|
+
variable?: VariableEvent[];
|
|
76
|
+
custom?: CustomEvent[];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface DecodedVersion {
|
|
80
|
+
major: number;
|
|
81
|
+
minor: number;
|
|
82
|
+
patch: number;
|
|
83
|
+
beta: number;
|
|
84
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Diagnostic } from "clarity-js";
|
|
2
|
+
import { PartialEvent } from "./core";
|
|
3
|
+
|
|
4
|
+
export interface ImageErrorEvent extends PartialEvent { data: Diagnostic.ImageErrorData; }
|
|
5
|
+
export interface ScriptErrorEvent extends PartialEvent { data: Diagnostic.ScriptErrorData; }
|
|
6
|
+
export interface LogEvent extends PartialEvent { data: Diagnostic.LogData; }
|
|
7
|
+
export interface DiagnosticEvent extends PartialEvent {
|
|
8
|
+
data: Diagnostic.ImageErrorData | Diagnostic.LogData | Diagnostic.ScriptErrorData;
|
|
9
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as Core from "./core";
|
|
2
|
+
import * as Data from "./data";
|
|
3
|
+
import * as Diagnostic from "./diagnostic";
|
|
4
|
+
import * as Layout from "./layout";
|
|
5
|
+
import * as Interaction from "./interaction";
|
|
6
|
+
import * as Performance from "./performance";
|
|
7
|
+
|
|
8
|
+
export function decode(data: string): Data.DecodedPayload;
|
|
9
|
+
|
|
10
|
+
export { Core, Data, Diagnostic, Layout, Interaction, Performance };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Interaction } from "clarity-js";
|
|
2
|
+
import { PartialEvent } from "./core";
|
|
3
|
+
|
|
4
|
+
export interface InputEvent extends PartialEvent { data: Interaction.InputData; }
|
|
5
|
+
export interface ClickEvent extends PartialEvent { data: Interaction.ClickData; }
|
|
6
|
+
export interface PointerEvent extends PartialEvent { data: Interaction.PointerData; }
|
|
7
|
+
export interface ResizeEvent extends PartialEvent { data: Interaction.ResizeData; }
|
|
8
|
+
export interface ScrollEvent extends PartialEvent { data: Interaction.ScrollData; }
|
|
9
|
+
export interface SelectionEvent extends PartialEvent { data: Interaction.SelectionData; }
|
|
10
|
+
export interface TimelineEvent extends PartialEvent { data: Interaction.TimelineData; }
|
|
11
|
+
export interface UnloadEvent extends PartialEvent { data: Interaction.UnloadData; }
|
|
12
|
+
export interface VisibilityEvent extends PartialEvent { data: Interaction.VisibilityData; }
|
|
13
|
+
export interface InteractionEvent extends PartialEvent {
|
|
14
|
+
data: Interaction.ClickData |
|
|
15
|
+
Interaction.InputData |
|
|
16
|
+
Interaction.PointerData |
|
|
17
|
+
Interaction.ResizeData |
|
|
18
|
+
Interaction.ScrollData |
|
|
19
|
+
Interaction.SelectionData |
|
|
20
|
+
Interaction.TimelineData |
|
|
21
|
+
Interaction.UnloadData |
|
|
22
|
+
Interaction.VisibilityData;
|
|
23
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Layout } from "clarity-js";
|
|
2
|
+
import { PartialEvent } from "./core";
|
|
3
|
+
|
|
4
|
+
export interface RegionEvent extends PartialEvent { data: Layout.RegionData[]; }
|
|
5
|
+
export interface DocumentEvent extends PartialEvent { data: Layout.DocumentData; }
|
|
6
|
+
export interface DomEvent extends PartialEvent { data: DomData[]; }
|
|
7
|
+
export interface BoxEvent extends PartialEvent { data: Layout.BoxData[]; }
|
|
8
|
+
export interface LayoutEvent extends PartialEvent {
|
|
9
|
+
data: Layout.RegionData[] | Layout.DocumentData | DomData[] | Layout.BoxData[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/* Redeclare enums */
|
|
13
|
+
export import Constant = Layout.Constant;
|
|
14
|
+
export import Interaction = Layout.InteractionState;
|
|
15
|
+
|
|
16
|
+
/* Event Data */
|
|
17
|
+
export interface DomData {
|
|
18
|
+
id: number;
|
|
19
|
+
parent: number;
|
|
20
|
+
previous: number;
|
|
21
|
+
tag: string;
|
|
22
|
+
position: number;
|
|
23
|
+
selector: string;
|
|
24
|
+
hash: string;
|
|
25
|
+
attributes?: Layout.Attributes;
|
|
26
|
+
value?: string;
|
|
27
|
+
width?: number;
|
|
28
|
+
height?: number;
|
|
29
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Performance } from "clarity-js";
|
|
2
|
+
import { PartialEvent } from "./core";
|
|
3
|
+
|
|
4
|
+
export interface ConnectionEvent extends PartialEvent { data: Performance.ConnectionData; }
|
|
5
|
+
export interface NavigationEvent extends PartialEvent { data: Performance.NavigationData; }
|
|
6
|
+
export interface PerformanceEvent extends PartialEvent {
|
|
7
|
+
data: Performance.ConnectionData | Performance.NavigationData
|
|
8
|
+
}
|