remove gtag
This commit is contained in:
parent
3461995791
commit
b7c3a4a2e6
|
@ -31,8 +31,8 @@ RUN yarn build
|
|||
FROM node:14.18.1-alpine AS runner
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV production
|
||||
ENV BUILDING_PROCESS false
|
||||
ENV NODE_ENV=production
|
||||
ENV BUILDING_PROCESS=false
|
||||
COPY --from=builder /app/next.config.js ./
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/.next ./.next
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
export enum Event {
|
||||
StartTest = 'start_test',
|
||||
FinishTest = 'finish_test',
|
||||
SelectAnswer = 'select_answer',
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
import { useEffect, useMemo, useRef, useState, Fragment } from 'react';
|
||||
import { Fragment, useRef, useState } from 'react';
|
||||
import { useUpdateEffect } from 'react-use';
|
||||
import clsx from 'clsx';
|
||||
import { usePrompt } from 'libs/hooks';
|
||||
|
@ -9,8 +9,6 @@ import {
|
|||
Query,
|
||||
Question as QuestionT,
|
||||
} from 'libs/graphql';
|
||||
import { Event } from 'config/analytics';
|
||||
import gtag from 'utils/gtag';
|
||||
import { QUERY_GENERATE_TEST_SIMILAR_QUALIFICATIONS } from '../../queries';
|
||||
import { QueryGenerateTestSimilarQualificationsArgs } from '../../types';
|
||||
|
||||
|
@ -53,20 +51,6 @@ const Test = ({ initialQuestions, qualification }: TestProps) => {
|
|||
const classes = useStyles();
|
||||
const maxTabIndex = questions.length + (reviewMode ? 1 : 0) - 1;
|
||||
usePrompt(!reviewMode);
|
||||
const analyticsParams = useMemo(
|
||||
() => ({
|
||||
qualificationID: qualification.id.toString(),
|
||||
questions: questions.length.toString(),
|
||||
}),
|
||||
[qualification, questions]
|
||||
);
|
||||
useEffect(() => {
|
||||
gtag(
|
||||
'event',
|
||||
reviewMode ? Event.FinishTest : Event.StartTest,
|
||||
analyticsParams
|
||||
);
|
||||
}, [reviewMode, analyticsParams]);
|
||||
useUpdateEffect(() => {
|
||||
if (headingRef.current?.scrollIntoView) {
|
||||
headingRef.current?.scrollIntoView({
|
||||
|
@ -104,12 +88,6 @@ const Test = ({ initialQuestions, qualification }: TestProps) => {
|
|||
index2 === index ? newAnswer : oldAnswer
|
||||
)
|
||||
);
|
||||
gtag('event', Event.SelectAnswer, {
|
||||
qualificationID: analyticsParams.qualificationID,
|
||||
questionID: questions[index].id.toString(),
|
||||
answer: newAnswer,
|
||||
correct: questions[index].correctAnswer === newAnswer ? '1' : '0',
|
||||
});
|
||||
};
|
||||
|
||||
const handleReset = async () => {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import React from 'react';
|
||||
import Document, {
|
||||
DocumentContext,
|
||||
Html,
|
||||
Main,
|
||||
NextScript,
|
||||
DocumentContext,
|
||||
Head,
|
||||
} from 'next/document';
|
||||
import { ServerStyleSheets } from '@material-ui/styles';
|
||||
|
@ -34,24 +34,7 @@ export default class MyDocument extends Document {
|
|||
render() {
|
||||
return (
|
||||
<Html>
|
||||
<Head>
|
||||
<script
|
||||
async
|
||||
src={`https://www.googletagmanager.com/gtag/js?id=${process.env.GA_TRACKING_ID}`}
|
||||
/>
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', '${process.env.GA_TRACKING_ID}', {
|
||||
page_path: window.location.pathname,
|
||||
});
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
</Head>
|
||||
<Head />
|
||||
<body>
|
||||
<Main />
|
||||
<NextScript />
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
import { Event } from 'config/analytics';
|
||||
|
||||
type GTagFN = (
|
||||
type: 'event',
|
||||
event: Event,
|
||||
params: { [key: string]: string }
|
||||
) => void;
|
||||
|
||||
interface customWindow extends Window {
|
||||
gtag: GTagFN;
|
||||
}
|
||||
|
||||
declare const window: customWindow;
|
||||
|
||||
const gtag: GTagFN = (t, event, params) => {
|
||||
window.gtag(t, event, params);
|
||||
};
|
||||
|
||||
export default gtag;
|
Reference in New Issue