mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix: clean up google analytics (#59178)
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
@@ -1,5 +1,2 @@
|
|||||||
export const prodAnalyticsId = 'GTM-57R6KJM';
|
export const prodAnalyticsId = 'GTM-57R6KJM';
|
||||||
export const devAnalyticsId = 'GTM-WSS47LM';
|
export const devAnalyticsId = 'GTM-WSS47LM';
|
||||||
|
|
||||||
// this id includes a stream for the spanish learn platform
|
|
||||||
export const prodAnalyticsESId = 'GTM-KCS6GSD';
|
|
||||||
|
|||||||
@@ -54,11 +54,6 @@ interface DonationViewEvent {
|
|||||||
action: DonationViewEventAction;
|
action: DonationViewEventAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface RenderTimeEvent {
|
|
||||||
event: 'render_time';
|
|
||||||
render_time_msec: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PageViewEvent {
|
interface PageViewEvent {
|
||||||
event: 'pageview';
|
event: 'pageview';
|
||||||
pagePath: string;
|
pagePath: string;
|
||||||
@@ -96,7 +91,6 @@ export type GAevent =
|
|||||||
| DonationViewEvent
|
| DonationViewEvent
|
||||||
| DonationEvent
|
| DonationEvent
|
||||||
| DonationRelatedEvent
|
| DonationRelatedEvent
|
||||||
| RenderTimeEvent
|
|
||||||
| PageViewEvent
|
| PageViewEvent
|
||||||
| ExperimentViewEvent
|
| ExperimentViewEvent
|
||||||
| ChallengeFailedEvent
|
| ChallengeFailedEvent
|
||||||
|
|||||||
@@ -2,17 +2,15 @@ import TagManager from 'react-gtm-module';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
devAnalyticsId,
|
devAnalyticsId,
|
||||||
prodAnalyticsId,
|
prodAnalyticsId
|
||||||
prodAnalyticsESId
|
|
||||||
} from '../../config/analytics-settings';
|
} from '../../config/analytics-settings';
|
||||||
|
|
||||||
import envData from '../../config/env.json';
|
import envData from '../../config/env.json';
|
||||||
|
|
||||||
const { deploymentEnv, clientLocale } = envData;
|
const { deploymentEnv } = envData;
|
||||||
|
|
||||||
const analyticsIDSelector = () => {
|
const analyticsIDSelector = () => {
|
||||||
if (deploymentEnv === 'staging') return devAnalyticsId;
|
if (deploymentEnv === 'staging') return devAnalyticsId;
|
||||||
else if (clientLocale === 'espanol') return prodAnalyticsESId;
|
|
||||||
else return prodAnalyticsId;
|
else return prodAnalyticsId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -47,8 +47,7 @@ import {
|
|||||||
initTests,
|
initTests,
|
||||||
stopResetting,
|
stopResetting,
|
||||||
openModal,
|
openModal,
|
||||||
resetAttempts,
|
resetAttempts
|
||||||
sendRenderTime
|
|
||||||
} from '../redux/actions';
|
} from '../redux/actions';
|
||||||
import {
|
import {
|
||||||
attemptsSelector,
|
attemptsSelector,
|
||||||
@@ -98,7 +97,6 @@ export interface EditorProps {
|
|||||||
openResetModal: () => void;
|
openResetModal: () => void;
|
||||||
resizeProps: ResizeProps;
|
resizeProps: ResizeProps;
|
||||||
saveChallenge: () => void;
|
saveChallenge: () => void;
|
||||||
sendRenderTime: (renderTime: number) => void;
|
|
||||||
saveEditorContent: () => void;
|
saveEditorContent: () => void;
|
||||||
setEditorFocusability: (isFocusable: boolean) => void;
|
setEditorFocusability: (isFocusable: boolean) => void;
|
||||||
submitChallenge: () => void;
|
submitChallenge: () => void;
|
||||||
@@ -180,7 +178,6 @@ const mapDispatchToProps = {
|
|||||||
initTests,
|
initTests,
|
||||||
stopResetting,
|
stopResetting,
|
||||||
resetAttempts,
|
resetAttempts,
|
||||||
sendRenderTime,
|
|
||||||
openHelpModal: () => openModal('help'),
|
openHelpModal: () => openModal('help'),
|
||||||
openResetModal: () => openModal('reset')
|
openResetModal: () => openModal('reset')
|
||||||
};
|
};
|
||||||
@@ -1222,11 +1219,6 @@ const Editor = (props: EditorProps): JSX.Element => {
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [props.challengeFiles, props.isResetting]);
|
}, [props.challengeFiles, props.isResetting]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
props.sendRenderTime(Date.now());
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, [props.description]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const { showProjectPreview, previewOpen } = props;
|
const { showProjectPreview, previewOpen } = props;
|
||||||
if (!previewOpen && showProjectPreview) {
|
if (!previewOpen && showProjectPreview) {
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ export const actionTypes = createTypes(
|
|||||||
'storePortalWindow',
|
'storePortalWindow',
|
||||||
'removePortalWindow',
|
'removePortalWindow',
|
||||||
'challengeMounted',
|
'challengeMounted',
|
||||||
'sendRenderTime',
|
|
||||||
'checkChallenge',
|
'checkChallenge',
|
||||||
'resetChallenge',
|
'resetChallenge',
|
||||||
'stopResetting',
|
'stopResetting',
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ export const storePortalWindow = createAction(actionTypes.storePortalWindow);
|
|||||||
export const removePortalWindow = createAction(actionTypes.removePortalWindow);
|
export const removePortalWindow = createAction(actionTypes.removePortalWindow);
|
||||||
|
|
||||||
export const challengeMounted = createAction(actionTypes.challengeMounted);
|
export const challengeMounted = createAction(actionTypes.challengeMounted);
|
||||||
export const sendRenderTime = createAction(actionTypes.sendRenderTime);
|
|
||||||
export const checkChallenge = createAction(actionTypes.checkChallenge);
|
export const checkChallenge = createAction(actionTypes.checkChallenge);
|
||||||
export const executeChallenge = createAction(actionTypes.executeChallenge);
|
export const executeChallenge = createAction(actionTypes.executeChallenge);
|
||||||
export const executeChallengeComplete = createAction(
|
export const executeChallengeComplete = createAction(
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
import { put, takeEvery, select, call } from 'redux-saga/effects';
|
import { put, takeEvery } from 'redux-saga/effects';
|
||||||
import store from 'store';
|
import store from 'store';
|
||||||
|
|
||||||
import { randomCompliment } from '../../../utils/get-words';
|
import { randomCompliment } from '../../../utils/get-words';
|
||||||
import { setRenderStartTime } from '../../../redux/actions';
|
|
||||||
import { renderStartTimeSelector } from '../../../redux/selectors';
|
|
||||||
import callGA from '../../../analytics/call-ga';
|
|
||||||
import { CURRENT_CHALLENGE_KEY } from './action-types';
|
import { CURRENT_CHALLENGE_KEY } from './action-types';
|
||||||
import { updateSuccessMessage } from './actions';
|
import { updateSuccessMessage } from './actions';
|
||||||
|
|
||||||
@@ -33,26 +30,9 @@ function* updateSuccessMessageSaga() {
|
|||||||
yield put(updateSuccessMessage(randomCompliment()));
|
yield put(updateSuccessMessage(randomCompliment()));
|
||||||
}
|
}
|
||||||
|
|
||||||
function* sendRenderTimeSaga({ payload }) {
|
|
||||||
/*
|
|
||||||
This saga sends the difference between a challenge submission time
|
|
||||||
and next challenge's description change time to google analytics.
|
|
||||||
*/
|
|
||||||
const renderStartTime = yield select(renderStartTimeSelector);
|
|
||||||
if (renderStartTime) {
|
|
||||||
const challengeRenderTime = payload - renderStartTime;
|
|
||||||
yield put(setRenderStartTime(null));
|
|
||||||
yield call(callGA, {
|
|
||||||
event: 'render_time',
|
|
||||||
render_time_msec: challengeRenderTime
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createCurrentChallengeSaga(types) {
|
export function createCurrentChallengeSaga(types) {
|
||||||
return [
|
return [
|
||||||
takeEvery(types.challengeMounted, currentChallengeSaga),
|
takeEvery(types.challengeMounted, currentChallengeSaga),
|
||||||
takeEvery(types.challengeMounted, updateSuccessMessageSaga),
|
takeEvery(types.challengeMounted, updateSuccessMessageSaga)
|
||||||
takeEvery(types.sendRenderTime, sendRenderTimeSaga)
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user