@atlaskit/insm 0.1.2 → 0.2.0
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/CHANGELOG.md +17 -0
- package/README.md +17 -0
- package/dist/cjs/index.js +5 -2
- package/dist/cjs/insm-period.js +20 -2
- package/dist/cjs/insm-session.js +82 -8
- package/dist/cjs/insm.js +49 -9
- package/dist/cjs/session-measurers/LongAnimationFrameMeasurer.js +164 -0
- package/dist/es2019/index.js +5 -2
- package/dist/es2019/insm-period.js +19 -1
- package/dist/es2019/insm-session.js +77 -5
- package/dist/es2019/insm.js +46 -9
- package/dist/es2019/session-measurers/LongAnimationFrameMeasurer.js +128 -0
- package/dist/esm/index.js +5 -2
- package/dist/esm/insm-period.js +19 -1
- package/dist/esm/insm-session.js +84 -8
- package/dist/esm/insm.js +49 -9
- package/dist/esm/session-measurers/LongAnimationFrameMeasurer.js +161 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/insm-period.d.ts +21 -2
- package/dist/types/insm-session.d.ts +13 -2
- package/dist/types/insm.d.ts +18 -4
- package/dist/types/session-measurers/LongAnimationFrameMeasurer.d.ts +63 -0
- package/dist/types/types.d.ts +25 -25
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/insm-period.d.ts +21 -2
- package/dist/types-ts4.5/insm-session.d.ts +13 -2
- package/dist/types-ts4.5/insm.d.ts +18 -4
- package/dist/types-ts4.5/session-measurers/LongAnimationFrameMeasurer.d.ts +63 -0
- package/dist/types-ts4.5/types.d.ts +25 -25
- package/package.json +11 -5
|
@@ -22,6 +22,9 @@ export declare class INSM {
|
|
|
22
22
|
* Starts a heavy task in the currently running session.
|
|
23
23
|
*
|
|
24
24
|
* This also pauses measurement.
|
|
25
|
+
*
|
|
26
|
+
* For PageLoads using the key 'PageLoad' will mean the heavy task duration
|
|
27
|
+
* is added to the insm session event as pageLoadTime.
|
|
25
28
|
*/
|
|
26
29
|
startHeavyTask(heavyTaskName: string): void;
|
|
27
30
|
/**
|
|
@@ -32,18 +35,29 @@ export declare class INSM {
|
|
|
32
35
|
* Call this when starting a new experience. This is expected to be wired to the product
|
|
33
36
|
* routing solution.
|
|
34
37
|
*
|
|
35
|
-
* It's expected this call will be paired with a `insm.session.startHeavyTask('
|
|
36
|
-
* so that performance degradations linked
|
|
38
|
+
* It's expected this call will be paired with a `insm.session.startHeavyTask('PageLoad')` and
|
|
39
|
+
* subsequent `insm.session.endHeavyTask('PageLoad')` so that performance degradations linked
|
|
40
|
+
* to the page initialisation are excluded from the active interactivity monitoring.
|
|
41
|
+
*
|
|
42
|
+
* Using the key 'PageLoad' is special and will result in the heavy task duration being added to the
|
|
43
|
+
* insm session event as pageLoadTime.
|
|
37
44
|
*
|
|
38
45
|
*
|
|
39
46
|
* ```ts
|
|
40
47
|
* insm.start('edit-page', { initial: true, contentId: '9001' })
|
|
41
|
-
* insm.session.startHeavyTask(''
|
|
48
|
+
* insm.session.startHeavyTask('PageLoad')
|
|
42
49
|
* // ... heavy initialisation work
|
|
43
|
-
* insm.session.endHeavyTask(''
|
|
50
|
+
* insm.session.endHeavyTask('PageLoad')
|
|
44
51
|
* ```
|
|
45
52
|
*/
|
|
46
53
|
start(experienceKey: string, experienceProperties: ExperienceProperties): void;
|
|
54
|
+
private lastStartedExperienceProperties;
|
|
55
|
+
/**
|
|
56
|
+
* Call this to update the name of the running session after it's started
|
|
57
|
+
* In the case it's been started with an unregistered name, and there is not running
|
|
58
|
+
* session. This will also trigger the session being started.
|
|
59
|
+
*/
|
|
60
|
+
overrideExperienceKey(experienceKey: string): void;
|
|
47
61
|
/**
|
|
48
62
|
* This prematurely halts any running experience measurement. It's expected to be used in
|
|
49
63
|
* scenarios such as when error boundaries are hit.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { INSMSession } from '../insm-session';
|
|
2
|
+
type LongAnimationFrameMeasurerOptions = {
|
|
3
|
+
initial: boolean;
|
|
4
|
+
insmSession: INSMSession;
|
|
5
|
+
limit: number;
|
|
6
|
+
reportingThreshold: number;
|
|
7
|
+
};
|
|
8
|
+
interface TrackedScriptTiming {
|
|
9
|
+
afDuration: number;
|
|
10
|
+
duration: number;
|
|
11
|
+
features: string[];
|
|
12
|
+
forcedStyleAndLayoutDuration: number;
|
|
13
|
+
invoker: string;
|
|
14
|
+
invokerType: string;
|
|
15
|
+
sourceCharPosition: number;
|
|
16
|
+
sourceFunctionName: string;
|
|
17
|
+
sourceURL: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class LongAnimationFrameMeasurer {
|
|
20
|
+
private observer?;
|
|
21
|
+
private longestScriptTimings;
|
|
22
|
+
private options;
|
|
23
|
+
private paused;
|
|
24
|
+
private minimumIndex;
|
|
25
|
+
private minimumDuration;
|
|
26
|
+
constructor(options: LongAnimationFrameMeasurerOptions);
|
|
27
|
+
private handleBatch;
|
|
28
|
+
private createScriptTiming;
|
|
29
|
+
private processScript;
|
|
30
|
+
/**
|
|
31
|
+
* Pauses tracking
|
|
32
|
+
*/
|
|
33
|
+
pause(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Resumes tracking
|
|
36
|
+
*/
|
|
37
|
+
resume(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the current tracked longest script timings sorted by duration
|
|
40
|
+
*/
|
|
41
|
+
get current(): TrackedScriptTiming[];
|
|
42
|
+
/**
|
|
43
|
+
* Cleans up the performance tracking (tracking cannot be resumed following this).
|
|
44
|
+
*/
|
|
45
|
+
cleanup(): void;
|
|
46
|
+
}
|
|
47
|
+
export interface _PerformanceScriptTiming extends PerformanceEntry {
|
|
48
|
+
readonly duration: DOMHighResTimeStamp;
|
|
49
|
+
readonly entryType: string;
|
|
50
|
+
readonly executionStart: DOMHighResTimeStamp;
|
|
51
|
+
readonly forcedStyleAndLayoutDuration: DOMHighResTimeStamp;
|
|
52
|
+
readonly invoker: string;
|
|
53
|
+
readonly invokerType: 'classic-script' | 'module-script' | 'event-listener' | 'user-callback' | 'resolve-promise' | 'reject-promise';
|
|
54
|
+
readonly name: string;
|
|
55
|
+
readonly pauseDuration: DOMHighResTimeStamp;
|
|
56
|
+
readonly sourceCharPosition: number;
|
|
57
|
+
readonly sourceFunctionName: string;
|
|
58
|
+
readonly sourceURL: string;
|
|
59
|
+
readonly startTime: DOMHighResTimeStamp;
|
|
60
|
+
readonly window?: Window;
|
|
61
|
+
readonly windowAttribution: 'self' | 'descendant' | 'ancestor' | 'same-page' | 'other';
|
|
62
|
+
}
|
|
63
|
+
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
|
|
2
2
|
export type INSMOptions = {
|
|
3
|
-
getAnalyticsWebClient: Promise<AnalyticsWebClient>;
|
|
4
3
|
/**
|
|
5
4
|
* If an experience is missing or not enabled - no session event will be fired
|
|
6
5
|
*/
|
|
@@ -9,12 +8,9 @@ export type INSMOptions = {
|
|
|
9
8
|
enabled: boolean;
|
|
10
9
|
} | undefined;
|
|
11
10
|
};
|
|
11
|
+
getAnalyticsWebClient: Promise<AnalyticsWebClient>;
|
|
12
12
|
};
|
|
13
13
|
export type ExperienceProperties = {
|
|
14
|
-
/**
|
|
15
|
-
* Whether this represents the initial page the user is visiting
|
|
16
|
-
*/
|
|
17
|
-
initial: boolean;
|
|
18
14
|
/**
|
|
19
15
|
* An optional content id (ie. for a Confluence page - the page id)
|
|
20
16
|
*
|
|
@@ -22,24 +18,44 @@ export type ExperienceProperties = {
|
|
|
22
18
|
* not expected to provide this property.
|
|
23
19
|
*/
|
|
24
20
|
contentId?: string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Whether this represents the initial page the user is visiting
|
|
23
|
+
*/
|
|
24
|
+
initial: boolean;
|
|
25
25
|
};
|
|
26
26
|
export type AddedProperties = {
|
|
27
|
-
[key: string]: string | number | boolean;
|
|
27
|
+
[key: string]: string | number | boolean | undefined;
|
|
28
28
|
} | (() => {
|
|
29
|
-
[key: string]: string | number | boolean;
|
|
29
|
+
[key: string]: string | number | boolean | undefined;
|
|
30
30
|
});
|
|
31
31
|
export type Measure = {
|
|
32
|
-
|
|
32
|
+
average: number;
|
|
33
33
|
denominator: number;
|
|
34
34
|
max: number;
|
|
35
35
|
min: number;
|
|
36
|
-
|
|
36
|
+
numerator: number;
|
|
37
37
|
};
|
|
38
38
|
export interface PeriodMeasurer {
|
|
39
|
+
/**
|
|
40
|
+
* Run any cleanup, and report the last periods interactivity.
|
|
41
|
+
*
|
|
42
|
+
* Important note: A new period can start after the end has been reached
|
|
43
|
+
* in cases where the measurement was ended due to a scenario such as an
|
|
44
|
+
* error boundary being hit (via `insm.stopEarly`).
|
|
45
|
+
*/
|
|
46
|
+
end: () => Measure;
|
|
39
47
|
/**
|
|
40
48
|
* Name of the interactivity measurement (measures in the resulting insm event will be under this key)
|
|
41
49
|
*/
|
|
42
50
|
name: string;
|
|
51
|
+
/**
|
|
52
|
+
* Pauses measurement (ie. when heavy work is triggered)
|
|
53
|
+
*/
|
|
54
|
+
pause: () => void;
|
|
55
|
+
/**
|
|
56
|
+
* Pauses measurement (ie. when heavy work completes)
|
|
57
|
+
*/
|
|
58
|
+
resume: () => void;
|
|
43
59
|
/**
|
|
44
60
|
* Called when an the state changes, and/or a new experience session starts.
|
|
45
61
|
*
|
|
@@ -62,20 +78,4 @@ export interface PeriodMeasurer {
|
|
|
62
78
|
* When started with paused = true. it indicates a heavy task is running at startup time.
|
|
63
79
|
*/
|
|
64
80
|
paused: boolean) => Measure | undefined;
|
|
65
|
-
/**
|
|
66
|
-
* Run any cleanup, and report the last periods interactivity.
|
|
67
|
-
*
|
|
68
|
-
* Important note: A new period can start after the end has been reached
|
|
69
|
-
* in cases where the measurement was ended due to a scenario such as an
|
|
70
|
-
* error boundary being hit (via `insm.stopEarly`).
|
|
71
|
-
*/
|
|
72
|
-
end: () => Measure;
|
|
73
|
-
/**
|
|
74
|
-
* Pauses measurement (ie. when heavy work is triggered)
|
|
75
|
-
*/
|
|
76
|
-
pause: () => void;
|
|
77
|
-
/**
|
|
78
|
-
* Pauses measurement (ie. when heavy work completes)
|
|
79
|
-
*/
|
|
80
|
-
resume: () => void;
|
|
81
81
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/insm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "INSM tooling measures user-perceived interactivity of a page",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -25,12 +25,18 @@
|
|
|
25
25
|
},
|
|
26
26
|
"atlaskit:src": "src/index.ts",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@atlaskit/analytics-listeners": "^9.
|
|
29
|
-
"@atlaskit/
|
|
30
|
-
"@
|
|
28
|
+
"@atlaskit/analytics-listeners": "^9.1.0",
|
|
29
|
+
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
30
|
+
"@atlaskit/tmp-editor-statsig": "^13.23.0",
|
|
31
|
+
"@babel/runtime": "^7.0.0",
|
|
32
|
+
"bowser-ultralight": "^1.0.6"
|
|
31
33
|
},
|
|
32
34
|
"peerDependencies": {
|
|
33
35
|
"react": "^18.2.0"
|
|
34
36
|
},
|
|
35
|
-
"platform-feature-flags": {
|
|
37
|
+
"platform-feature-flags": {
|
|
38
|
+
"cc_editor_insm_fix_attributes": {
|
|
39
|
+
"type": "boolean"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
36
42
|
}
|