chore: remove Google Analytics from CSP (#6888)

* disable ga

* comment
This commit is contained in:
Vignesh Mohankumar 2023-07-07 14:15:41 -04:00 committed by GitHub
parent e169c9d900
commit e4dbef80eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 12 deletions

@ -19,9 +19,9 @@
<meta <meta
http-equiv="Content-Security-Policy" http-equiv="Content-Security-Policy"
<% if (process.env.REACT_APP_CSP_ALLOW_UNSAFE_EVAL) { %> <% if (process.env.REACT_APP_CSP_ALLOW_UNSAFE_EVAL) { %>
content="script-src 'self' https://www.google-analytics.com https://www.googletagmanager.com 'unsafe-inline' 'unsafe-eval'" content="script-src 'self' 'unsafe-inline' 'unsafe-eval'"
<% } else { %> <% } else { %>
content="script-src 'self' https://www.google-analytics.com https://www.googletagmanager.com 'unsafe-inline'" content="script-src 'self' 'unsafe-inline'"
<% } %> <% } %>
/> />
@ -37,8 +37,6 @@
--> -->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link rel="preconnect" href="https://www.google-analytics.com/" />
<link rel="preload" href="%PUBLIC_URL%/fonts/Inter-roman.var.woff2" as="font" type="font/woff2" crossorigin /> <link rel="preload" href="%PUBLIC_URL%/fonts/Inter-roman.var.woff2" as="font" type="font/woff2" crossorigin />
<style> <style>

@ -1,4 +1,7 @@
import ReactGA from 'react-ga4' /* eslint-disable no-unused-vars */
// TODO(WEB-2166): Delete this file when we remove Google Analytics completely.
import { GaOptions, InitOptions, UaEventOptions } from 'react-ga4/types/ga4' import { GaOptions, InitOptions, UaEventOptions } from 'react-ga4/types/ga4'
/** /**
@ -6,7 +9,7 @@ import { GaOptions, InitOptions, UaEventOptions } from 'react-ga4/types/ga4'
*/ */
export default class GoogleAnalyticsProvider { export default class GoogleAnalyticsProvider {
public sendEvent(event: string | UaEventOptions, params?: any) { public sendEvent(event: string | UaEventOptions, params?: any) {
ReactGA.event(event, params) // ReactGA.event(event, params)
} }
public initialize( public initialize(
@ -19,11 +22,11 @@ export default class GoogleAnalyticsProvider {
gtagOptions?: any gtagOptions?: any
} }
) { ) {
ReactGA.initialize(GA_MEASUREMENT_ID, options) // ReactGA.initialize(GA_MEASUREMENT_ID, options)
} }
public set(fieldsObject: any) { public set(fieldsObject: any) {
ReactGA.set(fieldsObject) // ReactGA.set(fieldsObject)
} }
public outboundLink( public outboundLink(
@ -34,18 +37,18 @@ export default class GoogleAnalyticsProvider {
}, },
hitCallback: () => unknown hitCallback: () => unknown
) { ) {
ReactGA.outboundLink({ label }, hitCallback) // ReactGA.outboundLink({ label }, hitCallback)
} }
public pageview(path?: string, _?: string[], title?: string) { public pageview(path?: string, _?: string[], title?: string) {
ReactGA.pageview(path, _, title) // ReactGA.pageview(path, _, title)
} }
public ga(...args: any[]) { public ga(...args: any[]) {
ReactGA.ga(...args) // ReactGA.ga(...args)
} }
public gaCommandSendTiming(timingCategory: any, timingVar: any, timingValue: any, timingLabel: any) { public gaCommandSendTiming(timingCategory: any, timingVar: any, timingValue: any, timingLabel: any) {
ReactGA._gaCommandSendTiming(timingCategory, timingVar, timingValue, timingLabel) // ReactGA._gaCommandSendTiming(timingCategory, timingVar, timingValue, timingLabel)
} }
} }