@mushi-mushi/web 1.7.5 → 1.7.6
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/dist/index.cjs +32 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3140,6 +3140,15 @@ var optedIn = false;
|
|
|
3140
3140
|
var tierCache = null;
|
|
3141
3141
|
var tierCacheTime = 0;
|
|
3142
3142
|
var TIER_CACHE_TTL = 5 * 60 * 1e3;
|
|
3143
|
+
var rewardsApiBackoffUntil = 0;
|
|
3144
|
+
var REWARDS_4XX_BACKOFF_MS = 15 * 60 * 1e3;
|
|
3145
|
+
function isRewardsApiBackedOff() {
|
|
3146
|
+
return Date.now() < rewardsApiBackoffUntil;
|
|
3147
|
+
}
|
|
3148
|
+
function noteRewardsApiFailure(code) {
|
|
3149
|
+
if (!code?.startsWith("HTTP_4")) return;
|
|
3150
|
+
rewardsApiBackoffUntil = Date.now() + REWARDS_4XX_BACKOFF_MS;
|
|
3151
|
+
}
|
|
3143
3152
|
var seenRoutes = /* @__PURE__ */ new Set();
|
|
3144
3153
|
function getConsentKey(projectId) {
|
|
3145
3154
|
return `mushi_rewards_consent_${projectId}`;
|
|
@@ -3244,14 +3253,22 @@ async function flush(ctx) {
|
|
|
3244
3253
|
} catch {
|
|
3245
3254
|
}
|
|
3246
3255
|
}
|
|
3256
|
+
if (isRewardsApiBackedOff()) return;
|
|
3247
3257
|
const batch = pendingEvents.splice(0, 100);
|
|
3248
3258
|
try {
|
|
3249
|
-
await ctx.client.submitActivity(currentUserId, batch, {
|
|
3259
|
+
const result = await ctx.client.submitActivity(currentUserId, batch, {
|
|
3250
3260
|
userTraits: currentUserTraits ?? void 0,
|
|
3251
3261
|
reporterTokenHash: reporterTokenHash ?? void 0,
|
|
3252
3262
|
optedIn: true,
|
|
3253
3263
|
hostJwt: hostJwt ?? void 0
|
|
3254
3264
|
});
|
|
3265
|
+
if (!result.ok) {
|
|
3266
|
+
noteRewardsApiFailure(result.error?.code);
|
|
3267
|
+
const permanent = result.error?.code?.startsWith("HTTP_4");
|
|
3268
|
+
if (!permanent) {
|
|
3269
|
+
pendingEvents.unshift(...batch.slice(0, 50));
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3255
3272
|
} catch {
|
|
3256
3273
|
pendingEvents.unshift(...batch.slice(0, 50));
|
|
3257
3274
|
}
|
|
@@ -3262,13 +3279,14 @@ async function getTier(userId) {
|
|
|
3262
3279
|
return fetchAndCacheTier(userId);
|
|
3263
3280
|
}
|
|
3264
3281
|
async function fetchAndCacheTier(userId) {
|
|
3265
|
-
if (!apiClient) return null;
|
|
3282
|
+
if (!apiClient || isRewardsApiBackedOff()) return null;
|
|
3266
3283
|
const res = await apiClient.getMyTier(userId);
|
|
3267
3284
|
if (res.ok && res.data) {
|
|
3268
3285
|
tierCache = res.data;
|
|
3269
3286
|
tierCacheTime = Date.now();
|
|
3270
3287
|
return tierCache;
|
|
3271
3288
|
}
|
|
3289
|
+
noteRewardsApiFailure(res.error?.code);
|
|
3272
3290
|
return null;
|
|
3273
3291
|
}
|
|
3274
3292
|
var routeObserver = null;
|
|
@@ -4761,7 +4779,7 @@ function createProactiveManager(config = {}) {
|
|
|
4761
4779
|
|
|
4762
4780
|
// src/version.ts
|
|
4763
4781
|
var MUSHI_SDK_PACKAGE = "@mushi-mushi/web";
|
|
4764
|
-
var MUSHI_SDK_VERSION = "1.7.
|
|
4782
|
+
var MUSHI_SDK_VERSION = "1.7.6" ;
|
|
4765
4783
|
|
|
4766
4784
|
// src/mushi.ts
|
|
4767
4785
|
var instance = null;
|
|
@@ -4942,15 +4960,26 @@ function createInstance(config) {
|
|
|
4942
4960
|
});
|
|
4943
4961
|
let detachAutoBreadcrumbs = null;
|
|
4944
4962
|
detachAutoBreadcrumbs = installAutoBreadcrumbs(breadcrumbs);
|
|
4963
|
+
async function autoCaptureScreenshot(when) {
|
|
4964
|
+
const mode = activeConfig.capture?.screenshot;
|
|
4965
|
+
if (!screenshotCap || mode === "off" || pendingScreenshot) return;
|
|
4966
|
+
if (when === "open" && mode !== "auto") return;
|
|
4967
|
+
if (when === "submit" && mode !== "on-report" && mode !== "auto") return;
|
|
4968
|
+
log.debug("Auto-capturing screenshot", { when, mode });
|
|
4969
|
+
pendingScreenshot = await screenshotCap.take();
|
|
4970
|
+
widget.setScreenshotAttached(pendingScreenshot !== null);
|
|
4971
|
+
}
|
|
4945
4972
|
widget = new MushiWidget(bootstrapConfig.widget, {
|
|
4946
4973
|
onSubmit: async ({ category, description, intent }) => {
|
|
4947
4974
|
log.info("Report submitted", { category, intent });
|
|
4948
4975
|
proactiveManager?.recordSubmission();
|
|
4976
|
+
await autoCaptureScreenshot("submit");
|
|
4949
4977
|
const outcome = await submitReport(category, description, intent);
|
|
4950
4978
|
return outcome ?? { reportId: null, queuedOffline: true };
|
|
4951
4979
|
},
|
|
4952
4980
|
onOpen: () => {
|
|
4953
4981
|
log.debug("Widget opened");
|
|
4982
|
+
void autoCaptureScreenshot("open");
|
|
4954
4983
|
emit("widget:opened");
|
|
4955
4984
|
},
|
|
4956
4985
|
onClose: () => {
|