@brizz/sdk 0.1.27 → 0.1.29
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 +53 -1
- package/dist/index.cjs +319 -223
- package/dist/index.d.cts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +315 -223
- package/dist/preload.cjs +30 -17
- package/dist/preload.js +30 -17
- package/package.json +42 -42
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
|
|
|
@@ -329,6 +331,20 @@ await startSession('session-456', async (session) => {
|
|
|
329
331
|
});
|
|
330
332
|
```
|
|
331
333
|
|
|
334
|
+
**External link example:**
|
|
335
|
+
|
|
336
|
+
```typescript
|
|
337
|
+
import { addExternalLink, startSession } from '@brizz/sdk';
|
|
338
|
+
|
|
339
|
+
startSession('session-123', (session) => {
|
|
340
|
+
// Top-level function — resolves the active session from context.
|
|
341
|
+
addExternalLink('https://app.datadoghq.com/trace/abc', { title: 'Datadog trace' });
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
// Outside a session — pass the id explicitly.
|
|
345
|
+
addExternalLink('https://sentry.io/issues/456', { sessionId: 'session-123', linkType: 'sentry' });
|
|
346
|
+
```
|
|
347
|
+
|
|
332
348
|
### Session Title Generation
|
|
333
349
|
|
|
334
350
|
If you use an LLM call to generate session titles, wrap it so those spans don't appear as part of
|
|
@@ -495,7 +511,7 @@ Brizz.initialize({
|
|
|
495
511
|
Emit custom events and structured logs:
|
|
496
512
|
|
|
497
513
|
```typescript
|
|
498
|
-
import { emitEvent, logger } from '@brizz/sdk';
|
|
514
|
+
import { emitEvent, emitEventWithSessionId, logger } from '@brizz/sdk';
|
|
499
515
|
|
|
500
516
|
// Emit custom events
|
|
501
517
|
emitEvent('user.signup', {
|
|
@@ -510,6 +526,11 @@ emitEvent('ai.request.completed', {
|
|
|
510
526
|
latency: 1200,
|
|
511
527
|
});
|
|
512
528
|
|
|
529
|
+
// Emit with a known session ID, outside any session scope
|
|
530
|
+
emitEventWithSessionId('session-123', 'user.feedback.submitted', {
|
|
531
|
+
rating: 5,
|
|
532
|
+
});
|
|
533
|
+
|
|
513
534
|
// Structured logging
|
|
514
535
|
logger.info('Processing user request', { userId: '123', requestId: 'req-456' });
|
|
515
536
|
logger.error('AI request failed', { error: err.message, model: 'gpt-4' });
|
|
@@ -546,6 +567,37 @@ Brizz.initialize({ apiKey: 'your-api-key', disableSpanExporter: true });
|
|
|
546
567
|
|
|
547
568
|
Or via env var: `BRIZZ_DISABLE_SPAN_EXPORTER=true`.
|
|
548
569
|
|
|
570
|
+
## Dropping Spans
|
|
571
|
+
|
|
572
|
+
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.
|
|
573
|
+
|
|
574
|
+
```typescript
|
|
575
|
+
Brizz.initialize({
|
|
576
|
+
apiKey: 'your-api-key',
|
|
577
|
+
beforeSendSpan: (span) => {
|
|
578
|
+
// OpenInference (LangChain JS, LangGraph JS) packs per-call
|
|
579
|
+
// `config.metadata` into a JSON-stringified `metadata` attribute.
|
|
580
|
+
const raw = span.attributes['metadata'];
|
|
581
|
+
if (typeof raw !== 'string') return true;
|
|
582
|
+
try {
|
|
583
|
+
return JSON.parse(raw).customer_id !== 'cust_42';
|
|
584
|
+
} catch {
|
|
585
|
+
return true;
|
|
586
|
+
}
|
|
587
|
+
},
|
|
588
|
+
});
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
Tag the call so the filter has something to match on:
|
|
592
|
+
|
|
593
|
+
```typescript
|
|
594
|
+
await llm.invoke([new HumanMessage('Hello')], {
|
|
595
|
+
metadata: { customer_id: 'cust_42' },
|
|
596
|
+
});
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
Both sync and async filters are supported. Exceptions are caught and the span passes through.
|
|
600
|
+
|
|
549
601
|
## Advanced Configuration
|
|
550
602
|
|
|
551
603
|
```typescript
|