Commit 6acc9300 authored by lynn's avatar lynn Committed by GitHub

fix: add origin to every event (#4918)

* add origin to every event

* remove console log
parent 70d33fb2
...@@ -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,
}) })
} }
......
...@@ -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[]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment