Skip to content

Commit

Permalink
feat: extend reporting for 'canceled' event in sendform
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-sanderson committed Feb 10, 2025
1 parent ecd6561 commit 5a88230
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/suite-analytics/src/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export type SuiteAnalyticsEvent =
| {
type: EventType.TransactionCreated;
payload: {
action: 'sent' | 'copied' | 'downloaded' | 'replaced';
action: 'sent' | 'copied' | 'downloaded' | 'replaced' | 'canceled';
symbol: string;
tokens: string;
outputsCount: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ export const TransactionReviewModalContent = ({

const isBroadcastEnabled = options.includes('broadcast');

const reportTransactionCreatedEvent = (action: 'sent' | 'copied' | 'downloaded' | 'replaced') =>
const reportTransactionCreatedEvent = (
action: 'sent' | 'copied' | 'downloaded' | 'replaced' | 'canceled',
) =>
analytics.report({
type: EventType.TransactionCreated,
payload: {
Expand Down Expand Up @@ -155,7 +157,10 @@ export const TransactionReviewModalContent = ({
}
if (decision) {
decision.resolve(true);
reportTransactionCreatedEvent(isBumpFeeRbfAction ? 'replaced' : 'sent');
reportTransactionCreatedEvent(
// eslint-disable-next-line no-nested-ternary
isBumpFeeRbfAction ? 'replaced' : isCancelRbfAction ? 'canceled' : 'sent',
);
}
};

Expand Down
14 changes: 8 additions & 6 deletions suite-common/wallet-core/src/send/sendFormThunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,14 @@ export const enhancePrecomposedTransactionThunk = createThunk<
if (formValues.rbfParams) {
(enhancedPrecomposedTransaction as PrecomposedTransactionFinalBumpFeeRbf).prevTxid =
formValues.rbfParams.txid;
(enhancedPrecomposedTransaction as PrecomposedTransactionFinalBumpFeeRbf).feeDifference =
new BigNumber(precomposedTransaction.fee)
.minus(formValues.rbfParams.baseFee)
.toFixed();
(enhancedPrecomposedTransaction as PrecomposedTransactionFinalBumpFeeRbf).useNativeRbf =
!!useNativeRbf;
(
enhancedPrecomposedTransaction as PrecomposedTransactionFinalBumpFeeRbf
).feeDifference = new BigNumber(precomposedTransaction.fee)
.minus(formValues.rbfParams.baseFee)
.toFixed();
(
enhancedPrecomposedTransaction as PrecomposedTransactionFinalBumpFeeRbf
).useNativeRbf = !!useNativeRbf;
(
enhancedPrecomposedTransaction as PrecomposedTransactionFinalBumpFeeRbf
).useDecreaseOutput = !!hasDecreasedOutput;
Expand Down
4 changes: 3 additions & 1 deletion suite-native/module-send/src/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export const selectTransactionReviewOutputs = (
const precomposedTx = selectSendPrecomposedTx(state);

const decreaseOutputId =
precomposedTx !== undefined && isRbfBumpFeeTransaction(precomposedTx) && precomposedTx.useNativeRbf
precomposedTx !== undefined &&
isRbfBumpFeeTransaction(precomposedTx) &&
precomposedTx.useNativeRbf
? precomposedForm?.setMaxOutputId
: undefined;

Expand Down

0 comments on commit 5a88230

Please sign in to comment.