sentry-uniapp 0.12.1 → 1.0.1
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/README.md +1 -0
- package/dist/crossPlatform.d.ts +2 -1
- package/dist/crossPlatform.d.ts.map +1 -1
- package/dist/crossPlatform.js +106 -14
- package/dist/crossPlatform.js.map +1 -1
- package/dist/integrations/system.d.ts.map +1 -1
- package/dist/integrations/system.js +40 -35
- package/dist/integrations/system.js.map +1 -1
- package/dist/sdk.d.ts +1 -1
- package/dist/sentry-uniapp.min.js +17 -0
- package/dist/sentry-uniapp.min.js.map +1 -0
- package/esm/crossPlatform.d.ts +2 -1
- package/esm/crossPlatform.d.ts.map +1 -1
- package/esm/crossPlatform.js +106 -14
- package/esm/crossPlatform.js.map +1 -1
- package/esm/integrations/system.d.ts.map +1 -1
- package/esm/integrations/system.js +41 -36
- package/esm/integrations/system.js.map +1 -1
- package/package.json +7 -13
package/README.md
CHANGED
package/dist/crossPlatform.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
interface SDK {
|
|
5
5
|
request: Function;
|
|
6
6
|
httpRequest?: Function;
|
|
7
|
+
getSystemInfo: Function;
|
|
7
8
|
getSystemInfoSync: Function;
|
|
8
9
|
onError?: Function;
|
|
9
10
|
onUnhandledRejection?: Function;
|
|
@@ -14,7 +15,7 @@ interface SDK {
|
|
|
14
15
|
/**
|
|
15
16
|
* 小程序平台 接口
|
|
16
17
|
*/
|
|
17
|
-
declare type AppName = "uniapp" | "wechat" | "alipay" | "bytedance" | "dingtalk" | "qq" | "swan" | "unknown";
|
|
18
|
+
declare type AppName = "uniapp" | "wechat" | "alipay" | "bytedance" | "dingtalk" | "qq" | "swan" | "quickapp" | "unknown";
|
|
18
19
|
declare const sdk: SDK;
|
|
19
20
|
declare const appName: AppName;
|
|
20
21
|
export { sdk, appName };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crossPlatform.d.ts","sourceRoot":"","sources":["../src/crossPlatform.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"crossPlatform.d.ts","sourceRoot":"","sources":["../src/crossPlatform.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,UAAU,GAAG;IACX,OAAO,EAAE,QAAQ,CAAC;IAClB,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,aAAa,EAAE,QAAQ,CAAC;IACxB,iBAAiB,EAAE,QAAQ,CAAC;IAC5B,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,oBAAoB,CAAC,EAAE,QAAQ,CAAC;IAChC,cAAc,CAAC,EAAE,QAAQ,CAAC;IAC1B,eAAe,CAAC,EAAE,QAAQ,CAAC;IAC3B,oBAAoB,CAAC,EAAE,QAAQ,CAAC;CACjC;AAED;;GAEG;AACH,aAAK,OAAO,GACR,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,WAAW,GACX,UAAU,GACV,IAAI,GACJ,MAAM,GACN,UAAU,GACV,SAAS,CAAC;AA2Jd,QAAA,MAAM,GAAG,KAAW,CAAC;AACrB,QAAA,MAAM,OAAO,SAAe,CAAC;AAE7B,OAAO,EAAC,GAAG,EAAE,OAAO,EAAC,CAAC"}
|
package/dist/crossPlatform.js
CHANGED
|
@@ -1,44 +1,133 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
2
|
exports.appName = exports.sdk = void 0;
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var globalCopy = global;
|
|
5
|
+
var currentSdk = {
|
|
6
|
+
// tslint:disable-next-line: no-empty
|
|
7
|
+
request: function () {
|
|
8
|
+
},
|
|
9
|
+
// tslint:disable-next-line: no-empty
|
|
10
|
+
httpRequest: function () {
|
|
11
|
+
},
|
|
12
|
+
// tslint:disable-next-line: no-empty
|
|
13
|
+
getSystemInfoSync: function () {
|
|
14
|
+
},
|
|
15
|
+
// tslint:disable-next-line: no-empty
|
|
16
|
+
getSystemInfo: function () {
|
|
17
|
+
},
|
|
18
|
+
};
|
|
3
19
|
/**
|
|
4
20
|
* 获取跨平台的 SDK
|
|
5
21
|
*/
|
|
6
22
|
var getSDK = function () {
|
|
7
|
-
var currentSdk = {
|
|
8
|
-
// tslint:disable-next-line: no-empty
|
|
9
|
-
request: function () { },
|
|
10
|
-
// tslint:disable-next-line: no-empty
|
|
11
|
-
httpRequest: function () { },
|
|
12
|
-
// tslint:disable-next-line: no-empty
|
|
13
|
-
getSystemInfoSync: function () { },
|
|
14
|
-
};
|
|
15
23
|
if (typeof uni === "object") {
|
|
16
24
|
currentSdk = uni;
|
|
17
25
|
}
|
|
18
26
|
else if (typeof wx === "object") {
|
|
19
|
-
// tslint:disable-next-line: no-unsafe-any
|
|
20
27
|
currentSdk = uni;
|
|
21
28
|
}
|
|
22
29
|
else if (typeof my === "object") {
|
|
23
|
-
// tslint:disable-next-line: no-unsafe-any
|
|
24
30
|
currentSdk = my;
|
|
25
31
|
}
|
|
26
32
|
else if (typeof tt === "object") {
|
|
27
|
-
// tslint:disable-next-line: no-unsafe-any
|
|
28
33
|
currentSdk = tt;
|
|
29
34
|
}
|
|
30
35
|
else if (typeof dd === "object") {
|
|
31
|
-
// tslint:disable-next-line: no-unsafe-any
|
|
32
36
|
currentSdk = dd;
|
|
33
37
|
}
|
|
34
38
|
else if (typeof qq === "object") {
|
|
35
|
-
// tslint:disable-next-line: no-unsafe-any
|
|
36
39
|
currentSdk = qq;
|
|
37
40
|
}
|
|
38
41
|
else if (typeof swan === "object") {
|
|
39
|
-
// tslint:disable-next-line: no-unsafe-any
|
|
40
42
|
currentSdk = swan;
|
|
41
43
|
}
|
|
44
|
+
else if (typeof QuickApp === 'object') {
|
|
45
|
+
// 针对快应用的兼容性封装
|
|
46
|
+
globalCopy.getCurrentPages = function () {
|
|
47
|
+
var e_1, _a;
|
|
48
|
+
// tslint:disable-next-line:no-implicit-dependencies
|
|
49
|
+
var router = require('@system.router');
|
|
50
|
+
var stacks = router.getPages();
|
|
51
|
+
var ret = [];
|
|
52
|
+
try {
|
|
53
|
+
for (var stacks_1 = tslib_1.__values(stacks), stacks_1_1 = stacks_1.next(); !stacks_1_1.done; stacks_1_1 = stacks_1.next()) {
|
|
54
|
+
var route = stacks_1_1.value;
|
|
55
|
+
ret.push({
|
|
56
|
+
route: route.path,
|
|
57
|
+
options: {},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
62
|
+
finally {
|
|
63
|
+
try {
|
|
64
|
+
if (stacks_1_1 && !stacks_1_1.done && (_a = stacks_1.return)) _a.call(stacks_1);
|
|
65
|
+
}
|
|
66
|
+
finally { if (e_1) throw e_1.error; }
|
|
67
|
+
}
|
|
68
|
+
return ret;
|
|
69
|
+
};
|
|
70
|
+
// tslint:disable-next-line:no-implicit-dependencies
|
|
71
|
+
var fetch_1 = require('@system.fetch');
|
|
72
|
+
currentSdk.request = fetch_1.fetch;
|
|
73
|
+
currentSdk.getSystemInfo = function () {
|
|
74
|
+
return new Promise(function (resolve, reject) {
|
|
75
|
+
// tslint:disable-next-line:no-implicit-dependencies
|
|
76
|
+
var app = require('@system.app');
|
|
77
|
+
var appInfo = app.getInfo();
|
|
78
|
+
// tslint:disable-next-line:no-implicit-dependencies
|
|
79
|
+
var device = require('@system.device');
|
|
80
|
+
// tslint:disable-next-line:no-implicit-dependencies
|
|
81
|
+
var battery = require('@system.battery');
|
|
82
|
+
var ret = {
|
|
83
|
+
SDKVersion: appInfo.versionName,
|
|
84
|
+
battery: 0,
|
|
85
|
+
batteryLevel: 0,
|
|
86
|
+
currentBattery: 0,
|
|
87
|
+
appName: appInfo.name,
|
|
88
|
+
system: '',
|
|
89
|
+
model: String,
|
|
90
|
+
brand: String,
|
|
91
|
+
platform: String,
|
|
92
|
+
screenHeight: Number,
|
|
93
|
+
screenWidth: Number,
|
|
94
|
+
statusBarHeight: Number,
|
|
95
|
+
language: String,
|
|
96
|
+
windowWidth: Number,
|
|
97
|
+
windowHeight: Number,
|
|
98
|
+
};
|
|
99
|
+
device.getInfo({
|
|
100
|
+
// tslint:disable-next-line:no-shadowed-variable
|
|
101
|
+
success: function (deviceInfo) {
|
|
102
|
+
ret.language = deviceInfo.language;
|
|
103
|
+
ret.brand = deviceInfo.brand;
|
|
104
|
+
ret.model = deviceInfo.model;
|
|
105
|
+
ret.platform = deviceInfo.platformVersionName;
|
|
106
|
+
ret.screenHeight = deviceInfo.screenHeight;
|
|
107
|
+
ret.screenWidth = deviceInfo.screenWidth;
|
|
108
|
+
ret.statusBarHeight = deviceInfo.statusBarHeight;
|
|
109
|
+
ret.windowHeight = deviceInfo.windowHeight;
|
|
110
|
+
ret.windowWidth = deviceInfo.windowWidth;
|
|
111
|
+
ret.system = deviceInfo.osType + " " + deviceInfo.osVersionName;
|
|
112
|
+
battery.getStatus({
|
|
113
|
+
success: function (batteryStatus) {
|
|
114
|
+
ret.battery = batteryStatus.level;
|
|
115
|
+
ret.currentBattery = batteryStatus.level;
|
|
116
|
+
resolve(ret);
|
|
117
|
+
},
|
|
118
|
+
fail: function (e) {
|
|
119
|
+
reject(e);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
fail: function (e) {
|
|
124
|
+
reject(e);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
// end of QuickApp
|
|
130
|
+
}
|
|
42
131
|
else {
|
|
43
132
|
throw new Error("sentry-uniapp 暂不支持此平台");
|
|
44
133
|
}
|
|
@@ -70,6 +159,9 @@ var getAppName = function () {
|
|
|
70
159
|
else if (typeof swan === "object") {
|
|
71
160
|
currentAppName = "swan";
|
|
72
161
|
}
|
|
162
|
+
else if (typeof QuickApp === "object") {
|
|
163
|
+
currentAppName = "quickapp";
|
|
164
|
+
}
|
|
73
165
|
return currentAppName;
|
|
74
166
|
};
|
|
75
167
|
var sdk = getSDK();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crossPlatform.js","sourceRoot":"","sources":["../src/crossPlatform.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"crossPlatform.js","sourceRoot":"","sources":["../src/crossPlatform.ts"],"names":[],"mappings":";;;AAAA,IAAM,UAAU,GAAQ,MAAM,CAAC;AAwC/B,IAAI,UAAU,GAAQ;IACpB,qCAAqC;IACrC,OAAO,EAAE;IACT,CAAC;IACD,qCAAqC;IACrC,WAAW,EAAE;IACb,CAAC;IACD,qCAAqC;IACrC,iBAAiB,EAAE;IACnB,CAAC;IACD,qCAAqC;IACrC,aAAa,EAAE;IACf,CAAC;CACF,CAAC;AAEF;;GAEG;AACH,IAAM,MAAM,GAAG;IACb,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,UAAU,GAAG,GAAG,CAAC;KAClB;SAAM,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;QACjC,UAAU,GAAG,GAAG,CAAC;KAClB;SAAM,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;QACjC,UAAU,GAAG,EAAE,CAAC;KACjB;SAAM,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;QACjC,UAAU,GAAG,EAAE,CAAC;KACjB;SAAM,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;QACjC,UAAU,GAAG,EAAE,CAAC;KACjB;SAAM,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;QACjC,UAAU,GAAG,EAAE,CAAC;KACjB;SAAM,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QACnC,UAAU,GAAG,IAAI,CAAC;KACnB;SAAM,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;QAEvC,cAAc;QACd,UAAU,CAAC,eAAe,GAAG;;YAC3B,oDAAoD;YACpD,IAAM,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;YACxC,IAAM,MAAM,GAAQ,MAAM,CAAC,QAAQ,EAAE,CAAA;YACrC,IAAM,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AEF;;GAEG;AACH,IAAM,UAAU,GAAG;IACjB,IAAI,cAAc,GAAY,SAAS,CAAC;IAExC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,cAAc,GAAG,QAAQ,CAAC;KAC3B;SAAM,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;QACjC,cAAc,GAAG,QAAQ,CAAC;KAC3B;SAAM,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;QACjC,cAAc,GAAG,QAAQ,CAAC;KAC3B;SAAM,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;QACjC,cAAc,GAAG,WAAW,CAAC;KAC9B;SAAM,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;QACjC,cAAc,GAAG,UAAU,CAAC;KAC7B;SAAM,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;QACjC,cAAc,GAAG,IAAI,CAAC;KACvB;SAAM,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QACnC,cAAc,GAAG,MAAM,CAAC;KACzB;SAAM,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;QACvC,cAAc,GAAG,UAAU,CAAC;KAC7B;IAED,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC;AAEF,IAAM,GAAG,GAAG,MAAM,EAAE,CAAC;AAGb,kBAAG;AAFX,IAAM,OAAO,GAAG,UAAU,EAAE,CAAC;AAEhB,0BAAO","sourcesContent":["const globalCopy: any = global;\n\ndeclare const uni: any; // uniapp\ndeclare const wx: any; // 微信小程序、微信小游戏\ndeclare const my: any; // 支付宝小程序\ndeclare const tt: any; // 字节跳动小程序\ndeclare const dd: any; // 钉钉小程序\ndeclare const qq: any; // QQ 小程序、QQ 小游戏\ndeclare const swan: any; // 百度小程序\ndeclare const QuickApp: any; // 快应用\n\n/**\n * 小程序平台 SDK 接口\n */\ninterface SDK {\n request: Function;\n httpRequest?: Function; // 针对钉钉小程序\n getSystemInfo: Function;\n getSystemInfoSync: Function;\n onError?: Function;\n onUnhandledRejection?: Function;\n onPageNotFound?: Function;\n onMemoryWarning?: Function;\n getLaunchOptionsSync?: Function;\n}\n\n/**\n * 小程序平台 接口\n */\ntype AppName =\n | \"uniapp\"\n | \"wechat\"\n | \"alipay\"\n | \"bytedance\"\n | \"dingtalk\"\n | \"qq\"\n | \"swan\"\n | \"quickapp\"\n | \"unknown\";\n\nlet currentSdk: SDK = {\n // tslint:disable-next-line: no-empty\n request: () => {\n },\n // tslint:disable-next-line: no-empty\n httpRequest: () => {\n },\n // tslint:disable-next-line: no-empty\n getSystemInfoSync: () => {\n },\n // tslint:disable-next-line: no-empty\n getSystemInfo: () => {\n },\n};\n\n/**\n * 获取跨平台的 SDK\n */\nconst getSDK = () => {\n if (typeof uni === \"object\") {\n currentSdk = uni;\n } else if (typeof wx === \"object\") {\n currentSdk = uni;\n } else if (typeof my === \"object\") {\n currentSdk = my;\n } else if (typeof tt === \"object\") {\n currentSdk = tt;\n } else if (typeof dd === \"object\") {\n currentSdk = dd;\n } else if (typeof qq === \"object\") {\n currentSdk = qq;\n } else if (typeof swan === \"object\") {\n currentSdk = swan;\n } else if (typeof QuickApp === 'object') {\n\n // 针对快应用的兼容性封装\n globalCopy.getCurrentPages = () => {\n // tslint:disable-next-line:no-implicit-dependencies\n const router = require('@system.router')\n const stacks: any = router.getPages()\n const ret = []\n for (const route of stacks) {\n ret.push({\n route: route.path,\n options: {},\n })\n }\n\n return ret\n }\n\n // tslint:disable-next-line:no-implicit-dependencies\n const fetch = require('@system.fetch')\n currentSdk.request = fetch.fetch\n\n currentSdk.getSystemInfo = () => {\n return new Promise<any>((resolve, reject) => {\n // tslint:disable-next-line:no-implicit-dependencies\n const app = require('@system.app')\n const appInfo = app.getInfo();\n\n // tslint:disable-next-line:no-implicit-dependencies\n const device = require('@system.device')\n\n // tslint:disable-next-line:no-implicit-dependencies\n const battery = require('@system.battery')\n\n const ret = {\n SDKVersion: appInfo.versionName,\n battery: 0,\n batteryLevel: 0,\n currentBattery: 0,\n appName: appInfo.name,\n system: '',\n model: String,\n brand: String,\n platform: String,\n screenHeight: Number,\n screenWidth: Number,\n statusBarHeight: Number,\n language: String,\n windowWidth: Number,\n windowHeight: Number,\n }\n\n device.getInfo({\n // tslint:disable-next-line:no-shadowed-variable\n success: (deviceInfo: any) => {\n ret.language = deviceInfo.language;\n ret.brand = deviceInfo.brand;\n ret.model = deviceInfo.model;\n ret.platform = deviceInfo.platformVersionName;\n ret.screenHeight = deviceInfo.screenHeight;\n ret.screenWidth = deviceInfo.screenWidth;\n ret.statusBarHeight = deviceInfo.statusBarHeight;\n ret.windowHeight = deviceInfo.windowHeight;\n ret.windowWidth = deviceInfo.windowWidth;\n ret.system = `${deviceInfo.osType} ${deviceInfo.osVersionName}`;\n\n battery.getStatus({\n success: (batteryStatus: any) => {\n ret.battery = batteryStatus.level;\n ret.currentBattery = batteryStatus.level;\n resolve(ret)\n },\n fail: (e: any) => {\n reject(e)\n }\n })\n },\n fail: (e: any) => {\n reject(e)\n }\n })\n })\n }\n\n // end of QuickApp\n\n } else {\n throw new Error(\"sentry-uniapp 暂不支持此平台\");\n }\n\n return currentSdk;\n};\n\n/**\n * 获取平台名称\n */\nconst getAppName = () => {\n let currentAppName: AppName = \"unknown\";\n\n if (typeof uni === \"object\") {\n currentAppName = \"uniapp\";\n } else if (typeof wx === \"object\") {\n currentAppName = \"wechat\";\n } else if (typeof my === \"object\") {\n currentAppName = \"alipay\";\n } else if (typeof tt === \"object\") {\n currentAppName = \"bytedance\";\n } else if (typeof dd === \"object\") {\n currentAppName = \"dingtalk\";\n } else if (typeof qq === \"object\") {\n currentAppName = \"qq\";\n } else if (typeof swan === \"object\") {\n currentAppName = \"swan\";\n } else if (typeof QuickApp === \"object\") {\n currentAppName = \"quickapp\";\n }\n\n return currentAppName;\n};\n\nconst sdk = getSDK();\nconst appName = getAppName();\n\nexport {sdk, appName};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../src/integrations/system.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,WAAW,EAAE,MAAM,eAAe,CAAC;AAInD,gBAAgB;AAChB,qBAAa,MAAO,YAAW,WAAW;IACxC;;OAEG;IACI,IAAI,EAAE,MAAM,CAAa;IAEhC;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAY;IAEpC;;OAEG;IACI,SAAS,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../src/integrations/system.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,WAAW,EAAE,MAAM,eAAe,CAAC;AAInD,gBAAgB;AAChB,qBAAa,MAAO,YAAW,WAAW;IACxC;;OAEG;IACI,IAAI,EAAE,MAAM,CAAa;IAEhC;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAY;IAEpC;;OAEG;IACI,SAAS,IAAI,IAAI;CAmEzB"}
|
|
@@ -15,42 +15,47 @@ var System = /** @class */ (function () {
|
|
|
15
15
|
* @inheritDoc
|
|
16
16
|
*/
|
|
17
17
|
System.prototype.setupOnce = function () {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
18
|
+
var _this = this;
|
|
19
|
+
core_1.addGlobalEventProcessor(function (event) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
20
|
+
var systemInfo, _a, SDKVersion, batteryLevel, currentBattery, battery, brand, language, model, pixelRatio, platform, screenHeight, screenWidth, statusBarHeight, system, version, windowHeight, windowWidth, app, appName, fontSizeSetting, _b, systemName, systemVersion, e_1;
|
|
21
|
+
return tslib_1.__generator(this, function (_c) {
|
|
22
|
+
switch (_c.label) {
|
|
23
|
+
case 0:
|
|
24
|
+
if (!core_1.getCurrentHub().getIntegration(System)) return [3 /*break*/, 4];
|
|
25
|
+
_c.label = 1;
|
|
26
|
+
case 1:
|
|
27
|
+
_c.trys.push([1, 3, , 4]);
|
|
28
|
+
return [4 /*yield*/, crossPlatform_1.sdk.getSystemInfo()];
|
|
29
|
+
case 2:
|
|
30
|
+
systemInfo = _c.sent();
|
|
31
|
+
_a = systemInfo.SDKVersion, SDKVersion = _a === void 0 ? "0.0.0" : _a, batteryLevel = systemInfo.batteryLevel, currentBattery = systemInfo.currentBattery, battery = systemInfo.battery, brand = systemInfo.brand, language = systemInfo.language, model = systemInfo.model, pixelRatio = systemInfo.pixelRatio, platform = systemInfo.platform, screenHeight = systemInfo.screenHeight, screenWidth = systemInfo.screenWidth, statusBarHeight = systemInfo.statusBarHeight, system = systemInfo.system, version = systemInfo.version, windowHeight = systemInfo.windowHeight, windowWidth = systemInfo.windowWidth, app = systemInfo.app, appName = systemInfo.appName, fontSizeSetting = systemInfo.fontSizeSetting;
|
|
32
|
+
_b = tslib_1.__read(system.split(" "), 2), systemName = _b[0], systemVersion = _b[1];
|
|
33
|
+
return [2 /*return*/, tslib_1.__assign(tslib_1.__assign({}, event), { contexts: tslib_1.__assign(tslib_1.__assign({}, event.contexts), { device: {
|
|
34
|
+
brand: brand,
|
|
35
|
+
battery_level: batteryLevel || currentBattery || battery,
|
|
36
|
+
model: model,
|
|
37
|
+
screen_dpi: pixelRatio
|
|
38
|
+
}, os: {
|
|
39
|
+
name: systemName || system,
|
|
40
|
+
version: systemVersion || system
|
|
41
|
+
}, extra: tslib_1.__assign({ SDKVersion: SDKVersion,
|
|
42
|
+
language: language,
|
|
43
|
+
platform: platform,
|
|
44
|
+
screenHeight: screenHeight,
|
|
45
|
+
screenWidth: screenWidth,
|
|
46
|
+
statusBarHeight: statusBarHeight,
|
|
47
|
+
version: version,
|
|
48
|
+
windowHeight: windowHeight,
|
|
49
|
+
windowWidth: windowWidth,
|
|
50
|
+
fontSizeSetting: fontSizeSetting, app: app || appName || crossPlatform_1.appName }, systemInfo) }) })];
|
|
51
|
+
case 3:
|
|
52
|
+
e_1 = _c.sent();
|
|
53
|
+
console.warn("sentry-uniapp get system info fail: " + e_1);
|
|
54
|
+
return [3 /*break*/, 4];
|
|
55
|
+
case 4: return [2 /*return*/, event];
|
|
47
56
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return event;
|
|
53
|
-
});
|
|
57
|
+
});
|
|
58
|
+
}); });
|
|
54
59
|
};
|
|
55
60
|
/**
|
|
56
61
|
* @inheritDoc
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.js","sourceRoot":"","sources":["../../src/integrations/system.ts"],"names":[],"mappings":";;;AAAA,qCAAsE;AAGtE,kDAAkE;AAElE,gBAAgB;AAChB;IAAA;QACE;;WAEG;QACI,SAAI,GAAW,MAAM,CAAC,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"system.js","sourceRoot":"","sources":["../../src/integrations/system.ts"],"names":[],"mappings":";;;AAAA,qCAAsE;AAGtE,kDAAkE;AAElE,gBAAgB;AAChB;IAAA;QACE;;WAEG;QACI,SAAI,GAAW,MAAM,CAAC,EAAE,CAAC;IA6ElC,CAAC;IAtEC;;OAEG;IACI,0BAAS,GAAhB;QAAA,iBAkEC;QAjEC,8BAAuB,CAAC,UAAO,KAAY;;;;;6BACrC,oBAAa,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,EAAtC,wBAAsC;;;;wBAEnB,qBAAM,mBAAG,CAAC,aAAa,EAAE,EAAA;;wBAAtC,UAAU,GAAG,SAAyB;wBAG1C,KAmBE,UAAU,WAnBQ,EAApB,UAAU,mBAAG,OAAO,KAAA,EACpB,YAAY,GAkBV,UAAU,aA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;4BAI7D,sBAAO,KAAK,EAAC;;;aACd,CAAC,CAAC;IACL,CAAC;IA1ED;;OAEG;IACW,SAAE,GAAW,QAAQ,CAAC;IAwEtC,aAAC;CAAA,AAjFD,IAiFC;AAjFY,wBAAM","sourcesContent":["import { addGlobalEventProcessor, getCurrentHub } from \"@sentry/core\";\nimport { Event, Integration } from \"@sentry/types\";\n\nimport { appName as currentAppName, sdk } from \"../crossPlatform\";\n\n/** UserAgent */\nexport class System implements Integration {\n /**\n * @inheritDoc\n */\n public name: string = System.id;\n\n /**\n * @inheritDoc\n */\n public static id: string = \"System\";\n\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n addGlobalEventProcessor(async (event: Event) => {\n if (getCurrentHub().getIntegration(System)) {\n try {\n const systemInfo = await sdk.getSystemInfo()\n\n const {\n SDKVersion = \"0.0.0\",\n batteryLevel, // 微信小程序\n currentBattery, // 支付宝小程序、 钉钉小程序\n battery, // 字节跳动小程序\n brand,\n language,\n model,\n pixelRatio,\n platform,\n screenHeight,\n screenWidth,\n statusBarHeight,\n system,\n version,\n windowHeight,\n windowWidth,\n app, // 支付宝小程序\n appName, // 字节跳动小程序\n fontSizeSetting, // 支付宝小程序、 钉钉小程序、微信小程序\n } = systemInfo;\n const [systemName, systemVersion] = system.split(\" \");\n\n return {\n ...event,\n contexts: {\n ...event.contexts,\n device: {\n brand,\n battery_level: batteryLevel || currentBattery || battery,\n model,\n screen_dpi: pixelRatio\n },\n os: {\n name: systemName || system,\n version: systemVersion || system\n },\n extra: {\n SDKVersion,\n language,\n platform,\n screenHeight,\n screenWidth,\n statusBarHeight,\n version,\n windowHeight,\n windowWidth,\n fontSizeSetting,\n app: app || appName || currentAppName,\n ...systemInfo,\n }\n }\n };\n } catch (e) {\n console.warn(`sentry-uniapp get system info fail: ${e}`);\n }\n }\n\n return event;\n });\n }\n}\n"]}
|
package/dist/sdk.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Integrations as CoreIntegrations } from "@sentry/core";
|
|
|
2
2
|
import { MiniappOptions } from "./backend";
|
|
3
3
|
import { ReportDialogOptions } from "./client";
|
|
4
4
|
import { GlobalHandlers, IgnoreMpcrawlerErrors, LinkedErrors, Router, System, TryCatch } from "./integrations/index";
|
|
5
|
-
export declare const defaultIntegrations: (CoreIntegrations.
|
|
5
|
+
export declare const defaultIntegrations: (CoreIntegrations.InboundFilters | CoreIntegrations.FunctionToString | TryCatch | GlobalHandlers | LinkedErrors | System | Router | IgnoreMpcrawlerErrors)[];
|
|
6
6
|
/**
|
|
7
7
|
* The Sentry Uniapp SDK Client.
|
|
8
8
|
*
|