Skip to content

Commit

Permalink
Improve startup error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
MuTsunTsai committed Dec 19, 2022
1 parent 9d33daa commit 5b54623
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "box-pleating-studio",
"version": "0.5.0",
"version": "0.5.7",
"description": "Super-complex origami design made easy!",
"main": "./build/dist/bpstudio.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions src/log/20220205.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ Patches:
- 0.5.4: Fix dark mode coloration [#43](https://github.com/bp-studio/box-pleating-studio/pull/43).
- 0.5.5: Fix one minor startup error handling bug.
- 0.5.6: Fix one critical startup bug, welcome screen file opening bug, and one minor hotkey bug.
- 0.5.7: Improve startup error reporting.
25 changes: 20 additions & 5 deletions src/public/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, width=device-width, user-scalable=no">
<meta name="description" content="Super-complex origami design made easy!">
<meta name="google" content="notranslate">
<meta name="version" content="0.5.6">
<meta name="version" content="0.5.7">

<!-- Preload -->
<link rel="preload" as="font" type="font/woff2" crossorigin href="assets/bps/fonts/bps.woff2">
Expand All @@ -32,7 +32,7 @@
page_title: document.title,
page_path: "/",
app_name: document.title,
app_version: "1231"
app_version: "1232"
};
gtag('js', new Date());
gtag('config', 'G-GG1TEZGBCQ', app_config);
Expand Down Expand Up @@ -130,6 +130,16 @@

self.res = function() { self.resErr = true; }

/** GA parameter has a 100-character limit, so we split the message into chunks. */
function splitString(str) {
var chunks = [];
while (str.length > 0) {
chunks.push(str.substring(0, 100));
str = str.substring(100);
}
return chunks;
}

/**
* Final processing.
*
Expand All @@ -146,10 +156,15 @@
// Filter out Facebook Clawer; no need to report related errors.
!(self.runErr.indexOf("Illegal invocation") >= 0 && location.search.indexOf("fbclid") >= 0)
) {
gtag('event', 'unsupported', {
var chunks = splitString(self.runErr);
var data = {
app_version: app_config.app_version,
error: self.runErr
});
error: chunks[0]
};
for(var i = 1; i < chunks.length && i <= 10; i++) { // 1000 should be enough
data["error" + i] = chunks[i];
}
gtag('event', 'unsupported', data);
}
return false;
};
Expand Down

0 comments on commit 5b54623

Please sign in to comment.