From 5b546233310fa1193ff14157419e9b73dc72e307 Mon Sep 17 00:00:00 2001 From: Mu-Tsun Tsai Date: Mon, 19 Dec 2022 18:53:01 +0800 Subject: [PATCH] Improve startup error reporting --- package.json | 2 +- src/log/20220205.md | 1 + src/public/index.htm | 25 ++++++++++++++++++++----- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index a9fdb0d0..dfcb2926 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/log/20220205.md b/src/log/20220205.md index 6709e05f..04ebbef5 100644 --- a/src/log/20220205.md +++ b/src/log/20220205.md @@ -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. diff --git a/src/public/index.htm b/src/public/index.htm index 2450637b..4a4c2b8c 100644 --- a/src/public/index.htm +++ b/src/public/index.htm @@ -9,7 +9,7 @@ - + @@ -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); @@ -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. * @@ -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; };