@elliemae/pui-app-sdk 5.11.4 → 5.13.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/dist/cjs/utils/micro-frontend/scripting-objects/analytics.js +49 -27
- package/dist/esm/utils/micro-frontend/scripting-objects/analytics.js +49 -27
- package/dist/types/docusaurus.config.d.ts +2 -0
- package/dist/types/lib/utils/micro-frontend/scripting-objects/analytics.d.ts +14 -13
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -11
|
@@ -55,17 +55,21 @@ class Analytics extends import_em_ssf_host.default.ScriptingObject {
|
|
|
55
55
|
const po = new PerformanceObserver((list) => {
|
|
56
56
|
for (const entry of list.getEntries()) {
|
|
57
57
|
switch (entry.entryType) {
|
|
58
|
-
case "measure":
|
|
58
|
+
case "measure": {
|
|
59
|
+
const detail = entry.detail ?? {};
|
|
59
60
|
this.sendBAEvent({
|
|
60
|
-
event: "
|
|
61
|
+
event: "timing",
|
|
61
62
|
name: entry.name,
|
|
62
63
|
duration: entry.duration.toString(),
|
|
63
64
|
startTime: new Date(
|
|
64
65
|
performance.timeOrigin + entry.startTime
|
|
65
|
-
).toISOString()
|
|
66
|
+
).toISOString(),
|
|
67
|
+
...(0, import_web_analytics.getBAEventParameters)(),
|
|
68
|
+
...detail
|
|
66
69
|
}).catch(() => {
|
|
67
70
|
});
|
|
68
71
|
break;
|
|
72
|
+
}
|
|
69
73
|
default:
|
|
70
74
|
break;
|
|
71
75
|
}
|
|
@@ -91,46 +95,64 @@ class Analytics extends import_em_ssf_host.default.ScriptingObject {
|
|
|
91
95
|
return Promise.resolve();
|
|
92
96
|
};
|
|
93
97
|
/**
|
|
94
|
-
* start
|
|
95
|
-
* @param
|
|
96
|
-
* @param
|
|
98
|
+
* start timing measure
|
|
99
|
+
* @param name unique name for the timing measurement. If a measurement with the same name is already running, it will be replaced
|
|
100
|
+
* @param options additional details related to the measurement
|
|
97
101
|
* @returns a promise that resolves to a PerformanceMeasure object
|
|
98
102
|
*/
|
|
99
|
-
|
|
100
|
-
if (!
|
|
101
|
-
|
|
103
|
+
startTiming = (name, options) => {
|
|
104
|
+
if (!name) throw new Error("parameter mark is required");
|
|
105
|
+
if (!options || !options?.appId || !options?.appUrl)
|
|
106
|
+
throw new Error("parameter options is required");
|
|
107
|
+
const startMark = performance.mark(name, { detail: options });
|
|
102
108
|
return Promise.resolve(startMark);
|
|
103
109
|
};
|
|
104
110
|
/**
|
|
105
|
-
* end
|
|
106
|
-
* @param
|
|
107
|
-
* @
|
|
111
|
+
* end timing measure
|
|
112
|
+
* @param start name used to start timing measure or return value of the startTiming method
|
|
113
|
+
* @param options additional details related to the measurement
|
|
114
|
+
* @returns a promise that resolves when the timing measurement is ended
|
|
108
115
|
* @example
|
|
109
116
|
* ```typescript
|
|
110
|
-
* const
|
|
117
|
+
* const longTaskMeasurement = await analytics.startTiming('LongTask', { appId: 'myApp', appUrl: 'https://myapp.com' });
|
|
111
118
|
* // do some work
|
|
112
|
-
* await analytics.
|
|
119
|
+
* await analytics.endTiming(longTaskMeasurement, { appId: 'myApp', appUrl: 'https://myapp.com' });
|
|
113
120
|
* ```
|
|
114
121
|
* ```typescript
|
|
115
|
-
* await analytics.
|
|
122
|
+
* const longTaskMeasurement = await analytics.startTiming('LongTask', { appId: 'myApp', appUrl: 'https://myapp.com' });
|
|
116
123
|
* // do some work
|
|
117
|
-
* await analytics.
|
|
124
|
+
* await analytics.endTiming('LongTask', { appId: 'loanApp', appUrl: 'https://loanApp.com' });
|
|
118
125
|
* ```
|
|
119
126
|
*/
|
|
120
|
-
|
|
121
|
-
if (!
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
+
endTiming = (start, options) => {
|
|
128
|
+
if (!start) throw new Error("parameter start is required");
|
|
129
|
+
if (!options || !options?.appId || !options?.appUrl)
|
|
130
|
+
throw new Error("parameter options is required");
|
|
131
|
+
const measurementName = start.name ?? start;
|
|
132
|
+
const startMark = performance.getEntriesByName(
|
|
133
|
+
measurementName,
|
|
134
|
+
"mark"
|
|
135
|
+
)?.[0];
|
|
136
|
+
const detail = {
|
|
137
|
+
startAppId: startMark?.detail?.appId ?? options.appId,
|
|
138
|
+
startAppUrl: startMark?.detail?.appUrl ?? options.appUrl,
|
|
139
|
+
endAppId: options.appId,
|
|
140
|
+
endAppUrl: options.appUrl
|
|
141
|
+
};
|
|
142
|
+
if (startMark) {
|
|
143
|
+
if (typeof start === "string")
|
|
144
|
+
performance.measure(measurementName, {
|
|
145
|
+
detail,
|
|
146
|
+
start: measurementName
|
|
147
|
+
});
|
|
127
148
|
else
|
|
128
|
-
performance.measure(
|
|
129
|
-
|
|
149
|
+
performance.measure(measurementName, {
|
|
150
|
+
detail,
|
|
151
|
+
start: start.startTime
|
|
130
152
|
});
|
|
131
|
-
performance.clearMarks(
|
|
153
|
+
performance.clearMarks(measurementName);
|
|
132
154
|
} else {
|
|
133
|
-
performance.measure(
|
|
155
|
+
performance.measure(measurementName, { detail });
|
|
134
156
|
}
|
|
135
157
|
return Promise.resolve();
|
|
136
158
|
};
|
|
@@ -22,17 +22,21 @@ class Analytics extends ssfHost.ScriptingObject {
|
|
|
22
22
|
const po = new PerformanceObserver((list) => {
|
|
23
23
|
for (const entry of list.getEntries()) {
|
|
24
24
|
switch (entry.entryType) {
|
|
25
|
-
case "measure":
|
|
25
|
+
case "measure": {
|
|
26
|
+
const detail = entry.detail ?? {};
|
|
26
27
|
this.sendBAEvent({
|
|
27
|
-
event: "
|
|
28
|
+
event: "timing",
|
|
28
29
|
name: entry.name,
|
|
29
30
|
duration: entry.duration.toString(),
|
|
30
31
|
startTime: new Date(
|
|
31
32
|
performance.timeOrigin + entry.startTime
|
|
32
|
-
).toISOString()
|
|
33
|
+
).toISOString(),
|
|
34
|
+
...getBAEventParameters(),
|
|
35
|
+
...detail
|
|
33
36
|
}).catch(() => {
|
|
34
37
|
});
|
|
35
38
|
break;
|
|
39
|
+
}
|
|
36
40
|
default:
|
|
37
41
|
break;
|
|
38
42
|
}
|
|
@@ -58,46 +62,64 @@ class Analytics extends ssfHost.ScriptingObject {
|
|
|
58
62
|
return Promise.resolve();
|
|
59
63
|
};
|
|
60
64
|
/**
|
|
61
|
-
* start
|
|
62
|
-
* @param
|
|
63
|
-
* @param
|
|
65
|
+
* start timing measure
|
|
66
|
+
* @param name unique name for the timing measurement. If a measurement with the same name is already running, it will be replaced
|
|
67
|
+
* @param options additional details related to the measurement
|
|
64
68
|
* @returns a promise that resolves to a PerformanceMeasure object
|
|
65
69
|
*/
|
|
66
|
-
|
|
67
|
-
if (!
|
|
68
|
-
|
|
70
|
+
startTiming = (name, options) => {
|
|
71
|
+
if (!name) throw new Error("parameter mark is required");
|
|
72
|
+
if (!options || !options?.appId || !options?.appUrl)
|
|
73
|
+
throw new Error("parameter options is required");
|
|
74
|
+
const startMark = performance.mark(name, { detail: options });
|
|
69
75
|
return Promise.resolve(startMark);
|
|
70
76
|
};
|
|
71
77
|
/**
|
|
72
|
-
* end
|
|
73
|
-
* @param
|
|
74
|
-
* @
|
|
78
|
+
* end timing measure
|
|
79
|
+
* @param start name used to start timing measure or return value of the startTiming method
|
|
80
|
+
* @param options additional details related to the measurement
|
|
81
|
+
* @returns a promise that resolves when the timing measurement is ended
|
|
75
82
|
* @example
|
|
76
83
|
* ```typescript
|
|
77
|
-
* const
|
|
84
|
+
* const longTaskMeasurement = await analytics.startTiming('LongTask', { appId: 'myApp', appUrl: 'https://myapp.com' });
|
|
78
85
|
* // do some work
|
|
79
|
-
* await analytics.
|
|
86
|
+
* await analytics.endTiming(longTaskMeasurement, { appId: 'myApp', appUrl: 'https://myapp.com' });
|
|
80
87
|
* ```
|
|
81
88
|
* ```typescript
|
|
82
|
-
* await analytics.
|
|
89
|
+
* const longTaskMeasurement = await analytics.startTiming('LongTask', { appId: 'myApp', appUrl: 'https://myapp.com' });
|
|
83
90
|
* // do some work
|
|
84
|
-
* await analytics.
|
|
91
|
+
* await analytics.endTiming('LongTask', { appId: 'loanApp', appUrl: 'https://loanApp.com' });
|
|
85
92
|
* ```
|
|
86
93
|
*/
|
|
87
|
-
|
|
88
|
-
if (!
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
+
endTiming = (start, options) => {
|
|
95
|
+
if (!start) throw new Error("parameter start is required");
|
|
96
|
+
if (!options || !options?.appId || !options?.appUrl)
|
|
97
|
+
throw new Error("parameter options is required");
|
|
98
|
+
const measurementName = start.name ?? start;
|
|
99
|
+
const startMark = performance.getEntriesByName(
|
|
100
|
+
measurementName,
|
|
101
|
+
"mark"
|
|
102
|
+
)?.[0];
|
|
103
|
+
const detail = {
|
|
104
|
+
startAppId: startMark?.detail?.appId ?? options.appId,
|
|
105
|
+
startAppUrl: startMark?.detail?.appUrl ?? options.appUrl,
|
|
106
|
+
endAppId: options.appId,
|
|
107
|
+
endAppUrl: options.appUrl
|
|
108
|
+
};
|
|
109
|
+
if (startMark) {
|
|
110
|
+
if (typeof start === "string")
|
|
111
|
+
performance.measure(measurementName, {
|
|
112
|
+
detail,
|
|
113
|
+
start: measurementName
|
|
114
|
+
});
|
|
94
115
|
else
|
|
95
|
-
performance.measure(
|
|
96
|
-
|
|
116
|
+
performance.measure(measurementName, {
|
|
117
|
+
detail,
|
|
118
|
+
start: start.startTime
|
|
97
119
|
});
|
|
98
|
-
performance.clearMarks(
|
|
120
|
+
performance.clearMarks(measurementName);
|
|
99
121
|
} else {
|
|
100
|
-
performance.measure(
|
|
122
|
+
performance.measure(measurementName, { detail });
|
|
101
123
|
}
|
|
102
124
|
return Promise.resolve();
|
|
103
125
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ssfHost from '@elliemae/em-ssf-host';
|
|
2
|
-
import { IAnalytics, BAEvent } from '@elliemae/pui-scripting-object';
|
|
2
|
+
import { IAnalytics, BAEvent, TimingOptions } from '@elliemae/pui-scripting-object';
|
|
3
3
|
import { MicroFrontEndLogger } from '../../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Analytics scripting object
|
|
@@ -18,27 +18,28 @@ export declare class Analytics extends ssfHost.ScriptingObject implements IAnaly
|
|
|
18
18
|
*/
|
|
19
19
|
sendBAEvent: (event: BAEvent) => Promise<void>;
|
|
20
20
|
/**
|
|
21
|
-
* start
|
|
22
|
-
* @param
|
|
23
|
-
* @param
|
|
21
|
+
* start timing measure
|
|
22
|
+
* @param name unique name for the timing measurement. If a measurement with the same name is already running, it will be replaced
|
|
23
|
+
* @param options additional details related to the measurement
|
|
24
24
|
* @returns a promise that resolves to a PerformanceMeasure object
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
startTiming: (name: string, options: TimingOptions) => Promise<PerformanceMark>;
|
|
27
27
|
/**
|
|
28
|
-
* end
|
|
29
|
-
* @param
|
|
30
|
-
* @
|
|
28
|
+
* end timing measure
|
|
29
|
+
* @param start name used to start timing measure or return value of the startTiming method
|
|
30
|
+
* @param options additional details related to the measurement
|
|
31
|
+
* @returns a promise that resolves when the timing measurement is ended
|
|
31
32
|
* @example
|
|
32
33
|
* ```typescript
|
|
33
|
-
* const
|
|
34
|
+
* const longTaskMeasurement = await analytics.startTiming('LongTask', { appId: 'myApp', appUrl: 'https://myapp.com' });
|
|
34
35
|
* // do some work
|
|
35
|
-
* await analytics.
|
|
36
|
+
* await analytics.endTiming(longTaskMeasurement, { appId: 'myApp', appUrl: 'https://myapp.com' });
|
|
36
37
|
* ```
|
|
37
38
|
* ```typescript
|
|
38
|
-
* await analytics.
|
|
39
|
+
* const longTaskMeasurement = await analytics.startTiming('LongTask', { appId: 'myApp', appUrl: 'https://myapp.com' });
|
|
39
40
|
* // do some work
|
|
40
|
-
* await analytics.
|
|
41
|
+
* await analytics.endTiming('LongTask', { appId: 'loanApp', appUrl: 'https://loanApp.com' });
|
|
41
42
|
* ```
|
|
42
43
|
*/
|
|
43
|
-
|
|
44
|
+
endTiming: (start: string | PerformanceMeasure, options: TimingOptions) => Promise<void>;
|
|
44
45
|
}
|