@inappstory/game-center-api 1.3.14 → 1.3.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/TraceablePromise.d.ts +5 -0
- package/lib/TraceablePromise.js +14 -0
- package/lib/errorHandler.d.ts +4 -0
- package/lib/errorHandler.js +33 -2
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/logger.html +36 -7
- package/package.json +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TraceablePromise = void 0;
|
|
4
|
+
class TraceablePromise extends Promise {
|
|
5
|
+
__creationPoint;
|
|
6
|
+
constructor(executor) {
|
|
7
|
+
super(executor);
|
|
8
|
+
this.__creationPoint = new Error().stack;
|
|
9
|
+
}
|
|
10
|
+
get creationPoint() {
|
|
11
|
+
return this.__creationPoint;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.TraceablePromise = TraceablePromise;
|
package/lib/errorHandler.d.ts
CHANGED
package/lib/errorHandler.js
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.logError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* for call instead of console.error(err)
|
|
6
|
+
* this method collect Error stack to error logger
|
|
7
|
+
**/
|
|
4
8
|
const logError = (e, cause) => {
|
|
9
|
+
let error = null;
|
|
5
10
|
if (e instanceof Error) {
|
|
6
|
-
|
|
11
|
+
error = e;
|
|
12
|
+
}
|
|
13
|
+
if (typeof e === "string") {
|
|
14
|
+
error = new Error(e);
|
|
15
|
+
}
|
|
16
|
+
if (error !== null) {
|
|
7
17
|
const message = {
|
|
8
18
|
type: "error",
|
|
9
19
|
errorName: error.name ?? "",
|
|
10
20
|
message: error.message ?? "",
|
|
11
21
|
stack: error.stack ?? "",
|
|
12
|
-
cause: cause ?? error.cause ?? "",
|
|
22
|
+
cause: eventFromError(cause ?? error.cause ?? ""),
|
|
13
23
|
// @ts-ignore Non-standard: This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
|
|
14
24
|
fileName: error.fileName ?? "",
|
|
15
25
|
// @ts-ignore Non-standard: This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
|
|
@@ -25,3 +35,24 @@ const logError = (e, cause) => {
|
|
|
25
35
|
}
|
|
26
36
|
};
|
|
27
37
|
exports.logError = logError;
|
|
38
|
+
var eventFromError = function (error) {
|
|
39
|
+
if (error instanceof Error) {
|
|
40
|
+
var data = {
|
|
41
|
+
name: error.name,
|
|
42
|
+
message: error.message,
|
|
43
|
+
stack: error.stack,
|
|
44
|
+
};
|
|
45
|
+
if (error.cause != null) {
|
|
46
|
+
if (error.cause instanceof Error) {
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
data.cause = eventFromError(error.cause);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
data.cause = error.cause;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return data;
|
|
56
|
+
}
|
|
57
|
+
return error;
|
|
58
|
+
};
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = exports.logError = exports.openGameInstance = exports.getApplicationBuildVersion = exports.getApplicationVersion = exports.gameOnForeground = exports.gameShouldForegroundCallback = exports.hasFilePickerApi = exports.isLocalFile = exports.isFilePickerResultLocalFileList = exports.isFilePickerResultFileList = exports.FilePickerResultType = exports.openFilePicker = exports.reloadGameReader = exports.eventGame = exports.StaticResourceList = exports.staticResourcesImagePlaceholders = exports.dynamicResourceFonts = exports.dynamicResourceAssets = exports.ResourceManager = exports.openStory = exports.fetchLocalFile = exports.PlaceholderType = exports.ScreenOrientation = exports.getApiBaseUrl = exports.getSessionId = exports.getIsDemoMode = exports.getProjectFontFamilyStylesheet = exports.getDynamicResourceFont = exports.getDynamicResourceAsset = exports.vibrate = exports.shareFiles = exports.shareUrl = exports.shareText = exports.openUrl = exports.sendIasApiRequest = exports.gameLocalData = exports.getSemverSdkVersion = exports.getSdkVersion = exports.isDev = exports.isAndroid = exports.isWeb = exports.isIos = exports.gameLaunchConfig = exports.gameLoadFailedSdkCallback = exports.gameLoadedSdkCallback = exports.closeGameReader = exports.createSdkApi = void 0;
|
|
3
|
+
exports.TraceablePromise = exports.default = exports.logError = exports.openGameInstance = exports.getApplicationBuildVersion = exports.getApplicationVersion = exports.gameOnForeground = exports.gameShouldForegroundCallback = exports.hasFilePickerApi = exports.isLocalFile = exports.isFilePickerResultLocalFileList = exports.isFilePickerResultFileList = exports.FilePickerResultType = exports.openFilePicker = exports.reloadGameReader = exports.eventGame = exports.StaticResourceList = exports.staticResourcesImagePlaceholders = exports.dynamicResourceFonts = exports.dynamicResourceAssets = exports.ResourceManager = exports.openStory = exports.fetchLocalFile = exports.PlaceholderType = exports.ScreenOrientation = exports.getApiBaseUrl = exports.getSessionId = exports.getIsDemoMode = exports.getProjectFontFamilyStylesheet = exports.getDynamicResourceFont = exports.getDynamicResourceAsset = exports.vibrate = exports.shareFiles = exports.shareUrl = exports.shareText = exports.openUrl = exports.sendIasApiRequest = exports.gameLocalData = exports.getSemverSdkVersion = exports.getSdkVersion = exports.isDev = exports.isAndroid = exports.isWeb = exports.isIos = exports.gameLaunchConfig = exports.gameLoadFailedSdkCallback = exports.gameLoadedSdkCallback = exports.closeGameReader = exports.createSdkApi = void 0;
|
|
4
4
|
const env_1 = require("./env");
|
|
5
5
|
Object.defineProperty(exports, "getApplicationBuildVersion", { enumerable: true, get: function () { return env_1.getApplicationBuildVersion; } });
|
|
6
6
|
Object.defineProperty(exports, "getApplicationVersion", { enumerable: true, get: function () { return env_1.getApplicationVersion; } });
|
|
@@ -117,6 +117,8 @@ const GameCenterApi = {
|
|
|
117
117
|
logError: errorHandler_1.logError,
|
|
118
118
|
};
|
|
119
119
|
exports.default = GameCenterApi;
|
|
120
|
+
var TraceablePromise_1 = require("./TraceablePromise");
|
|
121
|
+
Object.defineProperty(exports, "TraceablePromise", { enumerable: true, get: function () { return TraceablePromise_1.TraceablePromise; } });
|
|
120
122
|
// export { Placeholder as default};
|
|
121
123
|
// types
|
|
122
124
|
// placeholders
|
package/lib/logger.html
CHANGED
|
@@ -115,6 +115,25 @@
|
|
|
115
115
|
}
|
|
116
116
|
}, 30000);
|
|
117
117
|
|
|
118
|
+
var eventFromError = function (error) {
|
|
119
|
+
if (error instanceof Error) {
|
|
120
|
+
var data = {
|
|
121
|
+
name: error.name,
|
|
122
|
+
message: error.message,
|
|
123
|
+
stack: error.stack,
|
|
124
|
+
};
|
|
125
|
+
if (error.cause != null) {
|
|
126
|
+
if (error.cause instanceof Error) {
|
|
127
|
+
data.cause = eventFromError(error.cause);
|
|
128
|
+
} else {
|
|
129
|
+
data.cause = error.cause;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return data;
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
};
|
|
136
|
+
|
|
118
137
|
window.onerror = function (msg, url, lineNo, columnNo, error) {
|
|
119
138
|
// console.log({msg, url, lineNo, columnNo, error});
|
|
120
139
|
|
|
@@ -128,12 +147,9 @@
|
|
|
128
147
|
lineno: lineNo,
|
|
129
148
|
colno: columnNo,
|
|
130
149
|
source: url,
|
|
131
|
-
errorMessage: error ? error.message : "",
|
|
132
|
-
errorStack: error ? error.stack : "",
|
|
133
150
|
};
|
|
134
151
|
if (error) {
|
|
135
|
-
payload.
|
|
136
|
-
payload.errorStack = error.stack;
|
|
152
|
+
payload.error = eventFromError(error);
|
|
137
153
|
}
|
|
138
154
|
if (window.gameLoadingInfo != null) {
|
|
139
155
|
payload.loadingState = window.gameLoadingInfo.state;
|
|
@@ -170,9 +186,17 @@
|
|
|
170
186
|
window.onunhandledrejection = function (event) {
|
|
171
187
|
var payload = {
|
|
172
188
|
type: "onunhandledrejection",
|
|
173
|
-
reason: event.reason,
|
|
189
|
+
reason: event.reason instanceof Error ? eventFromError(event.reason) : event.reason,
|
|
190
|
+
stack: "",
|
|
174
191
|
};
|
|
175
|
-
|
|
192
|
+
|
|
193
|
+
if (event.promise != null && event.promise.creationPoint != null) {
|
|
194
|
+
payload.stack = event.promise.creationPoint;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// window._sendErrorLog(payload);
|
|
198
|
+
// log via sdk logger and internal _sendErrorLog
|
|
199
|
+
console.error(payload);
|
|
176
200
|
};
|
|
177
201
|
|
|
178
202
|
window.console.log = function () {
|
|
@@ -231,11 +255,16 @@
|
|
|
231
255
|
}
|
|
232
256
|
}
|
|
233
257
|
payload[field] = value;
|
|
258
|
+
|
|
259
|
+
if (window.gameLoadingInfo != null) {
|
|
260
|
+
payload.loadingState = window.gameLoadingInfo.state;
|
|
261
|
+
payload.loadingDescription = window.gameLoadingInfo.description;
|
|
262
|
+
}
|
|
234
263
|
}
|
|
235
264
|
|
|
236
265
|
window._sendErrorLog(payload);
|
|
237
266
|
if (messages.length && messages[0] != null) {
|
|
238
|
-
|
|
267
|
+
var errorAsString = "";
|
|
239
268
|
try {
|
|
240
269
|
errorAsString = JSON.stringify(messages[0]);
|
|
241
270
|
} catch (e) {
|