@metamask-previews/bridge-controller 79.3.0-preview-bbf9454b2 → 79.3.0-preview-d23deb68f

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.
@@ -1,89 +0,0 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
- import { FailurePhase, SwapBridgeErrorCode } from "./constants.mjs";
3
- /**
4
- * Classify a thrown value for Quotes Error. Quote fetch always stays in the
5
- * `quote` phase; this only chooses `error_code`.
6
- *
7
- * @param error - The thrown value from quote fetch.
8
- * @returns The Mixpanel `error_code`.
9
- */
10
- export const getQuoteFetchErrorCode = (error) => {
11
- if (error === undefined || error === null) {
12
- return SwapBridgeErrorCode.MissingErrorObject;
13
- }
14
- if (error instanceof Error) {
15
- return SwapBridgeErrorCode.QuoteFetchFailed;
16
- }
17
- return SwapBridgeErrorCode.NonErrorRejection;
18
- };
19
- /**
20
- * Classify a thrown value from submit (sign/broadcast) catch paths.
21
- *
22
- * @param error - The thrown value from submit.
23
- * @returns The Mixpanel `error_code`.
24
- */
25
- export const getSubmitErrorCode = (error) => {
26
- if (error === undefined || error === null) {
27
- return SwapBridgeErrorCode.MissingErrorObject;
28
- }
29
- if (error instanceof Error) {
30
- return SwapBridgeErrorCode.Unknown;
31
- }
32
- return SwapBridgeErrorCode.NonErrorRejection;
33
- };
34
- /**
35
- * @param sourceHash - Source tx hash if known at emit time.
36
- * @param destinationHash - Destination tx hash if known at emit time.
37
- * @returns Boolean hash-presence properties.
38
- */
39
- export const getHashPresenceProperties = (sourceHash, destinationHash) => {
40
- return {
41
- source_hash_present: Boolean(sourceHash),
42
- destination_hash_present: Boolean(destinationHash),
43
- };
44
- };
45
- /**
46
- * Prefer destination_execution over source_execution over poll.
47
- *
48
- * @param hashPresence - Hash presence at emit time.
49
- * @returns The Mixpanel `failure_phase` for a status/polling Failed event.
50
- */
51
- export const getStatusFailurePhase = (hashPresence) => {
52
- if (hashPresence.destination_hash_present) {
53
- return FailurePhase.DestinationExecution;
54
- }
55
- if (hashPresence.source_hash_present) {
56
- return FailurePhase.SourceExecution;
57
- }
58
- return FailurePhase.Poll;
59
- };
60
- /**
61
- * Telemetry for Failed events emitted from the submit catch (no tx hash yet).
62
- *
63
- * @param error - The thrown value from submit.
64
- * @returns Phase, error code, and hash-presence flags.
65
- */
66
- export const getSubmitFailureTelemetry = (error) => {
67
- return {
68
- failure_phase: FailurePhase.Broadcast,
69
- error_code: getSubmitErrorCode(error),
70
- source_hash_present: false,
71
- destination_hash_present: false,
72
- };
73
- };
74
- /**
75
- * Telemetry for Failed events derived from a status poll.
76
- *
77
- * @param sourceHash - Source tx hash if known.
78
- * @param destinationHash - Destination tx hash if known.
79
- * @returns Phase, error code, and hash-presence flags.
80
- */
81
- export const getStatusFailureTelemetry = (sourceHash, destinationHash) => {
82
- const hashPresence = getHashPresenceProperties(sourceHash, destinationHash);
83
- return {
84
- ...hashPresence,
85
- failure_phase: getStatusFailurePhase(hashPresence),
86
- error_code: SwapBridgeErrorCode.StatusFailedWithoutReason,
87
- };
88
- };
89
- //# sourceMappingURL=failure-telemetry.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"failure-telemetry.mjs","sourceRoot":"","sources":["../../../src/utils/metrics/failure-telemetry.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,wBAAuB;AAYnE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAc,EAAuB,EAAE;IAC5E,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC1C,OAAO,mBAAmB,CAAC,kBAAkB,CAAC;IAChD,CAAC;IACD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,mBAAmB,CAAC,gBAAgB,CAAC;IAC9C,CAAC;IACD,OAAO,mBAAmB,CAAC,iBAAiB,CAAC;AAC/C,CAAC,CAAC;AAEF;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EAAE;IAC9B,MAAM,YAAY,GAAG,yBAAyB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IAC5E,OAAO;QACL,GAAG,YAAY;QACf,aAAa,EAAE,qBAAqB,CAAC,YAAY,CAAC;QAClD,UAAU,EAAE,mBAAmB,CAAC,yBAAyB;KAC1D,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport { FailurePhase, SwapBridgeErrorCode } from './constants.js';\n\nexport type HashPresenceProperties = {\n source_hash_present: boolean;\n destination_hash_present: boolean;\n};\n\nexport type FailureTelemetryProperties = HashPresenceProperties & {\n failure_phase: FailurePhase;\n error_code: SwapBridgeErrorCode;\n};\n\n/**\n * Classify a thrown value for Quotes Error. Quote fetch always stays in the\n * `quote` phase; this only chooses `error_code`.\n *\n * @param error - The thrown value from quote fetch.\n * @returns The Mixpanel `error_code`.\n */\nexport const getQuoteFetchErrorCode = (error: unknown): SwapBridgeErrorCode => {\n if (error === undefined || error === null) {\n return SwapBridgeErrorCode.MissingErrorObject;\n }\n if (error instanceof Error) {\n return SwapBridgeErrorCode.QuoteFetchFailed;\n }\n return SwapBridgeErrorCode.NonErrorRejection;\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"]}