@metamask-previews/bridge-status-controller 75.4.0-preview-ea6a28c61 → 75.4.0-preview-e12b5ece6
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 +3 -3
- package/dist/bridge-status-controller.cjs +0 -24
- package/dist/bridge-status-controller.cjs.map +1 -1
- package/dist/bridge-status-controller.d.cts.map +1 -1
- package/dist/bridge-status-controller.d.mts.map +1 -1
- package/dist/bridge-status-controller.mjs +2 -26
- package/dist/bridge-status-controller.mjs.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/utils/metrics.cjs +76 -107
- package/dist/utils/metrics.cjs.map +1 -1
- package/dist/utils/metrics.d.cts +35 -51
- package/dist/utils/metrics.d.cts.map +1 -1
- package/dist/utils/metrics.d.mts +35 -51
- package/dist/utils/metrics.d.mts.map +1 -1
- package/dist/utils/metrics.mjs +70 -100
- package/dist/utils/metrics.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACtB,mBAAmB,GACpB,0CAAyC;AAC1C,OAAO,EAAE,+BAA+B,EAAE,6CAA4C;AAGtF,OAAO,EACL,mBAAmB,EACnB,sCAAsC,EACtC,6BAA6B,EAC7B,YAAY,GACb,wBAAuB;AAExB,YAAY,EACV,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,0BAA0B,EAC1B,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,2BAA2B,EAC3B,uBAAuB,EACvB,+BAA+B,EAC/B,6BAA6B,EAC7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,EACjC,sBAAsB,GACvB,4BAA2B;AAE5B,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,yBAAyB,EACzB,kBAAkB,EAClB,yBAAyB,GAC1B,4BAA2B"}
|
package/dist/index.d.mts
CHANGED
|
@@ -6,5 +6,5 @@ export type { BridgeStatusControllerStartPollingForBridgeTxStatusAction, BridgeS
|
|
|
6
6
|
export { BridgeId, BridgeStatusAction } from "./types.mjs";
|
|
7
7
|
export { BridgeStatusController } from "./bridge-status-controller.mjs";
|
|
8
8
|
export { getBatchSellHistoryItemsForTxHash, isBatchSellHistoryItem, } from "./utils/history.mjs";
|
|
9
|
-
export { getHashPresenceProperties, getStatusFailurePhase,
|
|
9
|
+
export { getHashPresenceProperties, getStatusFailurePhase, getStatusFailureTelemetry, getSubmitErrorCode, getSubmitFailureTelemetry, } from "./utils/metrics.mjs";
|
|
10
10
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACtB,mBAAmB,GACpB,0CAAyC;AAC1C,OAAO,EAAE,+BAA+B,EAAE,6CAA4C;AAGtF,OAAO,EACL,mBAAmB,EACnB,sCAAsC,EACtC,6BAA6B,EAC7B,YAAY,GACb,wBAAuB;AAExB,YAAY,EACV,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,0BAA0B,EAC1B,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,2BAA2B,EAC3B,uBAAuB,EACvB,+BAA+B,EAC/B,6BAA6B,EAC7B,oCAAoC,EACpC,4BAA4B,EAC5B,sCAAsC,EACtC,iCAAiC,EACjC,2CAA2C,EAC3C,2BAA2B,EAC3B,uBAAuB,GACxB,oBAAmB;AAEpB,YAAY,EACV,yDAAyD,EACzD,4CAA4C,EAC5C,sCAAsC,EACtC,oCAAoC,EACpC,wCAAwC,EACxC,2DAA2D,EAC3D,0DAA0D,GAC3D,2DAA0D;AAE3D,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,oBAAmB;AAE1D,OAAO,EAAE,sBAAsB,EAAE,uCAAsC;AAEvE,OAAO,EACL,iCAAiC,EACjC,sBAAsB,GACvB,4BAA2B;AAE5B,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACtB,mBAAmB,GACpB,0CAAyC;AAC1C,OAAO,EAAE,+BAA+B,EAAE,6CAA4C;AAGtF,OAAO,EACL,mBAAmB,EACnB,sCAAsC,EACtC,6BAA6B,EAC7B,YAAY,GACb,wBAAuB;AAExB,YAAY,EACV,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,0BAA0B,EAC1B,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,2BAA2B,EAC3B,uBAAuB,EACvB,+BAA+B,EAC/B,6BAA6B,EAC7B,oCAAoC,EACpC,4BAA4B,EAC5B,sCAAsC,EACtC,iCAAiC,EACjC,2CAA2C,EAC3C,2BAA2B,EAC3B,uBAAuB,GACxB,oBAAmB;AAEpB,YAAY,EACV,yDAAyD,EACzD,4CAA4C,EAC5C,sCAAsC,EACtC,oCAAoC,EACpC,wCAAwC,EACxC,2DAA2D,EAC3D,0DAA0D,GAC3D,2DAA0D;AAE3D,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,oBAAmB;AAE1D,OAAO,EAAE,sBAAsB,EAAE,uCAAsC;AAEvE,OAAO,EACL,iCAAiC,EACjC,sBAAsB,GACvB,4BAA2B;AAE5B,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,yBAAyB,EACzB,kBAAkB,EAClB,yBAAyB,GAC1B,4BAA2B"}
|
package/dist/index.mjs
CHANGED
|
@@ -6,5 +6,5 @@ export { REFRESH_INTERVAL_MS, DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE, BRIDGE_STA
|
|
|
6
6
|
export { BridgeId, BridgeStatusAction } from "./types.mjs";
|
|
7
7
|
export { BridgeStatusController } from "./bridge-status-controller.mjs";
|
|
8
8
|
export { getBatchSellHistoryItemsForTxHash, isBatchSellHistoryItem } from "./utils/history.mjs";
|
|
9
|
-
export { getHashPresenceProperties, getStatusFailurePhase,
|
|
9
|
+
export { getHashPresenceProperties, getStatusFailurePhase, getStatusFailureTelemetry, getSubmitErrorCode, getSubmitFailureTelemetry } from "./utils/metrics.mjs";
|
|
10
10
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACpB,0CAAyC;AAC1C,OAAO,EAAE,+BAA+B,EAAE,6CAA4C;AAEtF,mBAAmB;AACnB,OAAO,EACL,mBAAmB,EACnB,sCAAsC,EACtC,6BAA6B,EAC7B,YAAY,EACb,wBAAuB;AAiCxB,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,oBAAmB;AAE1D,OAAO,EAAE,sBAAsB,EAAE,uCAAsC;AAEvE,OAAO,EACL,iCAAiC,EACjC,sBAAsB,EACvB,4BAA2B;AAE5B,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACpB,0CAAyC;AAC1C,OAAO,EAAE,+BAA+B,EAAE,6CAA4C;AAEtF,mBAAmB;AACnB,OAAO,EACL,mBAAmB,EACnB,sCAAsC,EACtC,6BAA6B,EAC7B,YAAY,EACb,wBAAuB;AAiCxB,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,oBAAmB;AAE1D,OAAO,EAAE,sBAAsB,EAAE,uCAAsC;AAEvE,OAAO,EACL,iCAAiC,EACjC,sBAAsB,EACvB,4BAA2B;AAE5B,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,yBAAyB,EACzB,kBAAkB,EAClB,yBAAyB,EAC1B,4BAA2B","sourcesContent":["// Export custom error classes\nexport {\n QuoteStatusUpdateError,\n QuoteStatusGetError,\n} from './quote-status-manager/errors.js';\nexport { BaseQuoteStatusUpdateErrorTypes } from './quote-status-manager/constants.js';\n\n// Export constants\nexport {\n REFRESH_INTERVAL_MS,\n DEFAULT_BRIDGE_STATUS_CONTROLLER_STATE,\n BRIDGE_STATUS_CONTROLLER_NAME,\n MAX_ATTEMPTS,\n} from './constants.js';\n\nexport type {\n FetchFunction,\n StatusRequest,\n StatusRequestDto,\n StatusRequestWithSrcTxHash,\n StatusResponse,\n RefuelStatusResponse,\n BridgeHistoryItem,\n BridgeStatusControllerState,\n QuoteStatusPersistEntry,\n BridgeStatusControllerMessenger,\n BridgeStatusControllerActions,\n BridgeStatusControllerGetStateAction,\n BridgeStatusControllerEvents,\n BridgeStatusControllerStateChangeEvent,\n StartPollingForBridgeTxStatusArgs,\n StartPollingForBridgeTxStatusArgsSerialized,\n TokenAmountValuesSerialized,\n QuoteMetadataSerialized,\n} from './types.js';\n\nexport type {\n BridgeStatusControllerStartPollingForBridgeTxStatusAction,\n BridgeStatusControllerWipeBridgeStatusAction,\n BridgeStatusControllerResetStateAction,\n BridgeStatusControllerSubmitTxAction,\n BridgeStatusControllerSubmitIntentAction,\n BridgeStatusControllerRestartPollingForFailedAttemptsAction,\n BridgeStatusControllerGetBridgeHistoryItemByTxMetaIdAction,\n} from './bridge-status-controller-method-action-types.js';\n\nexport { BridgeId, BridgeStatusAction } from './types.js';\n\nexport { BridgeStatusController } from './bridge-status-controller.js';\n\nexport {\n getBatchSellHistoryItemsForTxHash,\n isBatchSellHistoryItem,\n} from './utils/history.js';\n\nexport {\n getHashPresenceProperties,\n getStatusFailurePhase,\n getStatusFailureTelemetry,\n getSubmitErrorCode,\n getSubmitFailureTelemetry,\n} from './utils/metrics.js';\n"]}
|
package/dist/utils/metrics.cjs
CHANGED
|
@@ -1,110 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getStatusFailureTelemetry = exports.getSubmitFailureTelemetry = exports.getStatusFailurePhase = exports.getHashPresenceProperties = exports.getSubmitErrorCode = exports.getEVMTxPropertiesFromTransactionMeta = exports.getRequestMetadataFromHistory = exports.getTradeDataFromHistory = exports.getPreConfirmationPropertiesFromQuote = exports.getPriceImpactFromQuote = exports.getTradeDataFromQuote = exports.getRequestParamFromHistory = exports.getFinalizedTxProperties = exports.getTxStatusesFromHistory = void 0;
|
|
4
4
|
const bridge_controller_1 = require("@metamask/bridge-controller");
|
|
5
5
|
const transaction_controller_1 = require("@metamask/transaction-controller");
|
|
6
6
|
const bignumber_js_1 = require("bignumber.js");
|
|
7
7
|
const gas_js_1 = require("./gas.cjs");
|
|
8
8
|
const swap_received_amount_js_1 = require("./swap-received-amount.cjs");
|
|
9
|
-
/**
|
|
10
|
-
* Classify a thrown value from submit (sign/broadcast) catch paths.
|
|
11
|
-
*
|
|
12
|
-
* @param error - The thrown value from submit.
|
|
13
|
-
* @returns The Mixpanel `error_code`.
|
|
14
|
-
*/
|
|
15
|
-
const getSubmitErrorCode = (error) => {
|
|
16
|
-
if (error === undefined || error === null) {
|
|
17
|
-
return bridge_controller_1.SwapBridgeErrorCode.MissingErrorObject;
|
|
18
|
-
}
|
|
19
|
-
if (error instanceof Error) {
|
|
20
|
-
return bridge_controller_1.SwapBridgeErrorCode.Unknown;
|
|
21
|
-
}
|
|
22
|
-
return bridge_controller_1.SwapBridgeErrorCode.NonErrorRejection;
|
|
23
|
-
};
|
|
24
|
-
exports.getSubmitErrorCode = getSubmitErrorCode;
|
|
25
|
-
/**
|
|
26
|
-
* @param sourceHash - Source tx hash if known at emit time.
|
|
27
|
-
* @param destinationHash - Destination tx hash if known at emit time.
|
|
28
|
-
* @returns Boolean hash-presence properties.
|
|
29
|
-
*/
|
|
30
|
-
const getHashPresenceProperties = (sourceHash, destinationHash) => {
|
|
31
|
-
return {
|
|
32
|
-
source_hash_present: Boolean(sourceHash),
|
|
33
|
-
destination_hash_present: Boolean(destinationHash),
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
exports.getHashPresenceProperties = getHashPresenceProperties;
|
|
37
|
-
/**
|
|
38
|
-
* Prefer destination_execution over source_execution over poll.
|
|
39
|
-
*
|
|
40
|
-
* @param hashPresence - Hash presence at emit time.
|
|
41
|
-
* @returns The Mixpanel `failure_phase` for a status/polling Failed event.
|
|
42
|
-
*/
|
|
43
|
-
const getStatusFailurePhase = (hashPresence) => {
|
|
44
|
-
if (hashPresence.destination_hash_present) {
|
|
45
|
-
return bridge_controller_1.FailurePhase.DestinationExecution;
|
|
46
|
-
}
|
|
47
|
-
if (hashPresence.source_hash_present) {
|
|
48
|
-
return bridge_controller_1.FailurePhase.SourceExecution;
|
|
49
|
-
}
|
|
50
|
-
return bridge_controller_1.FailurePhase.Poll;
|
|
51
|
-
};
|
|
52
|
-
exports.getStatusFailurePhase = getStatusFailurePhase;
|
|
53
|
-
/**
|
|
54
|
-
* Align `failure_phase` with combined hash presence without turning a
|
|
55
|
-
* no-hash `broadcast` failure into `poll`.
|
|
56
|
-
*
|
|
57
|
-
* @param phase - Phase from the emitting path.
|
|
58
|
-
* @param hashPresence - Combined history + caller hash flags.
|
|
59
|
-
* @returns The Mixpanel `failure_phase`.
|
|
60
|
-
*/
|
|
61
|
-
const promoteFailurePhase = (phase, hashPresence) => {
|
|
62
|
-
if (hashPresence.destination_hash_present) {
|
|
63
|
-
return bridge_controller_1.FailurePhase.DestinationExecution;
|
|
64
|
-
}
|
|
65
|
-
if (hashPresence.source_hash_present &&
|
|
66
|
-
(phase === bridge_controller_1.FailurePhase.Broadcast ||
|
|
67
|
-
phase === bridge_controller_1.FailurePhase.Poll ||
|
|
68
|
-
phase === bridge_controller_1.FailurePhase.Unknown)) {
|
|
69
|
-
return bridge_controller_1.FailurePhase.SourceExecution;
|
|
70
|
-
}
|
|
71
|
-
return phase;
|
|
72
|
-
};
|
|
73
|
-
exports.promoteFailurePhase = promoteFailurePhase;
|
|
74
|
-
/**
|
|
75
|
-
* Mixpanel properties for Failed events in the `broadcast` phase (no tx hash yet).
|
|
76
|
-
*
|
|
77
|
-
* @param error - The thrown value from the submit/broadcast catch.
|
|
78
|
-
* @returns Phase, error code, and hash-presence flags.
|
|
79
|
-
*/
|
|
80
|
-
const getBroadcastFailureProperties = (error) => {
|
|
81
|
-
return {
|
|
82
|
-
failure_phase: bridge_controller_1.FailurePhase.Broadcast,
|
|
83
|
-
error_code: (0, exports.getSubmitErrorCode)(error),
|
|
84
|
-
source_hash_present: false,
|
|
85
|
-
destination_hash_present: false,
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
exports.getBroadcastFailureProperties = getBroadcastFailureProperties;
|
|
89
|
-
/**
|
|
90
|
-
* Mixpanel properties for Failed events derived from history hashes.
|
|
91
|
-
*
|
|
92
|
-
* Used for poll Failed and TransactionController Failed once a history
|
|
93
|
-
* item exists. Not poll-only.
|
|
94
|
-
*
|
|
95
|
-
* @param sourceHash - Source tx hash from history if known.
|
|
96
|
-
* @param destinationHash - Destination tx hash from history if known.
|
|
97
|
-
* @returns Phase, error code, and hash-presence flags.
|
|
98
|
-
*/
|
|
99
|
-
const getFailurePropertiesFromHistory = (sourceHash, destinationHash) => {
|
|
100
|
-
const hashPresence = (0, exports.getHashPresenceProperties)(sourceHash, destinationHash);
|
|
101
|
-
return {
|
|
102
|
-
...hashPresence,
|
|
103
|
-
failure_phase: (0, exports.getStatusFailurePhase)(hashPresence),
|
|
104
|
-
error_code: bridge_controller_1.SwapBridgeErrorCode.StatusFailedWithoutReason,
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
exports.getFailurePropertiesFromHistory = getFailurePropertiesFromHistory;
|
|
108
9
|
const getTxStatusesFromHistory = ({ status, hasApprovalTx, approvalTxId, quote, }) => {
|
|
109
10
|
const source_transaction = status.srcChain.txHash
|
|
110
11
|
? bridge_controller_1.StatusTypes.COMPLETE
|
|
@@ -341,14 +242,82 @@ const getEVMTxPropertiesFromTransactionMeta = (transactionMeta, account) => {
|
|
|
341
242
|
usd_actual_gas: 0,
|
|
342
243
|
action_type: bridge_controller_1.MetricsActionType.SWAPBRIDGE_V1,
|
|
343
244
|
...(transactionMeta.batchId ? { batch_id: transactionMeta.batchId } : {}),
|
|
344
|
-
...(0, exports.getHashPresenceProperties)(transactionMeta.hash, undefined),
|
|
345
|
-
failure_phase: transactionMeta.hash
|
|
346
|
-
? bridge_controller_1.FailurePhase.SourceExecution
|
|
347
|
-
: bridge_controller_1.FailurePhase.Broadcast,
|
|
348
|
-
error_code: transactionMeta.error
|
|
349
|
-
? bridge_controller_1.SwapBridgeErrorCode.Unknown
|
|
350
|
-
: bridge_controller_1.SwapBridgeErrorCode.MissingErrorObject,
|
|
351
245
|
};
|
|
352
246
|
};
|
|
353
247
|
exports.getEVMTxPropertiesFromTransactionMeta = getEVMTxPropertiesFromTransactionMeta;
|
|
248
|
+
/**
|
|
249
|
+
* Classify a thrown value from submit (sign/broadcast) catch paths.
|
|
250
|
+
*
|
|
251
|
+
* @param error - The thrown value from submit.
|
|
252
|
+
* @returns The Mixpanel `error_code`.
|
|
253
|
+
*/
|
|
254
|
+
const getSubmitErrorCode = (error) => {
|
|
255
|
+
if (error === undefined || error === null) {
|
|
256
|
+
return bridge_controller_1.SwapBridgeErrorCode.MissingErrorObject;
|
|
257
|
+
}
|
|
258
|
+
if (error instanceof Error) {
|
|
259
|
+
return bridge_controller_1.SwapBridgeErrorCode.Unknown;
|
|
260
|
+
}
|
|
261
|
+
return bridge_controller_1.SwapBridgeErrorCode.NonErrorRejection;
|
|
262
|
+
};
|
|
263
|
+
exports.getSubmitErrorCode = getSubmitErrorCode;
|
|
264
|
+
/**
|
|
265
|
+
* @param sourceHash - Source tx hash if known at emit time.
|
|
266
|
+
* @param destinationHash - Destination tx hash if known at emit time.
|
|
267
|
+
* @returns Boolean hash-presence properties.
|
|
268
|
+
*/
|
|
269
|
+
const getHashPresenceProperties = (sourceHash, destinationHash) => {
|
|
270
|
+
return {
|
|
271
|
+
source_hash_present: Boolean(sourceHash),
|
|
272
|
+
destination_hash_present: Boolean(destinationHash),
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
exports.getHashPresenceProperties = getHashPresenceProperties;
|
|
276
|
+
/**
|
|
277
|
+
* Prefer destination_execution over source_execution over poll.
|
|
278
|
+
*
|
|
279
|
+
* @param hashPresence - Hash presence at emit time.
|
|
280
|
+
* @returns The Mixpanel `failure_phase` for a status/polling Failed event.
|
|
281
|
+
*/
|
|
282
|
+
const getStatusFailurePhase = (hashPresence) => {
|
|
283
|
+
if (hashPresence.destination_hash_present) {
|
|
284
|
+
return bridge_controller_1.FailurePhase.DestinationExecution;
|
|
285
|
+
}
|
|
286
|
+
if (hashPresence.source_hash_present) {
|
|
287
|
+
return bridge_controller_1.FailurePhase.SourceExecution;
|
|
288
|
+
}
|
|
289
|
+
return bridge_controller_1.FailurePhase.Poll;
|
|
290
|
+
};
|
|
291
|
+
exports.getStatusFailurePhase = getStatusFailurePhase;
|
|
292
|
+
/**
|
|
293
|
+
* Telemetry for Failed events emitted from the submit catch (no tx hash yet).
|
|
294
|
+
*
|
|
295
|
+
* @param error - The thrown value from submit.
|
|
296
|
+
* @returns Phase, error code, and hash-presence flags.
|
|
297
|
+
*/
|
|
298
|
+
const getSubmitFailureTelemetry = (error) => {
|
|
299
|
+
return {
|
|
300
|
+
failure_phase: bridge_controller_1.FailurePhase.Broadcast,
|
|
301
|
+
error_code: (0, exports.getSubmitErrorCode)(error),
|
|
302
|
+
source_hash_present: false,
|
|
303
|
+
destination_hash_present: false,
|
|
304
|
+
};
|
|
305
|
+
};
|
|
306
|
+
exports.getSubmitFailureTelemetry = getSubmitFailureTelemetry;
|
|
307
|
+
/**
|
|
308
|
+
* Telemetry for Failed events derived from a status poll.
|
|
309
|
+
*
|
|
310
|
+
* @param sourceHash - Source tx hash if known.
|
|
311
|
+
* @param destinationHash - Destination tx hash if known.
|
|
312
|
+
* @returns Phase, error code, and hash-presence flags.
|
|
313
|
+
*/
|
|
314
|
+
const getStatusFailureTelemetry = (sourceHash, destinationHash) => {
|
|
315
|
+
const hashPresence = (0, exports.getHashPresenceProperties)(sourceHash, destinationHash);
|
|
316
|
+
return {
|
|
317
|
+
...hashPresence,
|
|
318
|
+
failure_phase: (0, exports.getStatusFailurePhase)(hashPresence),
|
|
319
|
+
error_code: bridge_controller_1.SwapBridgeErrorCode.StatusFailedWithoutReason,
|
|
320
|
+
};
|
|
321
|
+
};
|
|
322
|
+
exports.getStatusFailureTelemetry = getStatusFailureTelemetry;
|
|
354
323
|
//# sourceMappingURL=metrics.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.cjs","sourceRoot":"","sources":["../../src/utils/metrics.ts"],"names":[],"mappings":";;;AAIA,mEAiBqC;AAerC,6EAG0C;AAG1C,+CAAyC;AAGzC,sCAA6C;AAC7C,wEAGmC;AAEnC;;;;;GAKG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAAc,EAAuB,EAAE;IACxE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC1C,OAAO,uCAAmB,CAAC,kBAAkB,CAAC;IAChD,CAAC;IACD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,uCAAmB,CAAC,OAAO,CAAC;IACrC,CAAC;IACD,OAAO,uCAAmB,CAAC,iBAAiB,CAAC;AAC/C,CAAC,CAAC;AARW,QAAA,kBAAkB,sBAQ7B;AAEF;;;;GAIG;AACI,MAAM,yBAAyB,G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,GAAG,IAAA,iCAAyB,EAAC,eAAe,CAAC,IAAI,EAAE,SAAS,CAAC;QAC7D,aAAa,EAAE,eAAe,CAAC,IAAI;YACjC,CAAC,CAAC,gCAAY,CAAC,eAAe;YAC9B,CAAC,CAAC,gCAAY,CAAC,SAAS;QAC1B,UAAU,EAAE,eAAe,CAAC,KAAK;YAC/B,CAAC,CAAC,uCAAmB,CAAC,OAAO;YAC7B,CAAC,CAAC,uCAAmB,CAAC,kBAAkB;KAC3C,CAAC;AACJ,CAAC,CAAC;AAvEW,QAAA,qCAAqC,yCAuEhD","sourcesContent":["/* eslint-disable camelcase */\n/* eslint-disable @typescript-eslint/naming-convention */\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport type { AccountsControllerState } from '@metamask/accounts-controller';\nimport {\n StatusTypes,\n getAccountHardwareType,\n formatChainIdToHex,\n isEthUsdt,\n formatChainIdToCaip,\n formatProviderLabel,\n isCustomSlippage,\n getSwapType,\n formatAddressToAssetId,\n MetricsActionType,\n MetricsSwapType,\n MetaMetricsSwapsEventSource,\n FeatureId,\n UnifiedSwapBridgeEventName,\n FailurePhase,\n SwapBridgeErrorCode,\n} from '@metamask/bridge-controller';\nimport type {\n AccountHardwareType,\n QuoteFetchData,\n QuoteMetadata,\n QuoteResponseV1,\n TxStatusData,\n RequestParams,\n TradeData,\n RequestMetadata,\n BatchSellTradesResponse,\n RequiredEventContextFromClient,\n HashPresenceProperties,\n FailureTelemetryProperties,\n} from '@metamask/bridge-controller';\nimport {\n TransactionStatus,\n TransactionType,\n} from '@metamask/transaction-controller';\nimport type { TransactionMeta } from '@metamask/transaction-controller';\nimport type { CaipAssetType, Hex } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport type { BridgeHistoryItem } from '../types.js';\nimport { calcActualGasUsed } from './gas.js';\nimport {\n getActualBridgeReceivedAmount,\n getActualSwapReceivedAmount,\n} from './swap-received-amount.js';\n\n/**\n * Classify a thrown value from submit (sign/broadcast) catch paths.\n *\n * @param error - The thrown value from submit.\n * @returns The Mixpanel `error_code`.\n */\nexport const getSubmitErrorCode = (error: unknown): SwapBridgeErrorCode => {\n if (error === undefined || error === null) {\n return SwapBridgeErrorCode.MissingErrorObject;\n }\n if (error instanceof Error) {\n return SwapBridgeErrorCode.Unknown;\n }\n return SwapBridgeErrorCode.NonErrorRejection;\n};\n\n/**\n * @param sourceHash - Source tx hash if known at emit time.\n * @param destinationHash - Destination tx hash if known at emit time.\n * @returns Boolean hash-presence properties.\n */\nexport const getHashPresenceProperties = (\n sourceHash?: string | null,\n destinationHash?: string | null,\n): HashPresenceProperties => {\n return {\n source_hash_present: Boolean(sourceHash),\n destination_hash_present: Boolean(destinationHash),\n };\n};\n\n/**\n * Prefer destination_execution over source_execution over poll.\n *\n * @param hashPresence - Hash presence at emit time.\n * @returns The Mixpanel `failure_phase` for a status/polling Failed event.\n */\nexport const getStatusFailurePhase = (\n hashPresence: HashPresenceProperties,\n): FailurePhase => {\n if (hashPresence.destination_hash_present) {\n return FailurePhase.DestinationExecution;\n }\n if (hashPresence.source_hash_present) {\n return FailurePhase.SourceExecution;\n }\n return FailurePhase.Poll;\n};\n\n/**\n * Align `failure_phase` with combined hash presence without turning a\n * no-hash `broadcast` failure into `poll`.\n *\n * @param phase - Phase from the emitting path.\n * @param hashPresence - Combined history + caller hash flags.\n * @returns The Mixpanel `failure_phase`.\n */\nexport const promoteFailurePhase = (\n phase: FailurePhase,\n hashPresence: HashPresenceProperties,\n): FailurePhase => {\n if (hashPresence.destination_hash_present) {\n return FailurePhase.DestinationExecution;\n }\n if (\n hashPresence.source_hash_present &&\n (phase === FailurePhase.Broadcast ||\n phase === FailurePhase.Poll ||\n phase === FailurePhase.Unknown)\n ) {\n return FailurePhase.SourceExecution;\n }\n return phase;\n};\n\n/**\n * Mixpanel properties for Failed events in the `broadcast` phase (no tx hash yet).\n *\n * @param error - The thrown value from the submit/broadcast catch.\n * @returns Phase, error code, and hash-presence flags.\n */\nexport const getBroadcastFailureProperties = (\n error: unknown,\n): FailureTelemetryProperties => {\n return {\n failure_phase: FailurePhase.Broadcast,\n error_code: getSubmitErrorCode(error),\n source_hash_present: false,\n destination_hash_present: false,\n };\n};\n\n/**\n * Mixpanel properties for Failed events derived from history hashes.\n *\n * Used for poll Failed and TransactionController Failed once a history\n * item exists. Not poll-only.\n *\n * @param sourceHash - Source tx hash from history if known.\n * @param destinationHash - Destination tx hash from history if known.\n * @returns Phase, error code, and hash-presence flags.\n */\nexport const getFailurePropertiesFromHistory = (\n sourceHash?: string | null,\n destinationHash?: string | null,\n): FailureTelemetryProperties => {\n const hashPresence = getHashPresenceProperties(sourceHash, destinationHash);\n return {\n ...hashPresence,\n failure_phase: getStatusFailurePhase(hashPresence),\n error_code: SwapBridgeErrorCode.StatusFailedWithoutReason,\n };\n};\n\nexport const getTxStatusesFromHistory = ({\n status,\n hasApprovalTx,\n approvalTxId,\n quote,\n}: BridgeHistoryItem): TxStatusData => {\n const source_transaction = status.srcChain.txHash\n ? StatusTypes.COMPLETE\n : StatusTypes.PENDING;\n const destination_transaction = status.destChain?.txHash\n ? status.status\n : StatusTypes.PENDING;\n\n const hexChainId = formatChainIdToHex(quote.srcChainId);\n const isEthUsdtTx = isEthUsdt(hexChainId, quote.srcAsset.address);\n const allowance_reset_transaction = status.srcChain.txHash\n ? StatusTypes.COMPLETE\n : undefined;\n const approval_transaction = status.srcChain.txHash\n ? StatusTypes.COMPLETE\n : StatusTypes.PENDING;\n\n return {\n allowance_reset_transaction: isEthUsdtTx\n ? allowance_reset_transaction\n : undefined,\n approval_transaction:\n hasApprovalTx || approvalTxId ? approval_transaction : undefined,\n source_transaction,\n destination_transaction:\n status.status === StatusTypes.FAILED\n ? StatusTypes.FAILED\n : destination_transaction,\n };\n};\n\n/**\n * Calculate the properties for a finalized transaction event based on the txHistory\n * and txMeta\n *\n * @param historyItem - The bridge history item\n * @param txMeta - The transaction meta from the TransactionController\n * @param approvalTxMeta - The approval transaction meta from the TransactionController\n * @returns The properties for the finalized transaction\n */\nexport const getFinalizedTxProperties = (\n historyItem: BridgeHistoryItem,\n txMeta?: TransactionMeta,\n approvalTxMeta?: TransactionMeta,\n) => {\n const startTime =\n approvalTxMeta?.submittedTime ??\n txMeta?.submittedTime ??\n historyItem.startTime;\n const completionTime =\n txMeta?.type === TransactionType.swap\n ? txMeta?.time\n : historyItem.completionTime;\n\n const actualGas = calcActualGasUsed(\n historyItem,\n txMeta?.txReceipt,\n approvalTxMeta?.txReceipt,\n );\n\n const actualReturn =\n txMeta?.type === TransactionType.swap\n ? getActualSwapReceivedAmount(historyItem, actualGas, txMeta)\n : getActualBridgeReceivedAmount(historyItem);\n\n const quotedVsUsedGasRatio =\n historyItem.pricingData?.quotedGasAmount && actualGas?.amount\n ? new BigNumber(historyItem.pricingData.quotedGasAmount)\n .multipliedBy(new BigNumber(10).pow(18))\n .div(actualGas.amount)\n .toNumber()\n : 0;\n\n const quoteVsExecutionRatio =\n historyItem.pricingData?.quotedReturnInUsd && actualReturn?.usd\n ? new BigNumber(historyItem.pricingData.quotedReturnInUsd)\n .div(actualReturn.usd)\n .toNumber()\n : 0;\n\n return {\n actual_time_minutes:\n completionTime && startTime ? (completionTime - startTime) / 60000 : 0,\n usd_actual_return: Number(actualReturn?.usd ?? 0),\n usd_actual_gas: actualGas?.usd ?? 0,\n quote_vs_execution_ratio: quoteVsExecutionRatio,\n quoted_vs_used_gas_ratio: quotedVsUsedGasRatio,\n };\n};\n\nexport const getRequestParamFromHistory = (\n historyItem: BridgeHistoryItem,\n): RequestParams => {\n return {\n chain_id_source: formatChainIdToCaip(historyItem.quote.srcChainId),\n token_symbol_source: historyItem.quote.srcAsset.symbol,\n token_address_source: historyItem.quote.srcAsset.assetId,\n chain_id_destination: formatChainIdToCaip(historyItem.quote.destChainId),\n token_symbol_destination: historyItem.quote.destAsset.symbol,\n token_address_destination: historyItem.quote.destAsset.assetId,\n token_security_type_destination:\n historyItem.tokenSecurityTypeDestination ?? null,\n };\n};\n\nexport const getTradeDataFromQuote = (\n quoteResponse: QuoteResponseV1 & QuoteMetadata,\n batchSellTrades?: BatchSellTradesResponse | null,\n): TradeData => {\n return {\n usd_quoted_gas: Number(quoteResponse.gasFee?.total?.usd ?? 0),\n gas_included:\n quoteResponse.quote.gasIncluded ?? batchSellTrades?.gasIncluded ?? false,\n gas_included_7702:\n quoteResponse.quote.gasIncluded7702 ??\n batchSellTrades?.gasIncluded7702 ??\n false,\n provider: formatProviderLabel(quoteResponse.quote),\n quoted_time_minutes: Number(\n quoteResponse.estimatedProcessingTimeInSeconds / 60,\n ),\n usd_quoted_return: Number(quoteResponse?.adjustedReturn?.usd ?? 0),\n };\n};\n\nexport const getPriceImpactFromQuote = (\n quote: QuoteResponseV1['quote'],\n): Pick<QuoteFetchData, 'price_impact'> => {\n return { price_impact: Number(quote.priceData?.priceImpact ?? '0') };\n};\n\n/**\n * Before the tx is confirmed, its data is not available in txHistory\n * The quote is used to populate event properties before confirmation\n *\n * @param quoteResponse - The quote response\n * @param isStxEnabled - Whether smart transactions are enabled on the client, for example the getSmartTransactionsEnabled selector value from the extension\n * @param accountHardwareType - The hardware wallet type used to submit the tx, or null if not a hardware wallet\n * @param location - The entry point from which the user initiated the swap or bridge (e.g. Main View, Token View, Trending Explore)\n * @param abTests - Legacy A/B test context for `ab_tests` (backward compatibility)\n * @param activeAbTests - New A/B test context for `active_ab_tests` (migration target)\n * @param tokenSecurityTypeDestination - The security classification of the destination token, supplied by the client (e.g. from token security/scanning data). Pass `null` when no security data is available.\n * @param batchSellTrades - The batch sell trades response\n * @param batchId - The batch ID of the transaction batch.\n * @param quotesReceivedContext - The client context captured when quotes were received.\n * @returns The properties for the pre-confirmation event\n */\nexport const getPreConfirmationPropertiesFromQuote = (\n quoteResponse: QuoteResponseV1 & QuoteMetadata,\n isStxEnabled: boolean,\n accountHardwareType: AccountHardwareType,\n location?: MetaMetricsSwapsEventSource,\n abTests?: Record<string, string>,\n activeAbTests?: { key: string; value: string }[],\n tokenSecurityTypeDestination?: string | null,\n batchSellTrades?: BatchSellTradesResponse | null,\n batchId?: Hex,\n quotesReceivedContext?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived],\n) => {\n const { quote } = quoteResponse;\n return {\n ...getPriceImpactFromQuote(quote),\n ...getTradeDataFromQuote(quoteResponse, batchSellTrades),\n chain_id_source: formatChainIdToCaip(quote.srcChainId),\n token_symbol_source: quote.srcAsset.symbol,\n token_address_source: quote.srcAsset.assetId,\n chain_id_destination: formatChainIdToCaip(quote.destChainId),\n token_symbol_destination: quote.destAsset.symbol,\n token_address_destination: quote.destAsset.assetId,\n token_security_type_destination: tokenSecurityTypeDestination ?? null,\n account_hardware_type: accountHardwareType,\n is_hardware_wallet: accountHardwareType !== null,\n swap_type: getSwapType(\n quoteResponse.quote.srcChainId,\n quoteResponse.quote.destChainId,\n ),\n usd_amount_source: Number(quoteResponse?.sentAmount?.usd ?? 0),\n stx_enabled: isStxEnabled,\n action_type: MetricsActionType.SWAPBRIDGE_V1,\n slippage_limit:\n quotesReceivedContext?.slippage_limit ?? quote.slippage ?? 0,\n custom_slippage: quotesReceivedContext?.custom_slippage ?? false,\n location,\n ...(abTests &&\n Object.keys(abTests).length > 0 && {\n ab_tests: abTests,\n }),\n ...(activeAbTests &&\n activeAbTests.length > 0 && {\n active_ab_tests: activeAbTests,\n }),\n ...(batchId ? { batch_id: batchId } : {}),\n feature_id: quoteResponse.featureId ?? FeatureId.UNIFIED_SWAP_BRIDGE,\n };\n};\n\nexport const getTradeDataFromHistory = (\n historyItem: BridgeHistoryItem,\n): TradeData => {\n return {\n usd_quoted_gas: Number(historyItem.pricingData?.quotedGasInUsd ?? 0),\n gas_included: historyItem.quote.gasIncluded ?? false,\n gas_included_7702: historyItem.quote.gasIncluded7702 ?? false,\n provider: formatProviderLabel(historyItem.quote),\n quoted_time_minutes: Number(\n historyItem.estimatedProcessingTimeInSeconds / 60,\n ),\n usd_quoted_return: Number(historyItem.pricingData?.quotedReturnInUsd ?? 0),\n };\n};\n\nexport const getRequestMetadataFromHistory = (\n historyItem: BridgeHistoryItem,\n account?: AccountsControllerState['internalAccounts']['accounts'][string],\n): RequestMetadata => {\n const {\n quote,\n slippagePercentage,\n isStxEnabled,\n customSlippage,\n batchSellData,\n featureId,\n } = historyItem;\n const accountHardwareType = getAccountHardwareType(account);\n const isBatchSell =\n Boolean(batchSellData) || featureId === FeatureId.BATCH_SELL;\n const isUnifiedSwapBridge =\n featureId === undefined || featureId === FeatureId.UNIFIED_SWAP_BRIDGE;\n let inferredCustomSlippage = false;\n if (isBatchSell) {\n inferredCustomSlippage = isCustomSlippage(slippagePercentage ?? 0);\n } else if (!isUnifiedSwapBridge) {\n inferredCustomSlippage = isCustomSlippage(slippagePercentage);\n }\n\n return {\n slippage_limit: slippagePercentage ?? 0,\n custom_slippage: customSlippage ?? inferredCustomSlippage,\n usd_amount_source: Number(historyItem.pricingData?.amountSentInUsd ?? 0),\n swap_type: getSwapType(quote.srcChainId, quote.destChainId),\n account_hardware_type: accountHardwareType,\n is_hardware_wallet: accountHardwareType !== null,\n stx_enabled: isStxEnabled ?? false,\n security_warnings: [],\n };\n};\n\n/**\n * Get the properties for a swap transaction that is not in the txHistory\n *\n * @param transactionMeta - The transaction meta\n * @param account - The account that submitted the transaction\n * @returns The properties for the swap transaction\n */\nexport const getEVMTxPropertiesFromTransactionMeta = (\n transactionMeta: TransactionMeta,\n account?: AccountsControllerState['internalAccounts']['accounts'][string],\n) => {\n const accountHardwareType = getAccountHardwareType(account);\n\n return {\n source_transaction: [\n TransactionStatus.failed,\n TransactionStatus.dropped,\n TransactionStatus.rejected,\n ].includes(transactionMeta.status)\n ? StatusTypes.FAILED\n : StatusTypes.COMPLETE,\n error_message: [\n `Transaction ${transactionMeta.status}`,\n transactionMeta.error?.message,\n ]\n .filter(Boolean)\n .join('. '),\n chain_id_source: formatChainIdToCaip(transactionMeta.chainId),\n chain_id_destination: formatChainIdToCaip(transactionMeta.chainId),\n token_symbol_source: transactionMeta.sourceTokenSymbol ?? '',\n token_symbol_destination: transactionMeta.destinationTokenSymbol ?? '',\n usd_amount_source: 0,\n slippage_limit: 0,\n stx_enabled: false,\n token_address_source:\n formatAddressToAssetId(\n transactionMeta.sourceTokenAddress ?? '',\n transactionMeta.chainId,\n ) ?? ('' as CaipAssetType),\n token_address_destination:\n formatAddressToAssetId(\n transactionMeta.destinationTokenAddress ?? '',\n transactionMeta.chainId,\n ) ?? ('' as CaipAssetType),\n token_security_type_destination: null,\n custom_slippage: false,\n account_hardware_type: accountHardwareType,\n is_hardware_wallet: accountHardwareType !== null,\n swap_type:\n transactionMeta.type &&\n [TransactionType.swap, TransactionType.swapApproval].includes(\n transactionMeta.type,\n )\n ? MetricsSwapType.SINGLE\n : MetricsSwapType.CROSSCHAIN,\n security_warnings: [],\n price_impact: 0,\n usd_quoted_gas: 0,\n gas_included: false,\n gas_included_7702: false,\n quoted_time_minutes: 0,\n usd_quoted_return: 0,\n provider: '' as `${string}_${string}`,\n actual_time_minutes: 0,\n quote_vs_execution_ratio: 0,\n quoted_vs_used_gas_ratio: 0,\n usd_actual_return: 0,\n usd_actual_gas: 0,\n action_type: MetricsActionType.SWAPBRIDGE_V1,\n ...(transactionMeta.batchId ? { batch_id: transactionMeta.batchId } : {}),\n ...getHashPresenceProperties(transactionMeta.hash, undefined),\n failure_phase: transactionMeta.hash\n ? FailurePhase.SourceExecution\n : FailurePhase.Broadcast,\n error_code: transactionMeta.error\n ? SwapBridgeErrorCode.Unknown\n : SwapBridgeErrorCode.MissingErrorObject,\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"metrics.cjs","sourceRoot":"","sources":["../../src/utils/metrics.ts"],"names":[],"mappings":";;;AAIA,mEAiBqC;AAerC,6EAG0C;AAG1C,+CAAyC;AAGzC,sCAA6C;AAC7C,wEAGmC;AAE5B,MAAM,wBAAwB,GAAG,CAAC,EACvC,MAAM,EACN,aAAa,EACb,YAAY,EACZ,KAAK,GACa,EAAgB,EAAE;IACpC,MA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IAC1B,OAAO;QACL,mBAAmB,EAAE,OAAO,CAAC,UAAU,CAAC;QACxC,wBAAwB,EAAE,OAAO,CAAC,eAAe,CAAC;KACnD,CAAC;AACJ,CAAC,CAAC;AARW,QAAA,yBAAyB,6BAQpC;AAEF;;;;;GAKG;AACI,MAAM,qBAAqB,GAAG,CACnC,YAAoC,EACtB,EAAE;IAChB,IAAI,YAAY,CAAC,wBAAwB,EAAE,CAAC;QAC1C,OAAO,gCAAY,CAAC,oBAAoB,CAAC;IAC3C,CAAC;IACD,IAAI,YAAY,CAAC,mBAAmB,EAAE,CAAC;QACrC,OAAO,gCAAY,CAAC,eAAe,CAAC;IACtC,CAAC;IACD,OAAO,gCAAY,CAAC,IAAI,CAAC;AAC3B,CAAC,CAAC;AAVW,QAAA,qBAAqB,yBAUhC;AAEF;;;;;GAKG;AACI,MAAM,yBAAyB,GAAG,CACvC,KAAc,EACc,EAAE;IAC9B,OAAO;QACL,aAAa,EAAE,gCAAY,CAAC,SAAS;QACrC,UAAU,EAAE,IAAA,0BAAkB,EAAC,KAAK,CAAC;QACrC,mBAAmB,EAAE,KAAK;QAC1B,wBAAwB,EAAE,KAAK;KAChC,CAAC;AACJ,CAAC,CAAC;AATW,QAAA,yBAAyB,6BASpC;AAEF;;;;;;GAMG;AACI,MAAM,yBAAyB,GAAG,CACvC,UAA0B,EAC1B,eAA+B,EACH,EAAE;IAC9B,MAAM,YAAY,GAAG,IAAA,iCAAyB,EAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IAC5E,OAAO;QACL,GAAG,YAAY;QACf,aAAa,EAAE,IAAA,6BAAqB,EAAC,YAAY,CAAC;QAClD,UAAU,EAAE,uCAAmB,CAAC,yBAAyB;KAC1D,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,yBAAyB,6BAUpC","sourcesContent":["/* eslint-disable camelcase */\n/* eslint-disable @typescript-eslint/naming-convention */\n/* eslint-disable @typescript-eslint/explicit-function-return-type */\nimport type { AccountsControllerState } from '@metamask/accounts-controller';\nimport {\n StatusTypes,\n getAccountHardwareType,\n formatChainIdToHex,\n isEthUsdt,\n formatChainIdToCaip,\n formatProviderLabel,\n isCustomSlippage,\n getSwapType,\n formatAddressToAssetId,\n MetricsActionType,\n MetricsSwapType,\n MetaMetricsSwapsEventSource,\n FeatureId,\n UnifiedSwapBridgeEventName,\n FailurePhase,\n SwapBridgeErrorCode,\n} from '@metamask/bridge-controller';\nimport type {\n AccountHardwareType,\n QuoteFetchData,\n QuoteMetadata,\n QuoteResponseV1,\n TxStatusData,\n RequestParams,\n TradeData,\n RequestMetadata,\n BatchSellTradesResponse,\n RequiredEventContextFromClient,\n HashPresenceProperties,\n FailureTelemetryProperties,\n} from '@metamask/bridge-controller';\nimport {\n TransactionStatus,\n TransactionType,\n} from '@metamask/transaction-controller';\nimport type { TransactionMeta } from '@metamask/transaction-controller';\nimport type { CaipAssetType, Hex } from '@metamask/utils';\nimport { BigNumber } from 'bignumber.js';\n\nimport type { BridgeHistoryItem } from '../types.js';\nimport { calcActualGasUsed } from './gas.js';\nimport {\n getActualBridgeReceivedAmount,\n getActualSwapReceivedAmount,\n} from './swap-received-amount.js';\n\nexport const getTxStatusesFromHistory = ({\n status,\n hasApprovalTx,\n approvalTxId,\n quote,\n}: BridgeHistoryItem): TxStatusData => {\n const source_transaction = status.srcChain.txHash\n ? StatusTypes.COMPLETE\n : StatusTypes.PENDING;\n const destination_transaction = status.destChain?.txHash\n ? status.status\n : StatusTypes.PENDING;\n\n const hexChainId = formatChainIdToHex(quote.srcChainId);\n const isEthUsdtTx = isEthUsdt(hexChainId, quote.srcAsset.address);\n const allowance_reset_transaction = status.srcChain.txHash\n ? StatusTypes.COMPLETE\n : undefined;\n const approval_transaction = status.srcChain.txHash\n ? StatusTypes.COMPLETE\n : StatusTypes.PENDING;\n\n return {\n allowance_reset_transaction: isEthUsdtTx\n ? allowance_reset_transaction\n : undefined,\n approval_transaction:\n hasApprovalTx || approvalTxId ? approval_transaction : undefined,\n source_transaction,\n destination_transaction:\n status.status === StatusTypes.FAILED\n ? StatusTypes.FAILED\n : destination_transaction,\n };\n};\n\n/**\n * Calculate the properties for a finalized transaction event based on the txHistory\n * and txMeta\n *\n * @param historyItem - The bridge history item\n * @param txMeta - The transaction meta from the TransactionController\n * @param approvalTxMeta - The approval transaction meta from the TransactionController\n * @returns The properties for the finalized transaction\n */\nexport const getFinalizedTxProperties = (\n historyItem: BridgeHistoryItem,\n txMeta?: TransactionMeta,\n approvalTxMeta?: TransactionMeta,\n) => {\n const startTime =\n approvalTxMeta?.submittedTime ??\n txMeta?.submittedTime ??\n historyItem.startTime;\n const completionTime =\n txMeta?.type === TransactionType.swap\n ? txMeta?.time\n : historyItem.completionTime;\n\n const actualGas = calcActualGasUsed(\n historyItem,\n txMeta?.txReceipt,\n approvalTxMeta?.txReceipt,\n );\n\n const actualReturn =\n txMeta?.type === TransactionType.swap\n ? getActualSwapReceivedAmount(historyItem, actualGas, txMeta)\n : getActualBridgeReceivedAmount(historyItem);\n\n const quotedVsUsedGasRatio =\n historyItem.pricingData?.quotedGasAmount && actualGas?.amount\n ? new BigNumber(historyItem.pricingData.quotedGasAmount)\n .multipliedBy(new BigNumber(10).pow(18))\n .div(actualGas.amount)\n .toNumber()\n : 0;\n\n const quoteVsExecutionRatio =\n historyItem.pricingData?.quotedReturnInUsd && actualReturn?.usd\n ? new BigNumber(historyItem.pricingData.quotedReturnInUsd)\n .div(actualReturn.usd)\n .toNumber()\n : 0;\n\n return {\n actual_time_minutes:\n completionTime && startTime ? (completionTime - startTime) / 60000 : 0,\n usd_actual_return: Number(actualReturn?.usd ?? 0),\n usd_actual_gas: actualGas?.usd ?? 0,\n quote_vs_execution_ratio: quoteVsExecutionRatio,\n quoted_vs_used_gas_ratio: quotedVsUsedGasRatio,\n };\n};\n\nexport const getRequestParamFromHistory = (\n historyItem: BridgeHistoryItem,\n): RequestParams => {\n return {\n chain_id_source: formatChainIdToCaip(historyItem.quote.srcChainId),\n token_symbol_source: historyItem.quote.srcAsset.symbol,\n token_address_source: historyItem.quote.srcAsset.assetId,\n chain_id_destination: formatChainIdToCaip(historyItem.quote.destChainId),\n token_symbol_destination: historyItem.quote.destAsset.symbol,\n token_address_destination: historyItem.quote.destAsset.assetId,\n token_security_type_destination:\n historyItem.tokenSecurityTypeDestination ?? null,\n };\n};\n\nexport const getTradeDataFromQuote = (\n quoteResponse: QuoteResponseV1 & QuoteMetadata,\n batchSellTrades?: BatchSellTradesResponse | null,\n): TradeData => {\n return {\n usd_quoted_gas: Number(quoteResponse.gasFee?.total?.usd ?? 0),\n gas_included:\n quoteResponse.quote.gasIncluded ?? batchSellTrades?.gasIncluded ?? false,\n gas_included_7702:\n quoteResponse.quote.gasIncluded7702 ??\n batchSellTrades?.gasIncluded7702 ??\n false,\n provider: formatProviderLabel(quoteResponse.quote),\n quoted_time_minutes: Number(\n quoteResponse.estimatedProcessingTimeInSeconds / 60,\n ),\n usd_quoted_return: Number(quoteResponse?.adjustedReturn?.usd ?? 0),\n };\n};\n\nexport const getPriceImpactFromQuote = (\n quote: QuoteResponseV1['quote'],\n): Pick<QuoteFetchData, 'price_impact'> => {\n return { price_impact: Number(quote.priceData?.priceImpact ?? '0') };\n};\n\n/**\n * Before the tx is confirmed, its data is not available in txHistory\n * The quote is used to populate event properties before confirmation\n *\n * @param quoteResponse - The quote response\n * @param isStxEnabled - Whether smart transactions are enabled on the client, for example the getSmartTransactionsEnabled selector value from the extension\n * @param accountHardwareType - The hardware wallet type used to submit the tx, or null if not a hardware wallet\n * @param location - The entry point from which the user initiated the swap or bridge (e.g. Main View, Token View, Trending Explore)\n * @param abTests - Legacy A/B test context for `ab_tests` (backward compatibility)\n * @param activeAbTests - New A/B test context for `active_ab_tests` (migration target)\n * @param tokenSecurityTypeDestination - The security classification of the destination token, supplied by the client (e.g. from token security/scanning data). Pass `null` when no security data is available.\n * @param batchSellTrades - The batch sell trades response\n * @param batchId - The batch ID of the transaction batch.\n * @param quotesReceivedContext - The client context captured when quotes were received.\n * @returns The properties for the pre-confirmation event\n */\nexport const getPreConfirmationPropertiesFromQuote = (\n quoteResponse: QuoteResponseV1 & QuoteMetadata,\n isStxEnabled: boolean,\n accountHardwareType: AccountHardwareType,\n location?: MetaMetricsSwapsEventSource,\n abTests?: Record<string, string>,\n activeAbTests?: { key: string; value: string }[],\n tokenSecurityTypeDestination?: string | null,\n batchSellTrades?: BatchSellTradesResponse | null,\n batchId?: Hex,\n quotesReceivedContext?: RequiredEventContextFromClient[UnifiedSwapBridgeEventName.QuotesReceived],\n) => {\n const { quote } = quoteResponse;\n return {\n ...getPriceImpactFromQuote(quote),\n ...getTradeDataFromQuote(quoteResponse, batchSellTrades),\n chain_id_source: formatChainIdToCaip(quote.srcChainId),\n token_symbol_source: quote.srcAsset.symbol,\n token_address_source: quote.srcAsset.assetId,\n chain_id_destination: formatChainIdToCaip(quote.destChainId),\n token_symbol_destination: quote.destAsset.symbol,\n token_address_destination: quote.destAsset.assetId,\n token_security_type_destination: tokenSecurityTypeDestination ?? null,\n account_hardware_type: accountHardwareType,\n is_hardware_wallet: accountHardwareType !== null,\n swap_type: getSwapType(\n quoteResponse.quote.srcChainId,\n quoteResponse.quote.destChainId,\n ),\n usd_amount_source: Number(quoteResponse?.sentAmount?.usd ?? 0),\n stx_enabled: isStxEnabled,\n action_type: MetricsActionType.SWAPBRIDGE_V1,\n slippage_limit:\n quotesReceivedContext?.slippage_limit ?? quote.slippage ?? 0,\n custom_slippage: quotesReceivedContext?.custom_slippage ?? false,\n location,\n ...(abTests &&\n Object.keys(abTests).length > 0 && {\n ab_tests: abTests,\n }),\n ...(activeAbTests &&\n activeAbTests.length > 0 && {\n active_ab_tests: activeAbTests,\n }),\n ...(batchId ? { batch_id: batchId } : {}),\n feature_id: quoteResponse.featureId ?? FeatureId.UNIFIED_SWAP_BRIDGE,\n };\n};\n\nexport const getTradeDataFromHistory = (\n historyItem: BridgeHistoryItem,\n): TradeData => {\n return {\n usd_quoted_gas: Number(historyItem.pricingData?.quotedGasInUsd ?? 0),\n gas_included: historyItem.quote.gasIncluded ?? false,\n gas_included_7702: historyItem.quote.gasIncluded7702 ?? false,\n provider: formatProviderLabel(historyItem.quote),\n quoted_time_minutes: Number(\n historyItem.estimatedProcessingTimeInSeconds / 60,\n ),\n usd_quoted_return: Number(historyItem.pricingData?.quotedReturnInUsd ?? 0),\n };\n};\n\nexport const getRequestMetadataFromHistory = (\n historyItem: BridgeHistoryItem,\n account?: AccountsControllerState['internalAccounts']['accounts'][string],\n): RequestMetadata => {\n const {\n quote,\n slippagePercentage,\n isStxEnabled,\n customSlippage,\n batchSellData,\n featureId,\n } = historyItem;\n const accountHardwareType = getAccountHardwareType(account);\n const isBatchSell =\n Boolean(batchSellData) || featureId === FeatureId.BATCH_SELL;\n const isUnifiedSwapBridge =\n featureId === undefined || featureId === FeatureId.UNIFIED_SWAP_BRIDGE;\n let inferredCustomSlippage = false;\n if (isBatchSell) {\n inferredCustomSlippage = isCustomSlippage(slippagePercentage ?? 0);\n } else if (!isUnifiedSwapBridge) {\n inferredCustomSlippage = isCustomSlippage(slippagePercentage);\n }\n\n return {\n slippage_limit: slippagePercentage ?? 0,\n custom_slippage: customSlippage ?? inferredCustomSlippage,\n usd_amount_source: Number(historyItem.pricingData?.amountSentInUsd ?? 0),\n swap_type: getSwapType(quote.srcChainId, quote.destChainId),\n account_hardware_type: accountHardwareType,\n is_hardware_wallet: accountHardwareType !== null,\n stx_enabled: isStxEnabled ?? false,\n security_warnings: [],\n };\n};\n\n/**\n * Get the properties for a swap transaction that is not in the txHistory\n *\n * @param transactionMeta - The transaction meta\n * @param account - The account that submitted the transaction\n * @returns The properties for the swap transaction\n */\nexport const getEVMTxPropertiesFromTransactionMeta = (\n transactionMeta: TransactionMeta,\n account?: AccountsControllerState['internalAccounts']['accounts'][string],\n) => {\n const accountHardwareType = getAccountHardwareType(account);\n\n return {\n source_transaction: [\n TransactionStatus.failed,\n TransactionStatus.dropped,\n TransactionStatus.rejected,\n ].includes(transactionMeta.status)\n ? StatusTypes.FAILED\n : StatusTypes.COMPLETE,\n error_message: [\n `Transaction ${transactionMeta.status}`,\n transactionMeta.error?.message,\n ]\n .filter(Boolean)\n .join('. '),\n chain_id_source: formatChainIdToCaip(transactionMeta.chainId),\n chain_id_destination: formatChainIdToCaip(transactionMeta.chainId),\n token_symbol_source: transactionMeta.sourceTokenSymbol ?? '',\n token_symbol_destination: transactionMeta.destinationTokenSymbol ?? '',\n usd_amount_source: 0,\n slippage_limit: 0,\n stx_enabled: false,\n token_address_source:\n formatAddressToAssetId(\n transactionMeta.sourceTokenAddress ?? '',\n transactionMeta.chainId,\n ) ?? ('' as CaipAssetType),\n token_address_destination:\n formatAddressToAssetId(\n transactionMeta.destinationTokenAddress ?? '',\n transactionMeta.chainId,\n ) ?? ('' as CaipAssetType),\n token_security_type_destination: null,\n custom_slippage: false,\n account_hardware_type: accountHardwareType,\n is_hardware_wallet: accountHardwareType !== null,\n swap_type:\n transactionMeta.type &&\n [TransactionType.swap, TransactionType.swapApproval].includes(\n transactionMeta.type,\n )\n ? MetricsSwapType.SINGLE\n : MetricsSwapType.CROSSCHAIN,\n security_warnings: [],\n price_impact: 0,\n usd_quoted_gas: 0,\n gas_included: false,\n gas_included_7702: false,\n quoted_time_minutes: 0,\n usd_quoted_return: 0,\n provider: '' as `${string}_${string}`,\n actual_time_minutes: 0,\n quote_vs_execution_ratio: 0,\n quoted_vs_used_gas_ratio: 0,\n usd_actual_return: 0,\n usd_actual_gas: 0,\n action_type: MetricsActionType.SWAPBRIDGE_V1,\n ...(transactionMeta.batchId ? { batch_id: transactionMeta.batchId } : {}),\n };\n};\n\n/**\n * Classify a thrown value from submit (sign/broadcast) catch paths.\n *\n * @param error - The thrown value from submit.\n * @returns The Mixpanel `error_code`.\n */\nexport const getSubmitErrorCode = (error: unknown): SwapBridgeErrorCode => {\n if (error === undefined || error === null) {\n return SwapBridgeErrorCode.MissingErrorObject;\n }\n if (error instanceof Error) {\n return SwapBridgeErrorCode.Unknown;\n }\n return SwapBridgeErrorCode.NonErrorRejection;\n};\n\n/**\n * @param sourceHash - Source tx hash if known at emit time.\n * @param destinationHash - Destination tx hash if known at emit time.\n * @returns Boolean hash-presence properties.\n */\nexport const getHashPresenceProperties = (\n sourceHash?: string | null,\n destinationHash?: string | null,\n): HashPresenceProperties => {\n return {\n source_hash_present: Boolean(sourceHash),\n destination_hash_present: Boolean(destinationHash),\n };\n};\n\n/**\n * Prefer destination_execution over source_execution over poll.\n *\n * @param hashPresence - Hash presence at emit time.\n * @returns The Mixpanel `failure_phase` for a status/polling Failed event.\n */\nexport const getStatusFailurePhase = (\n hashPresence: HashPresenceProperties,\n): FailurePhase => {\n if (hashPresence.destination_hash_present) {\n return FailurePhase.DestinationExecution;\n }\n if (hashPresence.source_hash_present) {\n return FailurePhase.SourceExecution;\n }\n return FailurePhase.Poll;\n};\n\n/**\n * Telemetry for Failed events emitted from the submit catch (no tx hash yet).\n *\n * @param error - The thrown value from submit.\n * @returns Phase, error code, and hash-presence flags.\n */\nexport const getSubmitFailureTelemetry = (\n error: unknown,\n): FailureTelemetryProperties => {\n return {\n failure_phase: FailurePhase.Broadcast,\n error_code: getSubmitErrorCode(error),\n source_hash_present: false,\n destination_hash_present: false,\n };\n};\n\n/**\n * Telemetry for Failed events derived from a status poll.\n *\n * @param sourceHash - Source tx hash if known.\n * @param destinationHash - Destination tx hash if known.\n * @returns Phase, error code, and hash-presence flags.\n */\nexport const getStatusFailureTelemetry = (\n sourceHash?: string | null,\n destinationHash?: string | null,\n): FailureTelemetryProperties => {\n const hashPresence = getHashPresenceProperties(sourceHash, destinationHash);\n return {\n ...hashPresence,\n failure_phase: getStatusFailurePhase(hashPresence),\n error_code: SwapBridgeErrorCode.StatusFailedWithoutReason,\n };\n};\n"]}
|
package/dist/utils/metrics.d.cts
CHANGED
|
@@ -4,53 +4,6 @@ import type { AccountHardwareType, QuoteFetchData, QuoteMetadata, QuoteResponseV
|
|
|
4
4
|
import type { TransactionMeta } from "@metamask/transaction-controller";
|
|
5
5
|
import type { Hex } from "@metamask/utils";
|
|
6
6
|
import type { BridgeHistoryItem } from "../types.cjs";
|
|
7
|
-
/**
|
|
8
|
-
* Classify a thrown value from submit (sign/broadcast) catch paths.
|
|
9
|
-
*
|
|
10
|
-
* @param error - The thrown value from submit.
|
|
11
|
-
* @returns The Mixpanel `error_code`.
|
|
12
|
-
*/
|
|
13
|
-
export declare const getSubmitErrorCode: (error: unknown) => SwapBridgeErrorCode;
|
|
14
|
-
/**
|
|
15
|
-
* @param sourceHash - Source tx hash if known at emit time.
|
|
16
|
-
* @param destinationHash - Destination tx hash if known at emit time.
|
|
17
|
-
* @returns Boolean hash-presence properties.
|
|
18
|
-
*/
|
|
19
|
-
export declare const getHashPresenceProperties: (sourceHash?: string | null, destinationHash?: string | null) => HashPresenceProperties;
|
|
20
|
-
/**
|
|
21
|
-
* Prefer destination_execution over source_execution over poll.
|
|
22
|
-
*
|
|
23
|
-
* @param hashPresence - Hash presence at emit time.
|
|
24
|
-
* @returns The Mixpanel `failure_phase` for a status/polling Failed event.
|
|
25
|
-
*/
|
|
26
|
-
export declare const getStatusFailurePhase: (hashPresence: HashPresenceProperties) => FailurePhase;
|
|
27
|
-
/**
|
|
28
|
-
* Align `failure_phase` with combined hash presence without turning a
|
|
29
|
-
* no-hash `broadcast` failure into `poll`.
|
|
30
|
-
*
|
|
31
|
-
* @param phase - Phase from the emitting path.
|
|
32
|
-
* @param hashPresence - Combined history + caller hash flags.
|
|
33
|
-
* @returns The Mixpanel `failure_phase`.
|
|
34
|
-
*/
|
|
35
|
-
export declare const promoteFailurePhase: (phase: FailurePhase, hashPresence: HashPresenceProperties) => FailurePhase;
|
|
36
|
-
/**
|
|
37
|
-
* Mixpanel properties for Failed events in the `broadcast` phase (no tx hash yet).
|
|
38
|
-
*
|
|
39
|
-
* @param error - The thrown value from the submit/broadcast catch.
|
|
40
|
-
* @returns Phase, error code, and hash-presence flags.
|
|
41
|
-
*/
|
|
42
|
-
export declare const getBroadcastFailureProperties: (error: unknown) => FailureTelemetryProperties;
|
|
43
|
-
/**
|
|
44
|
-
* Mixpanel properties for Failed events derived from history hashes.
|
|
45
|
-
*
|
|
46
|
-
* Used for poll Failed and TransactionController Failed once a history
|
|
47
|
-
* item exists. Not poll-only.
|
|
48
|
-
*
|
|
49
|
-
* @param sourceHash - Source tx hash from history if known.
|
|
50
|
-
* @param destinationHash - Destination tx hash from history if known.
|
|
51
|
-
* @returns Phase, error code, and hash-presence flags.
|
|
52
|
-
*/
|
|
53
|
-
export declare const getFailurePropertiesFromHistory: (sourceHash?: string | null, destinationHash?: string | null) => FailureTelemetryProperties;
|
|
54
7
|
export declare const getTxStatusesFromHistory: ({ status, hasApprovalTx, approvalTxId, quote, }: BridgeHistoryItem) => TxStatusData;
|
|
55
8
|
/**
|
|
56
9
|
* Calculate the properties for a finalized transaction event based on the txHistory
|
|
@@ -132,10 +85,6 @@ export declare const getRequestMetadataFromHistory: (historyItem: BridgeHistoryI
|
|
|
132
85
|
* @returns The properties for the swap transaction
|
|
133
86
|
*/
|
|
134
87
|
export declare const getEVMTxPropertiesFromTransactionMeta: (transactionMeta: TransactionMeta, account?: AccountsControllerState['internalAccounts']['accounts'][string]) => {
|
|
135
|
-
failure_phase: FailurePhase;
|
|
136
|
-
error_code: SwapBridgeErrorCode;
|
|
137
|
-
source_hash_present: boolean;
|
|
138
|
-
destination_hash_present: boolean;
|
|
139
88
|
batch_id?: `0x${string}` | undefined;
|
|
140
89
|
source_transaction: StatusTypes;
|
|
141
90
|
error_message: string;
|
|
@@ -168,4 +117,39 @@ export declare const getEVMTxPropertiesFromTransactionMeta: (transactionMeta: Tr
|
|
|
168
117
|
usd_actual_gas: number;
|
|
169
118
|
action_type: MetricsActionType;
|
|
170
119
|
};
|
|
120
|
+
/**
|
|
121
|
+
* Classify a thrown value from submit (sign/broadcast) catch paths.
|
|
122
|
+
*
|
|
123
|
+
* @param error - The thrown value from submit.
|
|
124
|
+
* @returns The Mixpanel `error_code`.
|
|
125
|
+
*/
|
|
126
|
+
export declare const getSubmitErrorCode: (error: unknown) => SwapBridgeErrorCode;
|
|
127
|
+
/**
|
|
128
|
+
* @param sourceHash - Source tx hash if known at emit time.
|
|
129
|
+
* @param destinationHash - Destination tx hash if known at emit time.
|
|
130
|
+
* @returns Boolean hash-presence properties.
|
|
131
|
+
*/
|
|
132
|
+
export declare const getHashPresenceProperties: (sourceHash?: string | null, destinationHash?: string | null) => HashPresenceProperties;
|
|
133
|
+
/**
|
|
134
|
+
* Prefer destination_execution over source_execution over poll.
|
|
135
|
+
*
|
|
136
|
+
* @param hashPresence - Hash presence at emit time.
|
|
137
|
+
* @returns The Mixpanel `failure_phase` for a status/polling Failed event.
|
|
138
|
+
*/
|
|
139
|
+
export declare const getStatusFailurePhase: (hashPresence: HashPresenceProperties) => FailurePhase;
|
|
140
|
+
/**
|
|
141
|
+
* Telemetry for Failed events emitted from the submit catch (no tx hash yet).
|
|
142
|
+
*
|
|
143
|
+
* @param error - The thrown value from submit.
|
|
144
|
+
* @returns Phase, error code, and hash-presence flags.
|
|
145
|
+
*/
|
|
146
|
+
export declare const getSubmitFailureTelemetry: (error: unknown) => FailureTelemetryProperties;
|
|
147
|
+
/**
|
|
148
|
+
* Telemetry for Failed events derived from a status poll.
|
|
149
|
+
*
|
|
150
|
+
* @param sourceHash - Source tx hash if known.
|
|
151
|
+
* @param destinationHash - Destination tx hash if known.
|
|
152
|
+
* @returns Phase, error code, and hash-presence flags.
|
|
153
|
+
*/
|
|
154
|
+
export declare const getStatusFailureTelemetry: (sourceHash?: string | null, destinationHash?: string | null) => FailureTelemetryProperties;
|
|
171
155
|
//# sourceMappingURL=metrics.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.cts","sourceRoot":"","sources":["../../src/utils/metrics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,uBAAuB,EAAE,sCAAsC;AAC7E,OAAO,EACL,WAAW,EASX,iBAAiB,EAC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ClB,sBAAsB,KACnC,YAQF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,UAC7B,OAAO,KACb,0BAOF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,gBACvB,MAAM,GAAG,IAAI,oBACR,MAAM,GAAG,IAAI,KAC9B,0BAOF,CAAC"}
|
package/dist/utils/metrics.d.mts
CHANGED
|
@@ -4,53 +4,6 @@ import type { AccountHardwareType, QuoteFetchData, QuoteMetadata, QuoteResponseV
|
|
|
4
4
|
import type { TransactionMeta } from "@metamask/transaction-controller";
|
|
5
5
|
import type { Hex } from "@metamask/utils";
|
|
6
6
|
import type { BridgeHistoryItem } from "../types.mjs";
|
|
7
|
-
/**
|
|
8
|
-
* Classify a thrown value from submit (sign/broadcast) catch paths.
|
|
9
|
-
*
|
|
10
|
-
* @param error - The thrown value from submit.
|
|
11
|
-
* @returns The Mixpanel `error_code`.
|
|
12
|
-
*/
|
|
13
|
-
export declare const getSubmitErrorCode: (error: unknown) => SwapBridgeErrorCode;
|
|
14
|
-
/**
|
|
15
|
-
* @param sourceHash - Source tx hash if known at emit time.
|
|
16
|
-
* @param destinationHash - Destination tx hash if known at emit time.
|
|
17
|
-
* @returns Boolean hash-presence properties.
|
|
18
|
-
*/
|
|
19
|
-
export declare const getHashPresenceProperties: (sourceHash?: string | null, destinationHash?: string | null) => HashPresenceProperties;
|
|
20
|
-
/**
|
|
21
|
-
* Prefer destination_execution over source_execution over poll.
|
|
22
|
-
*
|
|
23
|
-
* @param hashPresence - Hash presence at emit time.
|
|
24
|
-
* @returns The Mixpanel `failure_phase` for a status/polling Failed event.
|
|
25
|
-
*/
|
|
26
|
-
export declare const getStatusFailurePhase: (hashPresence: HashPresenceProperties) => FailurePhase;
|
|
27
|
-
/**
|
|
28
|
-
* Align `failure_phase` with combined hash presence without turning a
|
|
29
|
-
* no-hash `broadcast` failure into `poll`.
|
|
30
|
-
*
|
|
31
|
-
* @param phase - Phase from the emitting path.
|
|
32
|
-
* @param hashPresence - Combined history + caller hash flags.
|
|
33
|
-
* @returns The Mixpanel `failure_phase`.
|
|
34
|
-
*/
|
|
35
|
-
export declare const promoteFailurePhase: (phase: FailurePhase, hashPresence: HashPresenceProperties) => FailurePhase;
|
|
36
|
-
/**
|
|
37
|
-
* Mixpanel properties for Failed events in the `broadcast` phase (no tx hash yet).
|
|
38
|
-
*
|
|
39
|
-
* @param error - The thrown value from the submit/broadcast catch.
|
|
40
|
-
* @returns Phase, error code, and hash-presence flags.
|
|
41
|
-
*/
|
|
42
|
-
export declare const getBroadcastFailureProperties: (error: unknown) => FailureTelemetryProperties;
|
|
43
|
-
/**
|
|
44
|
-
* Mixpanel properties for Failed events derived from history hashes.
|
|
45
|
-
*
|
|
46
|
-
* Used for poll Failed and TransactionController Failed once a history
|
|
47
|
-
* item exists. Not poll-only.
|
|
48
|
-
*
|
|
49
|
-
* @param sourceHash - Source tx hash from history if known.
|
|
50
|
-
* @param destinationHash - Destination tx hash from history if known.
|
|
51
|
-
* @returns Phase, error code, and hash-presence flags.
|
|
52
|
-
*/
|
|
53
|
-
export declare const getFailurePropertiesFromHistory: (sourceHash?: string | null, destinationHash?: string | null) => FailureTelemetryProperties;
|
|
54
7
|
export declare const getTxStatusesFromHistory: ({ status, hasApprovalTx, approvalTxId, quote, }: BridgeHistoryItem) => TxStatusData;
|
|
55
8
|
/**
|
|
56
9
|
* Calculate the properties for a finalized transaction event based on the txHistory
|
|
@@ -132,10 +85,6 @@ export declare const getRequestMetadataFromHistory: (historyItem: BridgeHistoryI
|
|
|
132
85
|
* @returns The properties for the swap transaction
|
|
133
86
|
*/
|
|
134
87
|
export declare const getEVMTxPropertiesFromTransactionMeta: (transactionMeta: TransactionMeta, account?: AccountsControllerState['internalAccounts']['accounts'][string]) => {
|
|
135
|
-
failure_phase: FailurePhase;
|
|
136
|
-
error_code: SwapBridgeErrorCode;
|
|
137
|
-
source_hash_present: boolean;
|
|
138
|
-
destination_hash_present: boolean;
|
|
139
88
|
batch_id?: `0x${string}` | undefined;
|
|
140
89
|
source_transaction: StatusTypes;
|
|
141
90
|
error_message: string;
|
|
@@ -168,4 +117,39 @@ export declare const getEVMTxPropertiesFromTransactionMeta: (transactionMeta: Tr
|
|
|
168
117
|
usd_actual_gas: number;
|
|
169
118
|
action_type: MetricsActionType;
|
|
170
119
|
};
|
|
120
|
+
/**
|
|
121
|
+
* Classify a thrown value from submit (sign/broadcast) catch paths.
|
|
122
|
+
*
|
|
123
|
+
* @param error - The thrown value from submit.
|
|
124
|
+
* @returns The Mixpanel `error_code`.
|
|
125
|
+
*/
|
|
126
|
+
export declare const getSubmitErrorCode: (error: unknown) => SwapBridgeErrorCode;
|
|
127
|
+
/**
|
|
128
|
+
* @param sourceHash - Source tx hash if known at emit time.
|
|
129
|
+
* @param destinationHash - Destination tx hash if known at emit time.
|
|
130
|
+
* @returns Boolean hash-presence properties.
|
|
131
|
+
*/
|
|
132
|
+
export declare const getHashPresenceProperties: (sourceHash?: string | null, destinationHash?: string | null) => HashPresenceProperties;
|
|
133
|
+
/**
|
|
134
|
+
* Prefer destination_execution over source_execution over poll.
|
|
135
|
+
*
|
|
136
|
+
* @param hashPresence - Hash presence at emit time.
|
|
137
|
+
* @returns The Mixpanel `failure_phase` for a status/polling Failed event.
|
|
138
|
+
*/
|
|
139
|
+
export declare const getStatusFailurePhase: (hashPresence: HashPresenceProperties) => FailurePhase;
|
|
140
|
+
/**
|
|
141
|
+
* Telemetry for Failed events emitted from the submit catch (no tx hash yet).
|
|
142
|
+
*
|
|
143
|
+
* @param error - The thrown value from submit.
|
|
144
|
+
* @returns Phase, error code, and hash-presence flags.
|
|
145
|
+
*/
|
|
146
|
+
export declare const getSubmitFailureTelemetry: (error: unknown) => FailureTelemetryProperties;
|
|
147
|
+
/**
|
|
148
|
+
* Telemetry for Failed events derived from a status poll.
|
|
149
|
+
*
|
|
150
|
+
* @param sourceHash - Source tx hash if known.
|
|
151
|
+
* @param destinationHash - Destination tx hash if known.
|
|
152
|
+
* @returns Phase, error code, and hash-presence flags.
|
|
153
|
+
*/
|
|
154
|
+
export declare const getStatusFailureTelemetry: (sourceHash?: string | null, destinationHash?: string | null) => FailureTelemetryProperties;
|
|
171
155
|
//# sourceMappingURL=metrics.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.d.mts","sourceRoot":"","sources":["../../src/utils/metrics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,uBAAuB,EAAE,sCAAsC;AAC7E,OAAO,EACL,WAAW,EASX,iBAAiB,EACjB,eAAe,EACf,2BAA2B,EAC3B,SAAS,EACT,0BAA0B,EAC1B,YAAY,EACZ,mBAAmB,EACpB,oCAAoC;AACrC,OAAO,KAAK,EACV,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,eAAe,EACf,YAAY,EACZ,aAAa,EACb,SAAS,EACT,eAAe,EACf,uBAAuB,EACvB,8BAA8B,EAC9B,sBAAsB,EACtB,0BAA0B,EAC3B,oCAAoC;AAKrC,OAAO,KAAK,EAAE,eAAe,EAAE,yCAAyC;AACxE,OAAO,KAAK,EAAiB,GAAG,EAAE,wBAAwB;AAG1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAoB;AAOrD
|
|
1
|
+
{"version":3,"file":"metrics.d.mts","sourceRoot":"","sources":["../../src/utils/metrics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,uBAAuB,EAAE,sCAAsC;AAC7E,OAAO,EACL,WAAW,EASX,iBAAiB,EACjB,eAAe,EACf,2BAA2B,EAC3B,SAAS,EACT,0BAA0B,EAC1B,YAAY,EACZ,mBAAmB,EACpB,oCAAoC;AACrC,OAAO,KAAK,EACV,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,eAAe,EACf,YAAY,EACZ,aAAa,EACb,SAAS,EACT,eAAe,EACf,uBAAuB,EACvB,8BAA8B,EAC9B,sBAAsB,EACtB,0BAA0B,EAC3B,oCAAoC;AAKrC,OAAO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