react-ga4
react-ga4 copied to clipboard
how to set csp for using in chrome extension app?
I got an error "Refused to load the script 'https://www.googletagmanager.com/gtag/js?id=G-....' because it violates the following Content Security Policy directive: "script-src 'self' 'wasm-unsafe-eval'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback."
I read about csp but I'm not sure what I do for solving this error.
I added csp rules like below in "manifest.json" file.
"host_permissions": [ "https://www.googletagmanager.com/*" ], "content_security_policy": { "extension_pages": "script-src 'self'; object-src 'self'; script-src-elem 'https://www.googletagmanager.com';" }
Maybe this doc will help https://developers.google.com/tag-platform/tag-manager/web/csp
react-ga4 is not working due to above error. Tried above doc.
Here is an example: https://github.com/GoogleChrome/chrome-extensions-samples/blob/main/functional-samples/tutorial.google-analytics/README.md. It would be better if you could encapsulate a layer to support Chrome Extension.