@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.
@@ -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: "performance",
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 a performance mark
95
- * @param markName name of the performance mark
96
- * @param markOptions
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
- perfMarkStart = (markName, markOptions) => {
100
- if (!markName) throw new Error("markName is required");
101
- const startMark = performance.mark(markName, markOptions);
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 a performance mark
106
- * @param startMarkNameorMark start mark name or start PerformanceMeasure object
107
- * @returns a promise that resolves when the mark is ended
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 startMark = await analytics.perfMarkStart('LongTask');
117
+ * const longTaskMeasurement = await analytics.startTiming('LongTask', { appId: 'myApp', appUrl: 'https://myapp.com' });
111
118
  * // do some work
112
- * await analytics.perfMarkEnd(startMark);
119
+ * await analytics.endTiming(longTaskMeasurement, { appId: 'myApp', appUrl: 'https://myapp.com' });
113
120
  * ```
114
121
  * ```typescript
115
- * await analytics.perfMarkStart('LongTask');
122
+ * const longTaskMeasurement = await analytics.startTiming('LongTask', { appId: 'myApp', appUrl: 'https://myapp.com' });
116
123
  * // do some work
117
- * await analytics.perfMarkEnd('LongTask');
124
+ * await analytics.endTiming('LongTask', { appId: 'loanApp', appUrl: 'https://loanApp.com' });
118
125
  * ```
119
126
  */
120
- perfMarkEnd = (startMarkNameorMark) => {
121
- if (!startMarkNameorMark)
122
- throw new Error("startMarkNameorMark is required");
123
- const markName = startMarkNameorMark.name ?? startMarkNameorMark;
124
- if (performance.getEntriesByName(markName, "mark").length) {
125
- if (typeof startMarkNameorMark === "string")
126
- performance.measure(markName, markName);
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(markName, {
129
- start: startMarkNameorMark.startTime
149
+ performance.measure(measurementName, {
150
+ detail,
151
+ start: start.startTime
130
152
  });
131
- performance.clearMarks(markName);
153
+ performance.clearMarks(measurementName);
132
154
  } else {
133
- performance.measure(markName);
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: "performance",
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 a performance mark
62
- * @param markName name of the performance mark
63
- * @param markOptions
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
- perfMarkStart = (markName, markOptions) => {
67
- if (!markName) throw new Error("markName is required");
68
- const startMark = performance.mark(markName, markOptions);
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 a performance mark
73
- * @param startMarkNameorMark start mark name or start PerformanceMeasure object
74
- * @returns a promise that resolves when the mark is ended
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 startMark = await analytics.perfMarkStart('LongTask');
84
+ * const longTaskMeasurement = await analytics.startTiming('LongTask', { appId: 'myApp', appUrl: 'https://myapp.com' });
78
85
  * // do some work
79
- * await analytics.perfMarkEnd(startMark);
86
+ * await analytics.endTiming(longTaskMeasurement, { appId: 'myApp', appUrl: 'https://myapp.com' });
80
87
  * ```
81
88
  * ```typescript
82
- * await analytics.perfMarkStart('LongTask');
89
+ * const longTaskMeasurement = await analytics.startTiming('LongTask', { appId: 'myApp', appUrl: 'https://myapp.com' });
83
90
  * // do some work
84
- * await analytics.perfMarkEnd('LongTask');
91
+ * await analytics.endTiming('LongTask', { appId: 'loanApp', appUrl: 'https://loanApp.com' });
85
92
  * ```
86
93
  */
87
- perfMarkEnd = (startMarkNameorMark) => {
88
- if (!startMarkNameorMark)
89
- throw new Error("startMarkNameorMark is required");
90
- const markName = startMarkNameorMark.name ?? startMarkNameorMark;
91
- if (performance.getEntriesByName(markName, "mark").length) {
92
- if (typeof startMarkNameorMark === "string")
93
- performance.measure(markName, markName);
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(markName, {
96
- start: startMarkNameorMark.startTime
116
+ performance.measure(measurementName, {
117
+ detail,
118
+ start: start.startTime
97
119
  });
98
- performance.clearMarks(markName);
120
+ performance.clearMarks(measurementName);
99
121
  } else {
100
- performance.measure(markName);
122
+ performance.measure(measurementName, { detail });
101
123
  }
102
124
  return Promise.resolve();
103
125
  };
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@docusaurus/types").Config;
2
+ export default _default;
@@ -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 a performance mark
22
- * @param markName name of the performance mark
23
- * @param markOptions
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
- perfMarkStart: (markName: string, markOptions?: PerformanceMarkOptions) => Promise<PerformanceMark>;
26
+ startTiming: (name: string, options: TimingOptions) => Promise<PerformanceMark>;
27
27
  /**
28
- * end a performance mark
29
- * @param startMarkNameorMark start mark name or start PerformanceMeasure object
30
- * @returns a promise that resolves when the mark is ended
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 startMark = await analytics.perfMarkStart('LongTask');
34
+ * const longTaskMeasurement = await analytics.startTiming('LongTask', { appId: 'myApp', appUrl: 'https://myapp.com' });
34
35
  * // do some work
35
- * await analytics.perfMarkEnd(startMark);
36
+ * await analytics.endTiming(longTaskMeasurement, { appId: 'myApp', appUrl: 'https://myapp.com' });
36
37
  * ```
37
38
  * ```typescript
38
- * await analytics.perfMarkStart('LongTask');
39
+ * const longTaskMeasurement = await analytics.startTiming('LongTask', { appId: 'myApp', appUrl: 'https://myapp.com' });
39
40
  * // do some work
40
- * await analytics.perfMarkEnd('LongTask');
41
+ * await analytics.endTiming('LongTask', { appId: 'loanApp', appUrl: 'https://loanApp.com' });
41
42
  * ```
42
43
  */
43
- perfMarkEnd: (startMarkNameorMark: string | PerformanceMeasure) => Promise<void>;
44
+ endTiming: (start: string | PerformanceMeasure, options: TimingOptions) => Promise<void>;
44
45
  }