Commit d4b8735c authored by vignesh mohankumar's avatar vignesh mohankumar Committed by GitHub

fix: remove sendTestAnalyticsEvent (#4653)

* fix: remove sendTestAnalyticsEvent

* comments
parent d31687d0
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
/** /**
* Initializes Amplitude with API key for project. * Initializes Amplitude with API key for project.
* *
...@@ -8,8 +10,6 @@ import { isProductionEnv } from 'utils/env' ...@@ -8,8 +10,6 @@ import { isProductionEnv } from 'utils/env'
* member of the organization on Amplitude to view details. * member of the organization on Amplitude to view details.
*/ */
export function initializeAnalytics() { export function initializeAnalytics() {
const API_KEY = isProductionEnv() ? process.env.REACT_APP_AMPLITUDE_KEY : process.env.REACT_APP_AMPLITUDE_TEST_KEY
if (typeof API_KEY === 'undefined') { if (typeof API_KEY === 'undefined') {
const keyName = isProductionEnv() ? 'REACT_APP_AMPLITUDE_KEY' : 'REACT_APP_AMPLITUDE_TEST_KEY' const keyName = isProductionEnv() ? 'REACT_APP_AMPLITUDE_KEY' : 'REACT_APP_AMPLITUDE_TEST_KEY'
console.error(`${keyName} is undefined, Amplitude analytics will not run.`) console.error(`${keyName} is undefined, Amplitude analytics will not run.`)
...@@ -33,23 +33,16 @@ export function initializeAnalytics() { ...@@ -33,23 +33,16 @@ export function initializeAnalytics() {
) )
} }
/** Sends an approved (finalized) event to Amplitude production project. */ /** Sends an event to Amplitude. */
export function sendAnalyticsEvent(eventName: string, eventProperties?: Record<string, unknown>) { export function sendAnalyticsEvent(eventName: string, eventProperties?: Record<string, unknown>) {
if (!isProductionEnv()) { if (!API_KEY) {
console.log(`[amplitude(${eventName})]: ${JSON.stringify(eventProperties)}`) console.log(`[analytics(${eventName})]: ${JSON.stringify(eventProperties)}`)
return return
} }
track(eventName, eventProperties) track(eventName, eventProperties)
} }
/** Sends a draft event to Amplitude test project. */
export function sendTestAnalyticsEvent(eventName: string, eventProperties?: Record<string, unknown>) {
if (isProductionEnv()) return
track(eventName, eventProperties)
}
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