aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/instant/src/components/buy_button.tsx6
-rw-r--r--packages/instant/src/util/analytics.ts31
2 files changed, 26 insertions, 11 deletions
diff --git a/packages/instant/src/components/buy_button.tsx b/packages/instant/src/components/buy_button.tsx
index 118e3c92f..eeb42d6fc 100644
--- a/packages/instant/src/components/buy_button.tsx
+++ b/packages/instant/src/components/buy_button.tsx
@@ -74,7 +74,6 @@ export class BuyButton extends React.Component<BuyButtonProps> {
takerAddress: accountAddress,
gasPrice: gasInfo.gasPriceInWei,
});
- analytics.trackBuyTxSubmitted(buyQuote, txHash);
} catch (e) {
if (e instanceof Error) {
if (e.message === AssetBuyerError.SignatureRequestDenied) {
@@ -93,16 +92,17 @@ export class BuyButton extends React.Component<BuyButtonProps> {
const expectedEndTimeUnix = startTimeUnix + gasInfo.estimatedTimeMs;
this.props.onBuyProcessing(buyQuote, txHash, startTimeUnix, expectedEndTimeUnix);
try {
+ analytics.trackBuyTxSubmitted(buyQuote, txHash, startTimeUnix, expectedEndTimeUnix);
await web3Wrapper.awaitTransactionSuccessAsync(txHash);
} catch (e) {
- analytics.trackBuyTxFailed(buyQuote, txHash);
if (e instanceof Error && e.message.startsWith(WEB_3_WRAPPER_TRANSACTION_FAILED_ERROR_MSG_PREFIX)) {
+ analytics.trackBuyTxFailed(buyQuote, txHash, startTimeUnix, expectedEndTimeUnix);
this.props.onBuyFailure(buyQuote, txHash);
return;
}
throw e;
}
- analytics.trackBuyTxSucceeded(buyQuote, txHash);
+ analytics.trackBuyTxSucceeded(buyQuote, txHash, startTimeUnix, expectedEndTimeUnix);
this.props.onBuySuccess(buyQuote, txHash);
};
}
diff --git a/packages/instant/src/util/analytics.ts b/packages/instant/src/util/analytics.ts
index 0fe7be705..283695ef8 100644
--- a/packages/instant/src/util/analytics.ts
+++ b/packages/instant/src/util/analytics.ts
@@ -47,7 +47,6 @@ function trackingEventFnWithPayload(eventName: EventNames): (eventProperties: Ev
}
const buyQuoteEventProperties = (buyQuote: BuyQuote) => {
- const assetData = buyQuote.assetData.toString();
const assetBuyAmount = buyQuote.assetBuyAmount.toString();
const assetEthAmount = buyQuote.worstCaseQuoteInfo.assetEthAmount.toString();
const feeEthAmount = buyQuote.worstCaseQuoteInfo.feeEthAmount.toString();
@@ -55,7 +54,6 @@ const buyQuoteEventProperties = (buyQuote: BuyQuote) => {
const feePercentage = !_.isUndefined(buyQuote.feePercentage) ? buyQuote.feePercentage.toString() : 0;
const hasFeeOrders = !_.isEmpty(buyQuote.feeOrders) ? 'true' : 'false';
return {
- assetData,
assetBuyAmount,
assetEthAmount,
feeEthAmount,
@@ -104,10 +102,27 @@ export const analytics = {
trackingEventFnWithPayload(EventNames.BUY_SIGNATURE_DENIED)(buyQuoteEventProperties(buyQuote)),
trackBuySimulationFailed: (buyQuote: BuyQuote) =>
trackingEventFnWithPayload(EventNames.BUY_SIMULATION_FAILED)(buyQuoteEventProperties(buyQuote)),
- trackBuyTxSubmitted: (buyQuote: BuyQuote, txHash: string) =>
- trackingEventFnWithPayload(EventNames.BUY_TX_SUBMITTED)({ ...buyQuoteEventProperties(buyQuote), txHash }),
- trackBuyTxSucceeded: (buyQuote: BuyQuote, txHash: string) =>
- trackingEventFnWithPayload(EventNames.BUY_TX_SUCCEEDED)({ ...buyQuoteEventProperties(buyQuote), txHash }),
- trackBuyTxFailed: (buyQuote: BuyQuote, txHash: string) =>
- trackingEventFnWithPayload(EventNames.BUY_TX_FAILED)({ ...buyQuoteEventProperties(buyQuote), txHash }),
+ trackBuyTxSubmitted: (buyQuote: BuyQuote, txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) =>
+ trackingEventFnWithPayload(EventNames.BUY_TX_SUBMITTED)({
+ ...buyQuoteEventProperties(buyQuote),
+ txHash,
+ startTimeUnix,
+ expectedEndTimeUnix,
+ }),
+ trackBuyTxSucceeded: (buyQuote: BuyQuote, txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) =>
+ trackingEventFnWithPayload(EventNames.BUY_TX_SUCCEEDED)({
+ ...buyQuoteEventProperties(buyQuote),
+ txHash,
+ startTimeUnix,
+ expectedEndTimeUnix,
+ actualEndTimeUnix: new Date().getTime(),
+ }),
+ trackBuyTxFailed: (buyQuote: BuyQuote, txHash: string, startTimeUnix: number, expectedEndTimeUnix: number) =>
+ trackingEventFnWithPayload(EventNames.BUY_TX_FAILED)({
+ ...buyQuoteEventProperties(buyQuote),
+ txHash,
+ startTimeUnix,
+ expectedEndTimeUnix,
+ actualEndTimeUnix: new Date().getTime(),
+ }),
};