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
4ef3746a
Unverified
Commit
4ef3746a
authored
May 14, 2020
by
Moody Salem
Committed by
GitHub
May 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add GA instrumentation to v2 (#769)
parent
d2462af8
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
60 additions
and
10 deletions
+60
-10
index.tsx
src/components/ExchangePage/index.tsx
+8
-1
index.tsx
src/components/TxnPopup/index.tsx
+0
-1
index.tsx
src/index.tsx
+0
-2
App.tsx
src/pages/App.tsx
+12
-2
AddLiquidity.tsx
src/pages/Pool/AddLiquidity.tsx
+6
-0
RemoveLiquidity.tsx
src/pages/Pool/RemoveLiquidity.tsx
+6
-0
components.tsx
src/theme/components.tsx
+28
-4
No files found.
src/components/ExchangePage/index.tsx
View file @
4ef3746a
import
React
,
{
useState
,
useCallback
,
useEffect
,
useContext
}
from
'
react
'
import
ReactGA
from
'
react-ga
'
import
{
ThemeContext
}
from
'
styled-components
'
import
{
parseEther
,
parseUnits
}
from
'
@ethersproject/units
'
import
{
JSBI
,
Percent
,
TokenAmount
,
TradeType
,
WETH
,
Fraction
}
from
'
@uniswap/sdk
'
...
...
@@ -75,7 +76,7 @@ const DEFAULT_DEADLINE_FROM_NOW = 60 * 20
const
ALLOWED_SLIPPAGE_MEDIUM
=
100
const
ALLOWED_SLIPPAGE_HIGH
=
500
interface
ExchangePageProps
extends
RouteComponentProps
<
{}
>
{
interface
ExchangePageProps
extends
RouteComponentProps
{
sendingInput
:
boolean
params
:
QueryParams
}
...
...
@@ -384,6 +385,7 @@ function ExchangePage({ sendingInput = false, history, params }: ExchangePagePro
.
sendTransaction
({
to
:
recipient
.
toString
(),
value
:
BigNumber
.
from
(
parsedAmounts
[
Field
.
INPUT
].
raw
.
toString
())
})
.
then
(
response
=>
{
setTxHash
(
response
.
hash
)
ReactGA
.
event
({
category
:
'
ExchangePage
'
,
action
:
'
Send
'
,
label
:
tokens
[
Field
.
INPUT
]?.
symbol
})
addTransaction
(
response
,
{
summary
:
'
Send
'
+
...
...
@@ -520,6 +522,11 @@ function ExchangePage({ sendingInput = false, history, params }: ExchangePagePro
gasLimit
:
calculateGasMargin
(
estimatedGasLimit
)
}).
then
(
response
=>
{
setTxHash
(
response
.
hash
)
ReactGA
.
event
({
category
:
'
ExchangePage
'
,
label
:
sending
&&
recipient
!==
account
?
'
Swap w/ Send
'
:
'
Swap
'
,
action
:
[
tokens
[
Field
.
INPUT
]?.
symbol
,
tokens
[
Field
.
OUTPUT
]?.
symbol
].
join
(
'
;
'
)
})
addTransaction
(
response
,
{
summary
:
'
Swap
'
+
...
...
src/components/TxnPopup/index.tsx
View file @
4ef3746a
import
React
,
{
useCallback
,
useState
}
from
'
react
'
import
{
AlertCircle
,
CheckCircle
}
from
'
react-feather
'
import
styled
from
'
styled-components
'
...
...
src/index.tsx
View file @
4ef3746a
...
...
@@ -33,8 +33,6 @@ if (process.env.NODE_ENV === 'production') {
ReactGA
.
initialize
(
'
test
'
,
{
testMode
:
true
,
debug
:
true
})
}
ReactGA
.
pageview
(
window
.
location
.
pathname
+
window
.
location
.
search
)
function
Updaters
()
{
return
(
<>
...
...
src/pages/App.tsx
View file @
4ef3746a
import
React
,
{
Suspense
}
from
'
react
'
import
React
,
{
Suspense
,
useEffect
}
from
'
react
'
import
styled
from
'
styled-components
'
import
{
BrowserRouter
,
Redirect
,
Route
,
Switch
}
from
'
react-router-dom
'
import
ReactGA
from
'
react-ga
'
import
{
BrowserRouter
,
Redirect
,
Route
,
RouteComponentProps
,
Switch
}
from
'
react-router-dom
'
import
Header
from
'
../components/Header
'
import
Footer
from
'
../components/Footer
'
...
...
@@ -91,6 +92,14 @@ const StyledRed = styled.div`
}
`
// fires a GA pageview every time the route changes
function
GoogleAnalyticsReporter
({
location
:
{
pathname
,
search
}
}:
RouteComponentProps
)
{
useEffect
(()
=>
{
ReactGA
.
pageview
(
`
${
pathname
}${
search
}
`
)
},
[
pathname
,
search
])
return
null
}
export
default
function
App
()
{
const
params
=
getAllQueryParams
()
...
...
@@ -98,6 +107,7 @@ export default function App() {
<>
<
Suspense
fallback=
{
null
}
>
<
BrowserRouter
>
<
Route
component=
{
GoogleAnalyticsReporter
}
/>
<
AppWrapper
>
<
HeaderWrapper
>
<
Header
/>
...
...
src/pages/Pool/AddLiquidity.tsx
View file @
4ef3746a
import
React
,
{
useReducer
,
useState
,
useCallback
,
useEffect
,
useContext
}
from
'
react
'
import
ReactGA
from
'
react-ga
'
import
styled
,
{
ThemeContext
}
from
'
styled-components
'
import
{
RouteComponentProps
,
withRouter
}
from
'
react-router-dom
'
import
{
parseUnits
,
parseEther
}
from
'
@ethersproject/units
'
...
...
@@ -497,6 +498,11 @@ function AddLiquidity({ token0, token1 }: AddLiquidityProps) {
...(
value
?
{
value
}
:
{}),
gasLimit
:
calculateGasMargin
(
estimatedGasLimit
)
}).
then
(
response
=>
{
ReactGA
.
event
({
category
:
'
Liquidity
'
,
action
:
'
Add
'
,
label
:
[
tokens
[
Field
.
INPUT
]?.
symbol
,
tokens
[
Field
.
OUTPUT
]?.
symbol
].
join
(
'
;
'
)
})
setTxHash
(
response
.
hash
)
addTransaction
(
response
,
{
summary
:
...
...
src/pages/Pool/RemoveLiquidity.tsx
View file @
4ef3746a
import
React
,
{
useReducer
,
useState
,
useCallback
,
useEffect
,
useContext
}
from
'
react
'
import
ReactGA
from
'
react-ga
'
import
styled
,
{
ThemeContext
}
from
'
styled-components
'
import
{
parseUnits
}
from
'
@ethersproject/units
'
import
{
Contract
}
from
'
@ethersproject/contracts
'
...
...
@@ -490,6 +491,11 @@ export default function RemoveLiquidity({ token0, token1 }: { token0: string; to
method
(...
args
,
{
gasLimit
:
calculateGasMargin
(
estimatedGasLimit
)
}).
then
(
response
=>
{
ReactGA
.
event
({
category
:
'
Liquidity
'
,
action
:
'
Remove
'
,
label
:
[
tokens
[
Field
.
TOKEN0
]?.
symbol
,
tokens
[
Field
.
TOKEN1
]?.
symbol
].
join
(
'
;
'
)
})
setPendingConfirmation
(
false
)
setTxHash
(
response
.
hash
)
addTransaction
(
response
,
{
...
...
src/theme/components.tsx
View file @
4ef3746a
import
React
,
{
HTMLProps
,
useCallback
}
from
'
react
'
import
ReactGA
from
'
react-ga
'
import
styled
,
{
keyframes
}
from
'
styled-components
'
import
{
darken
}
from
'
polished
'
import
{
X
}
from
'
react-feather
'
...
...
@@ -36,10 +38,7 @@ export const CloseIcon = styled(X)<{ onClick: () => void }>`
cursor: pointer;
`
export
const
Link
=
styled
.
a
.
attrs
({
target
:
'
_blank
'
,
rel
:
'
noopener noreferrer
'
})
`
const
StyledLink
=
styled
.
a
`
text-decoration: none;
cursor: pointer;
color:
${({
theme
})
=>
theme
.
primary1
}
;
...
...
@@ -59,6 +58,31 @@ export const Link = styled.a.attrs({
}
`
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export
function
Link
({
onClick
,
as
,
ref
,
target
,
href
,
rel
,
...
rest
}:
HTMLProps
<
HTMLAnchorElement
>
)
{
const
handleClick
=
useCallback
(
(
event
:
React
.
MouseEvent
<
HTMLAnchorElement
>
)
=>
{
onClick
&&
onClick
(
event
)
// first call back into the original onClick
if
(
!
href
)
return
event
.
preventDefault
()
// send a ReactGA event and then trigger a location change
ReactGA
.
outboundLink
({
label
:
href
},
()
=>
{
window
.
location
.
href
=
href
})
},
[
href
,
onClick
]
)
return
(
<
StyledLink
target=
{
target
??
'
_blank
'
}
rel=
{
rel
??
'
noopener noreferrer
'
}
href=
{
href
}
onClick=
{
handleClick
}
{
...
rest
}
/>
)
}
const
rotate
=
keyframes
`
from {
transform: rotate(0deg);
...
...
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