@wireai/activation 0.9.1 → 0.9.2

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.
@@ -858,8 +858,9 @@ var createEventQueue = (options) => {
858
858
  } catch {
859
859
  }
860
860
  })();
861
+ const DROP_STATUSES = /* @__PURE__ */ new Set([400, 404, 413, 422]);
861
862
  const postBatch = async (events) => {
862
- if (!(target == null ? void 0 : target.serverUrl) || events.length === 0) return false;
863
+ if (!(target == null ? void 0 : target.serverUrl) || events.length === 0) return "retry";
863
864
  const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
864
865
  const timer = setTimeout(() => controller == null ? void 0 : controller.abort(), 15e3);
865
866
  try {
@@ -872,9 +873,12 @@ var createEventQueue = (options) => {
872
873
  body: JSON.stringify({ events }),
873
874
  signal: controller == null ? void 0 : controller.signal
874
875
  });
875
- return !!(res && res.ok);
876
+ if (res && res.ok) return "ok";
877
+ const status = res == null ? void 0 : res.status;
878
+ if (typeof status === "number" && DROP_STATUSES.has(status)) return "drop";
879
+ return "retry";
876
880
  } catch {
877
- return false;
881
+ return "retry";
878
882
  } finally {
879
883
  clearTimeout(timer);
880
884
  }
@@ -906,8 +910,8 @@ var createEventQueue = (options) => {
906
910
  try {
907
911
  while (pending.length > 0) {
908
912
  const batch = pending.slice(0, batchSize);
909
- const ok = await postBatch(batch.map((item) => item.event));
910
- if (!ok) {
913
+ const result = await postBatch(batch.map((item) => item.event));
914
+ if (result === "retry") {
911
915
  scheduleRetry();
912
916
  return;
913
917
  }