@brizz/sdk 0.1.26 → 0.1.28
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 +39 -1
- package/dist/index.cjs +424 -216
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +420 -216
- package/dist/preload.cjs +55 -10
- package/dist/preload.js +55 -10
- package/package.json +45 -41
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ libraries including OpenAI, Anthropic, Vercel AI SDK, and more.
|
|
|
21
21
|
- [Custom Events & Logging](#custom-events--logging)
|
|
22
22
|
- [Environment Variables](#environment-variables)
|
|
23
23
|
- [Disable Span Export](#disable-span-export)
|
|
24
|
+
- [Dropping Spans](#dropping-spans)
|
|
24
25
|
- [Advanced Configuration](#advanced-configuration)
|
|
25
26
|
- [Testing & Development](#testing--development)
|
|
26
27
|
- [Package.json Examples](#packagejson-examples)
|
|
@@ -290,6 +291,7 @@ const result = await startSession(
|
|
|
290
291
|
- `session.setOutput(text, context?)` - (Optional) Manually track output text; optional context bag
|
|
291
292
|
attaches per-turn metadata rendered in the dashboard's Context panel
|
|
292
293
|
- `session.setTitle(text)` - Set a session title (typically used with `mode: 'title'`)
|
|
294
|
+
- `session.addExternalLink(url, options?)` - (Optional) Attach an external link (e.g. a Datadog trace or dashboard) to the session; it appears on the session detail panel. Also available as the top-level `addExternalLink(url, options?)`.
|
|
293
295
|
|
|
294
296
|
**Per-turn context example:**
|
|
295
297
|
|
|
@@ -495,7 +497,7 @@ Brizz.initialize({
|
|
|
495
497
|
Emit custom events and structured logs:
|
|
496
498
|
|
|
497
499
|
```typescript
|
|
498
|
-
import { emitEvent, logger } from '@brizz/sdk';
|
|
500
|
+
import { emitEvent, emitEventWithSessionId, logger } from '@brizz/sdk';
|
|
499
501
|
|
|
500
502
|
// Emit custom events
|
|
501
503
|
emitEvent('user.signup', {
|
|
@@ -510,6 +512,11 @@ emitEvent('ai.request.completed', {
|
|
|
510
512
|
latency: 1200,
|
|
511
513
|
});
|
|
512
514
|
|
|
515
|
+
// Emit with a known session ID, outside any session scope
|
|
516
|
+
emitEventWithSessionId('session-123', 'user.feedback.submitted', {
|
|
517
|
+
rating: 5,
|
|
518
|
+
});
|
|
519
|
+
|
|
513
520
|
// Structured logging
|
|
514
521
|
logger.info('Processing user request', { userId: '123', requestId: 'req-456' });
|
|
515
522
|
logger.error('AI request failed', { error: err.message, model: 'gpt-4' });
|
|
@@ -546,6 +553,37 @@ Brizz.initialize({ apiKey: 'your-api-key', disableSpanExporter: true });
|
|
|
546
553
|
|
|
547
554
|
Or via env var: `BRIZZ_DISABLE_SPAN_EXPORTER=true`.
|
|
548
555
|
|
|
556
|
+
## Dropping Spans
|
|
557
|
+
|
|
558
|
+
Filter spans before export with `beforeSendSpan`. Return `false` to drop a span, `true` to keep it. Useful for stripping noisy paths (health checks, internal tooling) or excluding telemetry for specific end-users.
|
|
559
|
+
|
|
560
|
+
```typescript
|
|
561
|
+
Brizz.initialize({
|
|
562
|
+
apiKey: 'your-api-key',
|
|
563
|
+
beforeSendSpan: (span) => {
|
|
564
|
+
// OpenInference (LangChain JS, LangGraph JS) packs per-call
|
|
565
|
+
// `config.metadata` into a JSON-stringified `metadata` attribute.
|
|
566
|
+
const raw = span.attributes['metadata'];
|
|
567
|
+
if (typeof raw !== 'string') return true;
|
|
568
|
+
try {
|
|
569
|
+
return JSON.parse(raw).customer_id !== 'cust_42';
|
|
570
|
+
} catch {
|
|
571
|
+
return true;
|
|
572
|
+
}
|
|
573
|
+
},
|
|
574
|
+
});
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
Tag the call so the filter has something to match on:
|
|
578
|
+
|
|
579
|
+
```typescript
|
|
580
|
+
await llm.invoke([new HumanMessage('Hello')], {
|
|
581
|
+
metadata: { customer_id: 'cust_42' },
|
|
582
|
+
});
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
Both sync and async filters are supported. Exceptions are caught and the span passes through.
|
|
586
|
+
|
|
549
587
|
## Advanced Configuration
|
|
550
588
|
|
|
551
589
|
```typescript
|