Skip to content

Commit

Permalink
Remove Google Analytics
Browse files Browse the repository at this point in the history
See #23
  • Loading branch information
generalmimon committed Apr 15, 2024
1 parent b8c359f commit f53caf2
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 39 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ jobs:
if: github.ref == 'refs/heads/stable'
- name: Set up environment variables for stable deployment
run: |
echo 'GA_ID=UA-76299550-2' >> "$GITHUB_ENV"
echo 'SENTRY_ENV=stable' >> "$GITHUB_ENV"
if: github.ref == 'refs/heads/stable'
- name: Set up environment variables for devel deployment
run: |
echo 'GA_ID=UA-76299550-3' >> "$GITHUB_ENV"
echo 'SENTRY_ENV=devel' >> "$GITHUB_ENV"
if: github.ref == 'refs/heads/master'
- name: Build
Expand Down
18 changes: 2 additions & 16 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
const { readFileSync, writeFileSync } = require("fs");
const { exec } = require("child_process");

const { GA_ID, SENTRY_DSN, SENTRY_ENV } = process.env;

const GA_TEMPLATE = GA_ID ? `
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','_ga');
_ga('create', '${GA_ID}', 'auto');
_ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
` : "";
const { SENTRY_DSN, SENTRY_ENV } = process.env;

const SENTRY_TEMPLATE = SENTRY_DSN && SENTRY_ENV ? `
<script src="https://cdn.ravenjs.com/3.17.0/raven.min.js" crossorigin="anonymous"></script>
Expand Down Expand Up @@ -64,7 +50,7 @@ function formatCommitDate(d) {
async function main() {
const { commitId, commitDate } = await fetchGitCommitInfo();
const scriptAppend =
SENTRY_TEMPLATE.replace("{{SENTRY_RELEASE}}", commitId) + GA_TEMPLATE;
SENTRY_TEMPLATE.replace("{{SENTRY_RELEASE}}", commitId);
if (scriptAppend) {
fileAction(outDir + "/index.html", html =>
appendAfter(html, "<!-- SCRIPT_INJECTION_POINT -->", scriptAppend)
Expand Down
7 changes: 3 additions & 4 deletions src/v1/app.errors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { htmlescape } from "../utils";
import { app, ga } from "./app";
import { app } from "./app";

export class ErrorWindowHandler {
lastErrWndSize = 100; // 34
Expand All @@ -18,8 +18,8 @@ export class ErrorWindowHandler {
this.errorWnd.getElement().addClass("errorWindow");
}
this.errorWnd.on("resize", () => this.lastErrWndSize = this.errorWnd.getElement().outerHeight());
this.errorWnd.on("destroy", () => { ga("errorwnd", "destroy"); this.errorWnd = null; });
this.errorWnd.on("close", () => { ga("errorwnd", "close"); this.errorWnd = null; });
this.errorWnd.on("destroy", () => { this.errorWnd = null; });
this.errorWnd.on("close", () => { this.errorWnd = null; });
this.errorWnd.getElement().empty().append($("<div>").html(htmlescape(errMsg).replace(/\n|\\n/g, "<br>")));
}

Expand All @@ -46,4 +46,3 @@ export class ErrorWindowHandler {
}
}
}

7 changes: 1 addition & 6 deletions src/v1/app.files.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as localforage from "localforage";
import dateFormat = require("dateformat");

import { ga, app } from "./app";
import { app } from "./app";
import { IJSTreeNode } from "./parsedToTree";
import { downloadFile, saveFile, openFilesWithDialog } from "../utils";

Expand Down Expand Up @@ -360,9 +360,6 @@ export function initFileTree() {
});
});

fileTreeCont.on("rename_node.jstree", () => ga("filetree", "rename"));
fileTreeCont.on("move_node.jstree", () => ga("filetree", "move"));

fileTreeCont.on("create_node.jstree rename_node.jstree delete_node.jstree move_node.jstree paste.jstree", saveTree);
fileTreeCont.on("move_node.jstree", (e, data) => app.ui.fileTree.open_node(app.ui.fileTree.get_node(data.parent)));
fileTreeCont.on("select_node.jstree", (e, selectNodeArgs) => {
Expand All @@ -372,8 +369,6 @@ export function initFileTree() {

var lastMultiSelectReport = 0;
fileTreeCont.on("select_node.jstree", (e, args) => {
if (e.timeStamp - lastMultiSelectReport > 1000 && args.selected.length > 1)
ga("filetree", "multi_select");
lastMultiSelectReport = e.timeStamp;
});

Expand Down
11 changes: 0 additions & 11 deletions src/v1/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ import KaitaiStructCompiler = require("kaitai-struct-compiler");

$.jstree.defaults.core.force_text = true;

export function ga(category: string, action: string, label?: string, value?: number) {
console.log(`[GA Event] cat:${category} act:${action} lab:${label || ""}`);
if (typeof window["_ga"] !== "undefined")
window["_ga"]("send", "event", category, action, label, value);
}

const qs = {};
location.search.substr(1).split("&").map(x => x.split("=")).forEach(x => qs[x[0]] = x[1]);

Expand Down Expand Up @@ -72,10 +66,8 @@ class AppController {

compile(srcYamlFsItem: IFsItem, srcYaml: string, kslang: string, debug: true | false | "both"): Promise<any> {
return this.compilerService.compile(srcYamlFsItem, srcYaml, kslang, debug).then(result => {
ga("compile", "success");
return result;
}, (error: CompilationError) => {
ga("compile", "error", `${error.type}: ${error.error}`);
this.errors.handle(error.error);
return Promise.reject(error);
});
Expand Down Expand Up @@ -331,7 +323,4 @@ $(() => {
});

kaitaiIde.app = app;

precallHook(app.ui.layout.layout.constructor["__lm"].controls, "DragProxy", () => ga("layout", "window_drag"));
$("body").on("mousedown", ".lm_drag_handle", () => { ga("layout", "splitter_drag"); });
});

0 comments on commit f53caf2

Please sign in to comment.