@antglobal/rlog-sdk 0.0.1755855517-dev.7 → 0.0.1755855517-dev.8

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 (98) hide show
  1. package/dist/esm/index.d.ts +65 -0
  2. package/dist/esm/index.d.ts.map +1 -0
  3. package/dist/esm/index.js +132 -0
  4. package/dist/esm/lib/api.d.ts +9 -0
  5. package/dist/esm/lib/api.d.ts.map +1 -0
  6. package/dist/esm/lib/api.js +85 -0
  7. package/dist/esm/lib/config.d.ts +75 -0
  8. package/dist/esm/lib/config.d.ts.map +1 -0
  9. package/dist/esm/lib/config.js +202 -0
  10. package/dist/esm/lib/drive/indexeddb-adapt.d.ts +16 -0
  11. package/dist/esm/lib/drive/indexeddb-adapt.d.ts.map +1 -0
  12. package/dist/esm/lib/drive/indexeddb-adapt.js +483 -0
  13. package/dist/esm/lib/drive/localstorage-adapt.d.ts +33 -0
  14. package/dist/esm/lib/drive/localstorage-adapt.d.ts.map +1 -0
  15. package/dist/esm/lib/drive/localstorage-adapt.js +420 -0
  16. package/dist/esm/lib/drive/memory-adapt.d.ts +25 -0
  17. package/dist/esm/lib/drive/memory-adapt.d.ts.map +1 -0
  18. package/dist/esm/lib/drive/memory-adapt.js +278 -0
  19. package/dist/esm/lib/drive/storage-interface.d.ts +8 -0
  20. package/dist/esm/lib/drive/storage-interface.d.ts.map +1 -0
  21. package/dist/esm/lib/drive/storage-interface.js +1 -0
  22. package/dist/esm/lib/error.d.ts +4 -0
  23. package/dist/esm/lib/error.d.ts.map +1 -0
  24. package/dist/esm/lib/error.js +185 -0
  25. package/dist/esm/lib/init.d.ts +24 -0
  26. package/dist/esm/lib/init.d.ts.map +1 -0
  27. package/dist/esm/lib/init.js +116 -0
  28. package/dist/esm/lib/net.d.ts +32 -0
  29. package/dist/esm/lib/net.d.ts.map +1 -0
  30. package/dist/esm/lib/net.js +401 -0
  31. package/dist/esm/lib/request.d.ts +37 -0
  32. package/dist/esm/lib/request.d.ts.map +1 -0
  33. package/dist/esm/lib/request.js +165 -0
  34. package/dist/esm/lib/router-monitor.d.ts +39 -0
  35. package/dist/esm/lib/router-monitor.d.ts.map +1 -0
  36. package/dist/esm/lib/router-monitor.js +278 -0
  37. package/dist/esm/lib/rrweb.d.ts +3 -0
  38. package/dist/esm/lib/rrweb.d.ts.map +1 -0
  39. package/dist/esm/lib/rrweb.js +99 -0
  40. package/dist/esm/lib/storage-manager.d.ts +33 -0
  41. package/dist/esm/lib/storage-manager.d.ts.map +1 -0
  42. package/dist/esm/lib/storage-manager.js +280 -0
  43. package/dist/esm/lib/uploader.d.ts +19 -0
  44. package/dist/esm/lib/uploader.d.ts.map +1 -0
  45. package/dist/esm/lib/uploader.js +212 -0
  46. package/dist/esm/lib/utils.d.ts +3 -0
  47. package/dist/esm/lib/utils.d.ts.map +1 -0
  48. package/dist/esm/lib/utils.js +16 -0
  49. package/dist/lib/index.d.ts +65 -0
  50. package/dist/lib/index.d.ts.map +1 -0
  51. package/dist/lib/index.js +207 -0
  52. package/dist/lib/lib/api.d.ts +9 -0
  53. package/dist/lib/lib/api.d.ts.map +1 -0
  54. package/dist/lib/lib/api.js +91 -0
  55. package/dist/lib/lib/config.d.ts +75 -0
  56. package/dist/lib/lib/config.d.ts.map +1 -0
  57. package/dist/lib/lib/config.js +209 -0
  58. package/dist/lib/lib/drive/indexeddb-adapt.d.ts +16 -0
  59. package/dist/lib/lib/drive/indexeddb-adapt.d.ts.map +1 -0
  60. package/dist/lib/lib/drive/indexeddb-adapt.js +488 -0
  61. package/dist/lib/lib/drive/localstorage-adapt.d.ts +33 -0
  62. package/dist/lib/lib/drive/localstorage-adapt.d.ts.map +1 -0
  63. package/dist/lib/lib/drive/localstorage-adapt.js +426 -0
  64. package/dist/lib/lib/drive/memory-adapt.d.ts +25 -0
  65. package/dist/lib/lib/drive/memory-adapt.d.ts.map +1 -0
  66. package/dist/lib/lib/drive/memory-adapt.js +284 -0
  67. package/dist/lib/lib/drive/storage-interface.d.ts +8 -0
  68. package/dist/lib/lib/drive/storage-interface.d.ts.map +1 -0
  69. package/dist/lib/lib/drive/storage-interface.js +5 -0
  70. package/dist/lib/lib/error.d.ts +4 -0
  71. package/dist/lib/lib/error.d.ts.map +1 -0
  72. package/dist/lib/lib/error.js +192 -0
  73. package/dist/lib/lib/init.d.ts +24 -0
  74. package/dist/lib/lib/init.d.ts.map +1 -0
  75. package/dist/lib/lib/init.js +124 -0
  76. package/dist/lib/lib/net.d.ts +32 -0
  77. package/dist/lib/lib/net.d.ts.map +1 -0
  78. package/dist/lib/lib/net.js +416 -0
  79. package/dist/lib/lib/request.d.ts +37 -0
  80. package/dist/lib/lib/request.d.ts.map +1 -0
  81. package/dist/lib/lib/request.js +170 -0
  82. package/dist/lib/lib/router-monitor.d.ts +39 -0
  83. package/dist/lib/lib/router-monitor.d.ts.map +1 -0
  84. package/dist/lib/lib/router-monitor.js +285 -0
  85. package/dist/lib/lib/rrweb.d.ts +3 -0
  86. package/dist/lib/lib/rrweb.d.ts.map +1 -0
  87. package/dist/lib/lib/rrweb.js +107 -0
  88. package/dist/lib/lib/storage-manager.d.ts +33 -0
  89. package/dist/lib/lib/storage-manager.d.ts.map +1 -0
  90. package/dist/lib/lib/storage-manager.js +285 -0
  91. package/dist/lib/lib/uploader.d.ts +19 -0
  92. package/dist/lib/lib/uploader.d.ts.map +1 -0
  93. package/dist/lib/lib/uploader.js +220 -0
  94. package/dist/lib/lib/utils.d.ts +3 -0
  95. package/dist/lib/lib/utils.d.ts.map +1 -0
  96. package/dist/lib/lib/utils.js +22 -0
  97. package/dist/rlog-sdk.min.js +1 -1
  98. package/package.json +9 -1
@@ -0,0 +1,65 @@
1
+ import { setCustomHeaders, setWhiteListUrls, setBlackListUrls, getBlackListUrls, getSdkLogEndpoint, getWhiteListUrls, shouldRecordUrl } from './lib/net';
2
+ import { forceResetUploadState } from './lib/uploader';
3
+ import { updateRouterConfig, getCurrentRouteInfo, manualRouteChange, stopRouterMonitor } from './lib/router-monitor';
4
+ import { cleanupErrorHandler } from './lib/error';
5
+ type Params = {
6
+ serv: string;
7
+ appId: string;
8
+ cdnConfigUrl?: string;
9
+ };
10
+ export declare function init(param: Params): {
11
+ cancel: (options?: {
12
+ clearData?: boolean;
13
+ }) => void;
14
+ };
15
+ export declare function cancelRecord(options?: {
16
+ clearData?: boolean;
17
+ }): void;
18
+ export declare function addCustomEvent(tagName: string, payload: any): void;
19
+ /**
20
+ * 设置只采集不上报模式
21
+ * @param enable 是否启用只采集不上报模式
22
+ */
23
+ export declare function setConsumeOnlyMode(enable: boolean): void;
24
+ /**
25
+ * 获取当前是否处于只采集不上报模式
26
+ * @returns 是否启用只采集不上报模式
27
+ */
28
+ export declare function isConsumeOnlyMode(): boolean;
29
+ /**
30
+ * 切换只采集不上报模式
31
+ */
32
+ export declare function toggleConsumeOnlyMode(): boolean;
33
+ export { updateRouterConfig, getCurrentRouteInfo, manualRouteChange, stopRouterMonitor, };
34
+ export { setCustomHeaders, setWhiteListUrls, setBlackListUrls, getBlackListUrls, getWhiteListUrls, getSdkLogEndpoint, };
35
+ export { cleanupErrorHandler };
36
+ export declare const debug: {
37
+ /**
38
+ * 获取存储适配器类型
39
+ */
40
+ getStorageAdapterType(): string;
41
+ /**
42
+ * 获取设备ID
43
+ */
44
+ getDeviceId: () => string;
45
+ /**
46
+ * 重置上传状态
47
+ */
48
+ resetUploadState: typeof forceResetUploadState;
49
+ /**
50
+ * 获取存储状态
51
+ */
52
+ getStorageState(): Promise<{
53
+ adapterType: string;
54
+ eventCount: number;
55
+ }>;
56
+ /**
57
+ * 清空存储数据
58
+ */
59
+ clearStorage(): Promise<void>;
60
+ /**
61
+ * 检查URL是否应该被记录(白名单且不在黑名单中)
62
+ */
63
+ shouldRecordUrl: typeof shouldRecordUrl;
64
+ };
65
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EAChB,MAAM,WAAW,CAAC;AAInB,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,KAAK,MAAM,GAAG;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IAEd,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM;uBAKZ;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;EAI5C;AAGD,wBAAgB,YAAY,CAAC,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,QAMjE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,QAE3D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAGxD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAK3C;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,CAI/C;AAGD,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,GAClB,CAAC;AAGF,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,GAClB,CAAC;AAGF,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAG/B,eAAO,MAAM,KAAK;IAChB;;OAEG;6BACsB,MAAM;IAO/B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;IAMH;;OAEG;;IAKH;;OAEG;;CAEJ,CAAC"}
@@ -0,0 +1,132 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ import { initRLog, cancelRlog } from "./lib/init";
6
+ import { setCustomHeaders, setWhiteListUrls, setBlackListUrls, getBlackListUrls, getSdkLogEndpoint, getWhiteListUrls, shouldRecordUrl } from "./lib/net";
7
+ import { record } from 'rrweb';
8
+ import { storage } from "./lib/storage-manager";
9
+ import { getDeviceId } from "./lib/utils";
10
+ import { forceResetUploadState } from "./lib/uploader";
11
+ import { updateRouterConfig, getCurrentRouteInfo, manualRouteChange, stopRouterMonitor } from "./lib/router-monitor";
12
+ import { updateConfig, getConfig } from "./lib/config";
13
+ import { cleanupErrorHandler } from "./lib/error";
14
+ export function init(param) {
15
+ // 初始化 RLog SDK
16
+ initRLog(param.serv, param.appId, param.cdnConfigUrl);
17
+ return {
18
+ cancel: function cancel() {
19
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
20
+ cancelRlog(options, 'SDK instance');
21
+ }
22
+ };
23
+ }
24
+
25
+ // 单独导出 cancelRecord 方法
26
+ export function cancelRecord() {
27
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
28
+ console.warn('Please use rlog.cancel() from initialized instance instead of standalone cancelRecord()');
29
+ cancelRlog(options, 'standalone function');
30
+ }
31
+ export function addCustomEvent(tagName, payload) {
32
+ record.addCustomEvent(tagName, payload);
33
+ }
34
+
35
+ /**
36
+ * 设置只采集不上报模式
37
+ * @param enable 是否启用只采集不上报模式
38
+ */
39
+ export function setConsumeOnlyMode(enable) {
40
+ updateConfig({
41
+ consumeOnly: enable
42
+ });
43
+ console.log("RLog consume only mode ".concat(enable ? 'enabled' : 'disabled'));
44
+ }
45
+
46
+ /**
47
+ * 获取当前是否处于只采集不上报模式
48
+ * @returns 是否启用只采集不上报模式
49
+ */
50
+ export function isConsumeOnlyMode() {
51
+ return sessionStorage.getItem('RLOG_CONSUME_ONLY') === 'true' || !!getConfig().consumeOnly;
52
+ }
53
+
54
+ /**
55
+ * 切换只采集不上报模式
56
+ */
57
+ export function toggleConsumeOnlyMode() {
58
+ var newMode = !getConfig().consumeOnly;
59
+ setConsumeOnlyMode(newMode);
60
+ return newMode;
61
+ }
62
+
63
+ // 路由监控相关API
64
+ export { updateRouterConfig, getCurrentRouteInfo, manualRouteChange, stopRouterMonitor };
65
+
66
+ // 网络监控相关函数
67
+ export { setCustomHeaders, setWhiteListUrls, setBlackListUrls, getBlackListUrls, getWhiteListUrls, getSdkLogEndpoint };
68
+
69
+ // 错误处理相关函数
70
+ export { cleanupErrorHandler };
71
+
72
+ // 调试和测试相关API
73
+ export var debug = {
74
+ /**
75
+ * 获取存储适配器类型
76
+ */
77
+ getStorageAdapterType: function getStorageAdapterType() {
78
+ return storage.getAdapterType();
79
+ },
80
+ // get storage() {
81
+ // return storage;
82
+ // },
83
+
84
+ /**
85
+ * 获取设备ID
86
+ */
87
+ getDeviceId: getDeviceId,
88
+ /**
89
+ * 重置上传状态
90
+ */
91
+ resetUploadState: forceResetUploadState,
92
+ /**
93
+ * 获取存储状态
94
+ */
95
+ getStorageState: function getStorageState() {
96
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
97
+ var deviceId;
98
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
99
+ while (1) switch (_context.prev = _context.next) {
100
+ case 0:
101
+ deviceId = getDeviceId();
102
+ return _context.abrupt("return", storage.getStorageState(deviceId));
103
+ case 2:
104
+ case "end":
105
+ return _context.stop();
106
+ }
107
+ }, _callee);
108
+ }))();
109
+ },
110
+ /**
111
+ * 清空存储数据
112
+ */
113
+ clearStorage: function clearStorage() {
114
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
115
+ var deviceId;
116
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
117
+ while (1) switch (_context2.prev = _context2.next) {
118
+ case 0:
119
+ deviceId = getDeviceId();
120
+ return _context2.abrupt("return", storage.clear(deviceId));
121
+ case 2:
122
+ case "end":
123
+ return _context2.stop();
124
+ }
125
+ }, _callee2);
126
+ }))();
127
+ },
128
+ /**
129
+ * 检查URL是否应该被记录(白名单且不在黑名单中)
130
+ */
131
+ shouldRecordUrl: shouldRecordUrl
132
+ };
@@ -0,0 +1,9 @@
1
+ type UploadOptions = {
2
+ url: string;
3
+ data: any[];
4
+ deviceId: string;
5
+ appId: string;
6
+ };
7
+ export declare const upload: (opt: UploadOptions) => Promise<void>;
8
+ export {};
9
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/lib/api.ts"],"names":[],"mappings":"AAIA,KAAK,aAAa,GAAG;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAqBF,eAAO,MAAM,MAAM,QAAe,aAAa,kBAoD9C,CAAC"}
@@ -0,0 +1,85 @@
1
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
2
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ import { generateUUIDCompat } from "./utils";
6
+ import { post } from "./request";
7
+ import { getConfig } from "./config";
8
+ // 从URL中提取指定参数并存储到sessionStorage中
9
+ var cacheUrlParams = function cacheUrlParams() {
10
+ var config = getConfig();
11
+ var paramsToCache = config.urlParamsToCache || ['taskId']; // 默认缓存taskId
12
+ var urlParams = new URLSearchParams(window.location.search);
13
+ paramsToCache.forEach(function (paramName) {
14
+ var paramValue = urlParams.get(paramName);
15
+ if (paramValue) {
16
+ sessionStorage.setItem("rlog-".concat(paramName), paramValue);
17
+ }
18
+ });
19
+ };
20
+
21
+ // 获取缓存的参数值
22
+ var getCachedParam = function getCachedParam(paramName) {
23
+ return sessionStorage.getItem("rlog-".concat(paramName));
24
+ };
25
+ export var upload = /*#__PURE__*/function () {
26
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(opt) {
27
+ var _opt$data, _opt$data2;
28
+ var lastIndex, queryParams, config, paramsToReport, queryString, api, formData, response, responseData, error;
29
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
30
+ while (1) switch (_context.prev = _context.next) {
31
+ case 0:
32
+ // 缓存URL中的参数
33
+ cacheUrlParams();
34
+
35
+ // 构建查询字符串
36
+ lastIndex = opt.data && opt.data.length > 0 ? opt.data.length - 1 : -1;
37
+ queryParams = {
38
+ deviceId: opt.deviceId,
39
+ appId: opt.appId,
40
+ startTime: (_opt$data = opt.data) === null || _opt$data === void 0 || (_opt$data = _opt$data[0]) === null || _opt$data === void 0 ? void 0 : _opt$data.timestamp,
41
+ endTime: (_opt$data2 = opt.data) === null || _opt$data2 === void 0 || (_opt$data2 = _opt$data2[lastIndex]) === null || _opt$data2 === void 0 ? void 0 : _opt$data2.timestamp
42
+ }; // 从配置中获取需要上报的参数名称列表
43
+ config = getConfig();
44
+ paramsToReport = config.urlParamsToCache || ['taskId']; // 默认上报taskId
45
+ // 添加缓存的参数到查询字符串中
46
+ paramsToReport.forEach(function (paramName) {
47
+ var paramValue = getCachedParam(paramName);
48
+ if (paramValue) {
49
+ queryParams[paramName] = paramValue;
50
+ }
51
+ });
52
+ queryString = new URLSearchParams(queryParams);
53
+ api = "".concat(opt.url).concat(queryString ? "?".concat(queryString) : '');
54
+ formData = new FormData();
55
+ formData.append('file', new Blob([JSON.stringify(opt.data)]), generateUUIDCompat() + '.json');
56
+ _context.next = 12;
57
+ return post(api, formData);
58
+ case 12:
59
+ response = _context.sent;
60
+ _context.prev = 13;
61
+ responseData = typeof response.data === 'string' ? JSON.parse(response.data) : response.data;
62
+ _context.next = 20;
63
+ break;
64
+ case 17:
65
+ _context.prev = 17;
66
+ _context.t0 = _context["catch"](13);
67
+ return _context.abrupt("return");
68
+ case 20:
69
+ if (!(responseData && _typeof(responseData) === 'object' && responseData.success === false)) {
70
+ _context.next = 24;
71
+ break;
72
+ }
73
+ error = new Error(responseData.errorMessage || 'Upload failed with success=false'); // 将完整的响应数据附加到错误对象上
74
+ error.responseData = responseData;
75
+ throw error;
76
+ case 24:
77
+ case "end":
78
+ return _context.stop();
79
+ }
80
+ }, _callee, null, [[13, 17]]);
81
+ }));
82
+ return function upload(_x) {
83
+ return _ref.apply(this, arguments);
84
+ };
85
+ }();
@@ -0,0 +1,75 @@
1
+ export interface ConsoleRecordConfig {
2
+ enable?: boolean;
3
+ level?: ('assert' | 'clear' | 'count' | 'countReset' | 'debug' | 'dir' | 'dirxml' | 'error' | 'group' | 'groupCollapsed' | 'groupEnd' | 'info' | 'log' | 'table' | 'time' | 'timeEnd' | 'timeLog' | 'trace' | 'warn')[];
4
+ lengthThreshold?: number;
5
+ stringifyOptions?: {
6
+ stringLengthLimit?: number;
7
+ numOfKeysLimit?: number;
8
+ depthOfLimit?: number;
9
+ };
10
+ }
11
+ export interface CdnConfig {
12
+ enable: boolean;
13
+ checkoutEveryNms?: number;
14
+ ignoreClass?: string;
15
+ blockClass?: string;
16
+ maskTextClass?: string;
17
+ samplingRate: number;
18
+ sampling?: {
19
+ mousemove?: number | boolean;
20
+ scroll?: number;
21
+ input?: 'all' | 'last';
22
+ };
23
+ configUpdateInterval?: number;
24
+ consumeOnly?: boolean;
25
+ uploadInterval: number;
26
+ maxRetryCount?: number;
27
+ urlParamsToCache?: string[];
28
+ clearStorageBeforeRecord?: boolean;
29
+ console?: {
30
+ enable?: boolean;
31
+ level?: ('assert' | 'clear' | 'count' | 'countReset' | 'debug' | 'dir' | 'dirxml' | 'error' | 'group' | 'groupCollapsed' | 'groupEnd' | 'info' | 'log' | 'table' | 'time' | 'timeEnd' | 'timeLog' | 'trace' | 'warn')[];
32
+ lengthThreshold?: number;
33
+ stringifyOptions?: {
34
+ stringLengthLimit?: number;
35
+ numOfKeysLimit?: number;
36
+ depthOfLimit?: number;
37
+ };
38
+ };
39
+ http?: boolean;
40
+ error?: boolean;
41
+ routerMonitor?: {
42
+ enable?: boolean;
43
+ trackHashChange?: boolean;
44
+ trackHistoryChange?: boolean;
45
+ trackPageStayTime?: boolean;
46
+ ignoreRoutes?: string[];
47
+ customMatchers?: Array<{
48
+ pattern: string | RegExp;
49
+ name?: string;
50
+ }>;
51
+ };
52
+ packEvents?: boolean;
53
+ }
54
+ /**
55
+ * 从 CDN 获取配置
56
+ * @param cdnUrl CDN 配置文件地址
57
+ * @returns 配置对象
58
+ */
59
+ export declare function fetchConfigFromCdn(cdnUrl: string): Promise<CdnConfig>;
60
+ /**
61
+ * 更新全局配置
62
+ * @param newConfig 新配置
63
+ */
64
+ export declare function updateConfig(newConfig: Partial<CdnConfig>): void;
65
+ /**
66
+ * 获取当前配置
67
+ * @returns 当前配置
68
+ */
69
+ export declare function getConfig(): CdnConfig;
70
+ /**
71
+ * 初始化配置管理器
72
+ * @param cdnUrl CDN 配置文件地址
73
+ */
74
+ export declare function initConfigManager(cdnUrl?: string): Promise<void>;
75
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/lib/config.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,mBAAmB;IAElC,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,KAAK,CAAC,EAAE,CACJ,QAAQ,GACR,OAAO,GACP,OAAO,GACP,YAAY,GACZ,OAAO,GACP,KAAK,GACL,QAAQ,GACR,OAAO,GACP,OAAO,GACP,gBAAgB,GAChB,UAAU,GACV,MAAM,GACN,KAAK,GACL,OAAO,GACP,MAAM,GACN,SAAS,GACT,SAAS,GACT,OAAO,GACP,MAAM,CACT,EAAE,CAAC;IAEJ,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,gBAAgB,CAAC,EAAE;QAEjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAE3B,cAAc,CAAC,EAAE,MAAM,CAAC;QAExB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAGD,MAAM,WAAW,SAAS;IAExB,MAAM,EAAE,OAAO,CAAC;IAEhB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,YAAY,EAAE,MAAM,CAAC;IAErB,QAAQ,CAAC,EAAE;QAET,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAE7B,MAAM,CAAC,EAAE,MAAM,CAAC;QAEhB,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;KACxB,CAAC;IAGF,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,cAAc,EAAE,MAAM,CAAC;IAEvB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAG5B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAGnC,OAAO,CAAC,EAAE;QAER,MAAM,CAAC,EAAE,OAAO,CAAC;QAEjB,KAAK,CAAC,EAAE,CACJ,QAAQ,GACR,OAAO,GACP,OAAO,GACP,YAAY,GACZ,OAAO,GACP,KAAK,GACL,QAAQ,GACR,OAAO,GACP,OAAO,GACP,gBAAgB,GAChB,UAAU,GACV,MAAM,GACN,KAAK,GACL,OAAO,GACP,MAAM,GACN,SAAS,GACT,SAAS,GACT,OAAO,GACP,MAAM,CACT,EAAE,CAAC;QAEJ,eAAe,CAAC,EAAE,MAAM,CAAC;QAEzB,gBAAgB,CAAC,EAAE;YAEjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;YAE3B,cAAc,CAAC,EAAE,MAAM,CAAC;YAExB,YAAY,CAAC,EAAE,MAAM,CAAC;SACvB,CAAC;KACH,CAAC;IAGF,IAAI,CAAC,EAAE,OAAO,CAAC;IAGf,KAAK,CAAC,EAAE,OAAO,CAAC;IAGhB,aAAa,CAAC,EAAE;QACd,MAAM,CAAC,EAAE,OAAO,CAAC;QAEjB,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAC;QAC5B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QAExB,cAAc,CAAC,EAAE,KAAK,CAAC;YACrB,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;YACzB,IAAI,CAAC,EAAE,MAAM,CAAC;SACf,CAAC,CAAC;KACJ,CAAC;IAGF,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AA0CD;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAwC3E;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,CAKhE;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,SAAS,CAErC;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBtE"}
@@ -0,0 +1,202 @@
1
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
2
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ import { get } from "./request";
11
+
12
+ // Console录制插件配置类型定义
13
+
14
+ // CDN 配置类型定义
15
+
16
+ // 默认配置
17
+ var DEFAULT_CONFIG = {
18
+ enable: true,
19
+ samplingRate: 15,
20
+ uploadInterval: 2000,
21
+ configUpdateInterval: 300000,
22
+ // 5分钟
23
+ console: {
24
+ enable: false,
25
+ // 默认不加载录制控制台输出的插件
26
+ level: ['log', 'warn', 'error', 'info']
27
+ },
28
+ http: false,
29
+ // 默认不开启接口请求抓取
30
+ consumeOnly: false,
31
+ // 默认关闭只采集不上报模式
32
+ maxRetryCount: 3,
33
+ // 默认最大重试次数3次
34
+ checkoutEveryNms: 2 * 1000,
35
+ // 每2秒做一次全量快照
36
+ ignoreClass: 'rr-ignore',
37
+ blockClass: 'rr-block',
38
+ maskTextClass: 'rr-mask',
39
+ sampling: {
40
+ mousemove: 50,
41
+ // 每50ms最多采集一次mousemove事件
42
+ scroll: 100,
43
+ // 滚动事件防抖,每100ms采集一次,
44
+ input: 'last' // 输入只记录最后一次,
45
+ },
46
+ error: false,
47
+ // 默认不启用错误处理
48
+ packEvents: false,
49
+ // 默认不使用rrweb的packFn压缩事件数据
50
+ clearStorageBeforeRecord: true,
51
+ // 默认在开始录制前清空存储数据
52
+ // 路由监控配置
53
+ routerMonitor: {
54
+ enable: false,
55
+ // 默认关闭路由监控
56
+ // 是否监听 History API 变化
57
+ trackHashChange: true,
58
+ trackHistoryChange: true,
59
+ trackPageStayTime: true,
60
+ // 是否计算页面停留时间
61
+ ignoreRoutes: [],
62
+ // 路由是否应该被忽略
63
+ customMatchers: [] // 自定义匹配规则
64
+ }
65
+ };
66
+
67
+ // 全局配置变量
68
+ var globalConfig = _objectSpread({}, DEFAULT_CONFIG);
69
+
70
+ /**
71
+ * 从 CDN 获取配置
72
+ * @param cdnUrl CDN 配置文件地址
73
+ * @returns 配置对象
74
+ */
75
+ export function fetchConfigFromCdn(_x) {
76
+ return _fetchConfigFromCdn.apply(this, arguments);
77
+ }
78
+
79
+ /**
80
+ * 更新全局配置
81
+ * @param newConfig 新配置
82
+ */
83
+ function _fetchConfigFromCdn() {
84
+ _fetchConfigFromCdn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(cdnUrl) {
85
+ var response, config;
86
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
87
+ while (1) switch (_context.prev = _context.next) {
88
+ case 0:
89
+ _context.prev = 0;
90
+ _context.next = 3;
91
+ return get(cdnUrl);
92
+ case 3:
93
+ response = _context.sent;
94
+ if (response.ok) {
95
+ _context.next = 6;
96
+ break;
97
+ }
98
+ throw new Error("Failed to fetch config: ".concat(response.status));
99
+ case 6:
100
+ config = {}; // 处理三种不同的响应格式
101
+ if (response.data) {
102
+ // 情况1: response.data 直接就是配置对象
103
+ if (_typeof(response.data) === 'object' && !response.data.data) {
104
+ config = response.data;
105
+ }
106
+ // 情况2: response.data.data 是 JSON 对象
107
+ else if (_typeof(response.data.data) === 'object') {
108
+ config = response.data.data;
109
+ }
110
+ // 情况3: response.data.data 是 JSON 字符串
111
+ else if (typeof response.data.data === 'string') {
112
+ try {
113
+ config = JSON.parse(response.data.data);
114
+ } catch (parseError) {
115
+ console.warn('Failed to parse config JSON string:', parseError);
116
+ }
117
+ }
118
+ }
119
+ return _context.abrupt("return", _objectSpread(_objectSpread({}, DEFAULT_CONFIG), config));
120
+ case 11:
121
+ _context.prev = 11;
122
+ _context.t0 = _context["catch"](0);
123
+ console.warn('Failed to fetch config from CDN, using default config:', _context.t0);
124
+ return _context.abrupt("return", _objectSpread({}, DEFAULT_CONFIG));
125
+ case 15:
126
+ case "end":
127
+ return _context.stop();
128
+ }
129
+ }, _callee, null, [[0, 11]]);
130
+ }));
131
+ return _fetchConfigFromCdn.apply(this, arguments);
132
+ }
133
+ export function updateConfig(newConfig) {
134
+ globalConfig = _objectSpread(_objectSpread({}, globalConfig), newConfig);
135
+ }
136
+
137
+ /**
138
+ * 获取当前配置
139
+ * @returns 当前配置
140
+ */
141
+ export function getConfig() {
142
+ return _objectSpread({}, globalConfig);
143
+ }
144
+
145
+ /**
146
+ * 初始化配置管理器
147
+ * @param cdnUrl CDN 配置文件地址
148
+ */
149
+ export function initConfigManager(_x2) {
150
+ return _initConfigManager.apply(this, arguments);
151
+ }
152
+ function _initConfigManager() {
153
+ _initConfigManager = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(cdnUrl) {
154
+ var config, updateInterval;
155
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
156
+ while (1) switch (_context3.prev = _context3.next) {
157
+ case 0:
158
+ if (!cdnUrl) {
159
+ _context3.next = 7;
160
+ break;
161
+ }
162
+ _context3.next = 3;
163
+ return fetchConfigFromCdn(cdnUrl);
164
+ case 3:
165
+ config = _context3.sent;
166
+ updateConfig(config);
167
+
168
+ // 定时更新配置
169
+ updateInterval = config.configUpdateInterval || DEFAULT_CONFIG.configUpdateInterval;
170
+ if (updateInterval) {
171
+ setInterval( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
172
+ var newConfig;
173
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
174
+ while (1) switch (_context2.prev = _context2.next) {
175
+ case 0:
176
+ _context2.prev = 0;
177
+ _context2.next = 3;
178
+ return fetchConfigFromCdn(cdnUrl);
179
+ case 3:
180
+ newConfig = _context2.sent;
181
+ updateConfig(newConfig);
182
+ _context2.next = 10;
183
+ break;
184
+ case 7:
185
+ _context2.prev = 7;
186
+ _context2.t0 = _context2["catch"](0);
187
+ console.warn('Failed to update config from CDN:', _context2.t0);
188
+ case 10:
189
+ case "end":
190
+ return _context2.stop();
191
+ }
192
+ }, _callee2, null, [[0, 7]]);
193
+ })), updateInterval);
194
+ }
195
+ case 7:
196
+ case "end":
197
+ return _context3.stop();
198
+ }
199
+ }, _callee3);
200
+ }));
201
+ return _initConfigManager.apply(this, arguments);
202
+ }