raindrop-ai 1.0.8 → 1.0.9-otelv2

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 CHANGED
@@ -580,6 +580,48 @@ network can never wedge your process exit. Like `forceFlush()`, it resolves
580
580
  (never rejects) to `{ delivered, timedOut, dropped, queued, inFlight }`;
581
581
  ignoring the result is fine.
582
582
 
583
+ ## Masking sensitive data yourself
584
+
585
+ `mask` is a function you write that replaces sensitive parts of content before
586
+ it leaves your process. It runs on every piece of content the SDK sends, just
587
+ before the send:
588
+
589
+ | `kind` | `field` | Value |
590
+ | --- | --- | --- |
591
+ | `event` | `ai_data.input`, `ai_data.output` | string |
592
+ | `event` | `properties` | object |
593
+ | `event` | `attachments` | array |
594
+ | `signal` | `properties` (holds `comment`) | object |
595
+ | `identify` | `traits` | object |
596
+ | `span` | the attribute name (prompts, completions, tool arguments and results), or `status.message` | string |
597
+ | `span` | `traceloop.association.properties.<key>`, the copy of each event property on the event's spans | string |
598
+
599
+ ```ts
600
+ const raindrop = new Raindrop({
601
+ writeKey: "...",
602
+ mask(value, { kind, field }) {
603
+ if (typeof value === "string") return value.replace(/\bACCT-\d{8}\b/g, "[ACCOUNT]");
604
+ if (kind === "identify" && typeof value === "object" && value !== null && "name" in value) {
605
+ delete value.name;
606
+ }
607
+ return value;
608
+ },
609
+ });
610
+ ```
611
+
612
+ - It runs whether or not `redactPii` and `redactTracePii` are on. When they
613
+ are, it runs after them, so it sees `<REDACTED EMAIL>` markers.
614
+ - The value is a copy, so you can change it in place. Return a string for a
615
+ string, an object for an object, an array for an array.
616
+ - It must be synchronous.
617
+ - IDs, user IDs, event names, model names, token counts and timing are never
618
+ passed to it. Span content arrives as the attribute's string, which is
619
+ often JSON.
620
+ - If it throws, returns a promise, or returns the wrong type, the field is
621
+ sent as `<MASK FAILED>` (`{ error: "<MASK FAILED>" }` for objects, `[]` for
622
+ attachments) instead of its content, and a warning is logged without the
623
+ content. The event or span is still sent.
624
+
583
625
  ## Notes
584
626
 
585
627
  - This package preserves the current dist structure and public exports.