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
58c94b72
Unverified
Commit
58c94b72
authored
Oct 27, 2022
by
blairmason
Committed by
GitHub
Oct 27, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: amplitude proxy (#5026)
* configure amplitude sdk to send events to Uniswap reverse proxy
parent
02d25daa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
17 deletions
+15
-17
.env
.env
+2
-2
.env.production
.env.production
+1
-2
index.ts
src/analytics/index.ts
+12
-13
No files found.
.env
View file @
58c94b72
REACT_APP_INFURA_KEY="4bf032f2d38a4ed6bb975b80d6340847"
REACT_APP_INFURA_KEY="4bf032f2d38a4ed6bb975b80d6340847"
REACT_APP_AMPLITUDE_
TEST_KEY="add-the-real-test-key-if-you-need-to-test-amplitude-events
"
REACT_APP_AMPLITUDE_
PROXY_URL="https://api.uniswap.org/v1/amplitude-proxy
"
REACT_APP_AWS_API_REGION="us-east-2"
REACT_APP_AWS_API_REGION="us-east-2"
REACT_APP_AWS_API_ACCESS_KEY="AKIAYJJWW6AQ47ODATHN"
REACT_APP_AWS_API_ACCESS_KEY="AKIAYJJWW6AQ47ODATHN"
REACT_APP_AWS_API_ACCESS_SECRET="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"
REACT_APP_AWS_API_ACCESS_SECRET="V9PoU0FhBP3cX760rPs9jMG/MIuDNLX6hYvVcaYO"
REACT_APP_AWS_X_API_KEY="z9dReS5UtHu7iTrUsTuWRozLthi3AxOZlvobrIdr14"
REACT_APP_AWS_X_API_KEY="z9dReS5UtHu7iTrUsTuWRozLthi3AxOZlvobrIdr14"
REACT_APP_AWS_API_ENDPOINT="https://beta.api.uniswap.org/v1/graphql"
REACT_APP_AWS_API_ENDPOINT="https://beta.api.uniswap.org/v1/graphql"
REACT_APP_TEMP_API_URL="https://temp.api.uniswap.org/v1"
REACT_APP_TEMP_API_URL="https://temp.api.uniswap.org/v1"
\ No newline at end of file
.env.production
View file @
58c94b72
REACT_APP_AMPLITUDE_KEY="b8f7dabddb1c3b03b394619767972160"
REACT_APP_AMPLITUDE_PROXY_URL="https://api.uniswap.org/v1/amplitude-proxy"
REACT_APP_AMPLITUDE_TEST_KEY="1c694b28cd089acc2c386d518f93a775"
REACT_APP_INFURA_KEY="099fc58e0de9451d80b18d7c74caa7c1"
REACT_APP_INFURA_KEY="099fc58e0de9451d80b18d7c74caa7c1"
REACT_APP_FORTMATIC_KEY="pk_live_F937DF033A1666BF"
REACT_APP_FORTMATIC_KEY="pk_live_F937DF033A1666BF"
REACT_APP_GOOGLE_ANALYTICS_ID="G-KDP9B6W4H8"
REACT_APP_GOOGLE_ANALYTICS_ID="G-KDP9B6W4H8"
...
...
src/analytics/index.ts
View file @
58c94b72
import
{
Identify
,
identify
,
init
,
track
}
from
'
@amplitude/analytics-browser
'
import
{
Identify
,
identify
,
init
,
track
}
from
'
@amplitude/analytics-browser
'
import
{
isProductionEnv
}
from
'
utils/env
'
import
{
isProductionEnv
}
from
'
utils/env
'
const
API_KEY
=
isProductionEnv
()
?
process
.
env
.
REACT_APP_AMPLITUDE_KEY
:
process
.
env
.
REACT_APP_AMPLITUDE_TEST_KEY
const
DUMMY_KEY
=
'
00000000000000000000000000000000
'
const
PROXY_URL
=
process
.
env
.
REACT_APP_AMPLITUDE_PROXY_URL
/**
/**
* Initializes Amplitude with API key for project.
* Initializes Amplitude SDK and configures it to send events to a Uniswap reverse proxy,
*
* which relays to events to relevant Amplitude endpoints. You must be a
* Uniswap has two Amplitude projects: test and production. You must be a
* member of the organization on Amplitude to view logged events.
* member of the organization on Amplitude to view details.
*/
*/
export
function
initializeAnalytics
()
{
export
function
initializeAnalytics
()
{
if
(
typeof
API_KEY
===
'
undefined
'
)
{
if
(
typeof
PROXY_URL
===
'
undefined
'
)
{
const
keyName
=
isProductionEnv
()
?
'
REACT_APP_AMPLITUDE_KEY
'
:
'
REACT_APP_AMPLITUDE_TEST_KEY
'
console
.
error
(
'
REACT_APP_AMPLITUDE_PROXY_URL is undefined, Amplitude analytics will not run.
'
)
console
.
error
(
`
${
keyName
}
is undefined, Amplitude analytics will not run.`
)
return
return
}
}
init
(
init
(
API
_KEY
,
DUMMY
_KEY
,
/* userId= */
undefined
,
// User ID should be undefined to let Amplitude default to Device ID
/* userId= */
undefined
,
// User ID should be undefined to let Amplitude default to Device ID
/* options= */
/* options= */
{
{
// Configure the SDK to work with alternate endpoint
serverUrl
:
PROXY_URL
,
// Disable tracking of private user information by Amplitude
// Disable tracking of private user information by Amplitude
trackingOptions
:
{
trackingOptions
:
{
// IP is being dropped before ingestion on Amplitude side, only being used to determine country.
ipAddress
:
false
,
ipAddress
:
isProductionEnv
()
?
false
:
true
,
carrier
:
false
,
carrier
:
false
,
city
:
false
,
city
:
false
,
region
:
false
,
region
:
false
,
...
@@ -35,8 +35,7 @@ export function initializeAnalytics() {
...
@@ -35,8 +35,7 @@ export function initializeAnalytics() {
/** Sends an event to Amplitude. */
/** Sends an event to Amplitude. */
export
function
sendAnalyticsEvent
(
eventName
:
string
,
eventProperties
?:
Record
<
string
,
unknown
>
)
{
export
function
sendAnalyticsEvent
(
eventName
:
string
,
eventProperties
?:
Record
<
string
,
unknown
>
)
{
const
origin
=
window
.
location
.
origin
if
(
!
PROXY_URL
)
{
if
(
!
API_KEY
)
{
console
.
log
(
`[analytics(
${
eventName
}
)]:
${
JSON
.
stringify
(
eventProperties
)}
`
)
console
.
log
(
`[analytics(
${
eventName
}
)]:
${
JSON
.
stringify
(
eventProperties
)}
`
)
return
return
}
}
...
...
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