mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-27 11:01:38 -04:00
24 lines
486 B
TypeScript
24 lines
486 B
TypeScript
import TagManager from 'react-gtm-module';
|
|
|
|
import {
|
|
devAnalyticsId,
|
|
prodAnalyticsId
|
|
} from '../../config/analytics-settings';
|
|
|
|
import envData from '../../config/env.json';
|
|
|
|
const { deploymentEnv } = envData;
|
|
|
|
const analyticsIDSelector = () => {
|
|
if (deploymentEnv === 'staging') return devAnalyticsId;
|
|
else return prodAnalyticsId;
|
|
};
|
|
|
|
const gtmId = analyticsIDSelector();
|
|
|
|
if (typeof document !== `undefined`) {
|
|
TagManager.initialize({ gtmId });
|
|
}
|
|
|
|
export default TagManager;
|