@paid-ai/paid-node 0.5.0-alpha3 → 0.5.0
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 +118 -36
- package/dist/cjs/Client.d.ts +35 -3
- package/dist/cjs/Client.js +57 -19
- package/dist/cjs/api/errors/InternalServerError.d.ts +9 -0
- package/dist/cjs/api/errors/InternalServerError.js +52 -0
- package/dist/cjs/api/errors/index.d.ts +1 -0
- package/dist/cjs/api/errors/index.js +1 -0
- package/dist/cjs/api/index.d.ts +1 -1
- package/dist/cjs/api/index.js +1 -1
- package/dist/cjs/api/resources/agents/client/Client.d.ts +16 -0
- package/dist/cjs/api/resources/agents/client/Client.js +16 -0
- package/dist/cjs/api/resources/customers/client/Client.d.ts +38 -0
- package/dist/cjs/api/resources/customers/client/Client.js +164 -0
- package/dist/cjs/api/resources/customers/client/requests/CustomerCreate.d.ts +2 -0
- package/dist/cjs/api/resources/customers/client/requests/CustomersGetCostsByExternalIdRequest.d.ts +30 -0
- package/dist/cjs/api/resources/customers/client/requests/CustomersGetUsageByExternalIdRequest.d.ts +30 -0
- package/dist/cjs/api/resources/customers/client/requests/CustomersGetUsageByExternalIdRequest.js +5 -0
- package/dist/cjs/api/resources/customers/client/requests/index.d.ts +2 -0
- package/dist/cjs/api/resources/index.d.ts +8 -1
- package/dist/cjs/api/resources/index.js +9 -2
- package/dist/cjs/api/resources/orders/client/requests/OrderCreate.d.ts +2 -0
- package/dist/cjs/api/resources/orders/resources/lines/client/Client.d.ts +0 -2
- package/dist/cjs/api/resources/orders/resources/lines/client/Client.js +0 -2
- package/dist/cjs/api/resources/orders/resources/lines/client/requests/LinesUpdateRequest.d.ts +0 -2
- package/dist/cjs/api/resources/plans/client/Client.d.ts +75 -0
- package/dist/cjs/api/resources/plans/client/Client.js +272 -0
- package/dist/cjs/api/resources/plans/client/index.d.ts +1 -0
- package/dist/cjs/api/resources/plans/client/index.js +17 -0
- package/dist/cjs/api/resources/plans/client/requests/PlansGetUsageRequest.d.ts +35 -0
- package/dist/cjs/api/resources/plans/client/requests/PlansGetUsageRequest.js +5 -0
- package/dist/cjs/api/resources/plans/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/resources/plans/client/requests/index.js +2 -0
- package/dist/cjs/api/resources/plans/index.d.ts +1 -0
- package/dist/cjs/api/resources/plans/index.js +17 -0
- package/dist/cjs/api/resources/products/client/Client.d.ts +109 -0
- package/dist/cjs/api/resources/products/client/Client.js +470 -0
- package/dist/cjs/api/resources/products/client/index.d.ts +1 -0
- package/dist/cjs/api/resources/products/client/index.js +17 -0
- package/dist/cjs/api/resources/products/client/requests/ProductCreate.d.ts +29 -0
- package/dist/cjs/api/resources/products/client/requests/ProductCreate.js +14 -0
- package/dist/cjs/api/resources/products/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/resources/products/client/requests/index.js +2 -0
- package/dist/cjs/api/resources/products/index.d.ts +1 -0
- package/dist/cjs/api/resources/products/index.js +17 -0
- package/dist/cjs/api/resources/traces/client/Client.d.ts +52 -0
- package/dist/cjs/api/resources/traces/client/Client.js +166 -0
- package/dist/cjs/api/resources/traces/client/index.d.ts +1 -0
- package/dist/cjs/api/resources/traces/client/index.js +17 -0
- package/dist/cjs/api/resources/traces/client/requests/GetTracesRequest.d.ts +50 -0
- package/dist/cjs/api/resources/traces/client/requests/GetTracesRequest.js +5 -0
- package/dist/cjs/api/resources/traces/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/resources/traces/client/requests/index.js +2 -0
- package/dist/cjs/api/resources/traces/index.d.ts +1 -0
- package/dist/cjs/api/resources/traces/index.js +17 -0
- package/dist/cjs/api/resources/usage/client/Client.d.ts +47 -0
- package/dist/cjs/api/resources/usage/client/Client.js +146 -0
- package/dist/cjs/api/resources/usage/client/requests/UsageCheckUsageRequest.d.ts +28 -0
- package/dist/cjs/api/resources/usage/client/requests/UsageCheckUsageRequest.js +5 -0
- package/dist/cjs/api/resources/usage/client/requests/UsageRecordBulkV2Request.d.ts +29 -0
- package/dist/cjs/api/resources/usage/client/requests/UsageRecordBulkV2Request.js +5 -0
- package/dist/cjs/api/resources/usage/client/requests/index.d.ts +2 -0
- package/dist/cjs/api/resources/usage/index.d.ts +1 -0
- package/dist/cjs/api/resources/usage/index.js +1 -0
- package/dist/cjs/api/resources/usage/types/UsageCheckUsageResponse.d.ts +17 -0
- package/dist/cjs/api/resources/usage/types/UsageCheckUsageResponse.js +5 -0
- package/dist/cjs/api/resources/usage/types/index.d.ts +1 -0
- package/dist/cjs/api/resources/usage/types/index.js +17 -0
- package/dist/cjs/api/types/CostAmount.d.ts +12 -0
- package/dist/cjs/api/types/CostAmount.js +5 -0
- package/dist/cjs/api/types/CostTrace.d.ts +22 -0
- package/dist/cjs/api/types/CostTrace.js +5 -0
- package/dist/cjs/api/types/CostTracesResponse.d.ts +11 -0
- package/dist/cjs/api/types/CostTracesResponse.js +5 -0
- package/dist/cjs/api/types/Customer.d.ts +2 -0
- package/dist/cjs/api/types/CustomerUpdate.d.ts +2 -0
- package/dist/cjs/api/types/OrderLineAttributeCreateOne.d.ts +4 -0
- package/dist/cjs/api/types/OrderLineAttributeCreateOne.js +5 -0
- package/dist/cjs/api/types/OrderLineCreate.d.ts +10 -4
- package/dist/cjs/api/types/PaginationMeta.d.ts +28 -0
- package/dist/cjs/api/types/PaginationMeta.js +5 -0
- package/dist/cjs/api/types/Plan.d.ts +58 -0
- package/dist/cjs/api/types/Plan.js +5 -0
- package/dist/cjs/api/types/PlanGroup.d.ts +23 -0
- package/dist/cjs/api/types/PlanGroup.js +5 -0
- package/dist/cjs/api/types/Product.d.ts +36 -0
- package/dist/cjs/api/types/Product.js +14 -0
- package/dist/cjs/api/types/ProductUpdate.d.ts +23 -0
- package/dist/cjs/api/types/ProductUpdate.js +14 -0
- package/dist/cjs/api/types/Signal.d.ts +7 -2
- package/dist/cjs/api/types/SignalV2.d.ts +22 -0
- package/dist/cjs/api/types/SignalV2.js +5 -0
- package/dist/cjs/api/types/Trace.d.ts +26 -0
- package/dist/cjs/api/types/Trace.js +5 -0
- package/dist/cjs/api/types/TracesResponse.d.ts +11 -0
- package/dist/cjs/api/types/TracesResponse.js +5 -0
- package/dist/cjs/api/types/UsagePaginationMeta.d.ts +16 -0
- package/dist/cjs/api/types/UsagePaginationMeta.js +5 -0
- package/dist/cjs/api/types/UsageSummariesResponse.d.ts +11 -0
- package/dist/cjs/api/types/UsageSummariesResponse.js +5 -0
- package/dist/cjs/api/types/UsageSummary.d.ts +58 -0
- package/dist/cjs/api/types/UsageSummary.js +5 -0
- package/dist/cjs/api/types/index.d.ts +15 -1
- package/dist/cjs/api/types/index.js +15 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/tracing/autoInstrumentation.d.ts +10 -0
- package/dist/cjs/tracing/autoInstrumentation.js +57 -0
- package/dist/cjs/tracing/index.d.ts +4 -0
- package/dist/cjs/tracing/index.js +12 -0
- package/dist/cjs/tracing/signal.d.ts +18 -1
- package/dist/cjs/tracing/signal.js +29 -13
- package/dist/cjs/tracing/spanProcessor.d.ts +10 -0
- package/dist/cjs/tracing/spanProcessor.js +82 -0
- package/dist/cjs/tracing/tracing.d.ts +12 -6
- package/dist/cjs/tracing/tracing.js +65 -58
- package/dist/cjs/tracing/tracingContext.d.ts +8 -0
- package/dist/cjs/tracing/tracingContext.js +28 -0
- package/dist/cjs/tracing/wrappers/anthropicWrapper.js +11 -7
- package/dist/cjs/tracing/wrappers/langchainCallback.js +11 -7
- package/dist/cjs/tracing/wrappers/mistralWrapper.js +11 -7
- package/dist/cjs/tracing/wrappers/openAiWrapper.js +24 -23
- package/dist/cjs/tracing/wrappers/vercelAIWrapper.js +68 -43
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Client.d.mts +35 -3
- package/dist/esm/Client.mjs +54 -16
- package/dist/esm/api/errors/InternalServerError.d.mts +9 -0
- package/dist/esm/api/errors/InternalServerError.mjs +15 -0
- package/dist/esm/api/errors/index.d.mts +1 -0
- package/dist/esm/api/errors/index.mjs +1 -0
- package/dist/esm/api/index.d.mts +1 -1
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/resources/agents/client/Client.d.mts +16 -0
- package/dist/esm/api/resources/agents/client/Client.mjs +16 -0
- package/dist/esm/api/resources/customers/client/Client.d.mts +38 -0
- package/dist/esm/api/resources/customers/client/Client.mjs +164 -0
- package/dist/esm/api/resources/customers/client/requests/CustomerCreate.d.mts +2 -0
- package/dist/esm/api/resources/customers/client/requests/CustomersGetCostsByExternalIdRequest.d.mts +30 -0
- package/dist/esm/api/resources/customers/client/requests/CustomersGetUsageByExternalIdRequest.d.mts +30 -0
- package/dist/esm/api/resources/customers/client/requests/CustomersGetUsageByExternalIdRequest.mjs +4 -0
- package/dist/esm/api/resources/customers/client/requests/index.d.mts +2 -0
- package/dist/esm/api/resources/index.d.mts +8 -1
- package/dist/esm/api/resources/index.mjs +8 -1
- package/dist/esm/api/resources/orders/client/requests/OrderCreate.d.mts +2 -0
- package/dist/esm/api/resources/orders/resources/lines/client/Client.d.mts +0 -2
- package/dist/esm/api/resources/orders/resources/lines/client/Client.mjs +0 -2
- package/dist/esm/api/resources/orders/resources/lines/client/requests/LinesUpdateRequest.d.mts +0 -2
- package/dist/esm/api/resources/plans/client/Client.d.mts +75 -0
- package/dist/esm/api/resources/plans/client/Client.mjs +232 -0
- package/dist/esm/api/resources/plans/client/index.d.mts +1 -0
- package/dist/esm/api/resources/plans/client/index.mjs +1 -0
- package/dist/esm/api/resources/plans/client/requests/PlansGetUsageRequest.d.mts +35 -0
- package/dist/esm/api/resources/plans/client/requests/PlansGetUsageRequest.mjs +4 -0
- package/dist/esm/api/resources/plans/client/requests/index.d.mts +1 -0
- package/dist/esm/api/resources/plans/client/requests/index.mjs +1 -0
- package/dist/esm/api/resources/plans/index.d.mts +1 -0
- package/dist/esm/api/resources/plans/index.mjs +1 -0
- package/dist/esm/api/resources/products/client/Client.d.mts +109 -0
- package/dist/esm/api/resources/products/client/Client.mjs +430 -0
- package/dist/esm/api/resources/products/client/index.d.mts +1 -0
- package/dist/esm/api/resources/products/client/index.mjs +1 -0
- package/dist/esm/api/resources/products/client/requests/ProductCreate.d.mts +29 -0
- package/dist/esm/api/resources/products/client/requests/ProductCreate.mjs +11 -0
- package/dist/esm/api/resources/products/client/requests/index.d.mts +1 -0
- package/dist/esm/api/resources/products/client/requests/index.mjs +1 -0
- package/dist/esm/api/resources/products/index.d.mts +1 -0
- package/dist/esm/api/resources/products/index.mjs +1 -0
- package/dist/esm/api/resources/traces/client/Client.d.mts +52 -0
- package/dist/esm/api/resources/traces/client/Client.mjs +126 -0
- package/dist/esm/api/resources/traces/client/index.d.mts +1 -0
- package/dist/esm/api/resources/traces/client/index.mjs +1 -0
- package/dist/esm/api/resources/traces/client/requests/GetTracesRequest.d.mts +50 -0
- package/dist/esm/api/resources/traces/client/requests/GetTracesRequest.mjs +4 -0
- package/dist/esm/api/resources/traces/client/requests/index.d.mts +1 -0
- package/dist/esm/api/resources/traces/client/requests/index.mjs +1 -0
- package/dist/esm/api/resources/traces/index.d.mts +1 -0
- package/dist/esm/api/resources/traces/index.mjs +1 -0
- package/dist/esm/api/resources/usage/client/Client.d.mts +47 -0
- package/dist/esm/api/resources/usage/client/Client.mjs +146 -0
- package/dist/esm/api/resources/usage/client/requests/UsageCheckUsageRequest.d.mts +28 -0
- package/dist/esm/api/resources/usage/client/requests/UsageCheckUsageRequest.mjs +4 -0
- package/dist/esm/api/resources/usage/client/requests/UsageRecordBulkV2Request.d.mts +29 -0
- package/dist/esm/api/resources/usage/client/requests/UsageRecordBulkV2Request.mjs +4 -0
- package/dist/esm/api/resources/usage/client/requests/index.d.mts +2 -0
- package/dist/esm/api/resources/usage/index.d.mts +1 -0
- package/dist/esm/api/resources/usage/index.mjs +1 -0
- package/dist/esm/api/resources/usage/types/UsageCheckUsageResponse.d.mts +17 -0
- package/dist/esm/api/resources/usage/types/UsageCheckUsageResponse.mjs +4 -0
- package/dist/esm/api/resources/usage/types/index.d.mts +1 -0
- package/dist/esm/api/resources/usage/types/index.mjs +1 -0
- package/dist/esm/api/types/CostAmount.d.mts +12 -0
- package/dist/esm/api/types/CostAmount.mjs +4 -0
- package/dist/esm/api/types/CostTrace.d.mts +22 -0
- package/dist/esm/api/types/CostTrace.mjs +4 -0
- package/dist/esm/api/types/CostTracesResponse.d.mts +11 -0
- package/dist/esm/api/types/CostTracesResponse.mjs +4 -0
- package/dist/esm/api/types/Customer.d.mts +2 -0
- package/dist/esm/api/types/CustomerUpdate.d.mts +2 -0
- package/dist/esm/api/types/OrderLineAttributeCreateOne.d.mts +4 -0
- package/dist/esm/api/types/OrderLineAttributeCreateOne.mjs +4 -0
- package/dist/esm/api/types/OrderLineCreate.d.mts +10 -4
- package/dist/esm/api/types/PaginationMeta.d.mts +28 -0
- package/dist/esm/api/types/PaginationMeta.mjs +4 -0
- package/dist/esm/api/types/Plan.d.mts +58 -0
- package/dist/esm/api/types/Plan.mjs +4 -0
- package/dist/esm/api/types/PlanGroup.d.mts +23 -0
- package/dist/esm/api/types/PlanGroup.mjs +4 -0
- package/dist/esm/api/types/Product.d.mts +36 -0
- package/dist/esm/api/types/Product.mjs +11 -0
- package/dist/esm/api/types/ProductUpdate.d.mts +23 -0
- package/dist/esm/api/types/ProductUpdate.mjs +11 -0
- package/dist/esm/api/types/Signal.d.mts +7 -2
- package/dist/esm/api/types/SignalV2.d.mts +22 -0
- package/dist/esm/api/types/SignalV2.mjs +4 -0
- package/dist/esm/api/types/Trace.d.mts +26 -0
- package/dist/esm/api/types/Trace.mjs +4 -0
- package/dist/esm/api/types/TracesResponse.d.mts +11 -0
- package/dist/esm/api/types/TracesResponse.mjs +4 -0
- package/dist/esm/api/types/UsagePaginationMeta.d.mts +16 -0
- package/dist/esm/api/types/UsagePaginationMeta.mjs +4 -0
- package/dist/esm/api/types/UsageSummariesResponse.d.mts +11 -0
- package/dist/esm/api/types/UsageSummariesResponse.mjs +4 -0
- package/dist/esm/api/types/UsageSummary.d.mts +58 -0
- package/dist/esm/api/types/UsageSummary.mjs +4 -0
- package/dist/esm/api/types/index.d.mts +15 -1
- package/dist/esm/api/types/index.mjs +15 -1
- package/dist/esm/index.d.mts +1 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/tracing/autoInstrumentation.d.mts +10 -0
- package/dist/esm/tracing/autoInstrumentation.mjs +54 -0
- package/dist/esm/tracing/index.d.mts +4 -0
- package/dist/esm/tracing/index.mjs +4 -0
- package/dist/esm/tracing/signal.d.mts +18 -1
- package/dist/esm/tracing/signal.mjs +28 -12
- package/dist/esm/tracing/spanProcessor.d.mts +10 -0
- package/dist/esm/tracing/spanProcessor.mjs +78 -0
- package/dist/esm/tracing/tracing.d.mts +12 -6
- package/dist/esm/tracing/tracing.mjs +59 -52
- package/dist/esm/tracing/tracingContext.d.mts +8 -0
- package/dist/esm/tracing/tracingContext.mjs +23 -0
- package/dist/esm/tracing/wrappers/anthropicWrapper.mjs +11 -7
- package/dist/esm/tracing/wrappers/langchainCallback.mjs +11 -7
- package/dist/esm/tracing/wrappers/mistralWrapper.mjs +11 -7
- package/dist/esm/tracing/wrappers/openAiWrapper.mjs +24 -23
- package/dist/esm/tracing/wrappers/vercelAIWrapper.mjs +68 -43
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +18 -10
- package/reference.md +1147 -153
- package/dist/cjs/api/types/OrderLineAttributeCreate.d.ts +0 -12
- package/dist/esm/api/types/OrderLineAttributeCreate.d.mts +0 -12
- /package/dist/cjs/api/{types/OrderLineAttributeCreate.js → resources/customers/client/requests/CustomersGetCostsByExternalIdRequest.js} +0 -0
- /package/dist/esm/api/{types/OrderLineAttributeCreate.mjs → resources/customers/client/requests/CustomersGetCostsByExternalIdRequest.mjs} +0 -0
|
@@ -11,11 +11,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.PaidOpenAI = void 0;
|
|
13
13
|
const api_1 = require("@opentelemetry/api");
|
|
14
|
-
const tracing_js_1 = require("
|
|
14
|
+
const tracing_js_1 = require("tracing/tracing.js");
|
|
15
|
+
const tracingContext_js_1 = require("tracing/tracingContext.js");
|
|
15
16
|
class PaidOpenAI {
|
|
16
17
|
constructor(openaiClient) {
|
|
17
18
|
this.openai = openaiClient;
|
|
18
|
-
|
|
19
|
+
const tracer = (0, tracing_js_1.getPaidTracer)();
|
|
20
|
+
if (!tracer) {
|
|
21
|
+
throw new Error("Paid tracer is not initialized, Make sure to call 'initializeTracing()' first");
|
|
22
|
+
}
|
|
23
|
+
this.tracer = tracer;
|
|
19
24
|
}
|
|
20
25
|
get chat() {
|
|
21
26
|
return new ChatWrapper(this.openai, this.tracer);
|
|
@@ -47,9 +52,8 @@ class ChatCompletionsWrapper {
|
|
|
47
52
|
}
|
|
48
53
|
create(params) {
|
|
49
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const token = (0, tracing_js_1.getTokenStorage)();
|
|
55
|
+
const token = (0, tracing_js_1.getToken)();
|
|
56
|
+
const { externalProductId, externalCustomerId } = (0, tracingContext_js_1.getTracingContext)();
|
|
53
57
|
if (!token || !externalCustomerId) {
|
|
54
58
|
throw new Error("No token or externalCustomerId: This wrapper should be used inside a callback to paid.trace().");
|
|
55
59
|
}
|
|
@@ -60,8 +64,8 @@ class ChatCompletionsWrapper {
|
|
|
60
64
|
};
|
|
61
65
|
attributes["external_customer_id"] = externalCustomerId;
|
|
62
66
|
attributes["token"] = token;
|
|
63
|
-
if (
|
|
64
|
-
attributes["external_agent_id"] =
|
|
67
|
+
if (externalProductId) {
|
|
68
|
+
attributes["external_agent_id"] = externalProductId;
|
|
65
69
|
}
|
|
66
70
|
span.setAttributes(attributes);
|
|
67
71
|
try {
|
|
@@ -95,9 +99,8 @@ class ResponsesWrapper {
|
|
|
95
99
|
}
|
|
96
100
|
create(params) {
|
|
97
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
const externalCustomerId = (0,
|
|
99
|
-
const
|
|
100
|
-
const token = (0, tracing_js_1.getTokenStorage)();
|
|
102
|
+
const { externalCustomerId, externalProductId } = (0, tracingContext_js_1.getTracingContext)();
|
|
103
|
+
const token = (0, tracing_js_1.getToken)();
|
|
101
104
|
if (!token || !externalCustomerId) {
|
|
102
105
|
throw new Error("No token or externalCustomerId: This wrapper should be used inside a callback to paid.trace().");
|
|
103
106
|
}
|
|
@@ -109,8 +112,8 @@ class ResponsesWrapper {
|
|
|
109
112
|
};
|
|
110
113
|
attributes["external_customer_id"] = externalCustomerId;
|
|
111
114
|
attributes["token"] = token;
|
|
112
|
-
if (
|
|
113
|
-
attributes["external_agent_id"] =
|
|
115
|
+
if (externalProductId) {
|
|
116
|
+
attributes["external_agent_id"] = externalProductId;
|
|
114
117
|
}
|
|
115
118
|
span.setAttributes(attributes);
|
|
116
119
|
try {
|
|
@@ -150,9 +153,8 @@ class EmbeddingsWrapper {
|
|
|
150
153
|
}
|
|
151
154
|
create(params) {
|
|
152
155
|
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
-
const externalCustomerId = (0,
|
|
154
|
-
const
|
|
155
|
-
const token = (0, tracing_js_1.getTokenStorage)();
|
|
156
|
+
const { externalCustomerId, externalProductId } = (0, tracingContext_js_1.getTracingContext)();
|
|
157
|
+
const token = (0, tracing_js_1.getToken)();
|
|
156
158
|
if (!token || !externalCustomerId) {
|
|
157
159
|
throw new Error("No token or externalCustomerId: This wrapper should be used inside a callback to paid.trace().");
|
|
158
160
|
}
|
|
@@ -163,8 +165,8 @@ class EmbeddingsWrapper {
|
|
|
163
165
|
};
|
|
164
166
|
attributes["external_customer_id"] = externalCustomerId;
|
|
165
167
|
attributes["token"] = token;
|
|
166
|
-
if (
|
|
167
|
-
attributes["external_agent_id"] =
|
|
168
|
+
if (externalProductId) {
|
|
169
|
+
attributes["external_agent_id"] = externalProductId;
|
|
168
170
|
}
|
|
169
171
|
span.setAttributes(attributes);
|
|
170
172
|
try {
|
|
@@ -197,9 +199,8 @@ class ImagesWrapper {
|
|
|
197
199
|
}
|
|
198
200
|
generate(params) {
|
|
199
201
|
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
-
const externalCustomerId = (0,
|
|
201
|
-
const
|
|
202
|
-
const token = (0, tracing_js_1.getTokenStorage)();
|
|
202
|
+
const { externalCustomerId, externalProductId } = (0, tracingContext_js_1.getTracingContext)();
|
|
203
|
+
const token = (0, tracing_js_1.getToken)();
|
|
203
204
|
const model = params.model || "";
|
|
204
205
|
if (!token || !externalCustomerId) {
|
|
205
206
|
throw new Error("No token or externalCustomerId: This wrapper should be used inside a callback to paid.trace().");
|
|
@@ -213,12 +214,12 @@ class ImagesWrapper {
|
|
|
213
214
|
};
|
|
214
215
|
attributes["external_customer_id"] = externalCustomerId;
|
|
215
216
|
attributes["token"] = token;
|
|
216
|
-
if (
|
|
217
|
-
attributes["external_agent_id"] =
|
|
217
|
+
if (externalProductId) {
|
|
218
|
+
attributes["external_agent_id"] = externalProductId;
|
|
218
219
|
}
|
|
219
220
|
span.setAttributes(attributes);
|
|
220
221
|
try {
|
|
221
|
-
const response = yield this.openai.images.generate(params);
|
|
222
|
+
const response = (yield this.openai.images.generate(params));
|
|
222
223
|
span.setAttributes({
|
|
223
224
|
"gen_ai.image.count": (_a = params.n) !== null && _a !== void 0 ? _a : 1,
|
|
224
225
|
"gen_ai.image.size": params.size || "",
|
|
@@ -16,28 +16,29 @@ exports.streamObject = streamObject;
|
|
|
16
16
|
exports.embed = embed;
|
|
17
17
|
exports.embedMany = embedMany;
|
|
18
18
|
const api_1 = require("@opentelemetry/api");
|
|
19
|
-
const tracing_js_1 = require("../tracing.js");
|
|
20
19
|
const ai_1 = require("ai");
|
|
20
|
+
const tracing_js_1 = require("tracing/tracing.js");
|
|
21
|
+
const tracingContext_js_1 = require("tracing/tracingContext.js");
|
|
21
22
|
function getModelInfo(model) {
|
|
22
23
|
if (model === null || model === void 0 ? void 0 : model.modelId) {
|
|
23
24
|
const modelId = model.modelId;
|
|
24
|
-
if (modelId.startsWith(
|
|
25
|
-
return { system:
|
|
25
|
+
if (modelId.startsWith("gpt-") || modelId.startsWith("text-embedding-") || modelId.startsWith("dall-e-")) {
|
|
26
|
+
return { system: "openai", modelName: modelId };
|
|
26
27
|
}
|
|
27
|
-
if (modelId.startsWith(
|
|
28
|
-
return { system:
|
|
28
|
+
if (modelId.startsWith("claude-")) {
|
|
29
|
+
return { system: "anthropic", modelName: modelId };
|
|
29
30
|
}
|
|
30
|
-
if (modelId.startsWith(
|
|
31
|
-
return { system:
|
|
31
|
+
if (modelId.startsWith("mistral-") || modelId.startsWith("codestral-")) {
|
|
32
|
+
return { system: "mistral", modelName: modelId };
|
|
32
33
|
}
|
|
33
|
-
if (modelId.includes(
|
|
34
|
-
return { system:
|
|
34
|
+
if (modelId.includes("gemini")) {
|
|
35
|
+
return { system: "google", modelName: modelId };
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
if (model === null || model === void 0 ? void 0 : model.provider) {
|
|
38
39
|
return { system: model.provider, modelName: model.modelId };
|
|
39
40
|
}
|
|
40
|
-
return { system:
|
|
41
|
+
return { system: "unknown" };
|
|
41
42
|
}
|
|
42
43
|
function extractUsageMetrics(usage) {
|
|
43
44
|
const usageAttrs = {};
|
|
@@ -59,14 +60,14 @@ function extractUsageMetrics(usage) {
|
|
|
59
60
|
return usageAttrs;
|
|
60
61
|
}
|
|
61
62
|
function validateContext() {
|
|
62
|
-
const
|
|
63
|
-
const
|
|
63
|
+
const token = (0, tracing_js_1.getToken)();
|
|
64
|
+
const { externalCustomerId, externalProductId } = (0, tracingContext_js_1.getTracingContext)();
|
|
64
65
|
if (!token || !externalCustomerId) {
|
|
65
66
|
throw new Error("No token or externalCustomerId: This wrapper should be used inside a callback to paid.trace().");
|
|
66
67
|
}
|
|
67
68
|
return {
|
|
68
69
|
externalCustomerId,
|
|
69
|
-
|
|
70
|
+
externalProductId,
|
|
70
71
|
token,
|
|
71
72
|
};
|
|
72
73
|
}
|
|
@@ -74,16 +75,20 @@ function generateText(params) {
|
|
|
74
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
76
|
const context = validateContext();
|
|
76
77
|
const { system: aiSystem, modelName } = getModelInfo(params.model);
|
|
77
|
-
|
|
78
|
+
const tracer = (0, tracing_js_1.getPaidTracer)();
|
|
79
|
+
if (!tracer) {
|
|
80
|
+
throw new Error("Paid tracer is not initialized, Make sure to call 'initializeTracing()' first");
|
|
81
|
+
}
|
|
82
|
+
return tracer.startActiveSpan("trace.ai-sdk.generateText", (span) => __awaiter(this, void 0, void 0, function* () {
|
|
78
83
|
var _a;
|
|
79
84
|
const attributes = {
|
|
80
85
|
"gen_ai.system": aiSystem,
|
|
81
86
|
"gen_ai.operation.name": "chat",
|
|
82
|
-
|
|
83
|
-
|
|
87
|
+
external_customer_id: context.externalCustomerId,
|
|
88
|
+
token: context.token,
|
|
84
89
|
};
|
|
85
|
-
if (context.
|
|
86
|
-
attributes["external_agent_id"] = context.
|
|
90
|
+
if (context.externalProductId) {
|
|
91
|
+
attributes["external_agent_id"] = context.externalProductId;
|
|
87
92
|
}
|
|
88
93
|
if (modelName) {
|
|
89
94
|
attributes["gen_ai.request.model"] = modelName;
|
|
@@ -116,15 +121,19 @@ function streamText(params) {
|
|
|
116
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
117
122
|
const context = validateContext();
|
|
118
123
|
const { system: aiSystem, modelName } = getModelInfo(params.model);
|
|
119
|
-
|
|
124
|
+
const tracer = (0, tracing_js_1.getPaidTracer)();
|
|
125
|
+
if (!tracer) {
|
|
126
|
+
throw new Error("Paid tracer is not initialized, Make sure to call 'initializeTracing()' first");
|
|
127
|
+
}
|
|
128
|
+
return tracer.startActiveSpan("trace.ai-sdk.streamText", (span) => __awaiter(this, void 0, void 0, function* () {
|
|
120
129
|
const attributes = {
|
|
121
130
|
"gen_ai.system": aiSystem,
|
|
122
131
|
"gen_ai.operation.name": "chat",
|
|
123
|
-
|
|
124
|
-
|
|
132
|
+
external_customer_id: context.externalCustomerId,
|
|
133
|
+
token: context.token,
|
|
125
134
|
};
|
|
126
|
-
if (context.
|
|
127
|
-
attributes["external_agent_id"] = context.
|
|
135
|
+
if (context.externalProductId) {
|
|
136
|
+
attributes["external_agent_id"] = context.externalProductId;
|
|
128
137
|
}
|
|
129
138
|
if (modelName) {
|
|
130
139
|
attributes["gen_ai.request.model"] = modelName;
|
|
@@ -161,16 +170,20 @@ function generateObject(params) {
|
|
|
161
170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
162
171
|
const context = validateContext();
|
|
163
172
|
const { system: aiSystem, modelName } = getModelInfo(params.model);
|
|
164
|
-
|
|
173
|
+
const tracer = (0, tracing_js_1.getPaidTracer)();
|
|
174
|
+
if (!tracer) {
|
|
175
|
+
throw new Error("Paid tracer is not initialized, Make sure to call 'initializeTracing()' first");
|
|
176
|
+
}
|
|
177
|
+
return tracer.startActiveSpan("trace.ai-sdk.generateObject", (span) => __awaiter(this, void 0, void 0, function* () {
|
|
165
178
|
var _a;
|
|
166
179
|
const attributes = {
|
|
167
180
|
"gen_ai.system": aiSystem,
|
|
168
181
|
"gen_ai.operation.name": "chat",
|
|
169
|
-
|
|
170
|
-
|
|
182
|
+
external_customer_id: context.externalCustomerId,
|
|
183
|
+
token: context.token,
|
|
171
184
|
};
|
|
172
|
-
if (context.
|
|
173
|
-
attributes["external_agent_id"] = context.
|
|
185
|
+
if (context.externalProductId) {
|
|
186
|
+
attributes["external_agent_id"] = context.externalProductId;
|
|
174
187
|
}
|
|
175
188
|
if (modelName) {
|
|
176
189
|
attributes["gen_ai.request.model"] = modelName;
|
|
@@ -203,15 +216,19 @@ function streamObject(params) {
|
|
|
203
216
|
return __awaiter(this, void 0, void 0, function* () {
|
|
204
217
|
const context = validateContext();
|
|
205
218
|
const { system: aiSystem, modelName } = getModelInfo(params.model);
|
|
206
|
-
|
|
219
|
+
const tracer = (0, tracing_js_1.getPaidTracer)();
|
|
220
|
+
if (!tracer) {
|
|
221
|
+
throw new Error("Paid tracer is not initialized, Make sure to call 'initializeTracing()' first");
|
|
222
|
+
}
|
|
223
|
+
return tracer.startActiveSpan("trace.ai-sdk.streamObject", (span) => __awaiter(this, void 0, void 0, function* () {
|
|
207
224
|
const attributes = {
|
|
208
225
|
"gen_ai.system": aiSystem,
|
|
209
226
|
"gen_ai.operation.name": "chat",
|
|
210
|
-
|
|
211
|
-
|
|
227
|
+
external_customer_id: context.externalCustomerId,
|
|
228
|
+
token: context.token,
|
|
212
229
|
};
|
|
213
|
-
if (context.
|
|
214
|
-
attributes["external_agent_id"] = context.
|
|
230
|
+
if (context.externalProductId) {
|
|
231
|
+
attributes["external_agent_id"] = context.externalProductId;
|
|
215
232
|
}
|
|
216
233
|
if (modelName) {
|
|
217
234
|
attributes["gen_ai.request.model"] = modelName;
|
|
@@ -245,15 +262,19 @@ function embed(params) {
|
|
|
245
262
|
return __awaiter(this, void 0, void 0, function* () {
|
|
246
263
|
const context = validateContext();
|
|
247
264
|
const { system: aiSystem, modelName } = getModelInfo(params.model);
|
|
248
|
-
|
|
265
|
+
const tracer = (0, tracing_js_1.getPaidTracer)();
|
|
266
|
+
if (!tracer) {
|
|
267
|
+
throw new Error("Paid tracer is not initialized, Make sure to call 'initializeTracing()' first");
|
|
268
|
+
}
|
|
269
|
+
return tracer.startActiveSpan("trace.ai-sdk.embed", (span) => __awaiter(this, void 0, void 0, function* () {
|
|
249
270
|
const attributes = {
|
|
250
271
|
"gen_ai.system": aiSystem,
|
|
251
272
|
"gen_ai.operation.name": "embeddings",
|
|
252
|
-
|
|
253
|
-
|
|
273
|
+
external_customer_id: context.externalCustomerId,
|
|
274
|
+
token: context.token,
|
|
254
275
|
};
|
|
255
|
-
if (context.
|
|
256
|
-
attributes["external_agent_id"] = context.
|
|
276
|
+
if (context.externalProductId) {
|
|
277
|
+
attributes["external_agent_id"] = context.externalProductId;
|
|
257
278
|
}
|
|
258
279
|
if (modelName) {
|
|
259
280
|
attributes["gen_ai.request.model"] = modelName;
|
|
@@ -283,15 +304,19 @@ function embedMany(params) {
|
|
|
283
304
|
return __awaiter(this, void 0, void 0, function* () {
|
|
284
305
|
const context = validateContext();
|
|
285
306
|
const { system: aiSystem, modelName } = getModelInfo(params.model);
|
|
286
|
-
|
|
307
|
+
const tracer = (0, tracing_js_1.getPaidTracer)();
|
|
308
|
+
if (!tracer) {
|
|
309
|
+
throw new Error("Paid tracer is not initialized, Make sure to call 'initializeTracing()' first");
|
|
310
|
+
}
|
|
311
|
+
return tracer.startActiveSpan("trace.ai-sdk.embedMany", (span) => __awaiter(this, void 0, void 0, function* () {
|
|
287
312
|
const attributes = {
|
|
288
313
|
"gen_ai.system": aiSystem,
|
|
289
314
|
"gen_ai.operation.name": "embeddings",
|
|
290
|
-
|
|
291
|
-
|
|
315
|
+
external_customer_id: context.externalCustomerId,
|
|
316
|
+
token: context.token,
|
|
292
317
|
};
|
|
293
|
-
if (context.
|
|
294
|
-
attributes["external_agent_id"] = context.
|
|
318
|
+
if (context.externalProductId) {
|
|
319
|
+
attributes["external_agent_id"] = context.externalProductId;
|
|
295
320
|
}
|
|
296
321
|
if (modelName) {
|
|
297
322
|
attributes["gen_ai.request.model"] = modelName;
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.9.0";
|
package/dist/cjs/version.js
CHANGED
package/dist/esm/Client.d.mts
CHANGED
|
@@ -5,15 +5,19 @@ import * as environments from "./environments.mjs";
|
|
|
5
5
|
import * as core from "./core/index.mjs";
|
|
6
6
|
import { Customers } from "./api/resources/customers/client/Client.mjs";
|
|
7
7
|
import { Agents } from "./api/resources/agents/client/Client.mjs";
|
|
8
|
+
import { Products } from "./api/resources/products/client/Client.mjs";
|
|
8
9
|
import { Contacts } from "./api/resources/contacts/client/Client.mjs";
|
|
9
10
|
import { Orders } from "./api/resources/orders/client/Client.mjs";
|
|
11
|
+
import { Plans } from "./api/resources/plans/client/Client.mjs";
|
|
10
12
|
import { Usage } from "./wrapper/BatchUsage.mjs";
|
|
13
|
+
import { Traces } from "./api/resources/traces/client/Client.mjs";
|
|
14
|
+
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
|
|
11
15
|
export declare namespace PaidClient {
|
|
12
16
|
interface Options {
|
|
13
17
|
environment?: core.Supplier<environments.PaidEnvironment | string>;
|
|
14
18
|
/** Specify a custom URL to connect the client to. */
|
|
15
19
|
baseUrl?: core.Supplier<string>;
|
|
16
|
-
token
|
|
20
|
+
token?: core.Supplier<core.BearerToken | undefined>;
|
|
17
21
|
/** Additional headers to include in requests. */
|
|
18
22
|
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
|
|
19
23
|
}
|
|
@@ -32,18 +36,41 @@ export declare class PaidClient {
|
|
|
32
36
|
protected readonly _options: PaidClient.Options;
|
|
33
37
|
protected _customers: Customers | undefined;
|
|
34
38
|
protected _agents: Agents | undefined;
|
|
39
|
+
protected _products: Products | undefined;
|
|
35
40
|
protected _contacts: Contacts | undefined;
|
|
36
41
|
protected _orders: Orders | undefined;
|
|
42
|
+
protected _plans: Plans | undefined;
|
|
37
43
|
protected _usage: Usage | undefined;
|
|
38
|
-
|
|
44
|
+
protected _traces: Traces | undefined;
|
|
45
|
+
constructor(_options?: PaidClient.Options);
|
|
39
46
|
get customers(): Customers;
|
|
40
47
|
get agents(): Agents;
|
|
48
|
+
get products(): Products;
|
|
41
49
|
get contacts(): Contacts;
|
|
42
50
|
get orders(): Orders;
|
|
51
|
+
get plans(): Plans;
|
|
43
52
|
get usage(): Usage;
|
|
53
|
+
get traces(): Traces;
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated use the standalone 'initializeTracing' instead
|
|
56
|
+
*/
|
|
44
57
|
initializeTracing(collectorEndpoint?: string): Promise<void>;
|
|
45
|
-
trace<T extends (...args: any[]) => any>(externalCustomerId: string, fn: T, externalAgentId?: string, ...args: Parameters<T>): Promise<ReturnType<T>>;
|
|
46
58
|
/**
|
|
59
|
+
* @deprecated use the standalone 'trace()' instead
|
|
60
|
+
* Use this method to track actions like LLM costs and sending signals.
|
|
61
|
+
* The callback to this function is the work that you want to trace.
|
|
62
|
+
*
|
|
63
|
+
* @param externalCustomerId - The external customer ID
|
|
64
|
+
* @param fn - The callback function containing the work to be traced
|
|
65
|
+
* @param externalAgentId - @deprecated Use externalProductId instead
|
|
66
|
+
* @param externalProductId - The external product ID
|
|
67
|
+
* @param storePrompt - Whether to store the prompt (defaults to false)
|
|
68
|
+
* @param args - Arguments to pass to the callback function
|
|
69
|
+
* @returns The return value of the callback function
|
|
70
|
+
*/
|
|
71
|
+
trace<T extends (...args: any[]) => any>(externalCustomerId: string, fn: T, externalAgentId?: string, externalProductId?: string, storePrompt?: boolean, ...args: Parameters<T>): Promise<ReturnType<T>>;
|
|
72
|
+
/**
|
|
73
|
+
* @deprecated use the standalone 'signal()' instead
|
|
47
74
|
* Sends Paid signal. Needs to be called as part of callback to Paid.trace().
|
|
48
75
|
* When enableCostTracing flag is on, signal is associated
|
|
49
76
|
* with cost traces from the same Paid.trace() context.
|
|
@@ -63,4 +90,9 @@ export declare class PaidClient {
|
|
|
63
90
|
signal(eventName: string): void;
|
|
64
91
|
signal(eventName: string, data: Record<string, any>): void;
|
|
65
92
|
signal(eventName: string, enableCostTracing: boolean, data?: Record<string, any>): void;
|
|
93
|
+
/**
|
|
94
|
+
* @deprecated use the standalone 'getPaidTracerProvider()' instead
|
|
95
|
+
* Export the tracer provider which user can use for his own tracing.
|
|
96
|
+
*/
|
|
97
|
+
get tracerProvider(): NodeTracerProvider | undefined;
|
|
66
98
|
}
|
package/dist/esm/Client.mjs
CHANGED
|
@@ -14,18 +14,20 @@ import * as core from "./core/index.mjs";
|
|
|
14
14
|
import { mergeHeaders } from "./core/headers.mjs";
|
|
15
15
|
import { Customers } from "./api/resources/customers/client/Client.mjs";
|
|
16
16
|
import { Agents } from "./api/resources/agents/client/Client.mjs";
|
|
17
|
+
import { Products } from "./api/resources/products/client/Client.mjs";
|
|
17
18
|
import { Contacts } from "./api/resources/contacts/client/Client.mjs";
|
|
18
19
|
import { Orders } from "./api/resources/orders/client/Client.mjs";
|
|
20
|
+
import { Plans } from "./api/resources/plans/client/Client.mjs";
|
|
19
21
|
import { Usage } from "./wrapper/BatchUsage.mjs";
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
+
import { Traces } from "./api/resources/traces/client/Client.mjs";
|
|
23
|
+
import { signal } from "./tracing/signal.mjs";
|
|
24
|
+
import { getPaidTracerProvider, initializeTracing, trace } from "./tracing/tracing.mjs";
|
|
22
25
|
export class PaidClient {
|
|
23
|
-
constructor(_options) {
|
|
26
|
+
constructor(_options = {}) {
|
|
24
27
|
this._options = Object.assign(Object.assign({}, _options), { headers: mergeHeaders({
|
|
25
28
|
"X-Fern-Language": "JavaScript",
|
|
26
|
-
"X-Fern-SDK-Name": "
|
|
27
|
-
"X-Fern-SDK-Version": "0.
|
|
28
|
-
"User-Agent": "@paid-ai/paid-node/0.5.0-alpha3",
|
|
29
|
+
"X-Fern-SDK-Name": "",
|
|
30
|
+
"X-Fern-SDK-Version": "0.8.0",
|
|
29
31
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
30
32
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
31
33
|
}, _options === null || _options === void 0 ? void 0 : _options.headers) });
|
|
@@ -38,6 +40,10 @@ export class PaidClient {
|
|
|
38
40
|
var _a;
|
|
39
41
|
return ((_a = this._agents) !== null && _a !== void 0 ? _a : (this._agents = new Agents(this._options)));
|
|
40
42
|
}
|
|
43
|
+
get products() {
|
|
44
|
+
var _a;
|
|
45
|
+
return ((_a = this._products) !== null && _a !== void 0 ? _a : (this._products = new Products(this._options)));
|
|
46
|
+
}
|
|
41
47
|
get contacts() {
|
|
42
48
|
var _a;
|
|
43
49
|
return ((_a = this._contacts) !== null && _a !== void 0 ? _a : (this._contacts = new Contacts(this._options)));
|
|
@@ -46,40 +52,72 @@ export class PaidClient {
|
|
|
46
52
|
var _a;
|
|
47
53
|
return ((_a = this._orders) !== null && _a !== void 0 ? _a : (this._orders = new Orders(this._options)));
|
|
48
54
|
}
|
|
55
|
+
get plans() {
|
|
56
|
+
var _a;
|
|
57
|
+
return ((_a = this._plans) !== null && _a !== void 0 ? _a : (this._plans = new Plans(this._options)));
|
|
58
|
+
}
|
|
49
59
|
get usage() {
|
|
50
60
|
var _a;
|
|
51
61
|
return ((_a = this._usage) !== null && _a !== void 0 ? _a : (this._usage = new Usage(this._options)));
|
|
52
62
|
}
|
|
53
|
-
|
|
63
|
+
get traces() {
|
|
64
|
+
var _a;
|
|
65
|
+
return ((_a = this._traces) !== null && _a !== void 0 ? _a : (this._traces = new Traces(this._options)));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @deprecated use the standalone 'initializeTracing' instead
|
|
69
|
+
*/
|
|
54
70
|
initializeTracing(collectorEndpoint) {
|
|
55
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
72
|
const tokenSupplier = this._options.token;
|
|
57
73
|
const token = typeof tokenSupplier === "function" ? yield tokenSupplier() : tokenSupplier;
|
|
58
74
|
const resolvedToken = yield Promise.resolve(token);
|
|
59
|
-
|
|
75
|
+
initializeTracing(resolvedToken, collectorEndpoint);
|
|
60
76
|
});
|
|
61
77
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
78
|
+
/**
|
|
79
|
+
* @deprecated use the standalone 'trace()' instead
|
|
80
|
+
* Use this method to track actions like LLM costs and sending signals.
|
|
81
|
+
* The callback to this function is the work that you want to trace.
|
|
82
|
+
*
|
|
83
|
+
* @param externalCustomerId - The external customer ID
|
|
84
|
+
* @param fn - The callback function containing the work to be traced
|
|
85
|
+
* @param externalAgentId - @deprecated Use externalProductId instead
|
|
86
|
+
* @param externalProductId - The external product ID
|
|
87
|
+
* @param storePrompt - Whether to store the prompt (defaults to false)
|
|
88
|
+
* @param args - Arguments to pass to the callback function
|
|
89
|
+
* @returns The return value of the callback function
|
|
90
|
+
*/
|
|
91
|
+
trace(externalCustomerId_1, fn_1, externalAgentId_1, externalProductId_1) {
|
|
92
|
+
return __awaiter(this, arguments, void 0, function* (externalCustomerId, fn, externalAgentId, externalProductId, storePrompt = false, ...args) {
|
|
93
|
+
// TODO: remove this after deprecation and replace externalAgentId with externalProductId everywhere
|
|
94
|
+
if (externalProductId) {
|
|
95
|
+
externalAgentId = externalProductId;
|
|
96
|
+
}
|
|
97
|
+
return yield trace({ externalCustomerId, externalProductId: externalAgentId, storePrompt }, fn, ...args);
|
|
67
98
|
});
|
|
68
99
|
}
|
|
69
100
|
signal(eventName, enableCostTracingOrData, data) {
|
|
70
101
|
let enableCostTracing = false;
|
|
71
102
|
let finalData;
|
|
72
|
-
if (typeof enableCostTracingOrData ===
|
|
103
|
+
if (typeof enableCostTracingOrData === "boolean") {
|
|
73
104
|
// Case: signal(eventName, boolean, data?)
|
|
74
105
|
enableCostTracing = enableCostTracingOrData;
|
|
75
106
|
finalData = data;
|
|
76
107
|
}
|
|
77
|
-
else if (typeof enableCostTracingOrData ===
|
|
108
|
+
else if (typeof enableCostTracingOrData === "object") {
|
|
78
109
|
// Case: signal(eventName, data)
|
|
79
110
|
enableCostTracing = false;
|
|
80
111
|
finalData = enableCostTracingOrData;
|
|
81
112
|
}
|
|
82
113
|
// Case: signal(eventName) - both remain default/undefined
|
|
83
|
-
return
|
|
114
|
+
return signal(eventName, enableCostTracing, finalData);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* @deprecated use the standalone 'getPaidTracerProvider()' instead
|
|
118
|
+
* Export the tracer provider which user can use for his own tracing.
|
|
119
|
+
*/
|
|
120
|
+
get tracerProvider() {
|
|
121
|
+
return getPaidTracerProvider();
|
|
84
122
|
}
|
|
85
123
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as errors from "../../errors/index.mjs";
|
|
5
|
+
import * as Paid from "../index.mjs";
|
|
6
|
+
import * as core from "../../core/index.mjs";
|
|
7
|
+
export declare class InternalServerError extends errors.PaidError {
|
|
8
|
+
constructor(body: Paid.Error_, rawResponse?: core.RawResponse);
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as errors from "../../errors/index.mjs";
|
|
5
|
+
export class InternalServerError extends errors.PaidError {
|
|
6
|
+
constructor(body, rawResponse) {
|
|
7
|
+
super({
|
|
8
|
+
message: "InternalServerError",
|
|
9
|
+
statusCode: 500,
|
|
10
|
+
body: body,
|
|
11
|
+
rawResponse: rawResponse,
|
|
12
|
+
});
|
|
13
|
+
Object.setPrototypeOf(this, InternalServerError.prototype);
|
|
14
|
+
}
|
|
15
|
+
}
|
package/dist/esm/api/index.d.mts
CHANGED
package/dist/esm/api/index.mjs
CHANGED