-
Notifications
You must be signed in to change notification settings - Fork 44
Add filled form event #767
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
Add filled form event #767
Conversation
|
📦 build.zip [updated at Apr 25, 4:28:02 PM UTC] |
| emitter.on('finalQuoteReceived', ({ quote, formView, scope }) => { | ||
| const params = createParams({ | ||
| request_name: 'swap_form_filled_out', | ||
| screen_name: scope === 'Swap' ? 'Swap' : 'Bridge', |
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.
I think, we can do
invariant(scope === 'Swap' || scope === 'Bridge')
And then
screen_name: scope,
client_scope: scope,
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.
thanks, yes, makes sense :) updated ✅
src/background/events.ts
Outdated
|
|
||
| export interface FinalQuoteReceivedParams { | ||
| quote: Quote; | ||
| formView: FormViewForAnalytics; |
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.
Because we went away from formView concept, we can rename this to formState?
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.
updated ✅
| quantity: string | null; | ||
| } | ||
|
|
||
| function assetQuantityToValue( |
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.
We can reuse the same function from src/shared/analytics/shared/addressActionToAnalytics.ts
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.
Ah I see. It is slightly different. Well, then it is on you to decide what to so with it. May be it is ok to keep it this way
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.
updated ✅
| isHighValueLoss, | ||
| } from 'src/ui/pages/SwapForm/shared/price-impact'; | ||
|
|
||
| function toMaybeArr<T>( |
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.
This one can be reused from src/shared/analytics/shared/addressActionToAnalytics.ts
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.
updated ✅
| formView: FormViewForAnalytics; | ||
| quote: Quote; | ||
| }) { | ||
| const zerion_fee_percentage = quote.protocol_fee; |
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.
it looks like we can extract all parts of the formView here and don't use it below.
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.
updated ✅
| }) { | ||
| const zerion_fee_percentage = quote.protocol_fee; | ||
| const feeAmount = quote.protocol_fee_amount; | ||
| const spendAsset = formView.spendAsset; |
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.
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.
updated ✅
| usd_amount_received: toMaybeArr([usdAmountReceived]), | ||
| asset_amount_sent: toMaybeArr([quote.input_amount_estimation]), | ||
| asset_amount_received: toMaybeArr([quote.output_amount_estimation]), | ||
| asset_name_sent: toMaybeArr([formView.spendAsset?.name]), |
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.
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.
updated ✅
| enough_balance, | ||
| enough_allowance: Boolean(quote.transaction), | ||
| warning_was_shown: isHighLoss, | ||
| // TODO add fdv_asset_sent |
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.
Should we add this in this PR?
Endpoint is ready to be used.
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.
added missing fields ✅
| request_name: 'swap_form_filled_out', | ||
| screen_name: scope, | ||
| client_scope: scope, | ||
| action_type: scope, |
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.
action_type can be Trade or Send 🫠🫠🫠
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.
in general it can, but not in formFilledOut event handler
so the scope should be of type scope: "Swap" | "Bridge" in FormFilledOutParams (if I'm not missing smth)
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.
I'll update this part in a minute
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.
updated ✅
| fdv_asset_sent: fdvAssetSent, | ||
| fdv_asset_received: fdvAssetReceived, | ||
| bridge_fee_usd_amount: bridgeFeeAmountInUsd, | ||
| outputAmountColor, |
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.
output_amount_color: outputAmountColor
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.
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.
ah, thanks! it should be
const outputAmountColor =
priceImpact && isSignificantValueLoss(priceImpact) ? 'red' : 'grey';
updated ✅
| contract_type: quote.contract_metadata?.name, | ||
| enough_balance, | ||
| enough_allowance: Boolean(quote.transaction), | ||
| warning_was_shown: isHighPriceImpact, |
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.
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.
should be fixed, just checked locally ✅
| return { | ||
| usd_amount_sent: toMaybeArr([usdAmountSend]), | ||
| usd_amount_received: toMaybeArr([usdAmountReceived]), | ||
| asset_amount_sent: toMaybeArr([quote.input_amount_estimation]), |
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.
Do we need to convert these values? Need to be checked
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.
Right now it shows value in gwei, not in the token itself
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.
we convert values like these in addressActionToAnalytics so probably I should do the same here
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.
fixed, updated ✅
| enabled?: boolean; | ||
| mapResponse?: (response: unknown) => T; | ||
| mergeResponse?(currentValue: T | null, nextValue: T | null): T | null; | ||
| onEnd?: (value: null | T) => void; |
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 about onDone?
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.
That way my first though as well, but ended up naming it onEnd to match the existing event name and the corresponding event handler
src/ui/shared/requests/useQuotes.ts
Outdated
| return updatedItem || item; | ||
| }); | ||
| }, | ||
| onEnd: (quotes) => emitter.emit('quotesReceived', quotes), |
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.
Can we add a param to useQuotes({ onEnd })?
To avoid event emitter here. Not sure is it important or not
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.
great idead, updated ✅
| `${url ?? 'no-url'}-${refetchHash}`, | ||
| url ?? null, | ||
| { | ||
| mergeResponse: (currentValue, nextValue) => { |
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.
Let's remove this param completely from useEventSource


No description provided.