sentry-uniapp 1.0.12 → 2.8.0

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 (357) hide show
  1. package/README.md +11 -9
  2. package/dist/client.d.ts +38 -40
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +46 -41
  5. package/dist/client.js.map +1 -1
  6. package/dist/crossPlatform.d.ts +1 -1
  7. package/dist/crossPlatform.js +11 -10
  8. package/dist/crossPlatform.js.map +1 -1
  9. package/dist/eventbuilder.d.ts +9 -10
  10. package/dist/eventbuilder.d.ts.map +1 -1
  11. package/dist/eventbuilder.js +131 -58
  12. package/dist/eventbuilder.js.map +1 -1
  13. package/dist/flags.js +1 -0
  14. package/dist/flags.js.map +1 -1
  15. package/dist/index.d.ts +10 -9
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +84 -21
  18. package/dist/index.js.map +1 -1
  19. package/dist/integrations/globalhandlers.d.ts +10 -44
  20. package/dist/integrations/globalhandlers.d.ts.map +1 -1
  21. package/dist/integrations/globalhandlers.js +101 -134
  22. package/dist/integrations/globalhandlers.js.map +1 -1
  23. package/dist/integrations/ignoreMpcrawlerErrors.d.ts +3 -18
  24. package/dist/integrations/ignoreMpcrawlerErrors.d.ts.map +1 -1
  25. package/dist/integrations/ignoreMpcrawlerErrors.js +28 -28
  26. package/dist/integrations/ignoreMpcrawlerErrors.js.map +1 -1
  27. package/dist/integrations/index.d.ts +4 -6
  28. package/dist/integrations/index.d.ts.map +1 -1
  29. package/dist/integrations/index.js +12 -10
  30. package/dist/integrations/index.js.map +1 -1
  31. package/dist/integrations/router.d.ts +6 -24
  32. package/dist/integrations/router.d.ts.map +1 -1
  33. package/dist/integrations/router.js +39 -42
  34. package/dist/integrations/router.js.map +1 -1
  35. package/dist/integrations/system.d.ts +5 -16
  36. package/dist/integrations/system.d.ts.map +1 -1
  37. package/dist/integrations/system.js +62 -60
  38. package/dist/integrations/system.js.map +1 -1
  39. package/dist/parsers.d.ts +2 -2
  40. package/dist/parsers.d.ts.map +1 -1
  41. package/dist/parsers.js +27 -26
  42. package/dist/parsers.js.map +1 -1
  43. package/dist/sdk.d.ts +9 -85
  44. package/dist/sdk.d.ts.map +1 -1
  45. package/dist/sdk.js +55 -128
  46. package/dist/sdk.js.map +1 -1
  47. package/dist/tracekit.js +35 -33
  48. package/dist/tracekit.js.map +1 -1
  49. package/dist/transport.d.ts +7 -0
  50. package/dist/transport.d.ts.map +1 -0
  51. package/dist/transport.js +45 -0
  52. package/dist/transport.js.map +1 -0
  53. package/dist/transports/index.d.ts +1 -2
  54. package/dist/transports/index.d.ts.map +1 -1
  55. package/dist/transports/index.js +4 -4
  56. package/dist/transports/index.js.map +1 -1
  57. package/dist/version.d.ts +1 -1
  58. package/dist/version.d.ts.map +1 -1
  59. package/dist/version.js +2 -2
  60. package/dist/version.js.map +1 -1
  61. package/esm/client.d.ts +38 -40
  62. package/esm/client.d.ts.map +1 -1
  63. package/esm/client.js +43 -40
  64. package/esm/client.js.map +1 -1
  65. package/esm/crossPlatform.d.ts +1 -1
  66. package/esm/crossPlatform.js +10 -10
  67. package/esm/crossPlatform.js.map +1 -1
  68. package/esm/eventbuilder.d.ts +9 -10
  69. package/esm/eventbuilder.d.ts.map +1 -1
  70. package/esm/eventbuilder.js +125 -52
  71. package/esm/eventbuilder.js.map +1 -1
  72. package/esm/flags.js +1 -1
  73. package/esm/flags.js.map +1 -1
  74. package/esm/index.d.ts +10 -9
  75. package/esm/index.d.ts.map +1 -1
  76. package/esm/index.js +13 -8
  77. package/esm/index.js.map +1 -1
  78. package/esm/integrations/globalhandlers.d.ts +10 -44
  79. package/esm/integrations/globalhandlers.d.ts.map +1 -1
  80. package/esm/integrations/globalhandlers.js +99 -133
  81. package/esm/integrations/globalhandlers.js.map +1 -1
  82. package/esm/integrations/ignoreMpcrawlerErrors.d.ts +3 -18
  83. package/esm/integrations/ignoreMpcrawlerErrors.d.ts.map +1 -1
  84. package/esm/integrations/ignoreMpcrawlerErrors.js +25 -26
  85. package/esm/integrations/ignoreMpcrawlerErrors.js.map +1 -1
  86. package/esm/integrations/index.d.ts +4 -6
  87. package/esm/integrations/index.d.ts.map +1 -1
  88. package/esm/integrations/index.js +5 -6
  89. package/esm/integrations/index.js.map +1 -1
  90. package/esm/integrations/router.d.ts +6 -24
  91. package/esm/integrations/router.d.ts.map +1 -1
  92. package/esm/integrations/router.js +37 -41
  93. package/esm/integrations/router.js.map +1 -1
  94. package/esm/integrations/system.d.ts +5 -16
  95. package/esm/integrations/system.d.ts.map +1 -1
  96. package/esm/integrations/system.js +60 -59
  97. package/esm/integrations/system.js.map +1 -1
  98. package/esm/parsers.d.ts +2 -2
  99. package/esm/parsers.d.ts.map +1 -1
  100. package/esm/parsers.js +20 -19
  101. package/esm/parsers.js.map +1 -1
  102. package/esm/sdk.d.ts +9 -85
  103. package/esm/sdk.d.ts.map +1 -1
  104. package/esm/sdk.js +49 -121
  105. package/esm/sdk.js.map +1 -1
  106. package/esm/tracekit.js +33 -31
  107. package/esm/tracekit.js.map +1 -1
  108. package/esm/transport.d.ts +7 -0
  109. package/esm/transport.d.ts.map +1 -0
  110. package/esm/transport.js +41 -0
  111. package/esm/transport.js.map +1 -0
  112. package/esm/transports/index.d.ts +1 -2
  113. package/esm/transports/index.d.ts.map +1 -1
  114. package/esm/transports/index.js +1 -2
  115. package/esm/transports/index.js.map +1 -1
  116. package/esm/version.d.ts +1 -1
  117. package/esm/version.d.ts.map +1 -1
  118. package/esm/version.js +2 -3
  119. package/esm/version.js.map +1 -1
  120. package/package.json +23 -27
  121. package/dist/backend.d.ts +0 -41
  122. package/dist/backend.d.ts.map +0 -1
  123. package/dist/backend.js +0 -68
  124. package/dist/backend.js.map +0 -1
  125. package/dist/helpers.d.ts +0 -35
  126. package/dist/helpers.d.ts.map +0 -1
  127. package/dist/helpers.js +0 -236
  128. package/dist/helpers.js.map +0 -1
  129. package/dist/integrations/linkederrors.d.ts +0 -40
  130. package/dist/integrations/linkederrors.d.ts.map +0 -1
  131. package/dist/integrations/linkederrors.js +0 -65
  132. package/dist/integrations/linkederrors.js.map +0 -1
  133. package/dist/integrations/trycatch.d.ts +0 -26
  134. package/dist/integrations/trycatch.d.ts.map +0 -1
  135. package/dist/integrations/trycatch.js +0 -166
  136. package/dist/integrations/trycatch.js.map +0 -1
  137. package/dist/package.json +0 -52
  138. package/dist/sentry-uniapp.min.js +0 -3
  139. package/dist/sentry-uniapp.min.js.LICENSE.txt +0 -14
  140. package/dist/sentry-uniapp.min.js.map +0 -1
  141. package/dist/src/backend.d.ts +0 -41
  142. package/dist/src/backend.d.ts.map +0 -1
  143. package/dist/src/backend.js +0 -68
  144. package/dist/src/backend.js.map +0 -1
  145. package/dist/src/client.d.ts +0 -55
  146. package/dist/src/client.d.ts.map +0 -1
  147. package/dist/src/client.js +0 -51
  148. package/dist/src/client.js.map +0 -1
  149. package/dist/src/crossPlatform.d.ts +0 -18
  150. package/dist/src/crossPlatform.d.ts.map +0 -1
  151. package/dist/src/crossPlatform.js +0 -80
  152. package/dist/src/crossPlatform.js.map +0 -1
  153. package/dist/src/eventbuilder.d.ts +0 -11
  154. package/dist/src/eventbuilder.d.ts.map +0 -1
  155. package/dist/src/eventbuilder.js +0 -79
  156. package/dist/src/eventbuilder.js.map +0 -1
  157. package/dist/src/flags.d.ts +0 -3
  158. package/dist/src/flags.d.ts.map +0 -1
  159. package/dist/src/flags.js +0 -18
  160. package/dist/src/flags.js.map +0 -1
  161. package/dist/src/helpers.d.ts +0 -35
  162. package/dist/src/helpers.d.ts.map +0 -1
  163. package/dist/src/helpers.js +0 -236
  164. package/dist/src/helpers.js.map +0 -1
  165. package/dist/src/index.d.ts +0 -10
  166. package/dist/src/index.d.ts.map +0 -1
  167. package/dist/src/index.js +0 -40
  168. package/dist/src/index.js.map +0 -1
  169. package/dist/src/integrations/globalhandlers.d.ts +0 -47
  170. package/dist/src/integrations/globalhandlers.d.ts.map +0 -1
  171. package/dist/src/integrations/globalhandlers.js +0 -153
  172. package/dist/src/integrations/globalhandlers.js.map +0 -1
  173. package/dist/src/integrations/ignoreMpcrawlerErrors.d.ts +0 -21
  174. package/dist/src/integrations/ignoreMpcrawlerErrors.d.ts.map +0 -1
  175. package/dist/src/integrations/ignoreMpcrawlerErrors.js +0 -40
  176. package/dist/src/integrations/ignoreMpcrawlerErrors.js.map +0 -1
  177. package/dist/src/integrations/index.d.ts +0 -7
  178. package/dist/src/integrations/index.d.ts.map +0 -1
  179. package/dist/src/integrations/index.js +0 -14
  180. package/dist/src/integrations/index.js.map +0 -1
  181. package/dist/src/integrations/linkederrors.d.ts +0 -40
  182. package/dist/src/integrations/linkederrors.d.ts.map +0 -1
  183. package/dist/src/integrations/linkederrors.js +0 -65
  184. package/dist/src/integrations/linkederrors.js.map +0 -1
  185. package/dist/src/integrations/router.d.ts +0 -28
  186. package/dist/src/integrations/router.d.ts.map +0 -1
  187. package/dist/src/integrations/router.js +0 -47
  188. package/dist/src/integrations/router.js.map +0 -1
  189. package/dist/src/integrations/system.d.ts +0 -17
  190. package/dist/src/integrations/system.d.ts.map +0 -1
  191. package/dist/src/integrations/system.js +0 -65
  192. package/dist/src/integrations/system.js.map +0 -1
  193. package/dist/src/integrations/trycatch.d.ts +0 -26
  194. package/dist/src/integrations/trycatch.d.ts.map +0 -1
  195. package/dist/src/integrations/trycatch.js +0 -166
  196. package/dist/src/integrations/trycatch.js.map +0 -1
  197. package/dist/src/parsers.d.ts +0 -21
  198. package/dist/src/parsers.d.ts.map +0 -1
  199. package/dist/src/parsers.js +0 -97
  200. package/dist/src/parsers.js.map +0 -1
  201. package/dist/src/sdk.d.ts +0 -99
  202. package/dist/src/sdk.d.ts.map +0 -1
  203. package/dist/src/sdk.js +0 -155
  204. package/dist/src/sdk.js.map +0 -1
  205. package/dist/src/tracekit.d.ts +0 -38
  206. package/dist/src/tracekit.d.ts.map +0 -1
  207. package/dist/src/tracekit.js +0 -222
  208. package/dist/src/tracekit.js.map +0 -1
  209. package/dist/src/transports/base.d.ts +0 -22
  210. package/dist/src/transports/base.d.ts.map +0 -1
  211. package/dist/src/transports/base.js +0 -28
  212. package/dist/src/transports/base.js.map +0 -1
  213. package/dist/src/transports/index.d.ts +0 -3
  214. package/dist/src/transports/index.d.ts.map +0 -1
  215. package/dist/src/transports/index.js +0 -6
  216. package/dist/src/transports/index.js.map +0 -1
  217. package/dist/src/transports/xhr.d.ts +0 -10
  218. package/dist/src/transports/xhr.d.ts.map +0 -1
  219. package/dist/src/transports/xhr.js +0 -42
  220. package/dist/src/transports/xhr.js.map +0 -1
  221. package/dist/src/version.d.ts +0 -3
  222. package/dist/src/version.d.ts.map +0 -1
  223. package/dist/src/version.js +0 -6
  224. package/dist/src/version.js.map +0 -1
  225. package/dist/transports/base.d.ts +0 -22
  226. package/dist/transports/base.d.ts.map +0 -1
  227. package/dist/transports/base.js +0 -28
  228. package/dist/transports/base.js.map +0 -1
  229. package/dist/transports/xhr.d.ts +0 -10
  230. package/dist/transports/xhr.d.ts.map +0 -1
  231. package/dist/transports/xhr.js +0 -42
  232. package/dist/transports/xhr.js.map +0 -1
  233. package/dist/utils/debug-build.d.ts +0 -7
  234. package/dist/utils/debug-build.d.ts.map +0 -1
  235. package/dist/utils/debug-build.js +0 -9
  236. package/dist/utils/debug-build.js.map +0 -1
  237. package/dist/utils/logger.d.ts +0 -16
  238. package/dist/utils/logger.d.ts.map +0 -1
  239. package/dist/utils/logger.js +0 -50
  240. package/dist/utils/logger.js.map +0 -1
  241. package/esm/backend.d.ts +0 -41
  242. package/esm/backend.d.ts.map +0 -1
  243. package/esm/backend.js +0 -66
  244. package/esm/backend.js.map +0 -1
  245. package/esm/helpers.d.ts +0 -35
  246. package/esm/helpers.d.ts.map +0 -1
  247. package/esm/helpers.js +0 -229
  248. package/esm/helpers.js.map +0 -1
  249. package/esm/integrations/linkederrors.d.ts +0 -40
  250. package/esm/integrations/linkederrors.d.ts.map +0 -1
  251. package/esm/integrations/linkederrors.js +0 -63
  252. package/esm/integrations/linkederrors.js.map +0 -1
  253. package/esm/integrations/trycatch.d.ts +0 -26
  254. package/esm/integrations/trycatch.d.ts.map +0 -1
  255. package/esm/integrations/trycatch.js +0 -164
  256. package/esm/integrations/trycatch.js.map +0 -1
  257. package/esm/package.json +0 -52
  258. package/esm/src/backend.d.ts +0 -41
  259. package/esm/src/backend.d.ts.map +0 -1
  260. package/esm/src/backend.js +0 -66
  261. package/esm/src/backend.js.map +0 -1
  262. package/esm/src/client.d.ts +0 -55
  263. package/esm/src/client.d.ts.map +0 -1
  264. package/esm/src/client.js +0 -49
  265. package/esm/src/client.js.map +0 -1
  266. package/esm/src/crossPlatform.d.ts +0 -18
  267. package/esm/src/crossPlatform.d.ts.map +0 -1
  268. package/esm/src/crossPlatform.js +0 -77
  269. package/esm/src/crossPlatform.js.map +0 -1
  270. package/esm/src/eventbuilder.d.ts +0 -11
  271. package/esm/src/eventbuilder.d.ts.map +0 -1
  272. package/esm/src/eventbuilder.js +0 -75
  273. package/esm/src/eventbuilder.js.map +0 -1
  274. package/esm/src/flags.d.ts +0 -3
  275. package/esm/src/flags.d.ts.map +0 -1
  276. package/esm/src/flags.js +0 -16
  277. package/esm/src/flags.js.map +0 -1
  278. package/esm/src/helpers.d.ts +0 -35
  279. package/esm/src/helpers.d.ts.map +0 -1
  280. package/esm/src/helpers.js +0 -229
  281. package/esm/src/helpers.js.map +0 -1
  282. package/esm/src/index.d.ts +0 -10
  283. package/esm/src/index.d.ts.map +0 -1
  284. package/esm/src/index.js +0 -9
  285. package/esm/src/index.js.map +0 -1
  286. package/esm/src/integrations/globalhandlers.d.ts +0 -47
  287. package/esm/src/integrations/globalhandlers.d.ts.map +0 -1
  288. package/esm/src/integrations/globalhandlers.js +0 -151
  289. package/esm/src/integrations/globalhandlers.js.map +0 -1
  290. package/esm/src/integrations/ignoreMpcrawlerErrors.d.ts +0 -21
  291. package/esm/src/integrations/ignoreMpcrawlerErrors.d.ts.map +0 -1
  292. package/esm/src/integrations/ignoreMpcrawlerErrors.js +0 -38
  293. package/esm/src/integrations/ignoreMpcrawlerErrors.js.map +0 -1
  294. package/esm/src/integrations/index.d.ts +0 -7
  295. package/esm/src/integrations/index.d.ts.map +0 -1
  296. package/esm/src/integrations/index.js +0 -7
  297. package/esm/src/integrations/index.js.map +0 -1
  298. package/esm/src/integrations/linkederrors.d.ts +0 -40
  299. package/esm/src/integrations/linkederrors.d.ts.map +0 -1
  300. package/esm/src/integrations/linkederrors.js +0 -63
  301. package/esm/src/integrations/linkederrors.js.map +0 -1
  302. package/esm/src/integrations/router.d.ts +0 -28
  303. package/esm/src/integrations/router.d.ts.map +0 -1
  304. package/esm/src/integrations/router.js +0 -45
  305. package/esm/src/integrations/router.js.map +0 -1
  306. package/esm/src/integrations/system.d.ts +0 -17
  307. package/esm/src/integrations/system.d.ts.map +0 -1
  308. package/esm/src/integrations/system.js +0 -63
  309. package/esm/src/integrations/system.js.map +0 -1
  310. package/esm/src/integrations/trycatch.d.ts +0 -26
  311. package/esm/src/integrations/trycatch.d.ts.map +0 -1
  312. package/esm/src/integrations/trycatch.js +0 -164
  313. package/esm/src/integrations/trycatch.js.map +0 -1
  314. package/esm/src/parsers.d.ts +0 -21
  315. package/esm/src/parsers.d.ts.map +0 -1
  316. package/esm/src/parsers.js +0 -91
  317. package/esm/src/parsers.js.map +0 -1
  318. package/esm/src/sdk.d.ts +0 -99
  319. package/esm/src/sdk.d.ts.map +0 -1
  320. package/esm/src/sdk.js +0 -147
  321. package/esm/src/sdk.js.map +0 -1
  322. package/esm/src/tracekit.d.ts +0 -38
  323. package/esm/src/tracekit.d.ts.map +0 -1
  324. package/esm/src/tracekit.js +0 -219
  325. package/esm/src/tracekit.js.map +0 -1
  326. package/esm/src/transports/base.d.ts +0 -22
  327. package/esm/src/transports/base.d.ts.map +0 -1
  328. package/esm/src/transports/base.js +0 -26
  329. package/esm/src/transports/base.js.map +0 -1
  330. package/esm/src/transports/index.d.ts +0 -3
  331. package/esm/src/transports/index.d.ts.map +0 -1
  332. package/esm/src/transports/index.js +0 -3
  333. package/esm/src/transports/index.js.map +0 -1
  334. package/esm/src/transports/xhr.d.ts +0 -10
  335. package/esm/src/transports/xhr.d.ts.map +0 -1
  336. package/esm/src/transports/xhr.js +0 -40
  337. package/esm/src/transports/xhr.js.map +0 -1
  338. package/esm/src/version.d.ts +0 -3
  339. package/esm/src/version.d.ts.map +0 -1
  340. package/esm/src/version.js +0 -4
  341. package/esm/src/version.js.map +0 -1
  342. package/esm/transports/base.d.ts +0 -22
  343. package/esm/transports/base.d.ts.map +0 -1
  344. package/esm/transports/base.js +0 -26
  345. package/esm/transports/base.js.map +0 -1
  346. package/esm/transports/xhr.d.ts +0 -10
  347. package/esm/transports/xhr.d.ts.map +0 -1
  348. package/esm/transports/xhr.js +0 -40
  349. package/esm/transports/xhr.js.map +0 -1
  350. package/esm/utils/debug-build.d.ts +0 -7
  351. package/esm/utils/debug-build.d.ts.map +0 -1
  352. package/esm/utils/debug-build.js +0 -7
  353. package/esm/utils/debug-build.js.map +0 -1
  354. package/esm/utils/logger.d.ts +0 -25
  355. package/esm/utils/logger.d.ts.map +0 -1
  356. package/esm/utils/logger.js +0 -42
  357. package/esm/utils/logger.js.map +0 -1
@@ -1,63 +1,64 @@
1
- import { __assign, __read } from "tslib";
2
- import { addGlobalEventProcessor, getCurrentHub } from "@sentry/core";
3
- import { appName as currentAppName, sdk } from "../crossPlatform";
4
- import { SDK_VERSION } from "../version";
5
- /** UserAgent */
6
- var System = /** @class */ (function () {
7
- function System() {
8
- /**
9
- * @inheritDoc
10
- */
11
- this.name = System.id;
12
- }
13
- /**
14
- * @inheritDoc
15
- */
16
- System.prototype.setupOnce = function () {
17
- addGlobalEventProcessor(function (event) {
18
- if (getCurrentHub().getIntegration(System)) {
19
- try {
20
- var systemInfo = sdk.getSystemInfoSync();
21
- var batteryLevel = systemInfo.batteryLevel, // 微信小程序
22
- currentBattery = systemInfo.currentBattery, // 支付宝小程序、 钉钉小程序
23
- battery = systemInfo.battery, // 字节跳动小程序
24
- 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, // 支付宝小程序
25
- appName = systemInfo.appName, // 字节跳动小程序
26
- fontSizeSetting = systemInfo.fontSizeSetting;
27
- // tslint:disable-next-line:variable-name
28
- var SDKVersion = SDK_VERSION;
29
- var _a = __read(system.split(" "), 2), systemName = _a[0], systemVersion = _a[1];
30
- return __assign(__assign({}, event), { contexts: __assign(__assign({}, event.contexts), { device: {
31
- brand: brand,
32
- battery_level: batteryLevel || currentBattery || battery,
33
- model: model,
34
- screen_dpi: pixelRatio
35
- }, os: {
36
- name: systemName || system,
37
- version: systemVersion || system
38
- }, extra: __assign({ SDKVersion: SDKVersion,
39
- language: language,
40
- platform: platform,
41
- screenHeight: screenHeight,
42
- screenWidth: screenWidth,
43
- statusBarHeight: statusBarHeight,
44
- version: version,
45
- windowHeight: windowHeight,
46
- windowWidth: windowWidth,
47
- fontSizeSetting: fontSizeSetting, app: app || appName || currentAppName }, systemInfo) }) });
48
- }
49
- catch (e) {
50
- console.warn("sentry-uniapp get system info fail: " + e);
51
- }
1
+ import { defineIntegration } from '@sentry/core';
2
+ import { appName as currentAppName, sdk } from '../crossPlatform';
3
+ const INTEGRATION_NAME = 'System';
4
+ const _systemIntegration = (() => {
5
+ return {
6
+ name: INTEGRATION_NAME,
7
+ setupOnce() {
8
+ // No setup needed
9
+ },
10
+ processEvent(event, _hint, _client) {
11
+ var _a, _b, _c;
12
+ try {
13
+ const systemInfo = sdk.getSystemInfoSync();
14
+ const { batteryLevel, currentBattery, battery, brand, language, model, pixelRatio, platform, screenHeight, screenWidth, statusBarHeight, system, version, windowHeight, windowWidth, app, appName, fontSizeSetting, } = systemInfo;
15
+ const [systemName, systemVersion] = (system || '').split(' ');
16
+ return {
17
+ ...event,
18
+ contexts: {
19
+ ...event.contexts,
20
+ device: {
21
+ ...(_a = event.contexts) === null || _a === void 0 ? void 0 : _a.device,
22
+ brand,
23
+ battery_level: batteryLevel || currentBattery || battery,
24
+ model,
25
+ screen_dpi: pixelRatio,
26
+ },
27
+ os: {
28
+ ...(_b = event.contexts) === null || _b === void 0 ? void 0 : _b.os,
29
+ name: systemName || system,
30
+ version: systemVersion || system,
31
+ },
32
+ app: {
33
+ ...(_c = event.contexts) === null || _c === void 0 ? void 0 : _c.app,
34
+ app_name: app || appName || currentAppName,
35
+ },
36
+ },
37
+ extra: {
38
+ ...event.extra,
39
+ systemInfo: {
40
+ language,
41
+ platform,
42
+ screenHeight,
43
+ screenWidth,
44
+ statusBarHeight,
45
+ version,
46
+ windowHeight,
47
+ windowWidth,
48
+ fontSizeSetting,
49
+ },
50
+ },
51
+ };
52
+ }
53
+ catch (e) {
54
+ // Silently fail if system info is not available
52
55
  }
53
56
  return event;
54
- });
57
+ },
55
58
  };
56
- /**
57
- * @inheritDoc
58
- */
59
- System.id = "System";
60
- return System;
61
- }());
62
- export { System };
59
+ });
60
+ /**
61
+ * System integration - collects system information from the miniapp environment
62
+ */
63
+ export const systemIntegration = defineIntegration(_systemIntegration);
63
64
  //# sourceMappingURL=system.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"system.js","sourceRoot":"","sources":["../../src/integrations/system.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGtE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,gBAAgB;AAChB;IAAA;QACE;;WAEG;QACI,SAAI,GAAW,MAAM,CAAC,EAAE,CAAC;IA+ElC,CAAC;IAxEC;;OAEG;IACI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a,IAAI,MAAM;6BACjC,EACD,KAAK,aACH,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,cAAc,IAClC,UAAU,QAGjB;iBACH;gBAAC,OAAO,CAAC,EAAE;oBACV,OAAO,CAAC,IAAI,CAAC,yCAAuC,CAAG,CAAC,CAAC;iBAC1D;aACF;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IA5ED;;OAEG;IACW,SAAE,GAAW,QAAQ,CAAC;IA0EtC,aAAC;CAAA,AAnFD,IAmFC;SAnFY,MAAM","sourcesContent":["import { addGlobalEventProcessor, getCurrentHub } from \"@sentry/core\";\nimport { Event, Integration } from \"@sentry/types\";\n\nimport { appName as currentAppName, sdk } from \"../crossPlatform\";\nimport { SDK_VERSION } from \"../version\";\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\n const {\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\n // tslint:disable-next-line:variable-name\n const SDKVersion = SDK_VERSION;\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"]}
1
+ {"version":3,"file":"system.js","sourceRoot":"","sources":["../../src/integrations/system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAa,MAAM,cAAc,CAAC;AAG5D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAElE,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAwBlC,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE;IAC/B,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,SAAS;YACP,kBAAkB;QACpB,CAAC;QACD,YAAY,CAAC,KAAY,EAAE,KAAc,EAAE,OAAe;;YACxD,IAAI,CAAC;gBACH,MAAM,UAAU,GAAe,GAAG,CAAC,iBAAiB,EAAE,CAAC;gBAEvD,MAAM,EACJ,YAAY,EACZ,cAAc,EACd,OAAO,EACP,KAAK,EACL,QAAQ,EACR,KAAK,EACL,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,eAAe,EACf,MAAM,EACN,OAAO,EACP,YAAY,EACZ,WAAW,EACX,GAAG,EACH,OAAO,EACP,eAAe,GAChB,GAAG,UAAU,CAAC;gBAEf,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAE9D,OAAO;oBACL,GAAG,KAAK;oBACR,QAAQ,EAAE;wBACR,GAAG,KAAK,CAAC,QAAQ;wBACjB,MAAM,EAAE;4BACN,GAAG,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM;4BACzB,KAAK;4BACL,aAAa,EAAE,YAAY,IAAI,cAAc,IAAI,OAAO;4BACxD,KAAK;4BACL,UAAU,EAAE,UAAU;yBACvB;wBACD,EAAE,EAAE;4BACF,GAAG,MAAA,KAAK,CAAC,QAAQ,0CAAE,EAAE;4BACrB,IAAI,EAAE,UAAU,IAAI,MAAM;4BAC1B,OAAO,EAAE,aAAa,IAAI,MAAM;yBACjC;wBACD,GAAG,EAAE;4BACH,GAAG,MAAA,KAAK,CAAC,QAAQ,0CAAE,GAAG;4BACtB,QAAQ,EAAE,GAAG,IAAI,OAAO,IAAI,cAAc;yBAC3C;qBACF;oBACD,KAAK,EAAE;wBACL,GAAG,KAAK,CAAC,KAAK;wBACd,UAAU,EAAE;4BACV,QAAQ;4BACR,QAAQ;4BACR,YAAY;4BACZ,WAAW;4BACX,eAAe;4BACf,OAAO;4BACP,YAAY;4BACZ,WAAW;4BACX,eAAe;yBAChB;qBACF;iBACF,CAAC;YACJ,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,gDAAgD;YAClD,CAAC;YAED,OAAO,KAAK,CAAC;QACf,CAAC;KACoB,CAAC;AAC1B,CAAC,CAAyB,CAAC;AAE3B;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,CAAC"}
package/esm/parsers.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Event, Exception, StackFrame } from '@sentry/types';
1
+ import type { Event, Exception, StackFrame } from '@sentry/core';
2
2
  import { StackFrame as TraceKitStackFrame, StackTrace as TraceKitStackTrace } from './tracekit';
3
3
  /**
4
4
  * This function creates an exception from an TraceKitStackTrace
@@ -9,7 +9,7 @@ export declare function exceptionFromStacktrace(stacktrace: TraceKitStackTrace):
9
9
  /**
10
10
  * @hidden
11
11
  */
12
- export declare function eventFromPlainObject(exception: {}, syntheticException?: Error, rejection?: boolean): Event;
12
+ export declare function eventFromPlainObject(exception: {}, syntheticException?: Error | null, rejection?: boolean): Event;
13
13
  /**
14
14
  * @hidden
15
15
  */
@@ -1 +1 @@
1
- {"version":3,"file":"parsers.d.ts","sourceRoot":"","sources":["../src/parsers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG7D,OAAO,EAAqB,UAAU,IAAI,kBAAkB,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAInH;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,kBAAkB,GAAG,SAAS,CAkBjF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,EAAE,EAAE,kBAAkB,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,KAAK,CAyB1G;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,kBAAkB,GAAG,KAAK,CAQzE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,kBAAkB,EAAE,GAAG,UAAU,EAAE,CAiC/E"}
1
+ {"version":3,"file":"parsers.d.ts","sourceRoot":"","sources":["../src/parsers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAGjE,OAAO,EAAqB,UAAU,IAAI,kBAAkB,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAInH;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,kBAAkB,GAAG,SAAS,CAkBjF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,EAAE,EACb,kBAAkB,CAAC,EAAE,KAAK,GAAG,IAAI,EACjC,SAAS,CAAC,EAAE,OAAO,GAClB,KAAK,CA0BP;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,kBAAkB,GAAG,KAAK,CAQzE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,kBAAkB,EAAE,GAAG,UAAU,EAAE,CAiC/E"}
package/esm/parsers.js CHANGED
@@ -1,19 +1,19 @@
1
- import { extractExceptionKeysForMessage, isEvent, normalizeToSize } from '@sentry/utils';
1
+ import { extractExceptionKeysForMessage, normalizeToSize } from '@sentry/core';
2
2
  import { computeStackTrace } from './tracekit';
3
- var STACKTRACE_LIMIT = 100;
3
+ const STACKTRACE_LIMIT = 100;
4
4
  /**
5
5
  * This function creates an exception from an TraceKitStackTrace
6
6
  * @param stacktrace TraceKitStackTrace that will be converted to an exception
7
7
  * @hidden
8
8
  */
9
9
  export function exceptionFromStacktrace(stacktrace) {
10
- var frames = prepareFramesForEvent(stacktrace.stack);
11
- var exception = {
10
+ const frames = prepareFramesForEvent(stacktrace.stack);
11
+ const exception = {
12
12
  type: stacktrace.name,
13
13
  value: stacktrace.message,
14
14
  };
15
15
  if (frames && frames.length) {
16
- exception.stacktrace = { frames: frames };
16
+ exception.stacktrace = { frames };
17
17
  }
18
18
  // tslint:disable-next-line:strict-type-predicates
19
19
  if (exception.type === undefined && exception.value === '') {
@@ -25,12 +25,13 @@ export function exceptionFromStacktrace(stacktrace) {
25
25
  * @hidden
26
26
  */
27
27
  export function eventFromPlainObject(exception, syntheticException, rejection) {
28
- var event = {
28
+ var _a, _b;
29
+ const event = {
29
30
  exception: {
30
31
  values: [
31
32
  {
32
- type: isEvent(exception) ? exception.constructor.name : rejection ? 'UnhandledRejection' : 'Error',
33
- value: "Non-Error " + (rejection ? 'promise rejection' : 'exception') + " captured with keys: " + extractExceptionKeysForMessage(exception),
33
+ type: (exception instanceof Error) ? exception.name : rejection ? 'UnhandledRejection' : 'Error',
34
+ value: `Non-Error ${rejection ? 'promise rejection' : 'exception'} captured with keys: ${extractExceptionKeysForMessage(exception)}`,
34
35
  },
35
36
  ],
36
37
  },
@@ -39,11 +40,11 @@ export function eventFromPlainObject(exception, syntheticException, rejection) {
39
40
  },
40
41
  };
41
42
  if (syntheticException) {
42
- var stacktrace = computeStackTrace(syntheticException);
43
- var frames_1 = prepareFramesForEvent(stacktrace.stack);
44
- event.stacktrace = {
45
- frames: frames_1,
46
- };
43
+ const stacktrace = computeStackTrace(syntheticException);
44
+ const frames = prepareFramesForEvent(stacktrace.stack);
45
+ if ((_b = (_a = event.exception) === null || _a === void 0 ? void 0 : _a.values) === null || _b === void 0 ? void 0 : _b[0]) {
46
+ event.exception.values[0].stacktrace = { frames: frames.reverse() };
47
+ }
47
48
  }
48
49
  return event;
49
50
  }
@@ -51,7 +52,7 @@ export function eventFromPlainObject(exception, syntheticException, rejection) {
51
52
  * @hidden
52
53
  */
53
54
  export function eventFromStacktrace(stacktrace) {
54
- var exception = exceptionFromStacktrace(stacktrace);
55
+ const exception = exceptionFromStacktrace(stacktrace);
55
56
  return {
56
57
  exception: {
57
58
  values: [exception],
@@ -65,9 +66,9 @@ export function prepareFramesForEvent(stack) {
65
66
  if (!stack || !stack.length) {
66
67
  return [];
67
68
  }
68
- var localStack = stack;
69
- var firstFrameFunction = localStack[0].func || '';
70
- var lastFrameFunction = localStack[localStack.length - 1].func || '';
69
+ let localStack = stack;
70
+ const firstFrameFunction = localStack[0].func || '';
71
+ const lastFrameFunction = localStack[localStack.length - 1].func || '';
71
72
  // If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call)
72
73
  if (firstFrameFunction.indexOf('captureMessage') !== -1 || firstFrameFunction.indexOf('captureException') !== -1) {
73
74
  localStack = localStack.slice(1);
@@ -78,13 +79,13 @@ export function prepareFramesForEvent(stack) {
78
79
  }
79
80
  // The frame where the crash happened, should be the last entry in the array
80
81
  return localStack
81
- .map(function (frame) { return ({
82
+ .map((frame) => ({
82
83
  colno: frame.column === null ? undefined : frame.column,
83
84
  filename: frame.url || localStack[0].url,
84
85
  function: frame.func || '?',
85
86
  in_app: true,
86
87
  lineno: frame.line === null ? undefined : frame.line,
87
- }); })
88
+ }))
88
89
  .slice(0, STACKTRACE_LIMIT)
89
90
  .reverse();
90
91
  }
@@ -1 +1 @@
1
- {"version":3,"file":"parsers.js","sourceRoot":"","sources":["../src/parsers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEzF,OAAO,EAAE,iBAAiB,EAAsE,MAAM,YAAY,CAAC;AAEnH,IAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,UAA8B;IACpE,IAAM,MAAM,GAAG,qBAAqB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAEvD,IAAM,SAAS,GAAc;QAC3B,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,KAAK,EAAE,UAAU,CAAC,OAAO;KAC1B,CAAC;IAEF,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE;QAC3B,SAAS,CAAC,UAAU,GAAG,EAAE,MAAM,QAAA,EAAE,CAAC;KACnC;IAED,kDAAkD;IAClD,IAAI,SAAS,CAAC,IAAI,KAAK,SAAS,IAAI,SAAS,CAAC,KAAK,KAAK,EAAE,EAAE;QAC1D,SAAS,CAAC,KAAK,GAAG,4BAA4B,CAAC;KAChD;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAAa,EAAE,kBAA0B,EAAE,SAAmB;IACjG,IAAM,KAAK,GAAU;QACnB,SAAS,EAAE;YACT,MAAM,EAAE;gBACN;oBACE,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,C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AK,CAAC,CAAC,CAAC,CAAC;KAClC;IAED,+HAA+H;IAC/H,IAAI,iBAAiB,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE;QACrD,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KACtC;IAED,4EAA4E;IAC5E,OAAO,UAAU;SACd,GAAG,CACF,UAAC,KAAyB,IAAiB,OAAA,CAAC;QAC1C,KAAK,EAAE,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM;QACvD,QAAQ,EAAE,KAAK,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG;QACxC,QAAQ,EAAE,KAAK,CAAC,IAAI,IAAI,GAAG;QAC3B,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI;KACrD,CAAC,EANyC,CAMzC,CACH;SACA,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC;SAC1B,OAAO,EAAE,CAAC;AACf,CAAC","sourcesContent":["import { Event, Exception, StackFrame } from '@sentry/types';\nimport { extractExceptionKeysForMessage, isEvent, normalizeToSize } from '@sentry/utils';\n\nimport { computeStackTrace, StackFrame as TraceKitStackFrame, StackTrace as TraceKitStackTrace } from './tracekit';\n\nconst STACKTRACE_LIMIT = 100;\n\n/**\n * This function creates an exception from an TraceKitStackTrace\n * @param stacktrace TraceKitStackTrace that will be converted to an exception\n * @hidden\n */\nexport function exceptionFromStacktrace(stacktrace: TraceKitStackTrace): Exception {\n const frames = prepareFramesForEvent(stacktrace.stack);\n\n const exception: Exception = {\n type: stacktrace.name,\n value: stacktrace.message,\n };\n\n if (frames && frames.length) {\n exception.stacktrace = { frames };\n }\n\n // tslint:disable-next-line:strict-type-predicates\n if (exception.type === undefined && exception.value === '') {\n exception.value = 'Unrecoverable error caught';\n }\n\n return exception;\n}\n\n/**\n * @hidden\n */\nexport function eventFromPlainObject(exception: {}, syntheticException?: Error, rejection?: boolean): Event {\n const event: Event = {\n exception: {\n values: [\n {\n type: isEvent(exception) ? exception.constructor.name : rejection ? 'UnhandledRejection' : 'Error',\n value: `Non-Error ${rejection ? 'promise rejection' : 'exception'\n } captured with keys: ${extractExceptionKeysForMessage(exception)}`,\n },\n ],\n },\n extra: {\n __serialized__: normalizeToSize(exception),\n },\n };\n\n if (syntheticException) {\n const stacktrace = computeStackTrace(syntheticException);\n const frames = prepareFramesForEvent(stacktrace.stack);\n event.stacktrace = {\n frames,\n };\n }\n\n return event;\n}\n\n/**\n * @hidden\n */\nexport function eventFromStacktrace(stacktrace: TraceKitStackTrace): Event {\n const exception = exceptionFromStacktrace(stacktrace);\n\n return {\n exception: {\n values: [exception],\n },\n };\n}\n\n/**\n * @hidden\n */\nexport function prepareFramesForEvent(stack: TraceKitStackFrame[]): StackFrame[] {\n if (!stack || !stack.length) {\n return [];\n }\n\n let localStack = stack;\n\n const firstFrameFunction = localStack[0].func || '';\n const lastFrameFunction = localStack[localStack.length - 1].func || '';\n\n // If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call)\n if (firstFrameFunction.indexOf('captureMessage') !== -1 || firstFrameFunction.indexOf('captureException') !== -1) {\n localStack = localStack.slice(1);\n }\n\n // If stack ends with one of our internal API calls, remove it (ends, meaning it's the bottom of the stack - aka top-most call)\n if (lastFrameFunction.indexOf('sentryWrapped') !== -1) {\n localStack = localStack.slice(0, -1);\n }\n\n // The frame where the crash happened, should be the last entry in the array\n return localStack\n .map(\n (frame: TraceKitStackFrame): StackFrame => ({\n colno: frame.column === null ? undefined : frame.column,\n filename: frame.url || localStack[0].url,\n function: frame.func || '?',\n in_app: true,\n lineno: frame.line === null ? undefined : frame.line,\n }),\n )\n .slice(0, STACKTRACE_LIMIT)\n .reverse();\n}\n"]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jH,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;IAED,+HAA+H;IAC/H,IAAI,iBAAiB,CAAC,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACtD,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC;IAED,4EAA4E;IAC5E,OAAO,UAAU;SACd,GAAG,CACF,CAAC,KAAyB,EAAc,EAAE,CAAC,CAAC;QAC1C,KAAK,EAAE,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM;QACvD,QAAQ,EAAE,KAAK,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG;QACxC,QAAQ,EAAE,KAAK,CAAC,IAAI,IAAI,GAAG;QAC3B,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI;KACrD,CAAC,CACH;SACA,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC;SAC1B,OAAO,EAAE,CAAC;AACf,CAAC"}
package/esm/sdk.d.ts CHANGED
@@ -1,99 +1,23 @@
1
- import { Integrations as CoreIntegrations } from "@sentry/core";
2
- import { MiniappOptions } from "./backend";
3
- import { ReportDialogOptions } from "./client";
4
- import { GlobalHandlers, IgnoreMpcrawlerErrors, LinkedErrors, Router, System, TryCatch } from "./integrations/index";
5
- export declare const defaultIntegrations: (CoreIntegrations.FunctionToString | CoreIntegrations.InboundFilters | GlobalHandlers | TryCatch | LinkedErrors | System | Router | IgnoreMpcrawlerErrors)[];
1
+ import { UniappOptions, ReportDialogOptions } from './client';
6
2
  /**
7
- * The Sentry Uniapp SDK Client.
8
- *
9
- * To use this SDK, call the {@link init} function as early as possible when
10
- * launching the app. To set context information or send manual events, use
11
- * the provided methods.
12
- *
13
- * @example
14
- * ```
15
- * import { init } from 'sentry-uniapp';
16
- *
17
- * init({
18
- * dsn: '__DSN__',
19
- * // ...
20
- * });
21
- * ```
22
- *
23
- * @example
24
- * ```
25
- * import { configureScope } from 'sentry-uniapp';
26
- *
27
- * configureScope((scope: Scope) => {
28
- * scope.setExtra({ battery: 0.7 });
29
- * scope.setTag({ user_mode: 'admin' });
30
- * scope.setUser({ id: '4711' });
31
- * });
32
- * ```
33
- *
34
- * @example
35
- * ```
36
- * import { addBreadcrumb } from 'sentry-uniapp';
37
- *
38
- * addBreadcrumb({
39
- * message: 'My Breadcrumb',
40
- * // ...
41
- * });
42
- * ```
43
- *
44
- * @example
45
- * ```
46
- * import * as Sentry from 'sentry-uniapp';
47
- *
48
- * Sentry.captureMessage('Hello, world!');
49
- * Sentry.captureException(new Error('Good bye'));
50
- * Sentry.captureEvent({
51
- * message: 'Manual',
52
- * stacktrace: [
53
- * // ...
54
- * ],
55
- * });
56
- * ```
57
- *
58
- * @see {@link MiniappOptions} for documentation on configuration options.
3
+ * Initialize the Sentry Uniapp SDK.
59
4
  */
60
- export declare function init(options?: MiniappOptions): void;
5
+ export declare function init(options?: Partial<UniappOptions>): void;
61
6
  /**
62
7
  * Present the user with a report dialog.
63
- * 向用户显示报告对话框。小程序上暂时不考虑实现该功能。
64
- *
65
- * @param options Everything is optional, we try to fetch all info need from the global scope.
8
+ * Not supported in miniapp environment - this is a no-op.
66
9
  */
67
10
  export declare function showReportDialog(options?: ReportDialogOptions): void;
68
11
  /**
69
- * This is the getter for lastEventId. 获取 lastEventId。
70
- *
71
- * @returns The last event id of a captured event.
12
+ * Get the last event ID captured.
72
13
  */
73
14
  export declare function lastEventId(): string | undefined;
74
15
  /**
75
- * A promise that resolves when all current events have been sent.
76
- * If you provide a timeout and the queue takes longer to drain the promise returns false.
77
- * 在发送所有当前事件时会变为 resolved 状态的 promise。如果提供了一个超时时间并且队列需要更长时间来消耗,则 promise 将返回 false。
78
- *
79
- * @param timeout Maximum time in ms the client should wait.
16
+ * Flush all pending events.
80
17
  */
81
- export declare function flush(timeout?: number): PromiseLike<boolean>;
18
+ export declare function flush(timeout?: number): Promise<boolean>;
82
19
  /**
83
- * A promise that resolves when all current events have been sent.
84
- * If you provide a timeout and the queue takes longer to drain the promise returns false.
85
- *
86
- * @param timeout Maximum time in ms the client should wait.
20
+ * Close the SDK and flush all pending events.
87
21
  */
88
- export declare function close(timeout?: number): PromiseLike<boolean>;
89
- /**
90
- * Wrap code within a try/catch block so the SDK is able to capture errors.
91
- * 在 try / catch 块中包装代码,以便 SDK 能够捕获错误。
92
- * 实际上是 ./helpers 文件中 warp 方法的进一步封装。
93
- *
94
- * @param fn A function to wrap.
95
- *
96
- * @returns The result of wrapped function call.
97
- */
98
- export declare function wrap(fn: Function): any;
22
+ export declare function close(timeout?: number): Promise<boolean>;
99
23
  //# sourceMappingURL=sdk.d.ts.map
package/esm/sdk.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,IAAI,gBAAgB,EACjC,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAiB,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE9D,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,MAAM,EACN,MAAM,EACN,QAAQ,EACT,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,mBAAmB,8JAU/B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,wBAAgB,IAAI,CAAC,OAAO,GAAE,cAAmB,GAAG,IAAI,CAavD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,mBAAwB,GAAG,IAAI,CAQxE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,MAAM,GAAG,SAAS,CAEhD;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAM5D;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,CAM5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,EAAE,EAAE,QAAQ,GAAG,GAAG,CAGtC"}
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAWA,OAAO,EAAgB,aAAa,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAuB5E;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,GAAE,OAAO,CAAC,aAAa,CAAM,GAAG,IAAI,CAkB/D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,mBAAwB,GAAG,IAAI,CAKxE;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,MAAM,GAAG,SAAS,CAGhD;AAED;;GAEG;AACH,wBAAsB,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAM9D;AAED;;GAEG;AACH,wBAAsB,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAM9D"}
package/esm/sdk.js CHANGED
@@ -1,147 +1,75 @@
1
- import { getCurrentHub, initAndBind, Integrations as CoreIntegrations, } from "@sentry/core";
2
- import { resolvedSyncPromise } from "@sentry/utils";
3
- import { MiniappClient } from "./client";
4
- import { wrap as internalWrap } from "./helpers";
5
- import { GlobalHandlers, IgnoreMpcrawlerErrors, LinkedErrors, Router, System, TryCatch, } from "./integrations/index";
6
- export var defaultIntegrations = [
7
- new CoreIntegrations.InboundFilters(),
8
- new CoreIntegrations.FunctionToString(),
9
- new TryCatch(),
10
- new GlobalHandlers(),
11
- new LinkedErrors(),
12
- new System(),
13
- new Router(),
14
- new IgnoreMpcrawlerErrors(),
15
- ];
1
+ import { inboundFiltersIntegration, functionToStringIntegration, linkedErrorsIntegration, dedupeIntegration, getClient, getCurrentScope, } from '@sentry/core';
2
+ import { createStackParser, nodeStackLineParser } from '@sentry/core';
3
+ import { UniappClient } from './client';
4
+ import { makeUniappTransport } from './transport';
5
+ import { globalHandlersIntegration, systemIntegration, routerIntegration, } from './integrations';
6
+ /** Get the default integrations for the Uniapp SDK. */
7
+ function getDefaultIntegrations(options) {
8
+ const integrations = [
9
+ inboundFiltersIntegration(),
10
+ functionToStringIntegration(),
11
+ linkedErrorsIntegration(),
12
+ dedupeIntegration(),
13
+ globalHandlersIntegration(options.extraOptions),
14
+ systemIntegration(),
15
+ routerIntegration(),
16
+ ];
17
+ return integrations;
18
+ }
16
19
  /**
17
- * The Sentry Uniapp SDK Client.
18
- *
19
- * To use this SDK, call the {@link init} function as early as possible when
20
- * launching the app. To set context information or send manual events, use
21
- * the provided methods.
22
- *
23
- * @example
24
- * ```
25
- * import { init } from 'sentry-uniapp';
26
- *
27
- * init({
28
- * dsn: '__DSN__',
29
- * // ...
30
- * });
31
- * ```
32
- *
33
- * @example
34
- * ```
35
- * import { configureScope } from 'sentry-uniapp';
36
- *
37
- * configureScope((scope: Scope) => {
38
- * scope.setExtra({ battery: 0.7 });
39
- * scope.setTag({ user_mode: 'admin' });
40
- * scope.setUser({ id: '4711' });
41
- * });
42
- * ```
43
- *
44
- * @example
45
- * ```
46
- * import { addBreadcrumb } from 'sentry-uniapp';
47
- *
48
- * addBreadcrumb({
49
- * message: 'My Breadcrumb',
50
- * // ...
51
- * });
52
- * ```
53
- *
54
- * @example
55
- * ```
56
- * import * as Sentry from 'sentry-uniapp';
57
- *
58
- * Sentry.captureMessage('Hello, world!');
59
- * Sentry.captureException(new Error('Good bye'));
60
- * Sentry.captureEvent({
61
- * message: 'Manual',
62
- * stacktrace: [
63
- * // ...
64
- * ],
65
- * });
66
- * ```
67
- *
68
- * @see {@link MiniappOptions} for documentation on configuration options.
20
+ * Initialize the Sentry Uniapp SDK.
69
21
  */
70
- export function init(options) {
71
- if (options === void 0) { options = {}; }
72
- // 如果将 options.defaultIntegrations 设置为 false,则不会添加默认集成,否则将在内部将其设置为建议的默认集成。
73
- // tslint:disable-next-line: strict-comparisons
74
- if (options.defaultIntegrations === undefined) {
75
- options.defaultIntegrations = defaultIntegrations;
76
- }
77
- options.normalizeDepth = options.normalizeDepth || 5;
78
- if (options.defaultIntegrations) {
79
- options.defaultIntegrations[3].setExtraOptions(options.extraOptions);
22
+ export function init(options = {}) {
23
+ const finalOptions = {
24
+ stackParser: createStackParser(nodeStackLineParser()),
25
+ transport: makeUniappTransport,
26
+ integrations: [],
27
+ ...options,
28
+ };
29
+ // Set default integrations if not provided
30
+ if (!options.integrations) {
31
+ finalOptions.integrations = getDefaultIntegrations(finalOptions);
80
32
  }
81
- initAndBind(MiniappClient, options);
33
+ const client = new UniappClient(finalOptions);
34
+ const scope = getCurrentScope();
35
+ scope.setClient(client);
36
+ client.init();
82
37
  }
83
38
  /**
84
39
  * Present the user with a report dialog.
85
- * 向用户显示报告对话框。小程序上暂时不考虑实现该功能。
86
- *
87
- * @param options Everything is optional, we try to fetch all info need from the global scope.
40
+ * Not supported in miniapp environment - this is a no-op.
88
41
  */
89
- export function showReportDialog(options) {
90
- if (options === void 0) { options = {}; }
91
- if (!options.eventId) {
92
- options.eventId = getCurrentHub().lastEventId();
93
- }
94
- var client = getCurrentHub().getClient();
95
- if (client) {
96
- client.showReportDialog(options);
42
+ export function showReportDialog(options = {}) {
43
+ // Not supported in miniapp environment
44
+ if (typeof console !== 'undefined' && console.warn) {
45
+ console.warn('sentry-uniapp: showReportDialog is not supported in miniapp environment');
97
46
  }
98
47
  }
99
48
  /**
100
- * This is the getter for lastEventId. 获取 lastEventId。
101
- *
102
- * @returns The last event id of a captured event.
49
+ * Get the last event ID captured.
103
50
  */
104
51
  export function lastEventId() {
105
- return getCurrentHub().lastEventId();
52
+ const scope = getCurrentScope();
53
+ return scope.lastEventId();
106
54
  }
107
55
  /**
108
- * A promise that resolves when all current events have been sent.
109
- * If you provide a timeout and the queue takes longer to drain the promise returns false.
110
- * 在发送所有当前事件时会变为 resolved 状态的 promise。如果提供了一个超时时间并且队列需要更长时间来消耗,则 promise 将返回 false。
111
- *
112
- * @param timeout Maximum time in ms the client should wait.
56
+ * Flush all pending events.
113
57
  */
114
- export function flush(timeout) {
115
- var client = getCurrentHub().getClient();
58
+ export async function flush(timeout) {
59
+ const client = getClient();
116
60
  if (client) {
117
61
  return client.flush(timeout);
118
62
  }
119
- return resolvedSyncPromise(false);
63
+ return Promise.resolve(false);
120
64
  }
121
65
  /**
122
- * A promise that resolves when all current events have been sent.
123
- * If you provide a timeout and the queue takes longer to drain the promise returns false.
124
- *
125
- * @param timeout Maximum time in ms the client should wait.
66
+ * Close the SDK and flush all pending events.
126
67
  */
127
- export function close(timeout) {
128
- var client = getCurrentHub().getClient();
68
+ export async function close(timeout) {
69
+ const client = getClient();
129
70
  if (client) {
130
71
  return client.close(timeout);
131
72
  }
132
- return resolvedSyncPromise(false);
133
- }
134
- /**
135
- * Wrap code within a try/catch block so the SDK is able to capture errors.
136
- * 在 try / catch 块中包装代码,以便 SDK 能够捕获错误。
137
- * 实际上是 ./helpers 文件中 warp 方法的进一步封装。
138
- *
139
- * @param fn A function to wrap.
140
- *
141
- * @returns The result of wrapped function call.
142
- */
143
- export function wrap(fn) {
144
- // tslint:disable-next-line: no-unsafe-any
145
- return internalWrap(fn)();
73
+ return Promise.resolve(false);
146
74
  }
147
75
  //# sourceMappingURL=sdk.js.map
package/esm/sdk.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,WAAW,EACX,Y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C,OAAO,CAAC,OAAO,EAAE;QACpB,OAAO,CAAC,OAAO,GAAG,aAAa,EAAE,CAAC,WAAW,EAAE,CAAC;KACjD;IACD,IAAM,MAAM,GAAG,aAAa,EAAE,CAAC,SAAS,EAAiB,CAAC;IAC1D,IAAI,MAAM,EAAE;QACV,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;KAClC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,aAAa,EAAE,CAAC,WAAW,EAAE,CAAC;AACvC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAC,OAAgB;IACpC,IAAM,MAAM,GAAG,aAAa,EAAE,CAAC,SAAS,EAAiB,CAAC;IAC1D,IAAI,MAAM,EAAE;QACV,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC9B;IACD,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,OAAgB;IACpC,IAAM,MAAM,GAAG,aAAa,EAAE,CAAC,SAAS,EAAiB,CAAC;IAC1D,IAAI,MAAM,EAAE;QACV,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC9B;IACD,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,IAAI,CAAC,EAAY;IAC/B,0CAA0C;IAC1C,OAAO,YAAY,CAAC,EAAE,CAAC,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["import {\n getCurrentHub,\n initAndBind,\n Integrations as CoreIntegrations,\n} from \"@sentry/core\";\nimport { resolvedSyncPromise } from \"@sentry/utils\";\n\nimport { MiniappOptions } from \"./backend\";\nimport { MiniappClient, ReportDialogOptions } from \"./client\";\nimport { wrap as internalWrap } from \"./helpers\";\nimport {\n GlobalHandlers,\n IgnoreMpcrawlerErrors,\n LinkedErrors,\n Router,\n System,\n TryCatch,\n} from \"./integrations/index\";\n\nexport const defaultIntegrations = [\n new CoreIntegrations.InboundFilters(),\n new CoreIntegrations.FunctionToString(),\n new TryCatch(),\n new GlobalHandlers(),\n new LinkedErrors(),\n\n new System(),\n new Router(),\n new IgnoreMpcrawlerErrors(),\n];\n\n/**\n * The Sentry Uniapp SDK Client.\n *\n * To use this SDK, call the {@link init} function as early as possible when\n * launching the app. To set context information or send manual events, use\n * the provided methods.\n *\n * @example\n * ```\n * import { init } from 'sentry-uniapp';\n *\n * init({\n * dsn: '__DSN__',\n * // ...\n * });\n * ```\n *\n * @example\n * ```\n * import { configureScope } from 'sentry-uniapp';\n *\n * configureScope((scope: Scope) => {\n * scope.setExtra({ battery: 0.7 });\n * scope.setTag({ user_mode: 'admin' });\n * scope.setUser({ id: '4711' });\n * });\n * ```\n *\n * @example\n * ```\n * import { addBreadcrumb } from 'sentry-uniapp';\n *\n * addBreadcrumb({\n * message: 'My Breadcrumb',\n * // ...\n * });\n * ```\n *\n * @example\n * ```\n * import * as Sentry from 'sentry-uniapp';\n *\n * Sentry.captureMessage('Hello, world!');\n * Sentry.captureException(new Error('Good bye'));\n * Sentry.captureEvent({\n * message: 'Manual',\n * stacktrace: [\n * // ...\n * ],\n * });\n * ```\n *\n * @see {@link MiniappOptions} for documentation on configuration options.\n */\nexport function init(options: MiniappOptions = {}): void {\n // 如果将 options.defaultIntegrations 设置为 false,则不会添加默认集成,否则将在内部将其设置为建议的默认集成。\n // tslint:disable-next-line: strict-comparisons\n if (options.defaultIntegrations === undefined) {\n options.defaultIntegrations = defaultIntegrations;\n }\n\n options.normalizeDepth = options.normalizeDepth || 5;\n if (options.defaultIntegrations) {\n (options.defaultIntegrations[3] as GlobalHandlers).setExtraOptions(options.extraOptions);\n }\n\n initAndBind(MiniappClient, options);\n}\n\n/**\n * Present the user with a report dialog.\n * 向用户显示报告对话框。小程序上暂时不考虑实现该功能。\n *\n * @param options Everything is optional, we try to fetch all info need from the global scope.\n */\nexport function showReportDialog(options: ReportDialogOptions = {}): void {\n if (!options.eventId) {\n options.eventId = getCurrentHub().lastEventId();\n }\n const client = getCurrentHub().getClient<MiniappClient>();\n if (client) {\n client.showReportDialog(options);\n }\n}\n\n/**\n * This is the getter for lastEventId. 获取 lastEventId。\n *\n * @returns The last event id of a captured event.\n */\nexport function lastEventId(): string | undefined {\n return getCurrentHub().lastEventId();\n}\n\n/**\n * A promise that resolves when all current events have been sent.\n * If you provide a timeout and the queue takes longer to drain the promise returns false.\n * 在发送所有当前事件时会变为 resolved 状态的 promise。如果提供了一个超时时间并且队列需要更长时间来消耗,则 promise 将返回 false。\n *\n * @param timeout Maximum time in ms the client should wait.\n */\nexport function flush(timeout?: number): PromiseLike<boolean> {\n const client = getCurrentHub().getClient<MiniappClient>();\n if (client) {\n return client.flush(timeout);\n }\n return resolvedSyncPromise(false);\n}\n\n/**\n * A promise that resolves when all current events have been sent.\n * If you provide a timeout and the queue takes longer to drain the promise returns false.\n *\n * @param timeout Maximum time in ms the client should wait.\n */\nexport function close(timeout?: number): PromiseLike<boolean> {\n const client = getCurrentHub().getClient<MiniappClient>();\n if (client) {\n return client.close(timeout);\n }\n return resolvedSyncPromise(false);\n}\n\n/**\n * Wrap code within a try/catch block so the SDK is able to capture errors.\n * 在 try / catch 块中包装代码,以便 SDK 能够捕获错误。\n * 实际上是 ./helpers 文件中 warp 方法的进一步封装。\n *\n * @param fn A function to wrap.\n *\n * @returns The result of wrapped function call.\n */\nexport function wrap(fn: Function): any {\n // tslint:disable-next-line: no-unsafe-any\n return internalWrap(fn)();\n}\n"]}
1
+ {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,uBAAuB,EACvB,iBAAiB,EACjB,SAAS,EACT,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,cA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