sentry-uniapp 0.12.0 → 1.0.2

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.
Files changed (44) hide show
  1. package/README.md +20 -42
  2. package/dist/client.js +2 -2
  3. package/dist/client.js.map +1 -1
  4. package/dist/crossPlatform.d.ts +2 -1
  5. package/dist/crossPlatform.d.ts.map +1 -1
  6. package/dist/crossPlatform.js +107 -15
  7. package/dist/crossPlatform.js.map +1 -1
  8. package/dist/integrations/globalhandlers.js +1 -1
  9. package/dist/integrations/globalhandlers.js.map +1 -1
  10. package/dist/integrations/router.js +1 -1
  11. package/dist/integrations/router.js.map +1 -1
  12. package/dist/integrations/system.d.ts.map +1 -1
  13. package/dist/integrations/system.js +40 -35
  14. package/dist/integrations/system.js.map +1 -1
  15. package/dist/sdk.d.ts +6 -6
  16. package/dist/sdk.js +6 -6
  17. package/dist/sdk.js.map +1 -1
  18. package/dist/sentry-uniapp.min.js +17 -0
  19. package/dist/sentry-uniapp.min.js.map +1 -0
  20. package/dist/version.d.ts +1 -1
  21. package/dist/version.d.ts.map +1 -1
  22. package/dist/version.js +1 -1
  23. package/dist/version.js.map +1 -1
  24. package/esm/client.js +2 -2
  25. package/esm/client.js.map +1 -1
  26. package/esm/crossPlatform.d.ts +2 -1
  27. package/esm/crossPlatform.d.ts.map +1 -1
  28. package/esm/crossPlatform.js +107 -15
  29. package/esm/crossPlatform.js.map +1 -1
  30. package/esm/integrations/globalhandlers.js +1 -1
  31. package/esm/integrations/globalhandlers.js.map +1 -1
  32. package/esm/integrations/router.js +1 -1
  33. package/esm/integrations/router.js.map +1 -1
  34. package/esm/integrations/system.d.ts.map +1 -1
  35. package/esm/integrations/system.js +41 -36
  36. package/esm/integrations/system.js.map +1 -1
  37. package/esm/sdk.d.ts +5 -5
  38. package/esm/sdk.js +6 -6
  39. package/esm/sdk.js.map +1 -1
  40. package/esm/version.d.ts +1 -1
  41. package/esm/version.d.ts.map +1 -1
  42. package/esm/version.js +1 -1
  43. package/esm/version.js.map +1 -1
  44. package/package.json +10 -26
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # Sentry 小程序 SDK
2
2
 
3
- ![npm version](https://img.shields.io/npm/v/sentry-miniapp)
4
- ![npm download](https://img.shields.io/npm/dm/sentry-miniapp)
5
- ![github forks](https://img.shields.io/github/forks/lizhiyao/sentry-miniapp?style=social)
6
- ![github stars](https://img.shields.io/github/stars/lizhiyao/sentry-miniapp?style=social)
7
- ![github watchers](https://img.shields.io/github/watchers/lizhiyao/sentry-miniapp?style=social)
8
- ![github license](https://img.shields.io/github/license/lizhiyao/sentry-miniapp)
3
+ ![npm version](https://img.shields.io/npm/v/sentry-uniapp)
4
+ ![npm download](https://img.shields.io/npm/dm/sentry-uniapp)
5
+ ![github forks](https://img.shields.io/github/forks/uappkit/sentry-uniapp?style=social)
6
+ ![github stars](https://img.shields.io/github/stars/uappkit/sentry-uniapp?style=social)
7
+ ![github watchers](https://img.shields.io/github/watchers/uappkit/sentry-uniapp?style=social)
8
+ ![github license](https://img.shields.io/github/license/uappkit/sentry-uniapp)
9
9
 
10
10
  用于小程序平台的 Sentry SDK
11
11
 
@@ -24,6 +24,7 @@
24
24
  - [x] 支持支付宝小程序
25
25
  - [x] 支持钉钉小程序
26
26
  - [x] 支持百度小程序
27
+ - [x] 支持快应用
27
28
  - [x] 支持在 [Taro](https://taro.aotu.io/) 等第三方小程序框架中使用
28
29
  - [x] 默认上报异常发生时的路由栈
29
30
  - [ ] 完善的代码测试
@@ -43,10 +44,10 @@
43
44
 
44
45
  ### 直接引用
45
46
 
46
- 1. 微信小程序和微信小游戏下载 [sentry-miniapp.wx.min.js](https://github.com/lizhiyao/sentry-miniapp/blob/master/examples/weapp/vendor/sentry-miniapp.wx.min.js);字节跳动小程序下载 [sentry-miniapp.tt.min.js](https://github.com/lizhiyao/sentry-miniapp/blob/master/examples/ttapp/vendor/sentry-miniapp.tt.min.js);支付宝小程序下载 [sentry-miniapp.my.min.js](https://github.com/lizhiyao/sentry-miniapp/blob/master/examples/myapp/vendor/sentry-miniapp.my.min.js),钉钉小程序下载 [sentry-miniapp.dd.min.js](https://github.com/lizhiyao/sentry-miniapp/blob/master/examples/ddapp/vendor/sentry-miniapp.dd.min.js)
47
- 2. 参照 `/examples` 中各项目使用方式,将 `sentry-miniapp.xx.min.js` 放入项目的合适目录中,比如放入 `vendor` 文件夹
47
+ 1. 微信小程序和微信小游戏下载 [sentry-uniapp.wx.min.js](https://github.com/uappkit/sentry-uniapp/blob/master/examples/weapp/vendor/sentry-uniapp.wx.min.js);字节跳动小程序下载 [sentry-uniapp.tt.min.js](https://github.com/uappkit/sentry-uniapp/blob/master/examples/ttapp/vendor/sentry-uniapp.tt.min.js);支付宝小程序下载 [sentry-uniapp.my.min.js](https://github.com/uappkit/sentry-uniapp/blob/master/examples/myapp/vendor/sentry-uniapp.my.min.js),钉钉小程序下载 [sentry-uniapp.dd.min.js](https://github.com/uappkit/sentry-uniapp/blob/master/examples/ddapp/vendor/sentry-uniapp.dd.min.js)
48
+ 2. 参照 `/examples` 中各项目使用方式,将 `sentry-uniapp.xx.min.js` 放入项目的合适目录中,比如放入 `vendor` 文件夹
48
49
  3. 参照 `/examples/app.js` 代码,进行 `Sentry` 的初始化
49
- 4. 对于提供了微信、字节跳动小程序 `sentry-miniapp` 会自动上报 `xx.onError()` 捕获的异常,对于支付宝小程序需要应用开发者在 `App.onError()` 中主动进行异常上报。详情可见 `/docs/cross-platform.md`。
50
+ 4. 对于提供了微信、字节跳动小程序 `sentry-uniapp` 会自动上报 `xx.onError()` 捕获的异常,对于支付宝小程序需要应用开发者在 `App.onError()` 中主动进行异常上报。详情可见 `/docs/cross-platform.md`。
50
51
 
51
52
  ### npm 方式
52
53
 
@@ -55,9 +56,9 @@
55
56
  1. 安装依赖
56
57
 
57
58
  ```bash
58
- npm install sentry-miniapp --save
59
+ npm install sentry-uniapp --save
59
60
  # 或者
60
- yarn add sentry-miniapp
61
+ yarn add sentry-uniapp
61
62
  ```
62
63
 
63
64
  2. 使用「微信开发者工具 - 工具 - 构建 npm」进行构建,详情可参考[npm 支持](https://developers.weixin.qq.com/miniprogram/dev/devtools/npm.html)
@@ -65,7 +66,7 @@
65
66
  3. 在 `app.js` 中引用并初始化 `Sentry`,根据实际需求设置上报到 Sentry 的元信息
66
67
 
67
68
  ```js
68
- import * as Sentry from "sentry-miniapp";
69
+ import * as Sentry from "sentry-uniapp";
69
70
 
70
71
  // init Sentry
71
72
  // init options: https://github.com/getsentry/sentry-javascript/blob/master/packages/types/src/options.ts
@@ -117,9 +118,9 @@
117
118
 
118
119
  ![Dashboard](docs/sentry-hub.png)
119
120
 
120
- #### sentry-miniapp 设计图
121
+ #### sentry-uniapp 设计图
121
122
 
122
- ![Dashboard](docs/sentry-miniapp.png)
123
+ ![Dashboard](docs/sentry-uniapp.png)
123
124
 
124
125
  ### 相关命令
125
126
 
@@ -127,25 +128,10 @@
127
128
  # 根据 package.json 中的版本号更新 SDK 源码中的版本号
128
129
  npm run version
129
130
 
130
- # 构建供小程序直接引用的 sentry-miniapp.xx.min.js;在本地可直接使用开发者工具打开 examples 下具体项目进行调试
131
+ # 构建供小程序直接引用的 sentry-uniapp.xx.min.js;在本地可直接使用开发者工具打开 examples 下具体项目进行调试
131
132
  npm run build:dist
132
133
 
133
- # 构建供微信小程序直接引用的 sentry-miniapp.wx.min.js
134
- npm run build:wx
135
-
136
- # 构建供支付宝小程序直接引用的 sentry-miniapp.my.min.js
137
- npm run build:my
138
-
139
- # 构建供钉钉小程序直接引用的 sentry-miniapp.dd.min.js
140
- npm run build:dd
141
-
142
- # 构建供字节跳动小程序直接引用的 sentry-miniapp.tt.min.js
143
- npm run build:tt
144
-
145
- # 构建供百度小程序直接引用的 sentry-miniapp.swan.min.js
146
- npm run build:swan
147
-
148
- # 构建用于发布到 npm 的 dist 资源
134
+ # 构建用于发布到 npm 的 dist & esm 资源
149
135
  npm run build
150
136
 
151
137
  # 构建用于发布到 npm 的 esm 资源
@@ -162,7 +148,7 @@ npm publish --registry=https://registry.npmjs.org/
162
148
  ![Error01](docs/screenshot/sentry-error-01.png)
163
149
  ![Error02](docs/screenshot/sentry-error-02.png)
164
150
 
165
- ## 谁在使用 sentry-miniapp
151
+ ## 谁在使用 sentry-uniapp
166
152
 
167
153
  ### 微信小程序
168
154
 
@@ -201,16 +187,8 @@ npm publish --registry=https://registry.npmjs.org/
201
187
 
202
188
  ## 贡献
203
189
 
204
- 欢迎通过 `issue`、`pull request`等方式贡献 `sentry-miniapp`。
190
+ 欢迎通过 `issue`、`pull request`等方式贡献 `sentry-uniapp`。
205
191
 
206
192
  ## 联系作者
207
193
 
208
- PS. 由于微信群二维码有时效性限制,想入群的同学还可以加作者微信(添加时请备注 sentry-miniapp),由作者邀请入群
209
-
210
- ### sentry-miniapp 微信交流群
211
-
212
- <img src="docs/qrcode/sentry-miniapp.jpeg" alt="微信交流群二维码" width="300" height="400" />
213
-
214
- ### 作者微信二维码
215
-
216
- <img src="docs/qrcode/zhiyao.jpeg" alt="作者微信二维码" width="300" height="300" />
194
+ 微信: yinqisen
package/dist/client.js CHANGED
@@ -28,7 +28,7 @@ var MiniappClient = /** @class */ (function (_super) {
28
28
  event.platform = event.platform || "javascript";
29
29
  event.sdk = tslib_1.__assign(tslib_1.__assign({}, event.sdk), { name: version_1.SDK_NAME, packages: tslib_1.__spread(((event.sdk && event.sdk.packages) || []), [
30
30
  {
31
- name: "npm:@sentry/miniapp",
31
+ name: "npm:sentry-uniapp",
32
32
  version: version_1.SDK_VERSION
33
33
  }
34
34
  ]), version: version_1.SDK_VERSION });
@@ -43,7 +43,7 @@ var MiniappClient = /** @class */ (function (_super) {
43
43
  MiniappClient.prototype.showReportDialog = function (options) {
44
44
  if (options === void 0) { options = {}; }
45
45
  // doesn't work without a document (React Native)
46
- console.log('sentry-miniapp 暂未实现该方法', options);
46
+ console.log('sentry-uniapp 暂未实现该方法', options);
47
47
  };
48
48
  return MiniappClient;
49
49
  }(core_1.BaseClient));
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,qCAAiD;AAGjD,qCAA2D;AAC3D,qCAAkD;AA6BlD;;;;;GAKG;AACH;IAAmC,yCAA0C;IAC3E;;;;OAIG;IACH,uBAAmB,OAA4B;QAA5B,wBAAA,EAAA,YAA4B;eAC7C,kBAAM,wBAAc,EAAE,OAAO,CAAC;IAChC,CAAC;IAED;;OAEG;IACO,qCAAa,GAAvB,UAAwB,KAAY,EAAE,KAAa,EAAE,IAAgB;QACnE,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,YAAY,CAAC;QAChD,KAAK,CAAC,GAAG,yCACJ,KAAK,CAAC,GAAG,KACZ,IAAI,EAAE,kBAAQ,EACd,QAAQ,mBACH,CAAC,CAAC,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAC5C;oBACE,IAAI,EAAE,qBAAqB;oBAC3B,OAAO,EAAE,qBAAW;iBACrB;gBAEH,OAAO,EAAE,qBAAW,GACrB,CAAC;QAEF,OAAO,iBAAM,aAAa,YAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACI,wCAAgB,GAAvB,UAAwB,OAAiC;QAAjC,wBAAA,EAAA,YAAiC;QACvD,iDAAiD;QACjD,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IACH,oBAAC;AAAD,CAAC,AAzCD,CAAmC,iBAAU,GAyC5C;AAzCY,sCAAa","sourcesContent":["import { BaseClient, Scope } from \"@sentry/core\";\nimport { DsnLike, Event, EventHint } from \"@sentry/types\";\n\nimport { MiniappBackend, MiniappOptions } from \"./backend\";\nimport { SDK_NAME, SDK_VERSION } from \"./version\";\n\n/**\n * All properties the report dialog supports\n */\nexport interface ReportDialogOptions {\n [key: string]: any;\n eventId?: string;\n dsn?: DsnLike;\n user?: {\n email?: string;\n name?: string;\n };\n lang?: string;\n title?: string;\n subtitle?: string;\n subtitle2?: string;\n labelName?: string;\n labelEmail?: string;\n labelComments?: string;\n labelClose?: string;\n labelSubmit?: string;\n errorGeneric?: string;\n errorFormEntry?: string;\n successMessage?: string;\n /** Callback after reportDialog showed up */\n onLoad?(): void;\n}\n\n/**\n * The Sentry Miniapp SDK Client.\n *\n * @see MiniappOptions for documentation on configuration options.\n * @see SentryClient for usage documentation.\n */\nexport class MiniappClient extends BaseClient<MiniappBackend, MiniappOptions> {\n /**\n * Creates a new Miniapp SDK instance.\n *\n * @param options Configuration options for this SDK.\n */\n public constructor(options: MiniappOptions = {}) {\n super(MiniappBackend, options);\n }\n\n /**\n * @inheritDoc\n */\n protected _prepareEvent(event: Event, scope?: Scope, hint?: EventHint): PromiseLike<Event | null> {\n event.platform = event.platform || \"javascript\";\n event.sdk = {\n ...event.sdk,\n name: SDK_NAME,\n packages: [\n ...((event.sdk && event.sdk.packages) || []),\n {\n name: \"npm:@sentry/miniapp\",\n version: SDK_VERSION\n }\n ],\n version: SDK_VERSION\n };\n\n return super._prepareEvent(event, scope, hint);\n }\n\n /**\n * Show a report dialog to the user to send feedback to a specific event.\n * 向用户显示报告对话框以将反馈发送到特定事件。---> 小程序上暂时用不到&不考虑。\n *\n * @param options Set individual options for the dialog\n */\n public showReportDialog(options: ReportDialogOptions = {}): void {\n // doesn't work without a document (React Native)\n console.log('sentry-miniapp 暂未实现该方法', options);\n }\n}\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,qCAAiD;AAGjD,qCAA2D;AAC3D,qCAAkD;AA6BlD;;;;;GAKG;AACH;IAAmC,yCAA0C;IAC3E;;;;OAIG;IACH,uBAAmB,OAA4B;QAA5B,wBAAA,EAAA,YAA4B;eAC7C,kBAAM,wBAAc,EAAE,OAAO,CAAC;IAChC,CAAC;IAED;;OAEG;IACO,qCAAa,GAAvB,UAAwB,KAAY,EAAE,KAAa,EAAE,IAAgB;QACnE,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,YAAY,CAAC;QAChD,KAAK,CAAC,GAAG,yCACJ,KAAK,CAAC,GAAG,KACZ,IAAI,EAAE,kBAAQ,EACd,QAAQ,mBACH,CAAC,CAAC,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;gBAC5C;oBACE,IAAI,EAAE,mBAAmB;oBACzB,OAAO,EAAE,qBAAW;iBACrB;gBAEH,OAAO,EAAE,qBAAW,GACrB,CAAC;QAEF,OAAO,iBAAM,aAAa,YAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IACjD,CAAC;IAED;;;;;OAKG;IACI,wCAAgB,GAAvB,UAAwB,OAAiC;QAAjC,wBAAA,EAAA,YAAiC;QACvD,iDAAiD;QACjD,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;IACH,oBAAC;AAAD,CAAC,AAzCD,CAAmC,iBAAU,GAyC5C;AAzCY,sCAAa","sourcesContent":["import { BaseClient, Scope } from \"@sentry/core\";\nimport { DsnLike, Event, EventHint } from \"@sentry/types\";\n\nimport { MiniappBackend, MiniappOptions } from \"./backend\";\nimport { SDK_NAME, SDK_VERSION } from \"./version\";\n\n/**\n * All properties the report dialog supports\n */\nexport interface ReportDialogOptions {\n [key: string]: any;\n eventId?: string;\n dsn?: DsnLike;\n user?: {\n email?: string;\n name?: string;\n };\n lang?: string;\n title?: string;\n subtitle?: string;\n subtitle2?: string;\n labelName?: string;\n labelEmail?: string;\n labelComments?: string;\n labelClose?: string;\n labelSubmit?: string;\n errorGeneric?: string;\n errorFormEntry?: string;\n successMessage?: string;\n /** Callback after reportDialog showed up */\n onLoad?(): void;\n}\n\n/**\n * The Sentry Miniapp SDK Client.\n *\n * @see MiniappOptions for documentation on configuration options.\n * @see SentryClient for usage documentation.\n */\nexport class MiniappClient extends BaseClient<MiniappBackend, MiniappOptions> {\n /**\n * Creates a new Miniapp SDK instance.\n *\n * @param options Configuration options for this SDK.\n */\n public constructor(options: MiniappOptions = {}) {\n super(MiniappBackend, options);\n }\n\n /**\n * @inheritDoc\n */\n protected _prepareEvent(event: Event, scope?: Scope, hint?: EventHint): PromiseLike<Event | null> {\n event.platform = event.platform || \"javascript\";\n event.sdk = {\n ...event.sdk,\n name: SDK_NAME,\n packages: [\n ...((event.sdk && event.sdk.packages) || []),\n {\n name: \"npm:sentry-uniapp\",\n version: SDK_VERSION\n }\n ],\n version: SDK_VERSION\n };\n\n return super._prepareEvent(event, scope, hint);\n }\n\n /**\n * Show a report dialog to the user to send feedback to a specific event.\n * 向用户显示报告对话框以将反馈发送到特定事件。---> 小程序上暂时用不到&不考虑。\n *\n * @param options Set individual options for the dialog\n */\n public showReportDialog(options: ReportDialogOptions = {}): void {\n // doesn't work without a document (React Native)\n console.log('sentry-uniapp 暂未实现该方法', options);\n }\n}\n"]}
@@ -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":"AAQA;;GAEG;AACH,UAAU,GAAG;IACX,O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AAO,EAAC,CAAC"}
@@ -1,46 +1,135 @@
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
- throw new Error("sentry-miniapp 暂不支持此平台");
132
+ throw new Error("sentry-uniapp 暂不支持此平台");
44
133
  }
45
134
  return currentSdk;
46
135
  };
@@ -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":";;AAmCA;;GAEG;AACH,IAAM,MAAM,GAAG;IACb,IAAI,UAAU,GAAQ;QACpB,qCAAqC;QACrC,OAAO,EAAE,cAAO,CAAC;QACjB,qCAAqC;QACrC,WAAW,EAAE,cAAO,CAAC;QACrB,qCAAqC;QACrC,iBAAiB,EAAE,cAAO,CAAC;KAC5B,CAAC;IAEF,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC3B,UAAU,GAAG,GAAG,CAAC;KAClB;SAAM,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;QACjC,0CAA0C;QAC1C,UAAU,GAAG,GAAG,CAAC;KAClB;SAAM,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;QACjC,0CAA0C;QAC1C,UAAU,GAAG,EAAE,CAAC;KACjB;SAAM,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE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O","sourcesContent":["declare 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; // 百度小程序\n\n/**\n * 小程序平台 SDK 接口\n */\ninterface SDK {\n request: Function;\n httpRequest?: 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 | \"unknown\";\n\n/**\n * 获取跨平台的 SDK\n */\nconst getSDK = () => {\n let currentSdk: SDK = {\n // tslint:disable-next-line: no-empty\n request: () => {},\n // tslint:disable-next-line: no-empty\n httpRequest: () => {},\n // tslint:disable-next-line: no-empty\n getSystemInfoSync: () => {},\n };\n\n if (typeof uni === \"object\") {\n currentSdk = uni;\n } else if (typeof wx === \"object\") {\n // tslint:disable-next-line: no-unsafe-any\n currentSdk = uni;\n } else if (typeof my === \"object\") {\n // tslint:disable-next-line: no-unsafe-any\n currentSdk = my;\n } else if (typeof tt === \"object\") {\n // tslint:disable-next-line: no-unsafe-any\n currentSdk = tt;\n } else if (typeof dd === \"object\") {\n // tslint:disable-next-line: no-unsafe-any\n currentSdk = dd;\n } else if (typeof qq === \"object\") {\n // tslint:disable-next-line: no-unsafe-any\n currentSdk = qq;\n } else if (typeof swan === \"object\") {\n // tslint:disable-next-line: no-unsafe-any\n currentSdk = swan;\n } else {\n throw new Error(\"sentry-miniapp 暂不支持此平台\");\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 }\n\n return currentAppName;\n};\n\nconst sdk = getSDK();\nconst appName = getAppName();\n\nexport { sdk, appName };\n"]}
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,IA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AAC,CAAM;wBACX,MAAM,CAAC,CAAC,CAAC,CAAA;oBACX,CAAC;iBACF,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;QACJ,CAAC,CAAA;QAED,kBAAkB;KAEnB;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;KAC1C;IAED,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF;;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"]}
@@ -53,7 +53,7 @@ var GlobalHandlers = /** @class */ (function () {
53
53
  var currentHub_1 = core_1.getCurrentHub();
54
54
  // https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onError.html
55
55
  crossPlatform_1.sdk.onError(function (err) {
56
- // console.info("sentry-miniapp", error);
56
+ // console.info("sentry-uniapp", error);
57
57
  var error = typeof err === 'string' ? new Error(err) : err;
58
58
  currentHub_1.captureException(error);
59
59
  });
@@ -1 +1 @@
1
- {"version":3,"file":"globalhandlers.js","sourceRoot":"","sources":["../../src/integrations/globalhandlers.ts"],"names":[],"mappings":";;;AAAA,qCAA6C;AAE7C,uCAAuC;AAEvC,kDAAuC;AAUvC,sBAAsB;AACtB;IA0BE,YAAY;IACZ,wBAAmB,OAAoC;QA1BvD;;WAEG;QACI,SAAI,GAAW,cAAc,CAAC,EAAE,CAAC;QAUxC,YAAY;QACJ,6BAAwB,GAAY,KAAK,CAAC;QAElD,YAAY;QACJ,0CAAqC,GAAY,KAAK,CAAC;QAE/D,YAAY;QACJ,oCAA+B,GAAY,KAAK,CAAC;QAEzD,YAAY;QACJ,qCAAgC,GAAY,KAAK,CAAC;QAIxD,IAAI,CAAC,QAAQ,sBACX,OAAO,EAAE,IAAI,EACb,oBAAoB,EAAE,IAAI,EAC1B,cAAc,EAAE,IAAI,EACpB,eAAe,EAAE,IAAI,IAClB,OAAO,CACX,CAAC;IACJ,CAAC;IACD;;OAEG;IACI,kCAAS,GAAhB;QACE,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC;QAE3B,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;YACzB,cAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;YAC/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AAiC;oBAA/B,aAAU,EAAV,KAAK,mBAAG,CAAC,CAAC,KAAA;gBAC/B,IAAI,YAAY,GAAG,aAAa,CAAC;gBAEjC,QAAQ,KAAK,EAAE;oBACb,KAAK,CAAC;wBACJ,YAAY,GAAG,8BAA8B,CAAC;wBAC9C,MAAM;oBACR,KAAK,EAAE;wBACL,YAAY,GAAG,yBAAyB,CAAC;wBACzC,MAAM;oBACR,KAAK,EAAE;wBACL,YAAY,GAAG,8BAA8B,CAAC;wBAC9C,MAAM;oBACR;wBACE,OAAO;iBACV;gBAED,YAAU,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;gBACnD,YAAU,CAAC,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;gBAC7C,YAAU,CAAC,cAAc,CAAC,sCAAQ,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;SACJ;QAED,IAAI,CAAC,gCAAgC,GAAG,IAAI,CAAC;IAC/C,CAAC;IAjKD;;OAEG;IACW,iBAAE,GAAW,gBAAgB,CAAC;IA+J9C,qBAAC;CAAA,AAxKD,IAwKC;AAxKY,wCAAc","sourcesContent":["import { getCurrentHub } from \"@sentry/core\";\nimport { Integration } from \"@sentry/types\";\nimport { logger } from \"@sentry/utils\";\n\nimport { sdk } from \"../crossPlatform\";\n\n/** JSDoc */\ninterface GlobalHandlersIntegrations {\n onerror: boolean;\n onunhandledrejection: boolean;\n onpagenotfound: boolean;\n onmemorywarning: boolean;\n}\n\n/** Global handlers */\nexport class GlobalHandlers implements Integration {\n /**\n * @inheritDoc\n */\n public name: string = GlobalHandlers.id;\n\n /**\n * @inheritDoc\n */\n public static id: string = \"GlobalHandlers\";\n\n /** JSDoc */\n private readonly _options: GlobalHandlersIntegrations;\n\n /** JSDoc */\n private _onErrorHandlerInstalled: boolean = false;\n\n /** JSDoc */\n private _onUnhandledRejectionHandlerInstalled: boolean = false;\n\n /** JSDoc */\n private _onPageNotFoundHandlerInstalled: boolean = false;\n\n /** JSDoc */\n private _onMemoryWarningHandlerInstalled: boolean = false;\n\n /** JSDoc */\n public constructor(options?: GlobalHandlersIntegrations) {\n this._options = {\n onerror: true,\n onunhandledrejection: true,\n onpagenotfound: true,\n onmemorywarning: true,\n ...options,\n };\n }\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n Error.stackTraceLimit = 50;\n\n if (this._options.onerror) {\n logger.log(\"Global Handler attached: onError\");\n this._installGlobalOnErrorHandler();\n }\n\n if (this._options.onunhandledrejection) {\n logger.log(\"Global Handler attached: onunhandledrejection\");\n this._installGlobalOnUnhandledRejectionHandler();\n }\n\n if (this._options.onpagenotfound) {\n logger.log(\"Global Handler attached: onPageNotFound\");\n this._installGlobalOnPageNotFoundHandler();\n }\n\n if (this._options.onmemorywarning) {\n logger.log(\"Global Handler attached: onMemoryWarning\");\n this._installGlobalOnMemoryWarningHandler();\n }\n }\n\n /** JSDoc */\n private _installGlobalOnErrorHandler(): void {\n if (this._onErrorHandlerInstalled) {\n return;\n }\n\n if (!!sdk.onError) {\n const currentHub = getCurrentHub();\n\n // https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onError.html\n sdk.onError((err: string | object) => {\n // console.info(\"sentry-miniapp\", error);\n const error = typeof err === 'string' ? new Error(err) : err\n currentHub.captureException(error);\n });\n }\n\n this._onErrorHandlerInstalled = true;\n }\n\n /** JSDoc */\n private _installGlobalOnUnhandledRejectionHandler(): void {\n if (this._onUnhandledRejectionHandlerInstalled) {\n return;\n }\n\n if (!!sdk.onUnhandledRejection) {\n const currentHub = getCurrentHub();\n /** JSDoc */\n interface OnUnhandledRejectionRes {\n reason: string | object;\n promise: Promise<any>;\n }\n\n // https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onUnhandledRejection.html\n sdk.onUnhandledRejection(\n ({ reason, promise }: OnUnhandledRejectionRes) => {\n // console.log(reason, typeof reason, promise)\n // 为什么官方文档上说 reason 是 string 类型,但是实际返回的确实 object 类型\n const error = typeof reason === 'string' ? new Error(reason) : reason\n currentHub.captureException(error, {\n data: promise,\n });\n }\n );\n }\n\n this._onUnhandledRejectionHandlerInstalled = true;\n }\n\n /** JSDoc */\n private _installGlobalOnPageNotFoundHandler(): void {\n if (this._onPageNotFoundHandlerInstalled) {\n return;\n }\n\n if (!!sdk.onPageNotFound) {\n const currentHub = getCurrentHub();\n\n sdk.onPageNotFound((res: { path: string }) => {\n const url = res.path.split(\"?\")[0];\n\n currentHub.setTag(\"pagenotfound\", url);\n currentHub.setExtra(\"message\", JSON.stringify(res));\n currentHub.captureMessage(`页面无法找到: ${url}`);\n });\n }\n\n this._onPageNotFoundHandlerInstalled = true;\n }\n\n /** JSDoc */\n private _installGlobalOnMemoryWarningHandler(): void {\n if (this._onMemoryWarningHandlerInstalled) {\n return;\n }\n\n if (!!sdk.onMemoryWarning) {\n const currentHub = getCurrentHub();\n\n sdk.onMemoryWarning(({ level = -1 }: { level: number }) => {\n let levelMessage = \"没有获取到告警级别信息\";\n\n switch (level) {\n case 5:\n levelMessage = \"TRIM_MEMORY_RUNNING_MODERATE\";\n break;\n case 10:\n levelMessage = \"TRIM_MEMORY_RUNNING_LOW\";\n break;\n case 15:\n levelMessage = \"TRIM_MEMORY_RUNNING_CRITICAL\";\n break;\n default:\n return;\n }\n\n currentHub.setTag(\"memory-warning\", String(level));\n currentHub.setExtra(\"message\", levelMessage);\n currentHub.captureMessage(`内存不足告警`);\n });\n }\n\n this._onMemoryWarningHandlerInstalled = true;\n }\n}\n"]}
1
+ {"version":3,"file":"globalhandlers.js","sourceRoot":"","sources":["../../src/integrations/globalhandlers.ts"],"names":[],"mappings":";;;AAAA,qCAA6C;AAE7C,uCAAuC;AAEvC,kDAAuC;AAUvC,sBAAsB;AACtB;IA0BE,YAAY;IACZ,wBAAmB,OAAoC;QA1BvD;;WAEG;QACI,SAAI,GAAW,cAAc,CAAC,EAAE,CAAC;QAUxC,YAAY;QACJ,6BAAwB,GAAY,KAAK,CA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core\";\nimport { Integration } from \"@sentry/types\";\nimport { logger } from \"@sentry/utils\";\n\nimport { sdk } from \"../crossPlatform\";\n\n/** JSDoc */\ninterface GlobalHandlersIntegrations {\n onerror: boolean;\n onunhandledrejection: boolean;\n onpagenotfound: boolean;\n onmemorywarning: boolean;\n}\n\n/** Global handlers */\nexport class GlobalHandlers implements Integration {\n /**\n * @inheritDoc\n */\n public name: string = GlobalHandlers.id;\n\n /**\n * @inheritDoc\n */\n public static id: string = \"GlobalHandlers\";\n\n /** JSDoc */\n private readonly _options: GlobalHandlersIntegrations;\n\n /** JSDoc */\n private _onErrorHandlerInstalled: boolean = false;\n\n /** JSDoc */\n private _onUnhandledRejectionHandlerInstalled: boolean = false;\n\n /** JSDoc */\n private _onPageNotFoundHandlerInstalled: boolean = false;\n\n /** JSDoc */\n private _onMemoryWarningHandlerInstalled: boolean = false;\n\n /** JSDoc */\n public constructor(options?: GlobalHandlersIntegrations) {\n this._options = {\n onerror: true,\n onunhandledrejection: true,\n onpagenotfound: true,\n onmemorywarning: true,\n ...options,\n };\n }\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n Error.stackTraceLimit = 50;\n\n if (this._options.onerror) {\n logger.log(\"Global Handler attached: onError\");\n this._installGlobalOnErrorHandler();\n }\n\n if (this._options.onunhandledrejection) {\n logger.log(\"Global Handler attached: onunhandledrejection\");\n this._installGlobalOnUnhandledRejectionHandler();\n }\n\n if (this._options.onpagenotfound) {\n logger.log(\"Global Handler attached: onPageNotFound\");\n this._installGlobalOnPageNotFoundHandler();\n }\n\n if (this._options.onmemorywarning) {\n logger.log(\"Global Handler attached: onMemoryWarning\");\n this._installGlobalOnMemoryWarningHandler();\n }\n }\n\n /** JSDoc */\n private _installGlobalOnErrorHandler(): void {\n if (this._onErrorHandlerInstalled) {\n return;\n }\n\n if (!!sdk.onError) {\n const currentHub = getCurrentHub();\n\n // https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onError.html\n sdk.onError((err: string | object) => {\n // console.info(\"sentry-uniapp\", error);\n const error = typeof err === 'string' ? new Error(err) : err\n currentHub.captureException(error);\n });\n }\n\n this._onErrorHandlerInstalled = true;\n }\n\n /** JSDoc */\n private _installGlobalOnUnhandledRejectionHandler(): void {\n if (this._onUnhandledRejectionHandlerInstalled) {\n return;\n }\n\n if (!!sdk.onUnhandledRejection) {\n const currentHub = getCurrentHub();\n /** JSDoc */\n interface OnUnhandledRejectionRes {\n reason: string | object;\n promise: Promise<any>;\n }\n\n // https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onUnhandledRejection.html\n sdk.onUnhandledRejection(\n ({ reason, promise }: OnUnhandledRejectionRes) => {\n // console.log(reason, typeof reason, promise)\n // 为什么官方文档上说 reason 是 string 类型,但是实际返回的确实 object 类型\n const error = typeof reason === 'string' ? new Error(reason) : reason\n currentHub.captureException(error, {\n data: promise,\n });\n }\n );\n }\n\n this._onUnhandledRejectionHandlerInstalled = true;\n }\n\n /** JSDoc */\n private _installGlobalOnPageNotFoundHandler(): void {\n if (this._onPageNotFoundHandlerInstalled) {\n return;\n }\n\n if (!!sdk.onPageNotFound) {\n const currentHub = getCurrentHub();\n\n sdk.onPageNotFound((res: { path: string }) => {\n const url = res.path.split(\"?\")[0];\n\n currentHub.setTag(\"pagenotfound\", url);\n currentHub.setExtra(\"message\", JSON.stringify(res));\n currentHub.captureMessage(`页面无法找到: ${url}`);\n });\n }\n\n this._onPageNotFoundHandlerInstalled = true;\n }\n\n /** JSDoc */\n private _installGlobalOnMemoryWarningHandler(): void {\n if (this._onMemoryWarningHandlerInstalled) {\n return;\n }\n\n if (!!sdk.onMemoryWarning) {\n const currentHub = getCurrentHub();\n\n sdk.onMemoryWarning(({ level = -1 }: { level: number }) => {\n let levelMessage = \"没有获取到告警级别信息\";\n\n switch (level) {\n case 5:\n levelMessage = \"TRIM_MEMORY_RUNNING_MODERATE\";\n break;\n case 10:\n levelMessage = \"TRIM_MEMORY_RUNNING_LOW\";\n break;\n case 15:\n levelMessage = \"TRIM_MEMORY_RUNNING_CRITICAL\";\n break;\n default:\n return;\n }\n\n currentHub.setTag(\"memory-warning\", String(level));\n currentHub.setExtra(\"message\", levelMessage);\n currentHub.captureMessage(`内存不足告警`);\n });\n }\n\n this._onMemoryWarningHandlerInstalled = true;\n }\n}\n"]}
@@ -30,7 +30,7 @@ var Router = /** @class */ (function () {
30
30
  return tslib_1.__assign(tslib_1.__assign({}, event), { extra: tslib_1.__assign(tslib_1.__assign({}, event.extra), { routers: routers }) });
31
31
  }
32
32
  catch (e) {
33
- console.warn("sentry-miniapp get router info fail: " + e);
33
+ console.warn("sentry-uniapp get router info fail: " + e);
34
34
  }
35
35
  }
36
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/integrations/router.ts"],"names":[],"mappings":";;;AAAA,qCAAsE;AAUtE,gBAAgB;AAChB;IAcE;;OAEG;IACH,gBAAmB,OAA4B;QAhB/C;;WAEG;QACI,SAAI,GAAW,MAAM,CAAC,EAAE,CAAC;QAc9B,IAAI,CAAC,QAAQ,sBACX,MAAM,EAAE,IAAI,IACT,OAAO,CACX,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,0BAAS,GAAhB;QAAA,iBA2BC;QA1BC,8BAAuB,CAAC,UAAC,KAAY;YACnC,IAAI,oBAAa,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE;gBAC1C,IAAI,KAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;oBACxB,IAAI;wBACF,IAAM,OAAO,GAAG,eAAe,EAAE,CAAC,GAAG,CACnC,UAAC,KAAyC,IAAK,OAAA,CAAC;4BAC9C,KAAK,EAAE,KAAK,CAAC,KAAK;4BAClB,OAAO,EAAE,KAAK,CAAC,OAAO;yBACvB,CAAC,EAH6C,CAG7C,CACH,CAAC;wBAEF,6CACK,KAAK,KACR,KAAK,wCACA,KAAK,CAAC,KAAK,KACd,OAAO,SAAA,OAET;qBACH;oBAAC,OAAO,CAAC,EAAE;wBACV,OAAO,CAAC,IAAI,CAAC,0CAAwC,CAAG,CAAC,CAAC;qBAC3D;iBACF;aACF;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IAhDD;;OAEG;IACW,SAAE,GAAW,QAAQ,CAAC;IA8CtC,aAAC;CAAA,AAvDD,IAuDC;AAvDY,wBAAM","sourcesContent":["import { addGlobalEventProcessor, getCurrentHub } from \"@sentry/core\";\nimport { Event, Integration } from \"@sentry/types\";\n\ndeclare const getCurrentPages: any;\n\n/** JSDoc */\ninterface RouterIntegrations {\n enable?: boolean;\n}\n\n/** UserAgent */\nexport class Router implements Integration {\n /**\n * @inheritDoc\n */\n public name: string = Router.id;\n\n /**\n * @inheritDoc\n */\n public static id: string = \"Router\";\n\n /** JSDoc */\n private readonly _options: RouterIntegrations;\n\n /**\n * @inheritDoc\n */\n public constructor(options?: RouterIntegrations) {\n this._options = {\n enable: true,\n ...options,\n };\n }\n\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n addGlobalEventProcessor((event: Event) => {\n if (getCurrentHub().getIntegration(Router)) {\n if (this._options.enable) {\n try {\n const routers = getCurrentPages().map(\n (route: { route: string; options: object }) => ({\n route: route.route,\n options: route.options,\n })\n );\n\n return {\n ...event,\n extra: {\n ...event.extra,\n routers,\n },\n };\n } catch (e) {\n console.warn(`sentry-miniapp get router info fail: ${e}`);\n }\n }\n }\n\n return event;\n });\n }\n}\n"]}
1
+ {"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/integrations/router.ts"],"names":[],"mappings":";;;AAAA,qCAAsE;AAUtE,gBAAgB;AAChB;IAcE;;OAEG;IACH,gBAAmB,OAA4B;QAhB/C;;WAEG;QACI,SAAI,GAAW,MAAM,CAAC,EAAE,CAAC;QAc9B,IAAI,CAAC,QAAQ,sBACX,MAAM,EAAE,IAAI,IACT,OAAO,CACX,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,0BAAS,GAAhB;QAAA,iBA2BC;QA1BC,8BAAuB,CAAC,UAAC,KAAY;YACnC,IAAI,oBAAa,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE;gBAC1C,IAAI,KAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;oBACxB,IAAI;wBACF,IAAM,OAAO,GAAG,eAAe,EAAE,CAAC,GAAG,CACnC,UAAC,KAAyC,IAAK,OAAA,CAAC;4BAC9C,KAAK,EAAE,KAAK,CAAC,KAAK;4BAClB,OAAO,EAAE,KAAK,CAAC,OAAO;yBACvB,CAAC,EAH6C,CAG7C,CACH,CAAC;wBAEF,6CACK,KAAK,KACR,KAAK,wCACA,KAAK,CAAC,KAAK,KACd,OAAO,SAAA,OAET;qBACH;oBAAC,OAAO,CAAC,EAAE;wBACV,OAAO,CAAC,IAAI,CAAC,yCAAuC,CAAG,CAAC,CAAC;qBAC1D;iBACF;aACF;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IAhDD;;OAEG;IACW,SAAE,GAAW,QAAQ,CAAC;IA8CtC,aAAC;CAAA,AAvDD,IAuDC;AAvDY,wBAAM","sourcesContent":["import { addGlobalEventProcessor, getCurrentHub } from \"@sentry/core\";\nimport { Event, Integration } from \"@sentry/types\";\n\ndeclare const getCurrentPages: any;\n\n/** JSDoc */\ninterface RouterIntegrations {\n enable?: boolean;\n}\n\n/** UserAgent */\nexport class Router implements Integration {\n /**\n * @inheritDoc\n */\n public name: string = Router.id;\n\n /**\n * @inheritDoc\n */\n public static id: string = \"Router\";\n\n /** JSDoc */\n private readonly _options: RouterIntegrations;\n\n /**\n * @inheritDoc\n */\n public constructor(options?: RouterIntegrations) {\n this._options = {\n enable: true,\n ...options,\n };\n }\n\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n addGlobalEventProcessor((event: Event) => {\n if (getCurrentHub().getIntegration(Router)) {\n if (this._options.enable) {\n try {\n const routers = getCurrentPages().map(\n (route: { route: string; options: object }) => ({\n route: route.route,\n options: route.options,\n })\n );\n\n return {\n ...event,\n extra: {\n ...event.extra,\n routers,\n },\n };\n } catch (e) {\n console.warn(`sentry-uniapp get router info fail: ${e}`);\n }\n }\n }\n\n return event;\n });\n }\n}\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;CAkEzB"}
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
- core_1.addGlobalEventProcessor(function (event) {
19
- if (core_1.getCurrentHub().getIntegration(System)) {
20
- try {
21
- var systemInfo = crossPlatform_1.sdk.getSystemInfoSync();
22
- var _a = systemInfo.SDKVersion, SDKVersion = _a === void 0 ? "0.0.0" : _a, batteryLevel = systemInfo.batteryLevel, // 微信小程序
23
- currentBattery = systemInfo.currentBattery, // 支付宝小程序、 钉钉小程序
24
- battery = systemInfo.battery, // 字节跳动小程序
25
- 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, // 支付宝小程序
26
- appName = systemInfo.appName, // 字节跳动小程序
27
- fontSizeSetting = systemInfo.fontSizeSetting;
28
- var _b = tslib_1.__read(system.split(" "), 2), systemName = _b[0], systemVersion = _b[1];
29
- return tslib_1.__assign(tslib_1.__assign({}, event), { contexts: tslib_1.__assign(tslib_1.__assign({}, event.contexts), { device: {
30
- brand: brand,
31
- battery_level: batteryLevel || currentBattery || battery,
32
- model: model,
33
- screen_dpi: pixelRatio
34
- }, os: {
35
- name: systemName || system,
36
- version: systemVersion || system
37
- }, extra: tslib_1.__assign({ SDKVersion: SDKVersion,
38
- language: language,
39
- platform: platform,
40
- screenHeight: screenHeight,
41
- screenWidth: screenWidth,
42
- statusBarHeight: statusBarHeight,
43
- version: version,
44
- windowHeight: windowHeight,
45
- windowWidth: windowWidth,
46
- fontSizeSetting: fontSizeSetting, app: app || appName || crossPlatform_1.appName }, systemInfo) }) });
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
- catch (e) {
49
- console.warn("sentry-miniapp get system info fail: " + e);
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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AI,EAAE,UAAU,IAAI,MAAM;gCAC1B,OAAO,EAAE,aAAa,IAAI,MAAM;6BACjC,EACD,KAAK,qBACH,UAAU,YAAA;gCACV,QAAQ,UAAA;gCACR,QAAQ,UAAA;gCACR,YAAY,cAAA;gCACZ,WAAW,aAAA;gCACX,eAAe,iBAAA;gCACf,OAAO,SAAA;gCACP,YAAY,cAAA;gCACZ,WAAW,aAAA;gCACX,eAAe,iBAAA,EACf,GAAG,EAAE,GAAG,IAAI,OAAO,IAAI,uBAAc,IAClC,UAAU,QAGjB;iBACH;gBAAC,OAAO,CAAC,EAAE;oBACV,OAAO,CAAC,IAAI,CAAC,0CAAwC,CAAG,CAAC,CAAC;iBAC3D;aACF;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IAzED;;OAEG;IACW,SAAE,GAAW,QAAQ,CAAC;IAuEtC,aAAC;CAAA,AAhFD,IAgFC;AAhFY,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((event: Event) => {\n if (getCurrentHub().getIntegration(System)) {\n try {\n const systemInfo = sdk.getSystemInfoSync();\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-miniapp get system info fail: ${e}`);\n }\n }\n\n return event;\n });\n }\n}\n"]}
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,aAlBA,EACZ,cAAc,GAiBZ,UAAU,eAjBE,EACd,OAAO,GAgBL,UAAU,QAhBL,EACP,KAAK,GAeH,UAAU,MAfP,EACL,QAAQ,GAcN,UAAU,SAdJ,EACR,KAAK,GAaH,UAAU,MAbP,EACL,UAAU,GAYR,UAAU,WAZF,EACV,QAAQ,GAWN,UAAU,SAXJ,EACR,YAAY,GAUV,UAAU,aAVA,EACZ,WAAW,GAST,UAAU,YATD,EACX,eAAe,GAQb,UAAU,gBARG,EACf,MAAM,GAOJ,UAAU,OAPN,EACN,OAAO,GAML,UAAU,QANL,EACP,YAAY,GAKV,UAAU,aALA,EACZ,WAAW,GAIT,UAAU,YAJD,EACX,GAAG,GAGD,UAAU,IAHT,EACH,OAAO,GAEL,UAAU,QAFL,EACP,eAAe,GACb,UAAU,gBADG,CACF;wBACT,KAAA,eAA8B,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAA,EAA9C,UAAU,QAAA,EAAE,aAAa,QAAA,CAAsB;wBAEtD,4DACK,KAAK,KACR,QAAQ,wCACH,KAAK,CAAC,QAAQ,KACjB,MAAM,EAAE;wCACN,KAAK,OAAA;wCACL,aAAa,EAAE,YAAY,IAAI,cAAc,IAAI,OAAO;wCACxD,KAAK,OAAA;wCACL,UAAU,EAAE,UAAU;qCACvB,EACD,EAAE,EAAE;wCACF,IAAI,EAAE,UAAU,IAAI,MAAM;wCAC1B,OAAO,EAAE,aAAa,IAAI,MAAM;qCACjC,EACD,KAAK,qBACH,UAAU,YAAA;wCACV,QAAQ,UAAA;wCACR,QAAQ,UAAA;wCACR,YAAY,cAAA;wCACZ,WAAW,aAAA;wCACX,eAAe,iBAAA;wCACf,OAAO,SAAA;wCACP,YAAY,cAAA;wCACZ,WAAW,aAAA;wCACX,eAAe,iBAAA,EACf,GAAG,EAAE,GAAG,IAAI,OAAO,IAAI,uBAAc,IAClC,UAAU,SAGjB;;;wBAEF,OAAO,CAAC,IAAI,CAAC,yCAAuC,GAAG,CAAC,CAAC;;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"]}