-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding TransactionTimeToConfirmation event for confirmations
- Loading branch information
Showing
7 changed files
with
132 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/background/services/wallet/utils/measureTransactionTime.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
enum TransactionTimeEvents { | ||
TRANSACTION_TIMED = 'transaction-timed', | ||
TRANSACTION_SUCCEEDED = 'transaction-succeeded', | ||
TRANSACTION_APPROVED = 'transaction-approved', | ||
} | ||
|
||
export const measureTransactionTime = (): { | ||
startMeasure: () => void; | ||
endMeasure: (callback: (duration: number) => void) => void; | ||
} => { | ||
const startMeasure = () => { | ||
performance.mark(TransactionTimeEvents.TRANSACTION_APPROVED); | ||
}; | ||
|
||
const endMeasure = (callback: (duration: number) => void) => { | ||
performance.mark(TransactionTimeEvents.TRANSACTION_SUCCEEDED); | ||
|
||
const measurement = performance.measure( | ||
TransactionTimeEvents.TRANSACTION_TIMED, | ||
TransactionTimeEvents.TRANSACTION_APPROVED, | ||
TransactionTimeEvents.TRANSACTION_SUCCEEDED | ||
); | ||
|
||
performance.clearMarks(TransactionTimeEvents.TRANSACTION_APPROVED); | ||
performance.clearMarks(TransactionTimeEvents.TRANSACTION_SUCCEEDED); | ||
performance.clearMarks(TransactionTimeEvents.TRANSACTION_TIMED); | ||
|
||
callback(measurement.duration); | ||
}; | ||
|
||
return { startMeasure, endMeasure }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters