sentry-miniapp 1.1.0 → 1.2.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.
- package/README.md +118 -123
- package/dist/sentry-miniapp.cjs.js +250 -37
- package/dist/sentry-miniapp.cjs.js.map +1 -1
- package/dist/sentry-miniapp.esm.js +250 -37
- package/dist/sentry-miniapp.esm.js.map +1 -1
- package/dist/sentry-miniapp.umd.js +250 -37
- package/dist/sentry-miniapp.umd.js.map +1 -1
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/crossPlatform.d.ts +5 -1
- package/dist/types/crossPlatform.d.ts.map +1 -1
- package/dist/types/integrations/dedupe.d.ts.map +1 -1
- package/dist/types/integrations/trycatch.d.ts +0 -2
- package/dist/types/integrations/trycatch.d.ts.map +1 -1
- package/dist/types/transports/index.d.ts +1 -0
- package/dist/types/transports/index.d.ts.map +1 -1
- package/dist/types/transports/offlineStore.d.ts +6 -0
- package/dist/types/transports/offlineStore.d.ts.map +1 -0
- package/dist/types/transports/xhr.d.ts.map +1 -1
- package/dist/types/types.d.ts +2 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +15 -6
|
@@ -249,7 +249,7 @@ var __yieldStar = (value) => {
|
|
|
249
249
|
ensurePolyfills();
|
|
250
250
|
const DEBUG_BUILD = typeof __SENTRY_DEBUG__ === "undefined" || __SENTRY_DEBUG__;
|
|
251
251
|
const GLOBAL_OBJ = globalThis;
|
|
252
|
-
const SDK_VERSION$1 = "10.
|
|
252
|
+
const SDK_VERSION$1 = "10.45.0";
|
|
253
253
|
function getMainCarrier() {
|
|
254
254
|
getSentryCarrier(GLOBAL_OBJ);
|
|
255
255
|
return GLOBAL_OBJ;
|
|
@@ -466,8 +466,7 @@ var __yieldStar = (value) => {
|
|
|
466
466
|
}
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
|
-
const
|
|
470
|
-
for (const k of allowedAttrs) {
|
|
469
|
+
for (const k of ["aria-label", "type", "name", "title", "alt"]) {
|
|
471
470
|
const attr = elem.getAttribute(k);
|
|
472
471
|
if (attr) {
|
|
473
472
|
out.push(`[${k}="${attr}"]`);
|
|
@@ -517,16 +516,9 @@ var __yieldStar = (value) => {
|
|
|
517
516
|
}
|
|
518
517
|
function getOwnProperties(obj) {
|
|
519
518
|
if (typeof obj === "object" && obj !== null) {
|
|
520
|
-
|
|
521
|
-
for (const property in obj) {
|
|
522
|
-
if (Object.prototype.hasOwnProperty.call(obj, property)) {
|
|
523
|
-
extractedProps[property] = obj[property];
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
return extractedProps;
|
|
527
|
-
} else {
|
|
528
|
-
return {};
|
|
519
|
+
return Object.fromEntries(Object.entries(obj));
|
|
529
520
|
}
|
|
521
|
+
return {};
|
|
530
522
|
}
|
|
531
523
|
let RESOLVED_RUNNER;
|
|
532
524
|
function withRandomSafeContext(cb) {
|
|
@@ -1557,14 +1549,13 @@ var __yieldStar = (value) => {
|
|
|
1557
1549
|
};
|
|
1558
1550
|
}
|
|
1559
1551
|
const SENTRY_BAGGAGE_KEY_PREFIX = "sentry-";
|
|
1560
|
-
const SENTRY_BAGGAGE_KEY_PREFIX_REGEX = /^sentry-/;
|
|
1561
1552
|
function baggageHeaderToDynamicSamplingContext(baggageHeader) {
|
|
1562
1553
|
const baggageObject = parseBaggageHeader(baggageHeader);
|
|
1563
1554
|
if (!baggageObject) {
|
|
1564
1555
|
return void 0;
|
|
1565
1556
|
}
|
|
1566
1557
|
const dynamicSamplingContext = Object.entries(baggageObject).reduce((acc, [key, value]) => {
|
|
1567
|
-
if (key.
|
|
1558
|
+
if (key.startsWith(SENTRY_BAGGAGE_KEY_PREFIX)) {
|
|
1568
1559
|
const nonPrefixedKey = key.slice(SENTRY_BAGGAGE_KEY_PREFIX.length);
|
|
1569
1560
|
acc[nonPrefixedKey] = value;
|
|
1570
1561
|
}
|
|
@@ -2244,28 +2235,24 @@ ${JSON.stringify(itemHeaders)}
|
|
|
2244
2235
|
buffer
|
|
2245
2236
|
];
|
|
2246
2237
|
}
|
|
2247
|
-
const
|
|
2248
|
-
session: "session",
|
|
2238
|
+
const DATA_CATEGORY_OVERRIDES = {
|
|
2249
2239
|
sessions: "session",
|
|
2250
|
-
attachment: "attachment",
|
|
2251
|
-
transaction: "transaction",
|
|
2252
2240
|
event: "error",
|
|
2253
2241
|
client_report: "internal",
|
|
2254
2242
|
user_report: "default",
|
|
2255
|
-
profile: "profile",
|
|
2256
2243
|
profile_chunk: "profile",
|
|
2257
2244
|
replay_event: "replay",
|
|
2258
2245
|
replay_recording: "replay",
|
|
2259
2246
|
check_in: "monitor",
|
|
2260
|
-
feedback: "feedback",
|
|
2261
|
-
span: "span",
|
|
2262
2247
|
raw_security: "security",
|
|
2263
2248
|
log: "log_item",
|
|
2264
|
-
metric: "metric",
|
|
2265
2249
|
trace_metric: "metric"
|
|
2266
2250
|
};
|
|
2251
|
+
function _isOverriddenType(type) {
|
|
2252
|
+
return type in DATA_CATEGORY_OVERRIDES;
|
|
2253
|
+
}
|
|
2267
2254
|
function envelopeItemTypeToDataCategory(type) {
|
|
2268
|
-
return
|
|
2255
|
+
return _isOverriddenType(type) ? DATA_CATEGORY_OVERRIDES[type] : type;
|
|
2269
2256
|
}
|
|
2270
2257
|
function getSdkMetadataForEnvelopeHeader(metadataOrEvent) {
|
|
2271
2258
|
if (!(metadataOrEvent == null ? void 0 : metadataOrEvent.sdk)) {
|
|
@@ -3557,10 +3544,10 @@ ${JSON.stringify(itemHeaders)}
|
|
|
3557
3544
|
}
|
|
3558
3545
|
function startSession(context) {
|
|
3559
3546
|
const isolationScope = getIsolationScope();
|
|
3560
|
-
const
|
|
3547
|
+
const { user } = getCombinedScopeData(isolationScope, getCurrentScope());
|
|
3561
3548
|
const { userAgent } = GLOBAL_OBJ.navigator || {};
|
|
3562
3549
|
const session = makeSession(__spreadValues(__spreadValues({
|
|
3563
|
-
user
|
|
3550
|
+
user
|
|
3564
3551
|
}, userAgent && { userAgent }), context));
|
|
3565
3552
|
const currentSession = isolationScope.getSession();
|
|
3566
3553
|
if ((currentSession == null ? void 0 : currentSession.status) === "ok") {
|
|
@@ -4227,6 +4214,7 @@ ${JSON.stringify(itemHeaders)}
|
|
|
4227
4214
|
// @ts-expect-error - PromiseLike is a subset of Promise
|
|
4228
4215
|
close(timeout) {
|
|
4229
4216
|
return __async(this, null, function* () {
|
|
4217
|
+
_INTERNAL_flushLogsBuffer(this);
|
|
4230
4218
|
const result = yield this.flush(timeout);
|
|
4231
4219
|
this.getOptions().enabled = false;
|
|
4232
4220
|
this.emit("close");
|
|
@@ -4374,6 +4362,14 @@ ${JSON.stringify(itemHeaders)}
|
|
|
4374
4362
|
return {};
|
|
4375
4363
|
});
|
|
4376
4364
|
}
|
|
4365
|
+
/**
|
|
4366
|
+
* Disposes of the client and releases all resources.
|
|
4367
|
+
*
|
|
4368
|
+
* Subclasses should override this method to clean up their own resources.
|
|
4369
|
+
* After calling dispose(), the client should not be used anymore.
|
|
4370
|
+
*/
|
|
4371
|
+
dispose() {
|
|
4372
|
+
}
|
|
4377
4373
|
/* eslint-enable @typescript-eslint/unified-signatures */
|
|
4378
4374
|
/** Setup integrations for this client. */
|
|
4379
4375
|
_setupIntegrations() {
|
|
@@ -4458,12 +4454,13 @@ ${JSON.stringify(itemHeaders)}
|
|
|
4458
4454
|
isolationScope.setLastEventId(event.event_id || hint.event_id);
|
|
4459
4455
|
}
|
|
4460
4456
|
return prepareEvent(options, event, hint, currentScope, this, isolationScope).then((evt) => {
|
|
4457
|
+
var _a;
|
|
4461
4458
|
if (evt === null) {
|
|
4462
4459
|
return evt;
|
|
4463
4460
|
}
|
|
4464
4461
|
this.emit("postprocessEvent", evt, hint);
|
|
4465
4462
|
evt.contexts = __spreadValues({
|
|
4466
|
-
trace: getTraceContextFromScope(currentScope)
|
|
4463
|
+
trace: __spreadValues(__spreadValues({}, (_a = evt.contexts) == null ? void 0 : _a.trace), getTraceContextFromScope(currentScope))
|
|
4467
4464
|
}, evt.contexts);
|
|
4468
4465
|
const dynamicSamplingContext = getDynamicSamplingContextFromScope(this, currentScope);
|
|
4469
4466
|
evt.sdkProcessingMetadata = __spreadValues({
|
|
@@ -4531,11 +4528,12 @@ ${JSON.stringify(itemHeaders)}
|
|
|
4531
4528
|
}
|
|
4532
4529
|
const dataCategory = getDataCategoryByType(event.type);
|
|
4533
4530
|
return this._prepareEvent(event, hint, currentScope, isolationScope).then((prepared) => {
|
|
4531
|
+
var _a;
|
|
4534
4532
|
if (prepared === null) {
|
|
4535
4533
|
this.recordDroppedEvent("event_processor", dataCategory);
|
|
4536
4534
|
throw _makeDoNotSendEventError("An event processor returned `null`, will not send event.");
|
|
4537
4535
|
}
|
|
4538
|
-
const isInternalException = hint.data
|
|
4536
|
+
const isInternalException = ((_a = hint.data) == null ? void 0 : _a.__sentry__) === true;
|
|
4539
4537
|
if (isInternalException) {
|
|
4540
4538
|
return prepared;
|
|
4541
4539
|
}
|
|
@@ -4820,6 +4818,112 @@ Reason: ${reason}`
|
|
|
4820
4818
|
function setCurrentClient(client) {
|
|
4821
4819
|
getCurrentScope().setClient(client);
|
|
4822
4820
|
}
|
|
4821
|
+
const MIN_DELAY = 100;
|
|
4822
|
+
const START_DELAY = 5e3;
|
|
4823
|
+
const MAX_DELAY = 36e5;
|
|
4824
|
+
function makeOfflineTransport(createTransport2) {
|
|
4825
|
+
function log2(...args) {
|
|
4826
|
+
DEBUG_BUILD && debug.log("[Offline]:", ...args);
|
|
4827
|
+
}
|
|
4828
|
+
return (options) => {
|
|
4829
|
+
const transport = createTransport2(options);
|
|
4830
|
+
if (!options.createStore) {
|
|
4831
|
+
throw new Error("No `createStore` function was provided");
|
|
4832
|
+
}
|
|
4833
|
+
const store = options.createStore(options);
|
|
4834
|
+
let retryDelay = START_DELAY;
|
|
4835
|
+
let flushTimer;
|
|
4836
|
+
function shouldQueue(env, error2, retryDelay2) {
|
|
4837
|
+
if (envelopeContainsItemType(env, ["client_report"])) {
|
|
4838
|
+
return false;
|
|
4839
|
+
}
|
|
4840
|
+
if (options.shouldStore) {
|
|
4841
|
+
return options.shouldStore(env, error2, retryDelay2);
|
|
4842
|
+
}
|
|
4843
|
+
return true;
|
|
4844
|
+
}
|
|
4845
|
+
function flushIn(delay) {
|
|
4846
|
+
if (flushTimer) {
|
|
4847
|
+
clearTimeout(flushTimer);
|
|
4848
|
+
}
|
|
4849
|
+
flushTimer = safeUnref(
|
|
4850
|
+
setTimeout(() => __async(null, null, function* () {
|
|
4851
|
+
flushTimer = void 0;
|
|
4852
|
+
const found = yield store.shift();
|
|
4853
|
+
if (found) {
|
|
4854
|
+
log2("Attempting to send previously queued event");
|
|
4855
|
+
found[0].sent_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
4856
|
+
void send(found, true).catch((e) => {
|
|
4857
|
+
log2("Failed to retry sending", e);
|
|
4858
|
+
});
|
|
4859
|
+
}
|
|
4860
|
+
}), delay)
|
|
4861
|
+
);
|
|
4862
|
+
}
|
|
4863
|
+
function flushWithBackOff() {
|
|
4864
|
+
if (flushTimer) {
|
|
4865
|
+
return;
|
|
4866
|
+
}
|
|
4867
|
+
flushIn(retryDelay);
|
|
4868
|
+
retryDelay = Math.min(retryDelay * 2, MAX_DELAY);
|
|
4869
|
+
}
|
|
4870
|
+
function send(envelope, isRetry = false) {
|
|
4871
|
+
return __async(this, null, function* () {
|
|
4872
|
+
var _a, _b;
|
|
4873
|
+
if (!isRetry && envelopeContainsItemType(envelope, ["replay_event", "replay_recording"])) {
|
|
4874
|
+
yield store.push(envelope);
|
|
4875
|
+
flushIn(MIN_DELAY);
|
|
4876
|
+
return {};
|
|
4877
|
+
}
|
|
4878
|
+
try {
|
|
4879
|
+
if (options.shouldSend && (yield options.shouldSend(envelope)) === false) {
|
|
4880
|
+
throw new Error("Envelope not sent because `shouldSend` callback returned false");
|
|
4881
|
+
}
|
|
4882
|
+
const result = yield transport.send(envelope);
|
|
4883
|
+
let delay = MIN_DELAY;
|
|
4884
|
+
if (result) {
|
|
4885
|
+
if ((_a = result.headers) == null ? void 0 : _a["retry-after"]) {
|
|
4886
|
+
delay = parseRetryAfterHeader(result.headers["retry-after"]);
|
|
4887
|
+
} else if ((_b = result.headers) == null ? void 0 : _b["x-sentry-rate-limits"]) {
|
|
4888
|
+
delay = 6e4;
|
|
4889
|
+
} else if ((result.statusCode || 0) >= 400) {
|
|
4890
|
+
return result;
|
|
4891
|
+
}
|
|
4892
|
+
}
|
|
4893
|
+
flushIn(delay);
|
|
4894
|
+
retryDelay = START_DELAY;
|
|
4895
|
+
return result;
|
|
4896
|
+
} catch (e) {
|
|
4897
|
+
if (yield shouldQueue(envelope, e, retryDelay)) {
|
|
4898
|
+
if (isRetry) {
|
|
4899
|
+
yield store.unshift(envelope);
|
|
4900
|
+
} else {
|
|
4901
|
+
yield store.push(envelope);
|
|
4902
|
+
}
|
|
4903
|
+
flushWithBackOff();
|
|
4904
|
+
log2("Error sending. Event queued.", e);
|
|
4905
|
+
return {};
|
|
4906
|
+
} else {
|
|
4907
|
+
throw e;
|
|
4908
|
+
}
|
|
4909
|
+
}
|
|
4910
|
+
});
|
|
4911
|
+
}
|
|
4912
|
+
if (options.flushAtStartup) {
|
|
4913
|
+
flushWithBackOff();
|
|
4914
|
+
}
|
|
4915
|
+
return {
|
|
4916
|
+
send,
|
|
4917
|
+
flush: (timeout) => {
|
|
4918
|
+
if (timeout === void 0) {
|
|
4919
|
+
retryDelay = START_DELAY;
|
|
4920
|
+
flushIn(MIN_DELAY);
|
|
4921
|
+
}
|
|
4922
|
+
return transport.flush(timeout);
|
|
4923
|
+
}
|
|
4924
|
+
};
|
|
4925
|
+
};
|
|
4926
|
+
}
|
|
4823
4927
|
const DEFAULT_BREADCRUMBS = 100;
|
|
4824
4928
|
function addBreadcrumb(breadcrumb, hint) {
|
|
4825
4929
|
const client = getClient();
|
|
@@ -4836,7 +4940,7 @@ Reason: ${reason}`
|
|
|
4836
4940
|
}
|
|
4837
4941
|
isolationScope.addBreadcrumb(finalBreadcrumb, maxBreadcrumbs);
|
|
4838
4942
|
}
|
|
4839
|
-
const SDK_VERSION = "1.
|
|
4943
|
+
const SDK_VERSION = "1.2.0";
|
|
4840
4944
|
const SDK_NAME = "sentry.javascript.miniapp";
|
|
4841
4945
|
const getSDK = () => {
|
|
4842
4946
|
let currentSdk = {
|
|
@@ -4864,9 +4968,35 @@ Reason: ${reason}`
|
|
|
4864
4968
|
currentSdk = qq;
|
|
4865
4969
|
} else if (typeof swan === "object" && swan !== null) {
|
|
4866
4970
|
currentSdk = swan;
|
|
4971
|
+
} else if (typeof ks === "object" && ks !== null) {
|
|
4972
|
+
currentSdk = ks;
|
|
4867
4973
|
} else {
|
|
4868
4974
|
throw new Error("sentry-miniapp 暂不支持此平台");
|
|
4869
4975
|
}
|
|
4976
|
+
if (typeof my === "object" && my !== null && currentSdk === my && !currentSdk.request && currentSdk.httpRequest) {
|
|
4977
|
+
currentSdk.request = currentSdk.httpRequest;
|
|
4978
|
+
}
|
|
4979
|
+
if (typeof my === "object" && my !== null && currentSdk === my || typeof dd === "object" && dd !== null && currentSdk === dd) {
|
|
4980
|
+
if (currentSdk.getStorageSync) {
|
|
4981
|
+
const originalGet = currentSdk.getStorageSync;
|
|
4982
|
+
currentSdk.getStorageSync = (key) => {
|
|
4983
|
+
const res = originalGet.call(currentSdk, { key });
|
|
4984
|
+
return res ? res.data : null;
|
|
4985
|
+
};
|
|
4986
|
+
}
|
|
4987
|
+
if (currentSdk.setStorageSync) {
|
|
4988
|
+
const originalSet = currentSdk.setStorageSync;
|
|
4989
|
+
currentSdk.setStorageSync = (key, data) => {
|
|
4990
|
+
originalSet.call(currentSdk, { key, data });
|
|
4991
|
+
};
|
|
4992
|
+
}
|
|
4993
|
+
if (currentSdk.removeStorageSync) {
|
|
4994
|
+
const originalRemove = currentSdk.removeStorageSync;
|
|
4995
|
+
currentSdk.removeStorageSync = (key) => {
|
|
4996
|
+
originalRemove.call(currentSdk, { key });
|
|
4997
|
+
};
|
|
4998
|
+
}
|
|
4999
|
+
}
|
|
4870
5000
|
return currentSdk;
|
|
4871
5001
|
};
|
|
4872
5002
|
const getAppName = () => {
|
|
@@ -4883,6 +5013,8 @@ Reason: ${reason}`
|
|
|
4883
5013
|
currentAppName = "qq";
|
|
4884
5014
|
} else if (typeof swan === "object" && swan !== null) {
|
|
4885
5015
|
currentAppName = "swan";
|
|
5016
|
+
} else if (typeof ks === "object" && ks !== null) {
|
|
5017
|
+
currentAppName = "kuaishou";
|
|
4886
5018
|
}
|
|
4887
5019
|
return currentAppName;
|
|
4888
5020
|
};
|
|
@@ -4922,7 +5054,11 @@ Reason: ${reason}`
|
|
|
4922
5054
|
return result;
|
|
4923
5055
|
}
|
|
4924
5056
|
if (currentSdk.getSystemInfoSync) {
|
|
4925
|
-
|
|
5057
|
+
const syncInfo = currentSdk.getSystemInfoSync();
|
|
5058
|
+
if (!syncInfo.SDKVersion && syncInfo.version) {
|
|
5059
|
+
syncInfo.SDKVersion = syncInfo.version;
|
|
5060
|
+
}
|
|
5061
|
+
return syncInfo;
|
|
4926
5062
|
}
|
|
4927
5063
|
return null;
|
|
4928
5064
|
} catch (error2) {
|
|
@@ -4975,20 +5111,24 @@ Reason: ${reason}`
|
|
|
4975
5111
|
header: __spreadValues({
|
|
4976
5112
|
"Content-Type": "application/json"
|
|
4977
5113
|
}, request.headers),
|
|
5114
|
+
// Alipay uses `headers` instead of `header`
|
|
5115
|
+
headers: __spreadValues({
|
|
5116
|
+
"Content-Type": "application/json"
|
|
5117
|
+
}, request.headers),
|
|
4978
5118
|
timeout: 1e4,
|
|
4979
5119
|
success: (res) => {
|
|
4980
|
-
|
|
4981
|
-
const
|
|
5120
|
+
const status = res.statusCode || res.status;
|
|
5121
|
+
const resHeaders = res.header || res.headers || {};
|
|
4982
5122
|
resolve({
|
|
4983
5123
|
statusCode: status,
|
|
4984
5124
|
headers: {
|
|
4985
|
-
"x-sentry-rate-limits":
|
|
4986
|
-
"retry-after":
|
|
5125
|
+
"x-sentry-rate-limits": resHeaders["x-sentry-rate-limits"],
|
|
5126
|
+
"retry-after": resHeaders["retry-after"]
|
|
4987
5127
|
}
|
|
4988
5128
|
});
|
|
4989
5129
|
},
|
|
4990
5130
|
fail: (error2) => {
|
|
4991
|
-
reject(new Error(`Network request failed: ${error2.errMsg || error2.message || "Unknown error"}`));
|
|
5131
|
+
reject(new Error(`Network request failed: ${error2.errMsg || error2.errorMessage || error2.message || "Unknown error"}`));
|
|
4992
5132
|
}
|
|
4993
5133
|
};
|
|
4994
5134
|
if (sdk().request) {
|
|
@@ -5002,8 +5142,75 @@ Reason: ${reason}`
|
|
|
5002
5142
|
}
|
|
5003
5143
|
return createTransport(options, makeRequest);
|
|
5004
5144
|
}
|
|
5145
|
+
const MAX_OFFLINE_CACHE_SIZE = 30;
|
|
5146
|
+
const OFFLINE_STORE_KEY = "sentry_offline_store";
|
|
5147
|
+
function createMiniappOfflineStore(_options) {
|
|
5148
|
+
return {
|
|
5149
|
+
push: (env) => __async(null, null, function* () {
|
|
5150
|
+
try {
|
|
5151
|
+
const store = getStore();
|
|
5152
|
+
store.push(env);
|
|
5153
|
+
if (store.length > MAX_OFFLINE_CACHE_SIZE) {
|
|
5154
|
+
store.shift();
|
|
5155
|
+
}
|
|
5156
|
+
setStore(store);
|
|
5157
|
+
} catch (e) {
|
|
5158
|
+
console.warn("[Sentry] Failed to push to offline store", e);
|
|
5159
|
+
}
|
|
5160
|
+
}),
|
|
5161
|
+
unshift: (env) => __async(null, null, function* () {
|
|
5162
|
+
try {
|
|
5163
|
+
const store = getStore();
|
|
5164
|
+
store.unshift(env);
|
|
5165
|
+
if (store.length > MAX_OFFLINE_CACHE_SIZE) {
|
|
5166
|
+
store.pop();
|
|
5167
|
+
}
|
|
5168
|
+
setStore(store);
|
|
5169
|
+
} catch (e) {
|
|
5170
|
+
console.warn("[Sentry] Failed to unshift to offline store", e);
|
|
5171
|
+
}
|
|
5172
|
+
}),
|
|
5173
|
+
shift: () => __async(null, null, function* () {
|
|
5174
|
+
try {
|
|
5175
|
+
const store = getStore();
|
|
5176
|
+
if (store.length === 0) {
|
|
5177
|
+
return void 0;
|
|
5178
|
+
}
|
|
5179
|
+
const env = store.shift();
|
|
5180
|
+
setStore(store);
|
|
5181
|
+
return env;
|
|
5182
|
+
} catch (e) {
|
|
5183
|
+
console.warn("[Sentry] Failed to shift from offline store", e);
|
|
5184
|
+
return void 0;
|
|
5185
|
+
}
|
|
5186
|
+
})
|
|
5187
|
+
};
|
|
5188
|
+
}
|
|
5189
|
+
function getStore() {
|
|
5190
|
+
try {
|
|
5191
|
+
const storageApi = sdk().getStorageSync;
|
|
5192
|
+
if (storageApi) {
|
|
5193
|
+
const storedStr = storageApi(OFFLINE_STORE_KEY);
|
|
5194
|
+
if (storedStr) {
|
|
5195
|
+
return typeof storedStr === "string" ? JSON.parse(storedStr) : storedStr;
|
|
5196
|
+
}
|
|
5197
|
+
}
|
|
5198
|
+
} catch (e) {
|
|
5199
|
+
}
|
|
5200
|
+
return [];
|
|
5201
|
+
}
|
|
5202
|
+
function setStore(store) {
|
|
5203
|
+
try {
|
|
5204
|
+
const storageApi = sdk().setStorageSync;
|
|
5205
|
+
if (storageApi) {
|
|
5206
|
+
storageApi(OFFLINE_STORE_KEY, JSON.stringify(store));
|
|
5207
|
+
}
|
|
5208
|
+
} catch (e) {
|
|
5209
|
+
}
|
|
5210
|
+
}
|
|
5005
5211
|
const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5006
5212
|
__proto__: null,
|
|
5213
|
+
createMiniappOfflineStore,
|
|
5007
5214
|
createMiniappTransport
|
|
5008
5215
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5009
5216
|
class MiniappClient extends Client {
|
|
@@ -5015,9 +5222,17 @@ Reason: ${reason}`
|
|
|
5015
5222
|
constructor(options = {}) {
|
|
5016
5223
|
super(__spreadProps(__spreadValues({}, options), {
|
|
5017
5224
|
transport: options.transport || ((transportOptions) => {
|
|
5018
|
-
|
|
5225
|
+
const baseTransport = createMiniappTransport(__spreadProps(__spreadValues({}, transportOptions), {
|
|
5019
5226
|
headers: {}
|
|
5020
5227
|
}));
|
|
5228
|
+
if (options.enableOfflineCache !== false) {
|
|
5229
|
+
return makeOfflineTransport(() => baseTransport)(__spreadProps(__spreadValues({}, transportOptions), {
|
|
5230
|
+
createStore: createMiniappOfflineStore,
|
|
5231
|
+
flushAtStartup: true
|
|
5232
|
+
// 启动时自动重试发送
|
|
5233
|
+
}));
|
|
5234
|
+
}
|
|
5235
|
+
return baseTransport;
|
|
5021
5236
|
})
|
|
5022
5237
|
}));
|
|
5023
5238
|
}
|
|
@@ -5303,7 +5518,6 @@ Reason: ${reason}`
|
|
|
5303
5518
|
const _TryCatch = class _TryCatch {
|
|
5304
5519
|
constructor() {
|
|
5305
5520
|
this.name = _TryCatch.id;
|
|
5306
|
-
this._ignoreOnError = 0;
|
|
5307
5521
|
}
|
|
5308
5522
|
/** JSDoc */
|
|
5309
5523
|
_wrapTimeFunction(original) {
|
|
@@ -5341,7 +5555,6 @@ Reason: ${reason}`
|
|
|
5341
5555
|
* and provide better metadata.
|
|
5342
5556
|
*/
|
|
5343
5557
|
setupOnce() {
|
|
5344
|
-
this._ignoreOnError = this._ignoreOnError;
|
|
5345
5558
|
const global2 = globalThis;
|
|
5346
5559
|
if (global2.setTimeout) {
|
|
5347
5560
|
fill(global2, "setTimeout", this._wrapTimeFunction.bind(this));
|