Skip to content

Commit

Permalink
Update/recaptcha script (#1680)
Browse files Browse the repository at this point in the history
* chore:NEXT_PUBLIC_GA_MEASUREMENT_ID to constants

* update:wrapper recaptcha script in conditional

* Update _app.tsx

---------

Co-authored-by: Ruslan K <[email protected]>
  • Loading branch information
maceteligolden and evereq authored Oct 30, 2023
1 parent b922350 commit b027fd4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions apps/web/app/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const INVITE_CALLBACK_URL = process.env.INVITE_CALLBACK_URL;
export const INVITE_CALLBACK_PATH = '/auth/passcode';

Check warning on line 36 in apps/web/app/constants.ts

View workflow job for this annotation

GitHub Actions / Cspell

Unknown word (passcode)
export const VERIFY_EMAIL_CALLBACK_URL = process.env.VERIFY_EMAIL_CALLBACK_URL;
export const VERIFY_EMAIL_CALLBACK_PATH = '/verify-email';
export const GA_MEASUREMENT_ID = process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID

export const SMTP_FROM_ADDRESS = process.env.SMTP_FROM_ADDRESS || '[email protected]';
export const SMTP_HOST = process.env.SMTP_HOST || '';
Expand Down
30 changes: 18 additions & 12 deletions apps/web/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable no-mixed-spaces-and-tabs */
import 'react-loading-skeleton/dist/skeleton.css';
import '../styles/globals.css';

import { jitsuConfiguration } from '@app/constants';
import { GA_MEASUREMENT_ID, RECAPTCHA_SITE_KEY, jitsuConfiguration } from '@app/constants';
import { JitsuProvider } from '@jitsu/jitsu-react';
import { Analytics } from '@vercel/analytics/react';
import { AppState } from 'lib/app/init-state';
Expand All @@ -16,20 +15,27 @@ import { SkeletonTheme } from 'react-loading-skeleton';
import { RecoilRoot } from 'recoil';
import { JitsuAnalytics } from '../lib/components/services/jitsu-analytics';
import i18n from '../ni18n.config';

const MyApp = ({ Component, pageProps }: AppProps) => {
const isJitsuEnvsPresent = jitsuConfiguration.host && jitsuConfiguration.writeKey;
return (
<>
<Script
strategy="lazyOnload"
src={`https://www.googletagmanager.com/gtag/js?id=${process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID}`}
/>
<Script strategy="lazyOnload" id="google-analytic-script">
{` window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID}');`}
</Script>

{GA_MEASUREMENT_ID && (
<>
<Script
strategy="lazyOnload"
src={`https://www.googletagmanager.com/gtag/js?id=${GA_MEASUREMENT_ID}`}
/>
<Script strategy="lazyOnload" id="google-analytic-script">
{` window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}

Check warning on line 32 in apps/web/pages/_app.tsx

View workflow job for this annotation

GitHub Actions / Cspell

Unknown word (gtag)
gtag('js', new Date());

Check warning on line 33 in apps/web/pages/_app.tsx

View workflow job for this annotation

GitHub Actions / Cspell

Unknown word (gtag)
gtag('config', '${GA_MEASUREMENT_ID}');`}

Check warning on line 34 in apps/web/pages/_app.tsx

View workflow job for this annotation

GitHub Actions / Cspell

Unknown word (gtag)
</Script>
</>
)}

<Head>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="" />
Expand Down

0 comments on commit b027fd4

Please sign in to comment.