@waniwani/sdk 0.18.0 → 0.18.1
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/chat/embed.js +93 -93
- package/dist/chat/embed.js.map +1 -1
- package/dist/chat/express-js/index.d.ts +1 -23
- package/dist/chat/index.d.ts +101 -24
- package/dist/chat/index.js +7 -7
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/next-js/index.d.ts +1 -23
- package/dist/index.d.ts +2 -24
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/legacy/chat/express-js/index.d.ts +1 -23
- package/dist/legacy/chat/next-js/index.d.ts +1 -23
- package/dist/legacy/index.d.ts +39 -23
- package/dist/legacy/index.js +13 -13
- package/dist/legacy/index.js.map +1 -1
- package/dist/mcp/index.d.ts +16 -23
- package/dist/mcp/index.js +5 -5
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/react/skybridge.d.ts +2 -24
- package/dist/mcp/react/skybridge.js +1 -1
- package/dist/mcp/react/skybridge.js.map +1 -1
- package/dist/mcp/react.d.ts +2 -24
- package/dist/mcp/react.js +4 -4
- package/dist/mcp/react.js.map +1 -1
- package/package.json +1 -1
package/dist/legacy/index.d.ts
CHANGED
|
@@ -143,7 +143,7 @@ interface KbClient {
|
|
|
143
143
|
* first-class names at runtime (the widget transport passes these through
|
|
144
144
|
* verbatim instead of namespacing them as custom widget events).
|
|
145
145
|
*/
|
|
146
|
-
declare const EVENT_TYPES: readonly ["session.started", "page.viewed", "tool.called", "
|
|
146
|
+
declare const EVENT_TYPES: readonly ["session.started", "page.viewed", "tool.called", "link.clicked", "widget_render", "user.identified", "price_shown", "prices_compared", "option_selected", "lead_qualified", "converted"];
|
|
147
147
|
type EventType = (typeof EVENT_TYPES)[number];
|
|
148
148
|
/**
|
|
149
149
|
* Properties for `page.viewed` — emitted once when the chat widget initializes
|
|
@@ -172,17 +172,9 @@ interface ToolCalledProperties {
|
|
|
172
172
|
/** Retrieval traces for kb.search() calls made inside this tool handler. */
|
|
173
173
|
kbSearch?: KbSearchTrace[];
|
|
174
174
|
}
|
|
175
|
-
interface QuoteSucceededProperties {
|
|
176
|
-
amount?: number;
|
|
177
|
-
currency?: string;
|
|
178
|
-
}
|
|
179
175
|
interface LinkClickedProperties {
|
|
180
176
|
url?: string;
|
|
181
177
|
}
|
|
182
|
-
interface PurchaseCompletedProperties {
|
|
183
|
-
amount?: number;
|
|
184
|
-
currency?: string;
|
|
185
|
-
}
|
|
186
178
|
interface PriceShownProperties {
|
|
187
179
|
amount: number;
|
|
188
180
|
currency: string;
|
|
@@ -269,19 +261,9 @@ type TrackEvent = ({
|
|
|
269
261
|
} & BaseTrackEvent) | ({
|
|
270
262
|
event: "tool.called";
|
|
271
263
|
properties?: ToolCalledProperties;
|
|
272
|
-
} & BaseTrackEvent) | ({
|
|
273
|
-
event: "quote.requested";
|
|
274
|
-
} & BaseTrackEvent) | ({
|
|
275
|
-
event: "quote.succeeded";
|
|
276
|
-
properties?: QuoteSucceededProperties;
|
|
277
|
-
} & BaseTrackEvent) | ({
|
|
278
|
-
event: "quote.failed";
|
|
279
264
|
} & BaseTrackEvent) | ({
|
|
280
265
|
event: "link.clicked";
|
|
281
266
|
properties?: LinkClickedProperties;
|
|
282
|
-
} & BaseTrackEvent) | ({
|
|
283
|
-
event: "purchase.completed";
|
|
284
|
-
properties?: PurchaseCompletedProperties;
|
|
285
267
|
} & BaseTrackEvent) | ({
|
|
286
268
|
event: "user.identified";
|
|
287
269
|
} & BaseTrackEvent) | ({
|
|
@@ -310,11 +292,7 @@ interface LegacyTrackEvent extends TrackingContext {
|
|
|
310
292
|
properties?: Record<string, unknown>;
|
|
311
293
|
toolName?: string;
|
|
312
294
|
toolType?: ToolCalledProperties["type"];
|
|
313
|
-
quoteAmount?: number;
|
|
314
|
-
quoteCurrency?: string;
|
|
315
295
|
linkUrl?: string;
|
|
316
|
-
purchaseAmount?: number;
|
|
317
|
-
purchaseCurrency?: string;
|
|
318
296
|
}
|
|
319
297
|
/**
|
|
320
298
|
* Public track input accepted by `client.track()`.
|
|
@@ -435,6 +413,21 @@ interface ScopedWaniWaniClient {
|
|
|
435
413
|
* `sessionId` later). `undefined` when the host provided no session id.
|
|
436
414
|
*/
|
|
437
415
|
readonly sessionId?: string;
|
|
416
|
+
/**
|
|
417
|
+
* The anonymous visitor id, resolved from the request meta. Present on the
|
|
418
|
+
* web chat surface (a persisted per-device id threaded through as
|
|
419
|
+
* `waniwani/visitorId`); `undefined` on hosts that do not supply one, such
|
|
420
|
+
* as Claude. Ingest accepts it as an identity in its own right, so use it
|
|
421
|
+
* to correlate events before a session or user id exists.
|
|
422
|
+
*/
|
|
423
|
+
readonly visitorId?: string;
|
|
424
|
+
/**
|
|
425
|
+
* The external user id, resolved from the request meta (e.g. `openai/userId`
|
|
426
|
+
* for ChatGPT's anonymous users, or a host-provided `externalUserId`). Read
|
|
427
|
+
* it alongside `sessionId`/`visitorId` — whichever the current host provides.
|
|
428
|
+
* `undefined` when the host supplied no user id.
|
|
429
|
+
*/
|
|
430
|
+
readonly externalUserId?: string;
|
|
438
431
|
/**
|
|
439
432
|
* Track an event — request meta is automatically merged. Also exposes the
|
|
440
433
|
* revenue helpers flat (`track.priceShown()`, `track.converted()`, …), which
|
|
@@ -1436,6 +1429,14 @@ type DeepPartial<T> = T extends (...args: never[]) => unknown ? T : T extends ob
|
|
|
1436
1429
|
} : T;
|
|
1437
1430
|
type MessageOverrides = DeepPartial<Messages>;
|
|
1438
1431
|
|
|
1432
|
+
/**
|
|
1433
|
+
* A visitor id to apply, or a resolver that produces one. The resolver may be
|
|
1434
|
+
* sync (`() => posthog.get_distinct_id()`) or async
|
|
1435
|
+
* (`async () => (await sdk.ready()).id`), for analytics SDKs whose id is only
|
|
1436
|
+
* available after they bootstrap.
|
|
1437
|
+
*/
|
|
1438
|
+
type VisitorIdInput = string | (() => string | undefined | null | Promise<string | undefined | null>);
|
|
1439
|
+
|
|
1439
1440
|
/**
|
|
1440
1441
|
* Built-in theme presets. `auto` follows the host's `prefers-color-scheme`
|
|
1441
1442
|
* and switches at runtime without re-rendering.
|
|
@@ -1594,6 +1595,21 @@ interface ChatBaseProps {
|
|
|
1594
1595
|
appearance?: ChatAppearance;
|
|
1595
1596
|
/** Per-slot class name overrides. See {@link ChatClassNames}. */
|
|
1596
1597
|
classNames?: ChatClassNames;
|
|
1598
|
+
/**
|
|
1599
|
+
* Override the anonymous visitor id the widget generates with one you
|
|
1600
|
+
* already track (a PostHog / Amplitude / Segment distinct id, your own
|
|
1601
|
+
* cookie, etc.). The chat sends it on every request, so Waniwani sessions
|
|
1602
|
+
* and events correlate to the same visitor, and server-side MCP tools and
|
|
1603
|
+
* flows read it back as `context.waniwani.visitorId`.
|
|
1604
|
+
*
|
|
1605
|
+
* A string, or a resolver that returns one — sync
|
|
1606
|
+
* (`() => posthog.get_distinct_id()`) or async
|
|
1607
|
+
* (`async () => (await sdk.ready()).id`), for analytics SDKs whose id is
|
|
1608
|
+
* only ready after they bootstrap. A blank / failed result is ignored, so
|
|
1609
|
+
* the auto-generated, `localStorage`-persisted id is kept. Leave unset to
|
|
1610
|
+
* always use the auto id.
|
|
1611
|
+
*/
|
|
1612
|
+
visitorId?: VisitorIdInput;
|
|
1597
1613
|
/** Additional headers to send with chat API requests */
|
|
1598
1614
|
headers?: Record<string, string>;
|
|
1599
1615
|
/** Additional body fields to send with each chat request */
|