Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RENO-3609: Remove GA Code #196

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ OAUTH_CLIENT_ID=askTeammate
OAUTH_CLIENT_SECRET=askTeammate
IPSTACK_KEY=askTeammate
# PRODUCTION
NEXT_PUBLIC_ADOBE_ANALYTICS_TAG=https://assets.adobedtm.com/1a9376472d37/8519dfce636d/launch-672b7e7f98ee.min.js

NEXT_PUBLIC_ADOBE_ANALYTICS_TAG=https://assets.adobedtm.com/1a9376472d37/8519dfce636d/launch-672b7e7f98ee.min.js
38 changes: 0 additions & 38 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import "../src/styles/main.scss";
import Head from "next/head";
import { useForm, FormProvider } from "react-hook-form";
import isEmpty from "lodash/isEmpty";
import gaUtils, { getGoogleGACode } from "../src/externals/gaUtils";
import {
FormDataContextProvider,
formInitialState,
Expand All @@ -28,24 +27,6 @@ interface MyAppProps {
pageProps: any;
}

/**
* Determines if we are running on server or in the client.
* @return {boolean} true if running on server
*/
function isServerRendered(): boolean {
return typeof window === "undefined";
}

// Get the Google Analytics code for the HTML snippet below.
const isProduction = appConfig.nodeEnv === "production";
const gaCode = getGoogleGACode(isProduction);
// Set up Google Analytics if it isn't already. There's an HTML snippet in the
// DOM below that initializes GA. If it fails, this tries again. The HTML
// snippet is better since it works without javascript.
if (!isServerRendered()) {
gaUtils.setupAnalytics(isProduction);
}

function MyApp({ Component, pageProps }: MyAppProps) {
const router = useRouter();
useRouterScroll({ top: 640 });
Expand Down Expand Up @@ -168,25 +149,6 @@ function MyApp({ Component, pageProps }: MyAppProps) {
name="twitter:image"
content="https://www.nypl.org/sites/default/files/library_card-1200x800.jpg"
/>
{/* <!-- Google Analytics --> */}
{/* We can't directly put the script into this component because React
doesn't allow it, so we must add it through the
`dangerouslySetInnerHTML` prop.
*/}
<script
dangerouslySetInnerHTML={{
__html: `
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', '${gaCode}', 'auto');
ga('send', 'pageview');
`,
}}
/>
{/* <!-- End Google Analytics --> */}
</Head>
<DSProvider>
<FormProvider {...formMethods}>
Expand Down
2 changes: 0 additions & 2 deletions src/components/AccountFormContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import RoutingLinks from "../RoutingLinks.tsx";
import AccountFormFields from "../AccountFormFields";
import AcceptTermsFormFields from "../AcceptTermsFormFields";
import { findLibraryCode, findLibraryName } from "../../utils/formDataUtils";
import { lcaEvents } from "../../externals/gaUtils";
import FormField from "../FormField";
import { createQueryParams } from "../../utils/utils";

Expand Down Expand Up @@ -40,7 +39,6 @@ const AccountFormContainer = (): React.ReactElement => {
});

const nextUrl = `/review?${queryStr}`;
lcaEvents("Navigation", `Next button to ${nextUrl}`);
router.push(nextUrl);
};

Expand Down
2 changes: 0 additions & 2 deletions src/components/AddressContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
import Loader from "../Loader";
import FormField from "../FormField";
import { constructAddressType } from "../../utils/formDataUtils";
import { lcaEvents } from "../../externals/gaUtils";
import { nyCounties, nyCities, createQueryParams } from "../../utils/utils";
import useFormDataContext from "../../context/FormDataContext";
import { commonAPIErrors } from "../../data/apiErrorMessageTranslations";
Expand Down Expand Up @@ -122,7 +121,6 @@ const AddressContainer: React.FC = () => {
} else {
nextUrl = `/address-verification?${queryStr}`;
}
lcaEvents("Navigation", `Next button to ${nextUrl}`);
router.push(nextUrl);
} else {
setTimeout(() => {
Expand Down
2 changes: 0 additions & 2 deletions src/components/AddressVerificationContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import useFormDataContext from "../../../src/context/FormDataContext";
import { Address, AddressResponse } from "../../../src/interfaces";
import RoutingLinks from "../../../src/components/RoutingLinks.tsx";
import styles from "./AddressVerificationContainer.module.css";
import { lcaEvents } from "../../externals/gaUtils";
import FormField from "../FormField";
import { createQueryParams } from "../../utils/utils";

Expand Down Expand Up @@ -131,7 +130,6 @@ function AddressVerificationContainer(): React.ReactElement {

// Finally, go to the acount page.
const nextUrl = `/account?${queryStr}`;
lcaEvents("Navigation", `Next button to ${nextUrl}`);
router.push(nextUrl);
};

Expand Down
2 changes: 0 additions & 2 deletions src/components/PersonalFormContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useRouter } from "next/router";
import useFormDataContext from "../../context/FormDataContext";
import PersonalFormFields from "../PersonalFormFields";
import RoutingLinks from "../RoutingLinks.tsx";
import { lcaEvents } from "../../externals/gaUtils";
import FormField from "../FormField";
import {
Form,
Expand Down Expand Up @@ -39,7 +38,6 @@ const PersonalFormContainer = () => {
});

const nextUrl = `/location?${queryStr}`;
lcaEvents("Navigation", `Next button to ${nextUrl}`);
router.push(nextUrl);
};

Expand Down
4 changes: 0 additions & 4 deletions src/components/ReviewFormContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import styles from "./ReviewFormContainer.module.css";
import AcceptTermsFormFields from "../AcceptTermsFormFields";
import Loader from "../Loader";
import FormField from "../FormField";
import { lcaEvents } from "../../externals/gaUtils";
import aaUtils from "../../externals/aaUtils";
import { createQueryParams } from "../../utils/utils";
import useFormDataContext from "../../../src/context/FormDataContext";
Expand Down Expand Up @@ -90,7 +89,6 @@ function ReviewFormContainer() {
buttonType="primary"
id={`editSectionButton-${sectionName}`}
onClick={() => {
lcaEvents("Edit", sectionName);
editSectionFlag(true);
}}
>
Expand All @@ -114,7 +112,6 @@ function ReviewFormContainer() {
buttonType="primary"
id="editAddressButton"
onClick={() => {
lcaEvents("Edit", "Location/Address");
router.push(`/location?${queryStr}`);
}}
>
Expand Down Expand Up @@ -188,7 +185,6 @@ function ReviewFormContainer() {
.then((response) => {
// Update the global state with a successful form submission data.
dispatch({ type: "SET_FORM_RESULTS", value: response.data });
lcaEvents("Submit", "Submit");

// Adobe Analytics
aaUtils.trackApplicationSubmitEvent({
Expand Down
11 changes: 1 addition & 10 deletions src/components/RoutingLinks.tsx/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import React from "react";
import Link from "next/link";
import { useTranslation } from "next-i18next";

import { lcaEvents } from "../../externals/gaUtils";
import aaUtils from "../../externals/aaUtils";
import styles from "./RoutingLinks.module.css";

Expand Down Expand Up @@ -36,14 +35,7 @@ function RoutingLinks({ previous, next }: RoutingLinksType): JSX.Element {
<div className={styles.container}>
{previous?.url && (
<Link href={previous.url}>
<a
className={styles.previous}
onClick={() =>
lcaEvents("Navigation", `Previous button to ${previous.url}`)
}
>
{previousText}
</a>
<a className={styles.previous}>{previousText}</a>
</Link>
)}
{!next?.submit ? (
Expand All @@ -53,7 +45,6 @@ function RoutingLinks({ previous, next }: RoutingLinksType): JSX.Element {
// Just track the "Get Started" or "Submit" clicks. Routing events
// are tracked at the component level in each "onSubmit".
onClick={() => {
lcaEvents("Navigation", next.text);
aaUtils.trackCtaEvent("Start Application", next.text, next.url);
}}
>
Expand Down
4 changes: 0 additions & 4 deletions src/components/UsernameValidationFormFields/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { isAlphanumeric } from "validator";
import FormField from "../FormField";
import useFormDataContext from "../../context/FormDataContext";
import styles from "./UsernameValidationFormFields.module.css";
import { lcaEvents } from "../../externals/gaUtils";
import {
apiErrorTranslations,
commonAPIErrors,
Expand Down Expand Up @@ -74,8 +73,6 @@ const UsernameValidationForm = ({
if (lang !== "en") {
message = apiTranslations[message][lang] || message;
}

lcaEvents("Availability Checker", "Username - available");
setUsernameIsAvailable({
available: true,
message,
Expand All @@ -97,7 +94,6 @@ const UsernameValidationForm = ({
message = apiErrorTranslations[message][lang] || message;
}

lcaEvents("Availability Checker", "Username - unavailable");
setUsernameIsAvailable({
available: false,
message,
Expand Down
2 changes: 0 additions & 2 deletions src/components/WorkAddressContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
} from "../../interfaces";
import Loader from "../Loader";
import FormField from "../FormField";
import { lcaEvents } from "../../externals/gaUtils";
import { constructAddressType } from "../../utils/formDataUtils";
import useFormDataContext from "../../context/FormDataContext";
import { createQueryParams } from "../../utils/utils";
Expand Down Expand Up @@ -115,7 +114,6 @@ const AddressContainer: React.FC = () => {
} else {
setIsLoading(false);
nextUrl = `/address-verification?${queryStr}`;
lcaEvents("Navigation", `Next button to ${nextUrl}`);
router.push(nextUrl);
}
});
Expand Down
95 changes: 0 additions & 95 deletions src/externals/gaUtils.test.ts

This file was deleted.

Loading