@elliemae/pui-app-sdk 5.12.0 → 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 +40 -26
- package/dist/esm/utils/micro-frontend/scripting-objects/analytics.js +40 -26
- package/dist/types/lib/utils/micro-frontend/scripting-objects/analytics.d.ts +14 -14
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
|
@@ -64,6 +64,7 @@ class Analytics extends import_em_ssf_host.default.ScriptingObject {
|
|
|
64
64
|
startTime: new Date(
|
|
65
65
|
performance.timeOrigin + entry.startTime
|
|
66
66
|
).toISOString(),
|
|
67
|
+
...(0, import_web_analytics.getBAEventParameters)(),
|
|
67
68
|
...detail
|
|
68
69
|
}).catch(() => {
|
|
69
70
|
});
|
|
@@ -94,51 +95,64 @@ class Analytics extends import_em_ssf_host.default.ScriptingObject {
|
|
|
94
95
|
return Promise.resolve();
|
|
95
96
|
};
|
|
96
97
|
/**
|
|
97
|
-
* start
|
|
98
|
-
* @param
|
|
99
|
-
* @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
|
|
100
101
|
* @returns a promise that resolves to a PerformanceMeasure object
|
|
101
102
|
*/
|
|
102
|
-
|
|
103
|
-
if (!
|
|
104
|
-
|
|
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 });
|
|
105
108
|
return Promise.resolve(startMark);
|
|
106
109
|
};
|
|
107
110
|
/**
|
|
108
|
-
* end
|
|
109
|
-
* @param
|
|
110
|
-
* @param
|
|
111
|
-
* @returns a promise that resolves when the
|
|
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
|
|
112
115
|
* @example
|
|
113
116
|
* ```typescript
|
|
114
|
-
* const
|
|
117
|
+
* const longTaskMeasurement = await analytics.startTiming('LongTask', { appId: 'myApp', appUrl: 'https://myapp.com' });
|
|
115
118
|
* // do some work
|
|
116
|
-
* await analytics.
|
|
119
|
+
* await analytics.endTiming(longTaskMeasurement, { appId: 'myApp', appUrl: 'https://myapp.com' });
|
|
117
120
|
* ```
|
|
118
121
|
* ```typescript
|
|
119
|
-
* await analytics.
|
|
122
|
+
* const longTaskMeasurement = await analytics.startTiming('LongTask', { appId: 'myApp', appUrl: 'https://myapp.com' });
|
|
120
123
|
* // do some work
|
|
121
|
-
* await analytics.
|
|
124
|
+
* await analytics.endTiming('LongTask', { appId: 'loanApp', appUrl: 'https://loanApp.com' });
|
|
122
125
|
* ```
|
|
123
126
|
*/
|
|
124
|
-
|
|
125
|
-
if (!
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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, {
|
|
131
145
|
detail,
|
|
132
|
-
start:
|
|
146
|
+
start: measurementName
|
|
133
147
|
});
|
|
134
148
|
else
|
|
135
|
-
performance.measure(
|
|
149
|
+
performance.measure(measurementName, {
|
|
136
150
|
detail,
|
|
137
|
-
start:
|
|
151
|
+
start: start.startTime
|
|
138
152
|
});
|
|
139
|
-
performance.clearMarks(
|
|
153
|
+
performance.clearMarks(measurementName);
|
|
140
154
|
} else {
|
|
141
|
-
performance.measure(
|
|
155
|
+
performance.measure(measurementName, { detail });
|
|
142
156
|
}
|
|
143
157
|
return Promise.resolve();
|
|
144
158
|
};
|
|
@@ -31,6 +31,7 @@ class Analytics extends ssfHost.ScriptingObject {
|
|
|
31
31
|
startTime: new Date(
|
|
32
32
|
performance.timeOrigin + entry.startTime
|
|
33
33
|
).toISOString(),
|
|
34
|
+
...getBAEventParameters(),
|
|
34
35
|
...detail
|
|
35
36
|
}).catch(() => {
|
|
36
37
|
});
|
|
@@ -61,51 +62,64 @@ class Analytics extends ssfHost.ScriptingObject {
|
|
|
61
62
|
return Promise.resolve();
|
|
62
63
|
};
|
|
63
64
|
/**
|
|
64
|
-
* start
|
|
65
|
-
* @param
|
|
66
|
-
* @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
|
|
67
68
|
* @returns a promise that resolves to a PerformanceMeasure object
|
|
68
69
|
*/
|
|
69
|
-
|
|
70
|
-
if (!
|
|
71
|
-
|
|
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 });
|
|
72
75
|
return Promise.resolve(startMark);
|
|
73
76
|
};
|
|
74
77
|
/**
|
|
75
|
-
* end
|
|
76
|
-
* @param
|
|
77
|
-
* @param
|
|
78
|
-
* @returns a promise that resolves when the
|
|
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
|
|
79
82
|
* @example
|
|
80
83
|
* ```typescript
|
|
81
|
-
* const
|
|
84
|
+
* const longTaskMeasurement = await analytics.startTiming('LongTask', { appId: 'myApp', appUrl: 'https://myapp.com' });
|
|
82
85
|
* // do some work
|
|
83
|
-
* await analytics.
|
|
86
|
+
* await analytics.endTiming(longTaskMeasurement, { appId: 'myApp', appUrl: 'https://myapp.com' });
|
|
84
87
|
* ```
|
|
85
88
|
* ```typescript
|
|
86
|
-
* await analytics.
|
|
89
|
+
* const longTaskMeasurement = await analytics.startTiming('LongTask', { appId: 'myApp', appUrl: 'https://myapp.com' });
|
|
87
90
|
* // do some work
|
|
88
|
-
* await analytics.
|
|
91
|
+
* await analytics.endTiming('LongTask', { appId: 'loanApp', appUrl: 'https://loanApp.com' });
|
|
89
92
|
* ```
|
|
90
93
|
*/
|
|
91
|
-
|
|
92
|
-
if (!
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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, {
|
|
98
112
|
detail,
|
|
99
|
-
start:
|
|
113
|
+
start: measurementName
|
|
100
114
|
});
|
|
101
115
|
else
|
|
102
|
-
performance.measure(
|
|
116
|
+
performance.measure(measurementName, {
|
|
103
117
|
detail,
|
|
104
|
-
start:
|
|
118
|
+
start: start.startTime
|
|
105
119
|
});
|
|
106
|
-
performance.clearMarks(
|
|
120
|
+
performance.clearMarks(measurementName);
|
|
107
121
|
} else {
|
|
108
|
-
performance.measure(
|
|
122
|
+
performance.measure(measurementName, { detail });
|
|
109
123
|
}
|
|
110
124
|
return Promise.resolve();
|
|
111
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,28 +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
|
-
* @param
|
|
31
|
-
* @returns a promise that resolves when the
|
|
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
|
|
32
32
|
* @example
|
|
33
33
|
* ```typescript
|
|
34
|
-
* const
|
|
34
|
+
* const longTaskMeasurement = await analytics.startTiming('LongTask', { appId: 'myApp', appUrl: 'https://myapp.com' });
|
|
35
35
|
* // do some work
|
|
36
|
-
* await analytics.
|
|
36
|
+
* await analytics.endTiming(longTaskMeasurement, { appId: 'myApp', appUrl: 'https://myapp.com' });
|
|
37
37
|
* ```
|
|
38
38
|
* ```typescript
|
|
39
|
-
* await analytics.
|
|
39
|
+
* const longTaskMeasurement = await analytics.startTiming('LongTask', { appId: 'myApp', appUrl: 'https://myapp.com' });
|
|
40
40
|
* // do some work
|
|
41
|
-
* await analytics.
|
|
41
|
+
* await analytics.endTiming('LongTask', { appId: 'loanApp', appUrl: 'https://loanApp.com' });
|
|
42
42
|
* ```
|
|
43
43
|
*/
|
|
44
|
-
|
|
44
|
+
endTiming: (start: string | PerformanceMeasure, options: TimingOptions) => Promise<void>;
|
|
45
45
|
}
|