@mablhq/mabl-cli 1.58.25 → 1.59.5
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/api/basicApiClient.js +15 -21
- package/api/mablApiClient.js +54 -43
- package/api/mablApiClientFactory.js +1 -1
- package/auth/OktaClient.js +2 -1
- package/browserEngines/chromiumBrowserEngine.js +2 -2
- package/browserEngines/firefoxBrowserEngine.js +2 -2
- package/browserEngines/webkitBrowerEngine.js +2 -2
- package/browserLauncher/browserLauncherFactory.js +3 -2
- package/browserLauncher/elementHandle.js +2 -1
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumElementHandleDelegate.js +20 -12
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumFrameDelegate.js +1 -1
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumPageDelegate.js +10 -7
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxFrameDelegate.js +4 -3
- package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractElementHandleDelegate.js +5 -4
- package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractPageDelegate.js +7 -4
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +1 -1
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +7 -6
- package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +37 -31
- package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +9 -8
- package/browserLauncher/playwrightBrowserLauncher/playwrightHttpRequest.js +8 -4
- package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +5 -3
- package/browserLauncher/playwrightBrowserLauncher/webkit/webkitElementHandleDelegate.js +2 -1
- package/browserLauncher/playwrightBrowserLauncher/webkit/webkitFrameDelegate.js +1 -1
- package/browserTestMonitoring/cloudMonitoringPerformanceMetrics.js +28 -56
- package/browserTestMonitoring/distributions.js +1 -6
- package/browserTestMonitoring/metricsRecorder.js +47 -30
- package/commands/commandUtil/branches.js +3 -2
- package/commands/commandUtil/codeInsights.js +16 -13
- package/commands/commandUtil/fileUtil.js +1 -1
- package/commands/commandUtil/util.js +5 -3
- package/commands/commandUtil/versionUtil.js +5 -4
- package/commands/config/config_cmds/list.js +2 -2
- package/commands/datatables/datatables_cmds/create.js +3 -2
- package/commands/datatables/datatables_cmds/export.js +5 -3
- package/commands/datatables/datatables_cmds/list.js +2 -1
- package/commands/datatables/datatables_cmds/scenarios.js +2 -1
- package/commands/datatables/datatables_cmds/update.js +11 -11
- package/commands/datatables/utils.js +9 -9
- package/commands/deploy/deploy_cmds/awaitDeploymentCompletion.js +8 -6
- package/commands/deploy/deploy_cmds/create.js +13 -11
- package/commands/deploy/deploy_cmds/executionResultPresenter.js +11 -8
- package/commands/deploy/deploy_cmds/list.js +4 -3
- package/commands/deploy/deploy_cmds/watch.js +2 -1
- package/commands/environments/environments_cmds/create.js +2 -1
- package/commands/environments/environments_cmds/delete.js +2 -1
- package/commands/environments/environments_cmds/update.js +2 -1
- package/commands/environments/environments_cmds/urls_cmds/list.js +2 -1
- package/commands/flows/flows_cmds/export.js +5 -4
- package/commands/plans/plans_cmds/describe.js +2 -1
- package/commands/tests/mobileEmulationUtil.js +7 -5
- package/commands/tests/testsUtil.js +46 -42
- package/commands/tests/tests_cmds/export.js +2 -1
- package/commands/tests/tests_cmds/import.js +5 -4
- package/commands/tests/tests_cmds/run-cloud.js +34 -15
- package/commands/tests/tests_cmds/run.js +11 -11
- package/commands/users/users_cmds/list.js +2 -2
- package/commands/workspaces/workspace_cmds/copy.js +2 -1
- package/core/execution/ApiTestUtils.js +94 -82
- package/core/messaging/logLineMessaging.js +3 -2
- package/core/messaging/messaging.js +7 -6
- package/core/trainer/trainingSessions.js +32 -16
- package/coreWebVitals/index.js +18 -14
- package/execution/index.js +1 -1
- package/functions/apiTest/utils.js +5 -4
- package/http/MablHttpAgent.js +6 -4
- package/http/RequestSecurityError.js +1 -1
- package/http/axiosProxyConfig.js +5 -3
- package/http/httpUtil.js +3 -2
- package/http/requestInterceptor.js +15 -11
- package/mablApi/index.js +1 -1
- package/mablscript/MablAction.js +3 -2
- package/mablscript/MablStep.js +4 -2
- package/mablscript/MablSymbol.js +1 -1
- package/mablscript/actions/ConditionAction.js +4 -2
- package/mablscript/actions/FindAction.js +4 -2
- package/mablscript/diffing/diffingUtil.js +7 -8
- package/mablscript/importer.js +2 -1
- package/mablscript/steps/AccessibilityCheck.js +9 -7
- package/mablscript/steps/AssertStep.js +16 -11
- package/mablscript/steps/ClickAndHoldStep.js +2 -1
- package/mablscript/steps/CreateVariableStep.js +2 -1
- package/mablscript/steps/DownloadStep.js +2 -1
- package/mablscript/steps/EnterTextStep.js +2 -1
- package/mablscript/steps/EvaluateFlowStep.js +1 -1
- package/mablscript/steps/IfConditionStep.js +6 -4
- package/mablscript/steps/ReleaseStep.js +2 -1
- package/mablscript/steps/SendHttpRequestStep.js +4 -2
- package/mablscript/steps/SendKeyStep.js +1 -1
- package/mablscript/steps/SetCookieStep.js +8 -7
- package/mablscript/steps/SetViewportStep.js +1 -1
- package/mablscript/steps/SwitchContextStep.js +6 -3
- package/mablscript/steps/SyntheticStep.js +2 -1
- package/middleware.js +2 -1
- package/package.json +3 -3
- package/popupDismissal/index.js +5 -4
- package/providers/authenticationProvider.js +6 -5
- package/providers/cliConfigProvider.js +12 -10
- package/providers/exportRequestProvider.js +5 -3
- package/providers/logging/loggingProvider.js +1 -1
- package/reporters/mochAwesome/mochAwesomeReporter.js +14 -12
- package/util/TestOutputWriter.js +12 -8
- package/util/actionabilityUtil.js +1 -1
- package/util/analytics.js +9 -6
- package/util/browserTestUtils.js +2 -1
- package/util/markdownUtil.js +11 -9
|
@@ -21,10 +21,11 @@ function registerConsoleLoggerForOutput(eventEmitter) {
|
|
|
21
21
|
eventEmitter
|
|
22
22
|
.getOutputEventChannel()
|
|
23
23
|
.on(messaging_1.EventChannelMessageType.outputLogLine, (line, timestamp, color, metadata) => {
|
|
24
|
-
|
|
24
|
+
var _a;
|
|
25
|
+
const stepNumberPrefix = (_a = metadata === null || metadata === void 0 ? void 0 : metadata.stepNumberPrefix) !== null && _a !== void 0 ? _a : '';
|
|
25
26
|
const lineWithPrefix = stepNumberPrefix + line;
|
|
26
27
|
const formatted = color ? chalk_1.default[color](lineWithPrefix) : lineWithPrefix;
|
|
27
|
-
if (metadata
|
|
28
|
+
if ((metadata === null || metadata === void 0 ? void 0 : metadata.shouldOutputInConsole) === false) {
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
30
31
|
if (timestamp) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.createAssertFailureMessage = exports.getDefaultLogMetadataForInfo = exports.MablCoreProcessAction = exports.MablCoreAction = exports.ObservationErrorSeverity = exports.ObservationErrorCode = exports.ExecutionPhase = exports.EventChannelMessageType = exports.getEmitter = exports.mablEventEmitter = exports.MablCoreEventEmitter = void 0;
|
|
4
5
|
const events_1 = require("events");
|
|
@@ -10,7 +11,7 @@ class MablCoreEventEmitter {
|
|
|
10
11
|
this.messageIndex = -1;
|
|
11
12
|
this.outputEventChannel = new events_1.EventEmitter();
|
|
12
13
|
this.inputEventChannel = new events_1.EventEmitter();
|
|
13
|
-
this.debugOutputOn = debug
|
|
14
|
+
this.debugOutputOn = debug !== null && debug !== void 0 ? debug : false;
|
|
14
15
|
}
|
|
15
16
|
getOutputEventChannel() {
|
|
16
17
|
return this.outputEventChannel;
|
|
@@ -32,7 +33,7 @@ class MablCoreEventEmitter {
|
|
|
32
33
|
this.outputEventChannel.emit(EventChannelMessageType.outputLogLine, line, timestamp, color, metadata);
|
|
33
34
|
}
|
|
34
35
|
debug(line, timestamp, color, metadata) {
|
|
35
|
-
const effectiveMetadata = metadata
|
|
36
|
+
const effectiveMetadata = metadata !== null && metadata !== void 0 ? metadata : {
|
|
36
37
|
logLevel: loggingProvider_1.LogLevel.Debug,
|
|
37
38
|
timestamp: Date.now(),
|
|
38
39
|
};
|
|
@@ -43,10 +44,10 @@ class MablCoreEventEmitter {
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
exports.MablCoreEventEmitter = MablCoreEventEmitter;
|
|
46
|
-
global.mablEventEmitter = global.mablEventEmitter
|
|
47
|
+
global.mablEventEmitter = (_a = global.mablEventEmitter) !== null && _a !== void 0 ? _a : new MablCoreEventEmitter();
|
|
47
48
|
exports.mablEventEmitter = global.mablEventEmitter;
|
|
48
49
|
function getEmitter(eventEmitter) {
|
|
49
|
-
return eventEmitter
|
|
50
|
+
return eventEmitter !== null && eventEmitter !== void 0 ? eventEmitter : exports.mablEventEmitter;
|
|
50
51
|
}
|
|
51
52
|
exports.getEmitter = getEmitter;
|
|
52
53
|
var EventChannelMessageType;
|
|
@@ -92,8 +93,8 @@ exports.MablCoreProcessAction = MablCoreProcessAction;
|
|
|
92
93
|
function getDefaultLogMetadataForInfo(testId, testInvariantId) {
|
|
93
94
|
return {
|
|
94
95
|
executionIndex: {
|
|
95
|
-
testId: testId
|
|
96
|
-
testInvariantId: testInvariantId
|
|
96
|
+
testId: testId !== null && testId !== void 0 ? testId : NO_ID_PLACEHOLDER,
|
|
97
|
+
testInvariantId: testInvariantId !== null && testInvariantId !== void 0 ? testInvariantId : NO_ID_PLACEHOLDER,
|
|
97
98
|
},
|
|
98
99
|
executionPhase: ExecutionPhase.BEFORE_TEST,
|
|
99
100
|
logLevel: loggingProvider_1.LogLevel.Info,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.editTest = exports.trainNewTest = exports.ElectronProtocolUrl = exports.SENDER = exports.DEFAULT_WIDTH = exports.DEFAULT_HEIGHT = void 0;
|
|
3
|
+
exports.editTest = exports.getInitialFlows = exports.trainNewTest = exports.ElectronProtocolUrl = exports.SENDER = exports.DEFAULT_WIDTH = exports.DEFAULT_HEIGHT = void 0;
|
|
4
4
|
const branches_1 = require("../../commands/commandUtil/branches");
|
|
5
5
|
const testsUtil_1 = require("../../commands/tests/testsUtil");
|
|
6
6
|
const mablApi_1 = require("../../mablApi");
|
|
@@ -19,8 +19,9 @@ var ElectronProtocolUrl;
|
|
|
19
19
|
ElectronProtocolUrl["TRAIN_NEW_TEST"] = "trainNewTest";
|
|
20
20
|
})(ElectronProtocolUrl = exports.ElectronProtocolUrl || (exports.ElectronProtocolUrl = {}));
|
|
21
21
|
async function trainNewTest(trainingSessionOptions) {
|
|
22
|
+
var _a;
|
|
22
23
|
const apiClient = await (0, util_1.getApiClientFromOptions)(trainingSessionOptions, true);
|
|
23
|
-
const branchName = trainingSessionOptions.branchName
|
|
24
|
+
const branchName = (_a = trainingSessionOptions.branchName) !== null && _a !== void 0 ? _a : constants_1.DefaultBranchName;
|
|
24
25
|
const { authToken, autoBranch, dataTableIds, ...passThroughFields } = trainingSessionOptions;
|
|
25
26
|
const { applicationId, autoLogin, credentialsId, environmentId, height, planId, testDescription, testName, url, width, workspaceId, } = passThroughFields;
|
|
26
27
|
if (branchName !== 'master') {
|
|
@@ -43,6 +44,7 @@ async function trainNewTest(trainingSessionOptions) {
|
|
|
43
44
|
await apiClient.getApplication(applicationId);
|
|
44
45
|
}
|
|
45
46
|
const account = await apiClient.getAccountByWorkspaceId(workspaceId);
|
|
47
|
+
const flows = await getInitialFlows(apiClient, autoLogin, workspaceId);
|
|
46
48
|
(0, testsUtil_1.logTestInfoIfPresent)(`Creating test in desktop app: `, testName);
|
|
47
49
|
(0, testsUtil_1.logTestInfoIfPresent)(`Add auto login flow: `, autoLogin);
|
|
48
50
|
(0, testsUtil_1.logTestInfoIfPresent)(`URL: `, url);
|
|
@@ -53,32 +55,46 @@ async function trainNewTest(trainingSessionOptions) {
|
|
|
53
55
|
(0, testsUtil_1.logTestInfoIfPresent)(`Application ID: `, applicationId);
|
|
54
56
|
(0, testsUtil_1.logTestInfoIfPresent)(`Environment ID: `, environmentId);
|
|
55
57
|
(0, testsUtil_1.logTestInfoIfPresent)(`Credentials ID: `, credentialsId);
|
|
56
|
-
(0, testsUtil_1.logTestInfoIfPresent)(`Datatable ID(s): `, dataTableIds
|
|
58
|
+
(0, testsUtil_1.logTestInfoIfPresent)(`Datatable ID(s): `, dataTableIds === null || dataTableIds === void 0 ? void 0 : dataTableIds.join(', '));
|
|
57
59
|
(0, testsUtil_1.logTestInfoIfPresent)(`Test description: `, testDescription);
|
|
58
60
|
const scriptConfig = {
|
|
59
61
|
...passThroughFields,
|
|
60
62
|
accountId: account.id,
|
|
61
63
|
branchName,
|
|
62
64
|
dataTables: dataTableIds,
|
|
63
|
-
|
|
65
|
+
flows,
|
|
66
|
+
height: height !== null && height !== void 0 ? height : exports.DEFAULT_HEIGHT,
|
|
64
67
|
sender: exports.SENDER,
|
|
65
|
-
width: width
|
|
68
|
+
width: width !== null && width !== void 0 ? width : exports.DEFAULT_WIDTH,
|
|
66
69
|
};
|
|
67
70
|
await (0, openUtils_1.openUrlInDesktopApp)(ElectronProtocolUrl.TRAIN_NEW_TEST, scriptConfig);
|
|
68
71
|
}
|
|
69
72
|
exports.trainNewTest = trainNewTest;
|
|
73
|
+
async function getInitialFlows(apiClient, autoLogin, workspaceId) {
|
|
74
|
+
const initialFlows = [];
|
|
75
|
+
if (autoLogin) {
|
|
76
|
+
const loginFlows = await apiClient.getFlows({
|
|
77
|
+
flow_type: 'login',
|
|
78
|
+
organization_id: workspaceId,
|
|
79
|
+
});
|
|
80
|
+
if (loginFlows === null || loginFlows === void 0 ? void 0 : loginFlows[0]) {
|
|
81
|
+
initialFlows.push(loginFlows[0].id);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return initialFlows;
|
|
85
|
+
}
|
|
86
|
+
exports.getInitialFlows = getInitialFlows;
|
|
70
87
|
async function editTest(trainingSessionOptions) {
|
|
88
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
71
89
|
const apiClient = await (0, util_1.getApiClientFromOptions)(trainingSessionOptions, true);
|
|
72
90
|
let testRunIdConfig = { testId: '', filterHttpRequests: false };
|
|
73
91
|
if (trainingSessionOptions.testRunId) {
|
|
74
92
|
testRunIdConfig = await (0, testsUtil_1.pullDownTestRunConfig)(trainingSessionOptions.testRunId, apiClient);
|
|
75
93
|
}
|
|
76
|
-
const url = trainingSessionOptions.url
|
|
77
|
-
const credentialsId = trainingSessionOptions.credentialsId
|
|
78
|
-
const branchName = trainingSessionOptions.branchName
|
|
79
|
-
|
|
80
|
-
constants_1.DefaultBranchName;
|
|
81
|
-
const environmentId = trainingSessionOptions.environmentId ?? testRunIdConfig.environmentId;
|
|
94
|
+
const url = (_a = trainingSessionOptions.url) !== null && _a !== void 0 ? _a : testRunIdConfig.url;
|
|
95
|
+
const credentialsId = (_b = trainingSessionOptions.credentialsId) !== null && _b !== void 0 ? _b : testRunIdConfig.credentialsId;
|
|
96
|
+
const branchName = (_d = (_c = trainingSessionOptions.branchName) !== null && _c !== void 0 ? _c : testRunIdConfig.branchName) !== null && _d !== void 0 ? _d : constants_1.DefaultBranchName;
|
|
97
|
+
const environmentId = (_e = trainingSessionOptions.environmentId) !== null && _e !== void 0 ? _e : testRunIdConfig.environmentId;
|
|
82
98
|
if (credentialsId) {
|
|
83
99
|
const credential = await apiClient.getCredential(credentialsId);
|
|
84
100
|
if (credential.cloud_only) {
|
|
@@ -86,7 +102,7 @@ async function editTest(trainingSessionOptions) {
|
|
|
86
102
|
process.exit(1);
|
|
87
103
|
}
|
|
88
104
|
}
|
|
89
|
-
const testId = trainingSessionOptions.testId
|
|
105
|
+
const testId = (_f = trainingSessionOptions.testId) !== null && _f !== void 0 ? _f : testRunIdConfig.testId;
|
|
90
106
|
if (!testId) {
|
|
91
107
|
throw new Error('Unable to determine test Id run');
|
|
92
108
|
}
|
|
@@ -94,7 +110,7 @@ async function editTest(trainingSessionOptions) {
|
|
|
94
110
|
if (test.default) {
|
|
95
111
|
throw new Error('Editing of the mabl default supplied tests is not supported');
|
|
96
112
|
}
|
|
97
|
-
if (!test.flows
|
|
113
|
+
if (!((_g = test.flows) === null || _g === void 0 ? void 0 : _g.length) && test.test_type !== mablApi_1.TestTypeEnum.Performance) {
|
|
98
114
|
throw new Error(util_2.TEST_WITHOUT_FLOWS_MESSAGE);
|
|
99
115
|
}
|
|
100
116
|
const workspaceId = test.organization_id;
|
|
@@ -120,14 +136,14 @@ async function editTest(trainingSessionOptions) {
|
|
|
120
136
|
credentialsId,
|
|
121
137
|
disableIsolation: trainingSessionOptions.disableIsolation,
|
|
122
138
|
environmentId,
|
|
123
|
-
height: trainingSessionOptions.height
|
|
139
|
+
height: (_h = trainingSessionOptions.height) !== null && _h !== void 0 ? _h : exports.DEFAULT_HEIGHT,
|
|
124
140
|
ignoreCertificateErrors: trainingSessionOptions.ignoreCertificateErrors,
|
|
125
141
|
planId: testRunIdConfig.fromPlanId,
|
|
126
142
|
sender: exports.SENDER,
|
|
127
143
|
testId,
|
|
128
|
-
testType: test.test_type
|
|
144
|
+
testType: (_j = test.test_type) !== null && _j !== void 0 ? _j : mablApi_1.TestTypeEnum.Browser,
|
|
129
145
|
url: finalUrl,
|
|
130
|
-
width: trainingSessionOptions.width
|
|
146
|
+
width: (_k = trainingSessionOptions.width) !== null && _k !== void 0 ? _k : exports.DEFAULT_WIDTH,
|
|
131
147
|
workspaceId,
|
|
132
148
|
};
|
|
133
149
|
await (0, openUtils_1.openUrlInDesktopApp)(ElectronProtocolUrl.EDIT_TEST, scriptConfig);
|
package/coreWebVitals/index.js
CHANGED
|
@@ -15,43 +15,46 @@ function attachListeners() {
|
|
|
15
15
|
}
|
|
16
16
|
exports.attachListeners = attachListeners;
|
|
17
17
|
function handleNavigationEvent(eventName, callback) {
|
|
18
|
+
var _a;
|
|
18
19
|
const performanceEntries = performance.getEntriesByType('navigation');
|
|
19
|
-
const navigationTiming = performanceEntries
|
|
20
|
-
const eventTimestamp = navigationTiming
|
|
20
|
+
const navigationTiming = performanceEntries === null || performanceEntries === void 0 ? void 0 : performanceEntries[0];
|
|
21
|
+
const eventTimestamp = navigationTiming === null || navigationTiming === void 0 ? void 0 : navigationTiming[eventName];
|
|
21
22
|
callback({
|
|
22
23
|
name: eventName,
|
|
23
24
|
value: eventTimestamp,
|
|
24
25
|
delta: eventTimestamp,
|
|
25
26
|
rating: 'none',
|
|
26
27
|
id: `NAV:${eventName}:${eventTimestamp}:${Date.now()}`,
|
|
27
|
-
entries: performanceEntries
|
|
28
|
-
navigationType: navigationTiming
|
|
28
|
+
entries: performanceEntries === null || performanceEntries === void 0 ? void 0 : performanceEntries.map((entry) => entry === null || entry === void 0 ? void 0 : entry.toJSON()),
|
|
29
|
+
navigationType: (_a = navigationTiming === null || navigationTiming === void 0 ? void 0 : navigationTiming.type) !== null && _a !== void 0 ? _a : 'navigate',
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
function pollForEventTimestamp(eventName, callback, navigationTiming) {
|
|
33
|
+
var _a;
|
|
32
34
|
navigationTiming =
|
|
33
|
-
navigationTiming
|
|
34
|
-
|
|
35
|
-
if (navigationTiming?.[eventName]) {
|
|
35
|
+
navigationTiming !== null && navigationTiming !== void 0 ? navigationTiming : (_a = performance.getEntriesByType('navigation')) === null || _a === void 0 ? void 0 : _a[0];
|
|
36
|
+
if (navigationTiming === null || navigationTiming === void 0 ? void 0 : navigationTiming[eventName]) {
|
|
36
37
|
handleNavigationEvent(eventName, callback);
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
40
|
let attempts = 0;
|
|
40
41
|
const interval = window.setInterval(() => {
|
|
42
|
+
var _a;
|
|
41
43
|
attempts++;
|
|
42
|
-
const navigationTiming = performance.getEntriesByType('navigation')
|
|
43
|
-
if (navigationTiming
|
|
44
|
+
const navigationTiming = (_a = performance.getEntriesByType('navigation')) === null || _a === void 0 ? void 0 : _a[0];
|
|
45
|
+
if ((navigationTiming === null || navigationTiming === void 0 ? void 0 : navigationTiming[eventName]) || attempts >= POLLING_MAX_ATTEMPTS) {
|
|
44
46
|
handleNavigationEvent(eventName, callback);
|
|
45
47
|
window.clearInterval(interval);
|
|
46
48
|
}
|
|
47
49
|
}, POLLING_INTERVAL_MILLIS);
|
|
48
50
|
}
|
|
49
51
|
function onNavigationEvent(callback) {
|
|
50
|
-
|
|
52
|
+
var _a;
|
|
53
|
+
const navigationTiming = (_a = performance.getEntriesByType('navigation')) === null || _a === void 0 ? void 0 : _a[0];
|
|
51
54
|
if (navigationTiming !== undefined) {
|
|
52
55
|
handleNavigationEvent('startTime', callback);
|
|
53
56
|
}
|
|
54
|
-
if (navigationTiming
|
|
57
|
+
if (navigationTiming === null || navigationTiming === void 0 ? void 0 : navigationTiming.domContentLoadedEventEnd) {
|
|
55
58
|
handleNavigationEvent('domContentLoadedEventEnd', callback);
|
|
56
59
|
}
|
|
57
60
|
else {
|
|
@@ -61,13 +64,14 @@ function onNavigationEvent(callback) {
|
|
|
61
64
|
}
|
|
62
65
|
}
|
|
63
66
|
const sendMetric = (metric) => {
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
var _a, _b, _c;
|
|
68
|
+
const navigationTiming = (_a = performance.getEntriesByType('navigation')) === null || _a === void 0 ? void 0 : _a[0];
|
|
69
|
+
(_c = (_b = window).dispatchMablEvent) === null || _c === void 0 ? void 0 : _c.call(_b, {
|
|
66
70
|
createdTime: Date.now(),
|
|
67
71
|
timeOrigin: performance.timeOrigin,
|
|
68
72
|
type: 'WEB_PERFORMANCE_METRIC_DETECTED',
|
|
69
73
|
currentUrl: window.document.URL,
|
|
70
|
-
navigationUrl: navigationTiming
|
|
74
|
+
navigationUrl: navigationTiming === null || navigationTiming === void 0 ? void 0 : navigationTiming.name,
|
|
71
75
|
metric,
|
|
72
76
|
});
|
|
73
77
|
};
|