raindrop-ai 1.0.7 → 1.0.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.
@@ -26,6 +26,8 @@ import {
26
26
  normalizeFeatureFlags,
27
27
  normalizeProjectId,
28
28
  package_default,
29
+ piiRedaction,
30
+ piiRedactionNow,
29
31
  projectIdHeaders,
30
32
  raceWithTimeout,
31
33
  randomUUID,
@@ -37,6 +39,7 @@ import {
37
39
  runWithTracingSuppressed,
38
40
  sendJson,
39
41
  setDefaultMaxTextFieldChars,
42
+ snapshotPayload,
40
43
  summarize2,
41
44
  tracing,
42
45
  validAppCommitSha,
@@ -45,7 +48,7 @@ import {
45
48
  withReplayTraceDestination,
46
49
  withRoutingContext,
47
50
  withTask
48
- } from "./chunk-BMYWLBYI.mjs";
51
+ } from "./chunk-JK73MFZN.mjs";
49
52
  import {
50
53
  CapturedTraceSnapshotSchema,
51
54
  EvalCaseExpectationSchema,
@@ -7639,7 +7642,7 @@ var Raindrop = class {
7639
7642
  * retry schedule.
7640
7643
  */
7641
7644
  this.hasShutdown = false;
7642
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
7645
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
7643
7646
  const writeKey = (_a = config.writeKey) != null ? _a : "";
7644
7647
  const disabled = (_b = config.disabled) != null ? _b : false;
7645
7648
  const localDebuggerUrlOpt = config.localWorkshopUrl === false ? null : config.localWorkshopUrl;
@@ -7664,7 +7667,8 @@ var Raindrop = class {
7664
7667
  debug: this.debugLogs,
7665
7668
  prefix: "[raindrop]"
7666
7669
  });
7667
- this.redactPii = (_h = config.redactPii) != null ? _h : false;
7670
+ this.redactPii = config.redactPii;
7671
+ this.remotePiiConfig = config.remotePiiConfig;
7668
7672
  this.piiFields = new PiiFieldRedactor({
7669
7673
  startupFieldMap: config.redactPiiFields,
7670
7674
  logPrefix: "[raindrop]"
@@ -7678,7 +7682,7 @@ var Raindrop = class {
7678
7682
  "[raindrop] 'disableTracing' is deprecated and renamed to 'useExternalOtel'. Please update your config: { useExternalOtel: true }"
7679
7683
  );
7680
7684
  }
7681
- const useExternalOtel = (_j = (_i = config.useExternalOtel) != null ? _i : config.disableTracing) != null ? _j : false;
7685
+ const useExternalOtel = (_i = (_h = config.useExternalOtel) != null ? _h : config.disableTracing) != null ? _i : false;
7682
7686
  const disableBatching = resolveDisableBatching(config.disableBatching, {
7683
7687
  isProduction: process.env.NODE_ENV === "production",
7684
7688
  isLocalDebugger: localDebuggerEnabled(this.localDebuggerUrlOpt)
@@ -7704,7 +7708,8 @@ var Raindrop = class {
7704
7708
  maxTextFieldChars: config.maxTextFieldChars,
7705
7709
  redactPii: this.redactPii,
7706
7710
  redactPiiFields: config.redactPiiFields,
7707
- wizardSession: (_k = this.wizardSession) != null ? _k : void 0,
7711
+ remotePiiConfig: this.remotePiiConfig,
7712
+ wizardSession: (_j = this.wizardSession) != null ? _j : void 0,
7708
7713
  flushTimeoutMs: this.flushTimeoutMs
7709
7714
  });
7710
7715
  try {
@@ -7728,7 +7733,10 @@ var Raindrop = class {
7728
7733
  localDebuggerUrl: this.localDebuggerUrlOpt,
7729
7734
  cloudEnabled: !this.localOnly,
7730
7735
  projectId: this.projectId,
7731
- flushTimeoutMs: this.flushTimeoutMs
7736
+ flushTimeoutMs: this.flushTimeoutMs,
7737
+ redactTracePii: config.redactTracePii,
7738
+ redactPiiFields: config.redactPiiFields,
7739
+ remotePiiConfig: this.remotePiiConfig
7732
7740
  },
7733
7741
  this.debugLogs
7734
7742
  );
@@ -8330,9 +8338,14 @@ var Raindrop = class {
8330
8338
  }
8331
8339
  async sendBatchToApi(events, endpoint, deadlineAt) {
8332
8340
  const kind = PII_KIND_BY_ENDPOINT[endpoint];
8333
- const body = events.map(
8334
- ({ type, ...event }) => this.redactPii && kind ? this.piiFields.redact(kind, event) : event
8335
- );
8341
+ const writeKey = this.localOnly ? void 0 : this.writeKey;
8342
+ let rows = events.map(({ type, ...event }) => event);
8343
+ let redact = kind !== void 0 && piiRedactionNow(this.redactPii, this.remotePiiConfig, this.apiUrl, writeKey);
8344
+ if (redact === void 0) {
8345
+ rows = rows.map(snapshotPayload);
8346
+ redact = await piiRedaction(this.redactPii, this.remotePiiConfig, this.apiUrl, writeKey, deadlineAt);
8347
+ }
8348
+ const body = rows.map((event) => redact && kind ? this.piiFields.redact(kind, event) : event);
8336
8349
  this.mirrorBatchToLocalDebugger(endpoint, body);
8337
8350
  if (this.localOnly) {
8338
8351
  return void 0;