@withgateway/sdk 0.1.7 → 0.1.8
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +64 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -0
- package/dist/index.mjs.map +1 -1
- package/dist/tracing/index.js +64 -0
- package/dist/tracing/index.js.map +1 -1
- package/dist/tracing/index.mjs +64 -0
- package/dist/tracing/index.mjs.map +1 -1
- package/dist/users/index.d.mts +50 -1
- package/dist/users/index.d.ts +50 -1
- package/dist/users/index.js +64 -0
- package/dist/users/index.js.map +1 -1
- package/dist/users/index.mjs +64 -0
- package/dist/users/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ export { Persona, PersonaError, PersonaMessage, PersonaReply, PersonasClient, Pe
|
|
|
5
5
|
export { DriftError, LocalTool, MissPolicy, REPLAY_ENVIRONMENT, RecordedToolCall, ReplayAgent, ReplayCase, ReplayCheck, ReplayCredentials, ReplayError, ReplayMode, ReplayReport, ReplayStatus, ReplaySuite, ReplaySuiteLoadOptions, ReplayTask, RunSuiteOptions, SessionLoader, StubCallLogEntry, StubFallback, StubMatch, StubMissError, StubRegistryMapping, ToolStub, ToolStubRegistry, TraceDiff, replay, runSuite, suite } from './replay/index.mjs';
|
|
6
6
|
export { GatewayAgentDescriptor, GatewaySecurity, GatewaySecurityConfig, GatewaySecurityContext, GatewaySecurityError, GatewayToolApprovalRequiredError, GatewayToolBlockedError, GatewayToolCallAuthorizeResponse, GatewayToolDescriptor, GatewayToolsetResolveResponse, SecureToolsOptions, gateway } from './security/index.mjs';
|
|
7
7
|
export { DEFAULT_TIMEOUT_SECONDS, ENV_GATEWAY_HOST, ENV_GATEWAY_PUBLIC_KEY, ENV_GATEWAY_SECRET_KEY, LoadSessionOptions, SessionLoadError, SessionObservation, SessionRecording, SessionTrace, basicAuthHeader, loadSession, sessionObservationFromApi, sessions } from './sessions/index.mjs';
|
|
8
|
-
export { UserProfile, UserProfileError, UserProfileUpdate, UsersClient, UsersClientConfig, UsersClientFromEnvConfig, users } from './users/index.mjs';
|
|
8
|
+
export { UserEvent, UserEventOptions, UserProfile, UserProfileError, UserProfileUpdate, UsersClient, UsersClientConfig, UsersClientFromEnvConfig, users } from './users/index.mjs';
|
|
9
9
|
import { _ as _tracingModule } from './index-CubrUmOe.mjs';
|
|
10
10
|
export { I as IdentifyOptions, i as identify, r as resolveUserId } from './index-CubrUmOe.mjs';
|
|
11
11
|
import 'async_hooks';
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { Persona, PersonaError, PersonaMessage, PersonaReply, PersonasClient, Pe
|
|
|
5
5
|
export { DriftError, LocalTool, MissPolicy, REPLAY_ENVIRONMENT, RecordedToolCall, ReplayAgent, ReplayCase, ReplayCheck, ReplayCredentials, ReplayError, ReplayMode, ReplayReport, ReplayStatus, ReplaySuite, ReplaySuiteLoadOptions, ReplayTask, RunSuiteOptions, SessionLoader, StubCallLogEntry, StubFallback, StubMatch, StubMissError, StubRegistryMapping, ToolStub, ToolStubRegistry, TraceDiff, replay, runSuite, suite } from './replay/index.js';
|
|
6
6
|
export { GatewayAgentDescriptor, GatewaySecurity, GatewaySecurityConfig, GatewaySecurityContext, GatewaySecurityError, GatewayToolApprovalRequiredError, GatewayToolBlockedError, GatewayToolCallAuthorizeResponse, GatewayToolDescriptor, GatewayToolsetResolveResponse, SecureToolsOptions, gateway } from './security/index.js';
|
|
7
7
|
export { DEFAULT_TIMEOUT_SECONDS, ENV_GATEWAY_HOST, ENV_GATEWAY_PUBLIC_KEY, ENV_GATEWAY_SECRET_KEY, LoadSessionOptions, SessionLoadError, SessionObservation, SessionRecording, SessionTrace, basicAuthHeader, loadSession, sessionObservationFromApi, sessions } from './sessions/index.js';
|
|
8
|
-
export { UserProfile, UserProfileError, UserProfileUpdate, UsersClient, UsersClientConfig, UsersClientFromEnvConfig, users } from './users/index.js';
|
|
8
|
+
export { UserEvent, UserEventOptions, UserProfile, UserProfileError, UserProfileUpdate, UsersClient, UsersClientConfig, UsersClientFromEnvConfig, users } from './users/index.js';
|
|
9
9
|
import { _ as _tracingModule } from './index-CubrUmOe.js';
|
|
10
10
|
export { I as IdentifyOptions, i as identify, r as resolveUserId } from './index-CubrUmOe.js';
|
|
11
11
|
import 'async_hooks';
|
package/dist/index.js
CHANGED
|
@@ -2542,6 +2542,58 @@ var UsersClient = class _UsersClient {
|
|
|
2542
2542
|
await this.requestJson("POST", "/api/public/user-profiles", body)
|
|
2543
2543
|
);
|
|
2544
2544
|
}
|
|
2545
|
+
/**
|
|
2546
|
+
* Record a VALUE EVENT for a user — the per-user ROI stream. `value` is
|
|
2547
|
+
* whatever the event is worth in your terms (minutes saved, revenue…);
|
|
2548
|
+
* Gateway sums it in the hours-saved/ROI rollups, and evals and task-set
|
|
2549
|
+
* replays can assert against the events. Link `traceId`/`sessionId` to tie
|
|
2550
|
+
* the event to the run that produced it.
|
|
2551
|
+
*
|
|
2552
|
+
* @example
|
|
2553
|
+
* ```ts
|
|
2554
|
+
* await client.trackEvent("user-123", "checkout_completed", {
|
|
2555
|
+
* value: 25,
|
|
2556
|
+
* metadata: { cartSize: 3 },
|
|
2557
|
+
* sessionId,
|
|
2558
|
+
* });
|
|
2559
|
+
* ```
|
|
2560
|
+
*/
|
|
2561
|
+
async trackEvent(userId, event, options = {}) {
|
|
2562
|
+
const body = {
|
|
2563
|
+
userId,
|
|
2564
|
+
event,
|
|
2565
|
+
metadata: options.metadata ?? {},
|
|
2566
|
+
...options.value !== void 0 ? { value: options.value } : {},
|
|
2567
|
+
...options.traceId !== void 0 ? { traceId: options.traceId } : {},
|
|
2568
|
+
...options.sessionId !== void 0 ? { sessionId: options.sessionId } : {}
|
|
2569
|
+
};
|
|
2570
|
+
return parseEvent(
|
|
2571
|
+
await this.requestJson("POST", "/api/public/user-events", body)
|
|
2572
|
+
);
|
|
2573
|
+
}
|
|
2574
|
+
/** List a project's user events, optionally filtered by user/event/time. */
|
|
2575
|
+
async listEvents(filter = {}) {
|
|
2576
|
+
const params = new URLSearchParams();
|
|
2577
|
+
if (filter.userId) params.set("userId", filter.userId);
|
|
2578
|
+
if (filter.event) params.set("event", filter.event);
|
|
2579
|
+
if (filter.fromTimestamp)
|
|
2580
|
+
params.set("fromTimestamp", filter.fromTimestamp.toISOString());
|
|
2581
|
+
if (filter.toTimestamp)
|
|
2582
|
+
params.set("toTimestamp", filter.toTimestamp.toISOString());
|
|
2583
|
+
if (filter.page) params.set("page", String(filter.page));
|
|
2584
|
+
if (filter.limit) params.set("limit", String(filter.limit));
|
|
2585
|
+
const qs = params.toString();
|
|
2586
|
+
const payload = await this.requestJson(
|
|
2587
|
+
"GET",
|
|
2588
|
+
`/api/public/user-events${qs ? `?${qs}` : ""}`
|
|
2589
|
+
);
|
|
2590
|
+
const rows = Array.isArray(payload.data) ? payload.data : [];
|
|
2591
|
+
const meta = payload.meta && typeof payload.meta === "object" ? payload.meta : {};
|
|
2592
|
+
return {
|
|
2593
|
+
data: rows.map((row) => parseEvent(row)),
|
|
2594
|
+
totalItems: Number(meta.totalItems ?? rows.length)
|
|
2595
|
+
};
|
|
2596
|
+
}
|
|
2545
2597
|
async requestJson(method, path, payload) {
|
|
2546
2598
|
let response;
|
|
2547
2599
|
try {
|
|
@@ -2580,6 +2632,18 @@ var UsersClient = class _UsersClient {
|
|
|
2580
2632
|
}
|
|
2581
2633
|
}
|
|
2582
2634
|
};
|
|
2635
|
+
function parseEvent(payload) {
|
|
2636
|
+
return {
|
|
2637
|
+
id: String(payload.id ?? ""),
|
|
2638
|
+
userId: String(payload.userId ?? ""),
|
|
2639
|
+
event: String(payload.event ?? ""),
|
|
2640
|
+
value: typeof payload.value === "number" ? payload.value : null,
|
|
2641
|
+
metadata: payload.metadata && typeof payload.metadata === "object" && !Array.isArray(payload.metadata) ? payload.metadata : {},
|
|
2642
|
+
traceId: typeof payload.traceId === "string" ? payload.traceId : null,
|
|
2643
|
+
sessionId: typeof payload.sessionId === "string" ? payload.sessionId : null,
|
|
2644
|
+
createdAt: typeof payload.createdAt === "string" ? new Date(payload.createdAt) : /* @__PURE__ */ new Date(0)
|
|
2645
|
+
};
|
|
2646
|
+
}
|
|
2583
2647
|
function parseProfile(payload) {
|
|
2584
2648
|
return {
|
|
2585
2649
|
userId: String(payload.userId ?? ""),
|