mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-12-27 14:29:39 +00:00
added ga events for menu, exceptions
This commit is contained in:
parent
af26db3396
commit
f93bdece20
24
src/ui.ts
24
src/ui.ts
@ -18,6 +18,7 @@ import { GHSession, GithubService, getRepos, parseGithubURL } from "./services";
|
|||||||
|
|
||||||
// external libs (TODO)
|
// external libs (TODO)
|
||||||
declare var Tour, GIF, saveAs, JSZip, Mousetrap, Split, firebase;
|
declare var Tour, GIF, saveAs, JSZip, Mousetrap, Split, firebase;
|
||||||
|
declare var ga;
|
||||||
// in index.html
|
// in index.html
|
||||||
declare var exports;
|
declare var exports;
|
||||||
|
|
||||||
@ -75,6 +76,7 @@ var TOOL_TO_SOURCE_STYLE = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function alertError(s:string) {
|
function alertError(s:string) {
|
||||||
|
if (ga) ga('send', 'event', 'error', 'error', s);
|
||||||
bootbox.alert(s);
|
bootbox.alert(s);
|
||||||
}
|
}
|
||||||
function alertInfo(s:string) {
|
function alertInfo(s:string) {
|
||||||
@ -1589,14 +1591,21 @@ function installErrorHandler() {
|
|||||||
window.onerror = function (msgevent, url, line, col, error) {
|
window.onerror = function (msgevent, url, line, col, error) {
|
||||||
var msgstr = msgevent+"";
|
var msgstr = msgevent+"";
|
||||||
console.log(msgevent, url, line, col, error);
|
console.log(msgevent, url, line, col, error);
|
||||||
|
// emulation threw EmuHalt
|
||||||
if (error instanceof EmuHalt || msgstr.indexOf("CPU STOP") >= 0) {
|
if (error instanceof EmuHalt || msgstr.indexOf("CPU STOP") >= 0) {
|
||||||
showErrorAlert([ {msg:msgstr, line:0} ]);
|
showErrorAlert([ {msg:msgstr, line:0} ]);
|
||||||
uiDebugCallback(platform.saveState());
|
uiDebugCallback(platform.saveState());
|
||||||
setDebugButtonState("pause", "stopped"); // TODO?
|
setDebugButtonState("pause", "stopped"); // TODO?
|
||||||
} else {
|
} else {
|
||||||
var msg = msgevent + " " + url + " " + " " + line + ":" + col + ", " + error;
|
// send exception msg to GA
|
||||||
|
var msg = msgevent + " (" + line + ":" + col + "): " + error + " - " + url;
|
||||||
|
if (msg.length > 256) { msg = msg.substring(0, 256); }
|
||||||
|
if (ga) ga('send', 'exception', {
|
||||||
|
'exDescription': msg,
|
||||||
|
'exFatal': true
|
||||||
|
});
|
||||||
$.get("/error?msg=" + encodeURIComponent(msg), "text");
|
$.get("/error?msg=" + encodeURIComponent(msg), "text");
|
||||||
alertError(msgevent+"");
|
alertError(msg);
|
||||||
}
|
}
|
||||||
_pause();
|
_pause();
|
||||||
};
|
};
|
||||||
@ -1647,6 +1656,16 @@ function showInstructions() {
|
|||||||
$("#emucontrols-" + getRootBasePlatform(platform_id)).show();
|
$("#emucontrols-" + getRootBasePlatform(platform_id)).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function installGAHooks() {
|
||||||
|
if (ga) {
|
||||||
|
$(".dropdown-item").click((e) => {
|
||||||
|
if (e.target && e.target.id) {
|
||||||
|
ga('send', 'event', 'menu', 'click', e.target.id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function startPlatform() {
|
function startPlatform() {
|
||||||
if (!PLATFORMS[platform_id]) throw Error("Invalid platform '" + platform_id + "'.");
|
if (!PLATFORMS[platform_id]) throw Error("Invalid platform '" + platform_id + "'.");
|
||||||
platform = new PLATFORMS[platform_id]($("#emulator")[0]);
|
platform = new PLATFORMS[platform_id]($("#emulator")[0]);
|
||||||
@ -1673,6 +1692,7 @@ function startPlatform() {
|
|||||||
setupDebugControls();
|
setupDebugControls();
|
||||||
updateSelector();
|
updateSelector();
|
||||||
addPageFocusHandlers();
|
addPageFocusHandlers();
|
||||||
|
installGAHooks();
|
||||||
showInstructions();
|
showInstructions();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user