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
def4ab3b
Unverified
Commit
def4ab3b
authored
Aug 14, 2023
by
Tina
Committed by
GitHub
Aug 14, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add time to sign analytics (#7140)
* add time to sign analytics * move comment
parent
bb6de905
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
0 deletions
+8
-0
useUniswapXSwapCallback.ts
src/hooks/useUniswapXSwapCallback.ts
+2
-0
useUniversalRouter.ts
src/hooks/useUniversalRouter.ts
+2
-0
analytics.ts
src/lib/utils/analytics.ts
+4
-0
No files found.
src/hooks/useUniswapXSwapCallback.ts
View file @
def4ab3b
...
@@ -105,6 +105,7 @@ export function useUniswapXSwapCallback({
...
@@ -105,6 +105,7 @@ export function useUniswapXSwapCallback({
}
}
}
}
const
beforeSign
=
Date
.
now
()
const
{
signature
,
updatedOrder
}
=
await
signDutchOrder
()
const
{
signature
,
updatedOrder
}
=
await
signDutchOrder
()
sendAnalyticsEvent
(
SwapEventName
.
SWAP_SIGNED
,
{
sendAnalyticsEvent
(
SwapEventName
.
SWAP_SIGNED
,
{
...
@@ -112,6 +113,7 @@ export function useUniswapXSwapCallback({
...
@@ -112,6 +113,7 @@ export function useUniswapXSwapCallback({
trade
,
trade
,
allowedSlippage
,
allowedSlippage
,
fiatValues
,
fiatValues
,
timeToSignSinceRequestMs
:
Date
.
now
()
-
beforeSign
,
}),
}),
...
analyticsContext
,
...
analyticsContext
,
})
})
...
...
src/hooks/useUniversalRouter.ts
View file @
def4ab3b
...
@@ -94,6 +94,7 @@ export function useUniversalRouterSwapCallback(
...
@@ -94,6 +94,7 @@ export function useUniversalRouterSwapCallback(
}
}
const
gasLimit
=
calculateGasMargin
(
gasEstimate
)
const
gasLimit
=
calculateGasMargin
(
gasEstimate
)
setTraceData
(
'
gasLimit
'
,
gasLimit
.
toNumber
())
setTraceData
(
'
gasLimit
'
,
gasLimit
.
toNumber
())
const
beforeSign
=
Date
.
now
()
const
response
=
await
provider
const
response
=
await
provider
.
getSigner
()
.
getSigner
()
.
sendTransaction
({
...
tx
,
gasLimit
})
.
sendTransaction
({
...
tx
,
gasLimit
})
...
@@ -101,6 +102,7 @@ export function useUniversalRouterSwapCallback(
...
@@ -101,6 +102,7 @@ export function useUniversalRouterSwapCallback(
sendAnalyticsEvent
(
SwapEventName
.
SWAP_SIGNED
,
{
sendAnalyticsEvent
(
SwapEventName
.
SWAP_SIGNED
,
{
...
formatSwapSignedAnalyticsEventProperties
({
...
formatSwapSignedAnalyticsEventProperties
({
trade
,
trade
,
timeToSignSinceRequestMs
:
Date
.
now
()
-
beforeSign
,
allowedSlippage
:
options
.
slippageTolerance
,
allowedSlippage
:
options
.
slippageTolerance
,
fiatValues
,
fiatValues
,
txHash
:
response
.
hash
,
txHash
:
response
.
hash
,
...
...
src/lib/utils/analytics.ts
View file @
def4ab3b
...
@@ -65,15 +65,19 @@ export const formatSwapSignedAnalyticsEventProperties = ({
...
@@ -65,15 +65,19 @@ export const formatSwapSignedAnalyticsEventProperties = ({
allowedSlippage
,
allowedSlippage
,
fiatValues
,
fiatValues
,
txHash
,
txHash
,
timeToSignSinceRequestMs
,
}:
{
}:
{
trade
:
InterfaceTrade
trade
:
InterfaceTrade
allowedSlippage
:
Percent
allowedSlippage
:
Percent
fiatValues
:
{
amountIn
?:
number
;
amountOut
?:
number
}
fiatValues
:
{
amountIn
?:
number
;
amountOut
?:
number
}
txHash
?:
string
txHash
?:
string
timeToSignSinceRequestMs
?:
number
})
=>
({
})
=>
({
transaction_hash
:
txHash
,
transaction_hash
:
txHash
,
token_in_amount_usd
:
fiatValues
.
amountIn
,
token_in_amount_usd
:
fiatValues
.
amountIn
,
token_out_amount_usd
:
fiatValues
.
amountOut
,
token_out_amount_usd
:
fiatValues
.
amountOut
,
// measures the amount of time the user took to sign the permit message or swap tx in their wallet
time_to_sign_since_request_ms
:
timeToSignSinceRequestMs
,
...
formatCommonPropertiesForTrade
(
trade
,
allowedSlippage
),
...
formatCommonPropertiesForTrade
(
trade
,
allowedSlippage
),
})
})
...
...
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