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
7786537c
Unverified
Commit
7786537c
authored
Feb 12, 2020
by
Ian Lapham
Committed by
GitHub
Feb 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add txn hash to analytics (#632)
parent
518f3842
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
43 deletions
+53
-43
index.jsx
src/components/ExchangePage/index.jsx
+23
-19
AddLiquidity.js
src/pages/Pool/AddLiquidity.js
+15
-13
RemoveLiquidity.js
src/pages/Pool/RemoveLiquidity.js
+15
-11
No files found.
src/components/ExchangePage/index.jsx
View file @
7786537c
...
...
@@ -15,7 +15,6 @@ import { useTransactionAdder } from '../../contexts/Transactions'
import
{
useAddressBalance
,
useExchangeReserves
}
from
'
../../contexts/Balances
'
import
{
useAddressAllowance
}
from
'
../../contexts/Allowances
'
import
{
useWalletModalToggle
}
from
'
../../contexts/Application
'
import
{
useETHPriceInUSD
}
from
'
../../contexts/Balances
'
import
{
Button
}
from
'
../../theme
'
import
CurrencyInputPanel
from
'
../CurrencyInputPanel
'
...
...
@@ -262,9 +261,6 @@ export default function ExchangePage({ initialCurrency, sending = false, params
urlAddedTokens
[
initialCurrency
]
=
true
}
// BigNumber.js instance
const
ethPrice
=
useETHPriceInUSD
()
const
addTransaction
=
useTransactionAdder
()
// check if URL specifies valid slippage, if so use as default
...
...
@@ -633,16 +629,16 @@ export default function ExchangePage({ initialCurrency, sending = false, params
if
(
inputCurrency
!==
'
ETH
'
)
{
inputEthPerToken
=
inputReserveToken
&&
inputReserveETH
?
inputReserveETH
/
inputReserveToken
:
null
}
let
usdTransactionSize
=
ethPrice
*
inputEthPerToken
*
inputValueFormatted
let
ethTransactionSize
=
inputEthPerToken
*
inputValueFormatted
// params for GA event
let
action
=
''
let
label
=
''
if
(
independentField
===
INPUT
)
{
// general details about transaction
ReactGA
.
event
({
category
:
'
Transaction
'
,
action
:
sending
?
'
SendInput
'
:
'
SwapInput
'
,
label
:
outputCurrency
,
value
:
usdTransactionSize
})
// set GA params
action
=
sending
?
'
SendInput
'
:
'
SwapInput
'
label
=
outputCurrency
if
(
swapType
===
ETH_TO_TOKEN
)
{
estimate
=
sending
?
contract
.
estimate
.
ethToTokenTransferInput
:
contract
.
estimate
.
ethToTokenSwapInput
...
...
@@ -672,13 +668,9 @@ export default function ExchangePage({ initialCurrency, sending = false, params
value
=
ethers
.
constants
.
Zero
}
}
else
if
(
independentField
===
OUTPUT
)
{
// general details about transaction
ReactGA
.
event
({
category
:
'
Transaction
'
,
action
:
sending
?
'
SendOutput
'
:
'
SwapOutput
'
,
label
:
outputCurrency
,
value
:
usdTransactionSize
})
// set GA params
action
=
sending
?
'
SendOutput
'
:
'
SwapOutput
'
label
=
outputCurrency
if
(
swapType
===
ETH_TO_TOKEN
)
{
estimate
=
sending
?
contract
.
estimate
.
ethToTokenTransferOutput
:
contract
.
estimate
.
ethToTokenSwapOutput
...
...
@@ -715,6 +707,18 @@ export default function ExchangePage({ initialCurrency, sending = false, params
gasLimit
:
calculateGasMargin
(
estimatedGasLimit
,
GAS_MARGIN
)
}).
then
(
response
=>
{
addTransaction
(
response
)
ReactGA
.
event
({
category
:
'
Transaction
'
,
action
:
action
,
label
:
label
,
value
:
ethTransactionSize
,
dimension1
:
response
.
hash
})
ReactGA
.
event
({
category
:
'
Hash
'
,
action
:
response
.
hash
,
label
:
ethTransactionSize
.
toString
()
})
})
}
...
...
src/pages/Pool/AddLiquidity.js
View file @
7786537c
...
...
@@ -17,7 +17,7 @@ import { brokenTokens } from '../../constants'
import
{
amountFormatter
,
calculateGasMargin
}
from
'
../../utils
'
import
{
useTransactionAdder
}
from
'
../../contexts/Transactions
'
import
{
useTokenDetails
,
INITIAL_TOKENS_CONTEXT
}
from
'
../../contexts/Tokens
'
import
{
useAddressBalance
,
useExchangeReserves
,
useETHPriceInUSD
}
from
'
../../contexts/Balances
'
import
{
useAddressBalance
,
useExchangeReserves
}
from
'
../../contexts/Balances
'
import
{
useAddressAllowance
}
from
'
../../contexts/Allowances
'
const
INPUT
=
0
...
...
@@ -202,9 +202,6 @@ export default function AddLiquidity({ params }) {
const
{
t
}
=
useTranslation
()
const
{
library
,
account
,
active
,
chainId
}
=
useWeb3React
()
// BigNumber.js instance
const
ethPrice
=
useETHPriceInUSD
()
const
urlAddedTokens
=
{}
if
(
params
.
token
)
{
urlAddedTokens
[
params
.
token
]
=
true
...
...
@@ -390,15 +387,7 @@ export default function AddLiquidity({ params }) {
async
function
onAddLiquidity
()
{
// take ETH amount, multiplied by ETH rate and 2 for total tx size
let
usdTransactionSize
=
ethPrice
*
(
inputValueParsed
/
1
e18
)
*
2
// log pool added to and total usd amount
ReactGA
.
event
({
category
:
'
Transaction
'
,
action
:
'
Add Liquidity
'
,
label
:
outputCurrency
,
value
:
usdTransactionSize
})
let
ethTransactionSize
=
(
inputValueParsed
/
1
e18
)
*
2
const
deadline
=
Math
.
ceil
(
Date
.
now
()
/
1000
)
+
DEADLINE_FROM_NOW
...
...
@@ -424,6 +413,19 @@ export default function AddLiquidity({ params }) {
}
)
.
then
(
response
=>
{
// log pool added to and total usd amount
ReactGA
.
event
({
category
:
'
Transaction
'
,
action
:
'
Add Liquidity
'
,
label
:
outputCurrency
,
value
:
ethTransactionSize
,
dimension1
:
response
.
hash
})
ReactGA
.
event
({
category
:
'
Hash
'
,
action
:
response
.
hash
,
label
:
ethTransactionSize
.
toString
()
})
addTransaction
(
response
)
})
}
...
...
src/pages/Pool/RemoveLiquidity.js
View file @
7786537c
...
...
@@ -8,7 +8,7 @@ import styled from 'styled-components'
import
{
useWeb3React
,
useExchangeContract
}
from
'
../../hooks
'
import
{
useTransactionAdder
}
from
'
../../contexts/Transactions
'
import
{
useTokenDetails
,
INITIAL_TOKENS_CONTEXT
}
from
'
../../contexts/Tokens
'
import
{
useAddressBalance
,
useETHPriceInUSD
}
from
'
../../contexts/Balances
'
import
{
useAddressBalance
}
from
'
../../contexts/Balances
'
import
{
calculateGasMargin
,
amountFormatter
}
from
'
../../utils
'
import
{
brokenTokens
}
from
'
../../constants
'
...
...
@@ -268,18 +268,9 @@ export default function RemoveLiquidity({ params }) {
}
},
[
fetchPoolTokens
,
library
])
// BigNumber.js instance
const
ethPrice
=
useETHPriceInUSD
()
async
function
onRemoveLiquidity
()
{
// take ETH amount, multiplied by ETH rate and 2 for total tx size
let
usdTransactionSize
=
ethPrice
*
(
ethWithdrawn
/
1
e18
)
*
2
ReactGA
.
event
({
category
:
'
Transaction
'
,
action
:
'
Remove Liquidity
'
,
label
:
outputCurrency
,
value
:
usdTransactionSize
})
let
ethTransactionSize
=
(
ethWithdrawn
/
1
e18
)
*
2
const
deadline
=
Math
.
ceil
(
Date
.
now
()
/
1000
)
+
DEADLINE_FROM_NOW
...
...
@@ -295,6 +286,19 @@ export default function RemoveLiquidity({ params }) {
gasLimit
:
calculateGasMargin
(
estimatedGasLimit
,
GAS_MARGIN
)
})
.
then
(
response
=>
{
ReactGA
.
event
({
category
:
'
Transaction
'
,
action
:
'
Remove Liquidity
'
,
label
:
outputCurrency
,
value
:
ethTransactionSize
,
dimension1
:
response
.
hash
})
ReactGA
.
event
({
category
:
'
Hash
'
,
action
:
response
.
hash
,
label
:
ethTransactionSize
.
toString
(),
value
:
ethTransactionSize
})
addTransaction
(
response
)
})
}
...
...
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