Skip to content

Commit 7125649

Browse files
author
Suhas Hariharan
authored
Merge pull request #245 from sas-fossdev/remove-analytics-code
removed analytics code, as it is not being used, modified extension options page
2 parents 4841045 + a0e241d commit 7125649

File tree

5 files changed

+2
-106
lines changed

5 files changed

+2
-106
lines changed

src/js/background.js

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
'use strict';
2626

27-
import $ from 'jquery';
2827
const browser = require('webextension-polyfill');
2928

3029
// Installation Process
@@ -34,75 +33,14 @@ browser.runtime.onInstalled.addListener((details) => {
3433
}
3534
});
3635

37-
// Analytics
38-
var analytics = {};
39-
var version = browser.runtime.getManifest().version;
40-
browser.storage.local.get({ analytics: true, id: "" }).then(function (returned) {
41-
analytics.enabled = returned.analytics;
42-
analytics.id = returned.id;
43-
if (analytics.id.length === 0) {
44-
reset_analytics();
45-
}
46-
});
47-
4836
// Listen for requests from tabs
4937
browser.runtime.onMessage.addListener(message_recieve);
5038
function message_recieve (message) {
5139
switch (message.action) {
52-
case "analytics_send":
53-
analytics_send(message.args);
54-
// Requires an args attribute. Args should be an object that must have a 'url' attribute and can have a string called 'action' and a object called 'extra'. The arg object can also have a boolean named 'override'.
55-
break;
5640
case "open_settings":
5741
browser.runtime.openOptionsPage();
5842
break;
59-
case "reset_analytics":
60-
reset_analytics();
61-
break;
6243
default:
6344
break;
6445
}
6546
}
66-
function analytics_send (arg) {
67-
browser.storage.local.get({ analytics: true, percent_main_page: true, save_grades_temp: true }).then(function (returned) {
68-
analytics.enabled = returned.analytics;
69-
if (analytics.enabled) {
70-
const cvar_json = JSON.stringify({ "1": ["version", version], "2": ["FP", returned.percent_main_page.toString()], "3": ["Save Grades Temp", returned.save_grades_temp.toString()] });
71-
const send_info = {
72-
'idsite': '4',
73-
'rec': '1',
74-
'url': arg.url,
75-
'_id': analytics.id,
76-
'apiv': '1',
77-
'cid': analytics.id,
78-
'_cvar': cvar_json,
79-
};
80-
if (typeof arg.action !== 'undefined') {
81-
send_info.action_name = arg.action;
82-
}
83-
if (typeof arg.extra === 'object') {
84-
const extra_entries = Object.entries(arg.extra);
85-
for (let i = 0; i < extra_entries.length; i++) {
86-
send_info[extra_entries[i][0]] = extra_entries[i][1];
87-
}
88-
}
89-
$.ajax({
90-
url: "https://analytics.ydgkim.com/piwik.php",
91-
type: "get",
92-
data: send_info,
93-
});
94-
}
95-
});
96-
}
97-
function reset_analytics () {
98-
analytics.id = random_str(16, '1234567890abcdef');
99-
browser.storage.local.set({ id: analytics.id });
100-
}
101-
102-
function random_str (len, chars) {
103-
let tr = "";
104-
for (let i = 0; i < len; i++) {
105-
tr += chars[Math.floor(Math.random() * chars.length)];
106-
}
107-
return tr;
108-
}

src/js/components/ExtensionInfo.vue

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,21 @@
4646
class="saspes-link"
4747
href="https://github.com/sas-fossdev/saspes"
4848
target="_blank"
49-
@click="link_analytics"
5049
>Website/Source Code</a> |
5150
<a
5251
href="https://github.com/sas-fossdev/saspes/blob/master/CHANGELOG.md"
5352
class="saspes-link"
5453
target="_blank"
55-
@click="link_analytics"
5654
>Changelog</a> |
5755
<a
5856
class="saspes-link"
5957
href="https://github.com/sas-fossdev/saspes/issues"
6058
target="_blank"
61-
@click="link_analytics"
6259
>Issue Tracker</a> |
6360
<a
6461
class="saspes-link"
6562
href="https://github.com/sas-fossdev/saspes/blob/master/LICENSE"
6663
target="_blank"
67-
@click="link_analytics"
6864
>License (AGPL-3.0-only)</a> |
6965
<a
7066
id="login-extension-settings"
@@ -88,13 +84,6 @@ export default {
8884
};
8985
},
9086
methods: {
91-
link_analytics (e) {
92-
const href = e.currentTarget.href;
93-
browser.runtime.sendMessage({
94-
action: "analytics_send",
95-
args: { url: href, extra: { link: href } },
96-
});
97-
},
9887
toggleInfo () {
9988
this.showInfo = !this.showInfo;
10089
browser.storage.local.set({ showExtensionInfo: this.showInfo });

src/js/helpers.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -214,16 +214,6 @@ async function saveGradesLocally (username, courses) {
214214
browser.storage.local.set(user_data);
215215
}
216216

217-
/**
218-
* Send Analytics ping
219-
* @param {String} action_input the action being taken
220-
* @param {String} [url] Url to report. Defaults to the current page in the browser
221-
*/
222-
async function analytics_message (action_input, url) {
223-
const href = url || window.location.href.split("?")[0];
224-
browser.runtime.sendMessage({ action: "analytics_send", args: { url: href, action: action_input } });
225-
}
226-
227217
export {
228218
gradeToFP,
229219
grade_fp,
@@ -235,7 +225,6 @@ export {
235225
extractFinalPercent,
236226
assignments,
237227
calculate_credit_hours,
238-
analytics_message,
239228
getSavedGrades,
240229
saveGradesLocally,
241230
};

src/js/saspowerschoolff.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import {
3434
calculate_gpa,
3535
extractFinalPercent,
3636
gradeToGPA,
37-
analytics_message,
3837
saveGradesLocally,
3938
getSavedGrades,
4039
} from './helpers';
@@ -67,15 +66,10 @@ function main () {
6766
const page_url = window.location.href.split('#')[0];
6867
if (page_url === "https://powerschool.sas.edu.sg/guardian/homeHS.html") {
6968
main_page();
70-
analytics_message("Main Page");
7169
} else if (page_url.match("https://powerschool.sas.edu.sg/guardian/scores") != null) {
7270
class_page();
73-
analytics_message("Course Page");
7471
} else if (page_url === "https://powerschool.sas.edu.sg/guardian/home.html" || page_url === "https://powerschool.sas.edu.sg/public/" || page_url === "https://powerschool.sas.edu.sg/public/home.html") {
7572
login_page();
76-
analytics_message("Login Page");
77-
} else {
78-
analytics_message("default");
7973
}
8074
}
8175

src/js/views/Options.vue

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
<div>
33
<h3>Version: {{ version }}</h3>
44
<form>
5-
<label><input
6-
v-model="options.analytics"
7-
type="checkbox"
8-
>Enable Analytics</label>
9-
<br>
105
<label><input
116
v-model="options.percent_main_page"
127
type="checkbox"
@@ -21,15 +16,9 @@
2116
<br>
2217
<footer>
2318
<br>
24-
Analytics ID: {{ options.id }}<span style="white-space: nowrap; padding-left: 5px;" /><button @click="copyId">
25-
<span v-if="copiedRecently">Copied!</span>
26-
<span v-else>Copy</span>
27-
</button><br>
28-
<br>
29-
SAS Powerschool Enhancement Suite is the collective work of many different people working together publicly. Visit our <a href="https://github.com/sas-fossdev/saspes">GitHub page</a> if you'd like to participate as well.<br>
19+
SAS Powerschool Enhancement Suite is the collective work of many different people working together publicly. Visit our <a href="https://github.com/sas-fossdev/saspes" target="_blank">GitHub page</a> if you'd like to participate as well.<br>
3020
<br>
31-
More info and source code (Anyone and everyone is welcome to contribute): <br>
32-
<a href="https://github.com/sas-fossdev/saspes">https://github.com/sas-fossdev/saspes</a><br>
21+
If you believe you have encountered a bug in the extension, or have any other inquiries, please create an issue on <a href="https://github.com/sas-fossdev/saspes/issues" target="_blank"> the repository</a> or email <a href="mailto:[email protected]" target="_blank">[email protected]</a><br>
3322
<br>
3423
Credits: <br>
3524
Special thanks to Alan Chang for the idea. <br>
@@ -42,14 +31,12 @@
4231
</template>
4332

4433
<script>
45-
import { analytics_message } from '../helpers';
4634
import browser from 'webextension-polyfill';
4735
4836
function defaultOptions () {
4937
return {
5038
id: "Not set yet",
5139
percent_main_page: true,
52-
analytics: true,
5340
save_last_grades: true,
5441
};
5542
}
@@ -78,7 +65,6 @@ export default {
7865
},
7966
},
8067
async mounted () {
81-
analytics_message("Options Page", "saspes://options");
8268
await this.resetData();
8369
browser.storage.onChanged.addListener(this.resetData);
8470
},

0 commit comments

Comments
 (0)