Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
3586a288
Unverified
Commit
3586a288
authored
Oct 18, 2022
by
lynn
Committed by
GitHub
Oct 18, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: swap quote event (#4923)
* init * testing * remove console line * remove todos
parent
5e2bdc4e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
7 deletions
+24
-7
index.tsx
src/components/Widget/index.tsx
+24
-7
No files found.
src/components/Widget/index.tsx
View file @
3586a288
...
@@ -18,12 +18,14 @@ import { SWAP_PRICE_UPDATE_USER_RESPONSE } from 'analytics/constants'
...
@@ -18,12 +18,14 @@ import { SWAP_PRICE_UPDATE_USER_RESPONSE } from 'analytics/constants'
import
{
useTrace
}
from
'
analytics/Trace
'
import
{
useTrace
}
from
'
analytics/Trace
'
import
{
import
{
formatPercentInBasisPointsNumber
,
formatPercentInBasisPointsNumber
,
formatSwapQuoteReceivedEventProperties
,
formatToDecimal
,
formatToDecimal
,
getDurationFromDateMilliseconds
,
getPriceUpdateBasisPoints
,
getPriceUpdateBasisPoints
,
getTokenAddress
,
getTokenAddress
,
}
from
'
analytics/utils
'
}
from
'
analytics/utils
'
import
{
useActiveLocale
}
from
'
hooks/useActiveLocale
'
import
{
useActiveLocale
}
from
'
hooks/useActiveLocale
'
import
{
useCallback
}
from
'
react
'
import
{
useCallback
,
useState
}
from
'
react
'
import
{
useIsDarkMode
}
from
'
state/user/hooks
'
import
{
useIsDarkMode
}
from
'
state/user/hooks
'
import
{
DARK_THEME
,
LIGHT_THEME
}
from
'
theme/widget
'
import
{
DARK_THEME
,
LIGHT_THEME
}
from
'
theme/widget
'
import
{
computeRealizedPriceImpact
}
from
'
utils/prices
'
import
{
computeRealizedPriceImpact
}
from
'
utils/prices
'
...
@@ -53,8 +55,24 @@ export default function Widget({ defaultToken, onReviewSwapClick }: WidgetProps)
...
@@ -53,8 +55,24 @@ export default function Widget({ defaultToken, onReviewSwapClick }: WidgetProps)
const
trace
=
useTrace
({
section
:
SectionName
.
WIDGET
})
const
trace
=
useTrace
({
section
:
SectionName
.
WIDGET
})
// TODO(lynnshaoyu): add back onInitialSwapQuote logging once widget side logic is fixed
const
[
initialQuoteDate
,
setInitialQuoteDate
]
=
useState
<
Date
>
()
// in onInitialSwapQuote handler.
const
onInitialSwapQuote
=
useCallback
(
(
trade
:
Trade
<
Currency
,
Currency
,
TradeType
>
)
=>
{
setInitialQuoteDate
(
new
Date
())
const
eventProperties
=
{
// TODO(1416): Include undefined values.
...
formatSwapQuoteReceivedEventProperties
(
trade
,
/* gasUseEstimateUSD= */
undefined
,
/* fetchingSwapQuoteStartTime= */
undefined
),
...
trace
,
}
sendAnalyticsEvent
(
EventName
.
SWAP_QUOTE_RECEIVED
,
eventProperties
)
},
[
trace
]
)
const
onApproveToken
=
useCallback
(()
=>
{
const
onApproveToken
=
useCallback
(()
=>
{
const
input
=
inputs
.
value
.
INPUT
const
input
=
inputs
.
value
.
INPUT
...
@@ -106,15 +124,13 @@ export default function Widget({ defaultToken, onReviewSwapClick }: WidgetProps)
...
@@ -106,15 +124,13 @@ export default function Widget({ defaultToken, onReviewSwapClick }: WidgetProps)
is_auto_router_api
:
undefined
,
is_auto_router_api
:
undefined
,
is_auto_slippage
:
undefined
,
is_auto_slippage
:
undefined
,
chain_id
:
trade
.
inputAmount
.
currency
.
chainId
,
chain_id
:
trade
.
inputAmount
.
currency
.
chainId
,
// duration should be getDurationFromDateMilliseconds(initialQuoteDate) once initialQuoteDate
duration_from_first_quote_to_swap_submission_milliseconds
:
getDurationFromDateMilliseconds
(
initialQuoteDate
),
// is made available from TODO above for onInitialSwapQuote logging.
duration_from_first_quote_to_swap_submission_milliseconds
:
undefined
,
swap_quote_block_number
:
undefined
,
swap_quote_block_number
:
undefined
,
...
trace
,
...
trace
,
}
}
sendAnalyticsEvent
(
EventName
.
SWAP_SUBMITTED_BUTTON_CLICKED
,
eventProperties
)
sendAnalyticsEvent
(
EventName
.
SWAP_SUBMITTED_BUTTON_CLICKED
,
eventProperties
)
},
},
[
trace
]
[
initialQuoteDate
,
trace
]
)
)
const
onSwitchChain
=
useCallback
(
const
onSwitchChain
=
useCallback
(
// TODO: Widget should not break if this rejects - upstream the catch to ignore it.
// TODO: Widget should not break if this rejects - upstream the catch to ignore it.
...
@@ -146,6 +162,7 @@ export default function Widget({ defaultToken, onReviewSwapClick }: WidgetProps)
...
@@ -146,6 +162,7 @@ export default function Widget({ defaultToken, onReviewSwapClick }: WidgetProps)
onReviewSwapClick=
{
onReviewSwapClick
}
onReviewSwapClick=
{
onReviewSwapClick
}
onSubmitSwapClick=
{
onSubmitSwapClick
}
onSubmitSwapClick=
{
onSubmitSwapClick
}
onSwapApprove=
{
onApproveToken
}
onSwapApprove=
{
onApproveToken
}
onInitialSwapQuote=
{
onInitialSwapQuote
}
onSwapPriceUpdateAck=
{
onSwapPriceUpdateAck
}
onSwapPriceUpdateAck=
{
onSwapPriceUpdateAck
}
/>
/>
{
tokenSelector
}
{
tokenSelector
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment