observa-sdk 0.0.4 → 0.0.6
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/dist/index.cjs +24 -7
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +24 -7
- package/package.json +5 -2
package/dist/index.cjs
CHANGED
|
@@ -418,9 +418,17 @@ var Observa = class {
|
|
|
418
418
|
finishReason: extracted.finishReason ?? null,
|
|
419
419
|
responseId: extracted.responseId ?? null,
|
|
420
420
|
systemFingerprint: extracted.systemFingerprint ?? null,
|
|
421
|
-
...headers !== void 0 && { headers }
|
|
421
|
+
...headers !== void 0 && { headers },
|
|
422
|
+
// Conversation tracking fields
|
|
423
|
+
...event.conversationId !== void 0 && { conversationId: event.conversationId },
|
|
424
|
+
...event.sessionId !== void 0 && { sessionId: event.sessionId },
|
|
425
|
+
...event.userId !== void 0 && { userId: event.userId },
|
|
426
|
+
...event.messageIndex !== void 0 && { messageIndex: event.messageIndex },
|
|
427
|
+
...event.parentMessageId !== void 0 && { parentMessageId: event.parentMessageId }
|
|
422
428
|
};
|
|
423
|
-
console.log(
|
|
429
|
+
console.log(
|
|
430
|
+
`[Observa] Trace data prepared, calling sendTrace for ${traceId}, response length: ${fullResponse.length}`
|
|
431
|
+
);
|
|
424
432
|
await this.sendTrace(traceData);
|
|
425
433
|
console.log(`[Observa] sendTrace completed for ${traceId}`);
|
|
426
434
|
} catch (err) {
|
|
@@ -439,8 +447,11 @@ var Observa = class {
|
|
|
439
447
|
formatBeautifulLog(trace);
|
|
440
448
|
}
|
|
441
449
|
try {
|
|
442
|
-
const
|
|
443
|
-
|
|
450
|
+
const baseUrl = this.apiUrl.replace(/\/+$/, "");
|
|
451
|
+
const url = `${baseUrl}/api/v1/traces/ingest`;
|
|
452
|
+
console.log(
|
|
453
|
+
`[Observa] Sending trace - URL: ${url}, TraceID: ${trace.traceId}, Tenant: ${trace.tenantId}, Project: ${trace.projectId}, APIKey: ${this.apiKey ? `Yes(${this.apiKey.length} chars)` : "No"}`
|
|
454
|
+
);
|
|
444
455
|
const controller = new AbortController();
|
|
445
456
|
const timeoutId = setTimeout(() => controller.abort(), 1e4);
|
|
446
457
|
try {
|
|
@@ -454,7 +465,9 @@ var Observa = class {
|
|
|
454
465
|
signal: controller.signal
|
|
455
466
|
});
|
|
456
467
|
clearTimeout(timeoutId);
|
|
457
|
-
console.log(
|
|
468
|
+
console.log(
|
|
469
|
+
`[Observa] Response status: ${response.status} ${response.statusText}`
|
|
470
|
+
);
|
|
458
471
|
if (!response.ok) {
|
|
459
472
|
const errorText = await response.text().catch(() => "Unknown error");
|
|
460
473
|
let errorJson;
|
|
@@ -468,7 +481,9 @@ var Observa = class {
|
|
|
468
481
|
errorJson.error || errorText
|
|
469
482
|
);
|
|
470
483
|
} else {
|
|
471
|
-
console.log(
|
|
484
|
+
console.log(
|
|
485
|
+
`\u2705 [Observa] Trace sent successfully - Trace ID: ${trace.traceId}`
|
|
486
|
+
);
|
|
472
487
|
}
|
|
473
488
|
} catch (fetchError) {
|
|
474
489
|
clearTimeout(timeoutId);
|
|
@@ -483,7 +498,9 @@ var Observa = class {
|
|
|
483
498
|
console.error("[Observa] Error message:", error.message);
|
|
484
499
|
console.error("[Observa] Error name:", error.name);
|
|
485
500
|
if (error.name === "AbortError") {
|
|
486
|
-
console.error(
|
|
501
|
+
console.error(
|
|
502
|
+
"[Observa] Request timed out - check network connectivity and API URL"
|
|
503
|
+
);
|
|
487
504
|
}
|
|
488
505
|
if (error.stack) {
|
|
489
506
|
console.error("[Observa] Error stack:", error.stack);
|
package/dist/index.d.cts
CHANGED
|
@@ -13,6 +13,11 @@ interface TrackEventInput {
|
|
|
13
13
|
context?: string;
|
|
14
14
|
model?: string;
|
|
15
15
|
metadata?: Record<string, any>;
|
|
16
|
+
conversationId?: string;
|
|
17
|
+
sessionId?: string;
|
|
18
|
+
userId?: string;
|
|
19
|
+
messageIndex?: number;
|
|
20
|
+
parentMessageId?: string;
|
|
16
21
|
}
|
|
17
22
|
declare class Observa {
|
|
18
23
|
private apiKey;
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,11 @@ interface TrackEventInput {
|
|
|
13
13
|
context?: string;
|
|
14
14
|
model?: string;
|
|
15
15
|
metadata?: Record<string, any>;
|
|
16
|
+
conversationId?: string;
|
|
17
|
+
sessionId?: string;
|
|
18
|
+
userId?: string;
|
|
19
|
+
messageIndex?: number;
|
|
20
|
+
parentMessageId?: string;
|
|
16
21
|
}
|
|
17
22
|
declare class Observa {
|
|
18
23
|
private apiKey;
|
package/dist/index.js
CHANGED
|
@@ -393,9 +393,17 @@ var Observa = class {
|
|
|
393
393
|
finishReason: extracted.finishReason ?? null,
|
|
394
394
|
responseId: extracted.responseId ?? null,
|
|
395
395
|
systemFingerprint: extracted.systemFingerprint ?? null,
|
|
396
|
-
...headers !== void 0 && { headers }
|
|
396
|
+
...headers !== void 0 && { headers },
|
|
397
|
+
// Conversation tracking fields
|
|
398
|
+
...event.conversationId !== void 0 && { conversationId: event.conversationId },
|
|
399
|
+
...event.sessionId !== void 0 && { sessionId: event.sessionId },
|
|
400
|
+
...event.userId !== void 0 && { userId: event.userId },
|
|
401
|
+
...event.messageIndex !== void 0 && { messageIndex: event.messageIndex },
|
|
402
|
+
...event.parentMessageId !== void 0 && { parentMessageId: event.parentMessageId }
|
|
397
403
|
};
|
|
398
|
-
console.log(
|
|
404
|
+
console.log(
|
|
405
|
+
`[Observa] Trace data prepared, calling sendTrace for ${traceId}, response length: ${fullResponse.length}`
|
|
406
|
+
);
|
|
399
407
|
await this.sendTrace(traceData);
|
|
400
408
|
console.log(`[Observa] sendTrace completed for ${traceId}`);
|
|
401
409
|
} catch (err) {
|
|
@@ -414,8 +422,11 @@ var Observa = class {
|
|
|
414
422
|
formatBeautifulLog(trace);
|
|
415
423
|
}
|
|
416
424
|
try {
|
|
417
|
-
const
|
|
418
|
-
|
|
425
|
+
const baseUrl = this.apiUrl.replace(/\/+$/, "");
|
|
426
|
+
const url = `${baseUrl}/api/v1/traces/ingest`;
|
|
427
|
+
console.log(
|
|
428
|
+
`[Observa] Sending trace - URL: ${url}, TraceID: ${trace.traceId}, Tenant: ${trace.tenantId}, Project: ${trace.projectId}, APIKey: ${this.apiKey ? `Yes(${this.apiKey.length} chars)` : "No"}`
|
|
429
|
+
);
|
|
419
430
|
const controller = new AbortController();
|
|
420
431
|
const timeoutId = setTimeout(() => controller.abort(), 1e4);
|
|
421
432
|
try {
|
|
@@ -429,7 +440,9 @@ var Observa = class {
|
|
|
429
440
|
signal: controller.signal
|
|
430
441
|
});
|
|
431
442
|
clearTimeout(timeoutId);
|
|
432
|
-
console.log(
|
|
443
|
+
console.log(
|
|
444
|
+
`[Observa] Response status: ${response.status} ${response.statusText}`
|
|
445
|
+
);
|
|
433
446
|
if (!response.ok) {
|
|
434
447
|
const errorText = await response.text().catch(() => "Unknown error");
|
|
435
448
|
let errorJson;
|
|
@@ -443,7 +456,9 @@ var Observa = class {
|
|
|
443
456
|
errorJson.error || errorText
|
|
444
457
|
);
|
|
445
458
|
} else {
|
|
446
|
-
console.log(
|
|
459
|
+
console.log(
|
|
460
|
+
`\u2705 [Observa] Trace sent successfully - Trace ID: ${trace.traceId}`
|
|
461
|
+
);
|
|
447
462
|
}
|
|
448
463
|
} catch (fetchError) {
|
|
449
464
|
clearTimeout(timeoutId);
|
|
@@ -458,7 +473,9 @@ var Observa = class {
|
|
|
458
473
|
console.error("[Observa] Error message:", error.message);
|
|
459
474
|
console.error("[Observa] Error name:", error.name);
|
|
460
475
|
if (error.name === "AbortError") {
|
|
461
|
-
console.error(
|
|
476
|
+
console.error(
|
|
477
|
+
"[Observa] Request timed out - check network connectivity and API URL"
|
|
478
|
+
);
|
|
462
479
|
}
|
|
463
480
|
if (error.stack) {
|
|
464
481
|
console.error("[Observa] Error stack:", error.stack);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "observa-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Enterprise-grade observability SDK for AI applications. Track and monitor LLM interactions with zero friction.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -31,5 +31,8 @@
|
|
|
31
31
|
"analytics"
|
|
32
32
|
],
|
|
33
33
|
"author": "Nicka",
|
|
34
|
-
"license": "MIT"
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
}
|
|
35
38
|
}
|