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
6424fdfb
Unverified
Commit
6424fdfb
authored
May 23, 2023
by
Tina
Committed by
GitHub
May 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: Simplify event logging for SWAP_QUOTE_RECEIVED (#6628)
* simplify event logging * remove unused function parameter
parent
95814e32
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
42 deletions
+10
-42
analytics.ts
src/lib/utils/analytics.ts
+1
-5
index.tsx
src/pages/Swap/index.tsx
+9
-37
No files found.
src/lib/utils/analytics.ts
View file @
6424fdfb
...
...
@@ -61,8 +61,7 @@ export const formatSwapSignedAnalyticsEventProperties = ({
export
const
formatSwapQuoteReceivedEventProperties
=
(
trade
:
Trade
<
Currency
,
Currency
,
TradeType
>
,
gasUseEstimateUSD
?:
string
,
fetchingSwapQuoteStartTime
?:
Date
gasUseEstimateUSD
?:
string
)
=>
{
return
{
token_in_symbol
:
trade
.
inputAmount
.
currency
.
symbol
,
...
...
@@ -77,8 +76,5 @@ export const formatSwapQuoteReceivedEventProperties = (
:
undefined
,
token_in_amount
:
formatToDecimal
(
trade
.
inputAmount
,
trade
.
inputAmount
.
currency
.
decimals
),
token_out_amount
:
formatToDecimal
(
trade
.
outputAmount
,
trade
.
outputAmount
.
currency
.
decimals
),
quote_latency_milliseconds
:
fetchingSwapQuoteStartTime
?
getDurationFromDateMilliseconds
(
fetchingSwapQuoteStartTime
)
:
undefined
,
}
}
src/pages/Swap/index.tsx
View file @
6424fdfb
...
...
@@ -177,8 +177,6 @@ export function Swap({
disableTokenInputs
?:
boolean
})
{
const
{
account
,
chainId
:
connectedChainId
,
connector
}
=
useWeb3React
()
const
[
newSwapQuoteNeedsLogging
,
setNewSwapQuoteNeedsLogging
]
=
useState
(
true
)
const
[
fetchingSwapQuoteStartTime
,
setFetchingSwapQuoteStartTime
]
=
useState
<
Date
|
undefined
>
()
const
trace
=
useTrace
()
// token warning stuff
...
...
@@ -526,42 +524,16 @@ export function Swap({
const
priceImpactTooHigh
=
priceImpactSeverity
>
3
&&
!
isExpertMode
const
showPriceImpactWarning
=
largerPriceImpact
&&
priceImpactSeverity
>
3
// Handle time based logging events and event properties.
const
prevTrade
=
usePrevious
(
trade
)
useEffect
(()
=>
{
const
now
=
new
Date
()
// If a trade exists, and we need to log the receipt of this new swap quote:
if
(
newSwapQuoteNeedsLogging
&&
!!
trade
)
{
// Set the current datetime as the time of receipt of latest swap quote.
setSwapQuoteReceivedDate
(
now
)
// Log swap quote.
if
(
!
trade
||
prevTrade
===
trade
)
return
// no new swap quote to log
setSwapQuoteReceivedDate
(
new
Date
())
sendAnalyticsEvent
(
SwapEventName
.
SWAP_QUOTE_RECEIVED
,
{
...
formatSwapQuoteReceivedEventProperties
(
trade
,
trade
.
gasUseEstimateUSD
??
undefined
,
fetchingSwapQuoteStartTime
),
...
formatSwapQuoteReceivedEventProperties
(
trade
,
trade
.
gasUseEstimateUSD
??
undefined
),
...
trace
,
})
// Latest swap quote has just been logged, so we don't need to log the current trade anymore
// unless user inputs change again and a new trade is in the process of being generated.
setNewSwapQuoteNeedsLogging
(
false
)
// New quote is not being fetched, so set start time of quote fetch to undefined.
setFetchingSwapQuoteStartTime
(
undefined
)
}
// If another swap quote is being loaded based on changed user inputs:
if
(
routeIsLoading
)
{
setNewSwapQuoteNeedsLogging
(
true
)
if
(
!
fetchingSwapQuoteStartTime
)
setFetchingSwapQuoteStartTime
(
now
)
}
},
[
newSwapQuoteNeedsLogging
,
routeIsSyncing
,
routeIsLoading
,
fetchingSwapQuoteStartTime
,
trade
,
setSwapQuoteReceivedDate
,
trace
,
])
},
[
prevTrade
,
trade
,
trace
])
const
showDetailsDropdown
=
Boolean
(
!
showWrap
&&
userHasSpecifiedInputOutput
&&
(
trade
||
routeIsLoading
||
routeIsSyncing
)
...
...
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