Skip to content

Commit

Permalink
feat: use local ga.js instead
Browse files Browse the repository at this point in the history
  • Loading branch information
ineo6 committed May 9, 2021
1 parent b858d3d commit d32f3fb
Show file tree
Hide file tree
Showing 5 changed files with 2,466 additions and 3 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ extension/
typings
**/*.d.ts
src/common/template/template.js
views/ga.js
3 changes: 2 additions & 1 deletion src/common/analytics.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { STORE } from '@/common/core.constants';
import extStore from '@/common/core.storage';
import { browser } from 'webextension-polyfill-ts';

export interface IEvent {
eventCategory: string;
Expand Down Expand Up @@ -70,7 +71,7 @@ export default class Analytics {
const ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = 'https://ssl.google-analytics.com/ga.js';
ga.src = browser.extension.getURL('/ga.js');
const s = document.getElementsByTagName('script')[0];
// @ts-ignore
s.parentNode.insertBefore(ga, s);
Expand Down
4 changes: 2 additions & 2 deletions src/manifest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const devMatches = ['https://github.com/*', 'https://gitlab.com/*', 'https://try

const prodMatches = ['http://*/*', 'https://*/*'];

let csp = "script-src 'self' https://ssl.google-analytics.com 'unsafe-eval'; object-src 'self'";
let csp = "script-src 'self' 'unsafe-eval'; object-src 'self'";

if (process.env.NODE_ENV === 'production') {
csp = "script-src 'self' https://ssl.google-analytics.com; object-src 'self'";
csp = "script-src 'self'; object-src 'self'";
}

const manifestInput = {
Expand Down

0 comments on commit d32f3fb

Please sign in to comment.