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