From 96c80bf57b27a9fded9fd727530933cb95f591ea Mon Sep 17 00:00:00 2001 From: Philip Garrison Date: Tue, 2 Jan 2024 19:52:33 -0800 Subject: [PATCH] Revert "Google Analytics" This reverts commit 590144502edd31acd579ab98267681b05b02a20c. --- README.md | 3 --- package.json | 6 +----- src/analytics/analytics.ts | 38 --------------------------------- src/content-script.ts | 9 ++------ src/content-script/fill-form.ts | 2 -- src/service-worker.ts | 4 +--- yarn.lock | 18 ---------------- 7 files changed, 4 insertions(+), 76 deletions(-) delete mode 100644 src/analytics/analytics.ts diff --git a/README.md b/README.md index 16bf61a..6dab660 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,6 @@ Chrome extension for autofilling Allen Institute time cards. With a single click, you can fill out a time card with a single time code for 8 hours M-F. -## Privacy and user data -This extension sends a minimal amount of data to Google Analytics to count how many people use it. - ## Installation Currently only Chrome is supported. diff --git a/package.json b/package.json index e98c9e9..7ff6424 100644 --- a/package.json +++ b/package.json @@ -5,10 +5,9 @@ "build": "webpack --config webpack.config.js", "test": "jest" }, - "devDependencies": { + "dependencies": { "@types/chrome": "^0.0.254", "@types/jest": "^29.5.11", - "@types/uuid": "^9", "copy-webpack-plugin": "^11.0.0", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", @@ -17,8 +16,5 @@ "typescript": "^5.3.3", "webpack": "^5.89.0", "webpack-cli": "^5.1.4" - }, - "dependencies": { - "uuid": "^9.0.1" } } diff --git a/src/analytics/analytics.ts b/src/analytics/analytics.ts deleted file mode 100644 index 812e102..0000000 --- a/src/analytics/analytics.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { v4 as uuidv4 } from 'uuid'; - -type Event = { - type: string, - message?: string -} - -const ENDPOINT = 'https://www.google-analytics.com/mp/collect'; -const MEASUREMENT_ID = 'G-1FJ6WGED0Z'; -// Google calls this a secret but it cannot actually be kept secret from the user, since it needs to -// be sent in the request body in plaintext -const API_SECRET = 't9gjFt5pRrOCONtfbr5M2g'; - -export function sendEvents(events: Event[]) { - return fetch(ENDPOINT + '?' + new URLSearchParams({ - measurement_id: MEASUREMENT_ID, - api_secret: API_SECRET, - }), { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - client_id: `bwicxmdh${uuidv4()}`, - events - }) - }).then(response => { - if (!response.ok) { - throw new Error(response.statusText) - } - return response.json() - }); -} - -export function sendError(error: Error) { - sendEvents([{ type: "error", message: error.toString() }]); - return error; -} \ No newline at end of file diff --git a/src/content-script.ts b/src/content-script.ts index 575eca7..4e3b2b3 100644 --- a/src/content-script.ts +++ b/src/content-script.ts @@ -1,12 +1,6 @@ import { SupportQuery, Supported, TimeCardOptionsMessage } from './time-card' import fillOutForm from './content-script/fill-form' import { navigateToAddTimeCard, isSupportedPage } from './content-script/navigate-to-time-cards' -import { sendError } from './analytics/analytics'; - -async function navigateAndFill(request: TimeCardOptionsMessage) { - await navigateToAddTimeCard(); - return fillOutForm(request); -} chrome.runtime.onMessage.addListener( async function(request: TimeCardOptionsMessage | SupportQuery, _, sendResponse) { @@ -17,7 +11,8 @@ chrome.runtime.onMessage.addListener( console.log('Time sheet autofiller activated on unsupported page.'); return; } - navigateAndFill(request).catch(sendError); + await navigateToAddTimeCard(); + fillOutForm(request); } } ); diff --git a/src/content-script/fill-form.ts b/src/content-script/fill-form.ts index 14751c5..2ce7f16 100644 --- a/src/content-script/fill-form.ts +++ b/src/content-script/fill-form.ts @@ -1,4 +1,3 @@ -import { sendError, sendEvents } from '../analytics/analytics'; import { TimeCardOptions } from '../time-card' import { waitForElms, findOne, xpathSnapshotToArray } from './domQuery'; import getWeekdayCells from './get-weekday-cells'; @@ -62,5 +61,4 @@ export default async function fillOutForm(request: TimeCardOptions) { enabledWeekdays.forEach(el => el.click()); (await findOne('img[title="Close"]')).click(); (await findOne('//a[span="OK"]', true)).click(); - sendEvents([{ type: "success" }]) } diff --git a/src/service-worker.ts b/src/service-worker.ts index 54171f8..de966f8 100644 --- a/src/service-worker.ts +++ b/src/service-worker.ts @@ -1,5 +1,4 @@ import { SupportQuery, Supported, TimeCardOptions, TimeCardOptionsMessage } from './time-card' -import { sendEvents, sendError } from './analytics/analytics'; function setSupported(isSupported: boolean) { const icon = isSupported ? 'icons/icon16.png' : 'icons/gray16.png'; @@ -22,9 +21,8 @@ chrome.runtime.onMessage.addListener((message: Supported) => { }); chrome.action.onClicked.addListener((tab) => { - sendEvents([{ type: "activated" }]); chrome.storage.sync.get().then((settings: TimeCardOptions) => { const options: TimeCardOptionsMessage = { messageType: 'click', ...settings }; chrome.tabs.sendMessage(tab.id, options); - }).catch(sendError); + }); }); \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index ee6372b..ea29578 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1005,13 +1005,6 @@ __metadata: languageName: node linkType: hard -"@types/uuid@npm:^9": - version: 9.0.7 - resolution: "@types/uuid@npm:9.0.7" - checksum: b329ebd4f9d1d8e08d4f2cc211be4922d70d1149f73d5772630e4a3acfb5170c6d37b3d7a39a0412f1a56e86e8a844c7f297c798b082f90380608bf766688787 - languageName: node - linkType: hard - "@types/yargs-parser@npm:*": version: 21.0.3 resolution: "@types/yargs-parser@npm:21.0.3" @@ -3795,14 +3788,12 @@ __metadata: dependencies: "@types/chrome": "npm:^0.0.254" "@types/jest": "npm:^29.5.11" - "@types/uuid": "npm:^9" copy-webpack-plugin: "npm:^11.0.0" jest: "npm:^29.7.0" jest-environment-jsdom: "npm:^29.7.0" ts-jest: "npm:^29.1.1" ts-loader: "npm:^9.5.1" typescript: "npm:^5.3.3" - uuid: "npm:^9.0.1" webpack: "npm:^5.89.0" webpack-cli: "npm:^5.1.4" languageName: unknown @@ -4732,15 +4723,6 @@ __metadata: languageName: node linkType: hard -"uuid@npm:^9.0.1": - version: 9.0.1 - resolution: "uuid@npm:9.0.1" - bin: - uuid: dist/bin/uuid - checksum: 1607dd32ac7fc22f2d8f77051e6a64845c9bce5cd3dd8aa0070c074ec73e666a1f63c7b4e0f4bf2bc8b9d59dc85a15e17807446d9d2b17c8485fbc2147b27f9b - languageName: node - linkType: hard - "v8-to-istanbul@npm:^9.0.1": version: 9.2.0 resolution: "v8-to-istanbul@npm:9.2.0"