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
6acc9300
Unverified
Commit
6acc9300
authored
Oct 13, 2022
by
lynn
Committed by
GitHub
Oct 13, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: add origin to every event (#4918)
* add origin to every event * remove console log
parent
70d33fb2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
3 deletions
+2
-3
Trace.tsx
src/analytics/Trace.tsx
+0
-2
index.ts
src/analytics/index.ts
+2
-1
No files found.
src/analytics/Trace.tsx
View file @
6acc9300
...
@@ -58,12 +58,10 @@ export const Trace = memo(
...
@@ -58,12 +58,10 @@ export const Trace = memo(
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
shouldLogImpression
)
{
if
(
shouldLogImpression
)
{
const
origin
=
window
.
location
.
origin
const
commitHash
=
process
.
env
.
REACT_APP_GIT_COMMIT_HASH
const
commitHash
=
process
.
env
.
REACT_APP_GIT_COMMIT_HASH
sendAnalyticsEvent
(
name
??
EventName
.
PAGE_VIEWED
,
{
sendAnalyticsEvent
(
name
??
EventName
.
PAGE_VIEWED
,
{
...
combinedProps
,
...
combinedProps
,
...
properties
,
...
properties
,
origin
,
git_commit_hash
:
commitHash
,
git_commit_hash
:
commitHash
,
})
})
}
}
...
...
src/analytics/index.ts
View file @
6acc9300
...
@@ -35,12 +35,13 @@ export function initializeAnalytics() {
...
@@ -35,12 +35,13 @@ 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
(
!
API_KEY
)
{
if
(
!
API_KEY
)
{
console
.
log
(
`[analytics(
${
eventName
}
)]:
${
JSON
.
stringify
(
eventProperties
)}
`
)
console
.
log
(
`[analytics(
${
eventName
}
)]:
${
JSON
.
stringify
(
eventProperties
)}
`
)
return
return
}
}
track
(
eventName
,
eventProperties
)
track
(
eventName
,
{
...
eventProperties
,
origin
}
)
}
}
type
Value
=
string
|
number
|
boolean
|
string
[]
|
number
[]
type
Value
=
string
|
number
|
boolean
|
string
[]
|
number
[]
...
...
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