@brizz/sdk 0.1.22 → 0.1.25
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 +30 -25
- package/dist/index.cjs +297 -335
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +273 -311
- package/dist/index.js.map +1 -1
- package/dist/preload.cjs +274 -322
- package/dist/preload.cjs.map +1 -1
- package/dist/preload.js +263 -311
- package/dist/preload.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ libraries including OpenAI, Anthropic, Vercel AI SDK, and more.
|
|
|
16
16
|
- [ESM Projects](#esm-projects)
|
|
17
17
|
- [Module System Support](#module-system-support)
|
|
18
18
|
- [Supported Libraries](#supported-libraries)
|
|
19
|
-
- [PII
|
|
19
|
+
- [PII Masking](#pii-masking)
|
|
20
20
|
- [Session Tracking](#session-tracking)
|
|
21
21
|
- [Custom Events & Logging](#custom-events--logging)
|
|
22
22
|
- [Environment Variables](#environment-variables)
|
|
@@ -33,7 +33,7 @@ libraries including OpenAI, Anthropic, Vercel AI SDK, and more.
|
|
|
33
33
|
|
|
34
34
|
- 🔍 **Automatic Instrumentation** - Zero-code setup for popular AI libraries
|
|
35
35
|
- 📊 **OpenTelemetry Native** - Standards-compliant tracing, metrics, and logs
|
|
36
|
-
- 🛡️ **PII
|
|
36
|
+
- 🛡️ **PII Masking** - Optional masking for sensitive data
|
|
37
37
|
- 🔄 **Session Tracking** - Group related operations and traces
|
|
38
38
|
- 📦 **Dual Module Support** - Works with both ESM and CommonJS
|
|
39
39
|
- ⚡ **Multiple Initialization Methods** - Preload, ESM loader, or manual setup
|
|
@@ -223,11 +223,18 @@ This enables automatic tracing of:
|
|
|
223
223
|
- Tool calls and executions
|
|
224
224
|
- Streaming data
|
|
225
225
|
|
|
226
|
-
## PII
|
|
226
|
+
## PII Masking
|
|
227
227
|
|
|
228
|
-
|
|
228
|
+
Optional masking for span attributes.
|
|
229
229
|
|
|
230
230
|
```typescript
|
|
231
|
+
// Enable default masking
|
|
232
|
+
Brizz.initialize({
|
|
233
|
+
apiKey: 'your-api-key',
|
|
234
|
+
masking: true,
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
// Custom masking configuration
|
|
231
238
|
Brizz.initialize({
|
|
232
239
|
apiKey: 'your-api-key',
|
|
233
240
|
masking: {
|
|
@@ -236,16 +243,7 @@ Brizz.initialize({
|
|
|
236
243
|
{
|
|
237
244
|
attributePattern: 'gen_ai\\.(prompt|completion)',
|
|
238
245
|
mode: 'partial', // 'partial' or 'full'
|
|
239
|
-
patterns: ['sk-[a-zA-Z0-9]{48}'],
|
|
240
|
-
},
|
|
241
|
-
],
|
|
242
|
-
},
|
|
243
|
-
logMasking: {
|
|
244
|
-
rules: [
|
|
245
|
-
{
|
|
246
|
-
attributePattern: 'message',
|
|
247
|
-
mode: 'full',
|
|
248
|
-
patterns: ['\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b'],
|
|
246
|
+
patterns: ['sk-[a-zA-Z0-9]{48}'],
|
|
249
247
|
},
|
|
250
248
|
],
|
|
251
249
|
},
|
|
@@ -253,8 +251,7 @@ Brizz.initialize({
|
|
|
253
251
|
});
|
|
254
252
|
```
|
|
255
253
|
|
|
256
|
-
|
|
257
|
-
API keys, crypto addresses, IPs, and more.
|
|
254
|
+
When enabled, defaults cover a curated set of common secret patterns. Add custom rules for anything else you need masked.
|
|
258
255
|
|
|
259
256
|
## Session Tracking
|
|
260
257
|
|
|
@@ -286,9 +283,12 @@ const result = await startSession(
|
|
|
286
283
|
```
|
|
287
284
|
|
|
288
285
|
**Session Methods:**
|
|
286
|
+
|
|
289
287
|
- `session.updateProperties({ key: value })` - Add custom properties to the session span
|
|
290
|
-
- `session.setInput(text, context?)` - (Optional) Manually track input text; optional context bag
|
|
291
|
-
|
|
288
|
+
- `session.setInput(text, context?)` - (Optional) Manually track input text; optional context bag
|
|
289
|
+
attaches per-turn metadata rendered in the dashboard's Context panel
|
|
290
|
+
- `session.setOutput(text, context?)` - (Optional) Manually track output text; optional context bag
|
|
291
|
+
attaches per-turn metadata rendered in the dashboard's Context panel
|
|
292
292
|
- `session.setTitle(text)` - Set a session title (typically used with `mode: 'title'`)
|
|
293
293
|
|
|
294
294
|
**Per-turn context example:**
|
|
@@ -306,7 +306,8 @@ await startSession('session-123', async (session) => {
|
|
|
306
306
|
|
|
307
307
|
**When to use manual input/output tracking:**
|
|
308
308
|
|
|
309
|
-
In most cases, Brizz automatically captures inputs and outputs from your LLM calls. Use
|
|
309
|
+
In most cases, Brizz automatically captures inputs and outputs from your LLM calls. Use
|
|
310
|
+
`setInput`/`setOutput` for special scenarios:
|
|
310
311
|
|
|
311
312
|
- **Multi-agent flows**: Track only user-facing input/output, not intermediate agent communications
|
|
312
313
|
- **Structured data extraction**: Track a specific field from complex JSON requests
|
|
@@ -330,7 +331,8 @@ await startSession('session-456', async (session) => {
|
|
|
330
331
|
|
|
331
332
|
### Session Title Generation
|
|
332
333
|
|
|
333
|
-
If you use an LLM call to generate session titles, wrap it so those spans don't appear as part of
|
|
334
|
+
If you use an LLM call to generate session titles, wrap it so those spans don't appear as part of
|
|
335
|
+
the conversation:
|
|
334
336
|
|
|
335
337
|
```typescript
|
|
336
338
|
import { startSession, startSessionTitle } from '@brizz/sdk';
|
|
@@ -362,7 +364,8 @@ await startSessionTitle(async (title) => {
|
|
|
362
364
|
|
|
363
365
|
### Accessing the Active Session
|
|
364
366
|
|
|
365
|
-
Use `getActiveSession()` to retrieve the current session from anywhere within a `startSession` scope
|
|
367
|
+
Use `getActiveSession()` to retrieve the current session from anywhere within a `startSession` scope
|
|
368
|
+
— no need to pass the session object through your call stack:
|
|
366
369
|
|
|
367
370
|
```typescript
|
|
368
371
|
import { startSession, getActiveSession } from '@brizz/sdk';
|
|
@@ -400,7 +403,9 @@ async function processUserWorkflow(userId: string) {
|
|
|
400
403
|
|
|
401
404
|
// Create a wrapped function that always executes with session context
|
|
402
405
|
// withSessionId(sessionId, fn, thisArg?, extraProperties?)
|
|
403
|
-
const sessionedWorkflow = withSessionId('session-123', processUserWorkflow, undefined, {
|
|
406
|
+
const sessionedWorkflow = withSessionId('session-123', processUserWorkflow, undefined, {
|
|
407
|
+
feature: 'workflow',
|
|
408
|
+
});
|
|
404
409
|
|
|
405
410
|
// Call multiple times, each with the same session context
|
|
406
411
|
await sessionedWorkflow('user-456');
|
|
@@ -531,9 +536,9 @@ OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true # Capture AI content
|
|
|
531
536
|
|
|
532
537
|
## Disable Span Export
|
|
533
538
|
|
|
534
|
-
Keep `Brizz.initialize()` in your code without sending any spans — useful for dev/test
|
|
535
|
-
|
|
536
|
-
|
|
539
|
+
Keep `Brizz.initialize()` in your code without sending any spans — useful for dev/test environments.
|
|
540
|
+
When enabled, the SDK skips span exporter and processor setup, so no spans are exported. Metrics and
|
|
541
|
+
logs continue to work.
|
|
537
542
|
|
|
538
543
|
```typescript
|
|
539
544
|
Brizz.initialize({ apiKey: 'your-api-key', disableSpanExporter: true });
|