-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: add estimated USD value to swap analytics events #4060
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
src/analytics/Properties.tsx
Outdated
@@ -1257,13 +1257,15 @@ interface SwapEventsProperties { | |||
fromTokenBalance: string | |||
swapExecuteTxId: string | |||
swapApproveTxId: string | |||
estimatedUsdValue?: number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Do you think it makes sense to include this field in the SwapQuoteEvent
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, probably. I was going to chat with you about clarifying some of the other fields (e.g., .usdValue
) before adding this one to SwapQuoteEvent
(and by implication swap_review_submit
).
src/swap/saga.ts
Outdated
@@ -162,6 +181,7 @@ export function* swapSubmitSaga(action: PayloadAction<SwapInfo>) { | |||
ValoraAnalytics.track(SwapEvents.swap_execute_success, { | |||
...defaultSwapExecuteProps, | |||
...timeMetrics, | |||
estimatedUsdValue, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think you can include this value in the defaultSwapExecuteProps
src/swap/saga.ts
Outdated
@@ -79,6 +94,10 @@ export function* swapSubmitSaga(action: PayloadAction<SwapInfo>) { | |||
? fromToken.balance.shiftedBy(fromToken.decimals).toString() | |||
: '' | |||
|
|||
const estimatedUsdValue = fromToken |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about having 2 fields, one for the estimated usd value for the selling token, and another for the buying token?
Something like:
const estimatedUsdValueSellingToken = calculateEstimatedUsdValue({ tokenInfo: fromToken, tokenAmount: sellAmount })
const estimatedUsdValueBuyingToken = calculateEstimatedUsdValue({ tokenInfo: toToken, tokenAmount: buyAmount })
In theory, fromToken
, toToken
, sellAmount
and buyAmount
will be defined. So I don't know if we need to check them.
If they aren't defined we will have errors in other parts as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Codecov Report
@@ Coverage Diff @@
## main #4060 +/- ##
==========================================
- Coverage 83.24% 83.23% -0.02%
==========================================
Files 718 718
Lines 26739 26752 +13
Branches 3634 3638 +4
==========================================
+ Hits 22259 22266 +7
- Misses 4417 4422 +5
- Partials 63 64 +1
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Test plan
Verify properties in analytics backends.