@waniwani/sdk 0.15.1 → 0.16.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/dist/chat/embed.js +62 -62
- package/dist/chat/embed.js.map +1 -1
- package/dist/chat/express-js/index.d.ts +20 -14
- package/dist/chat/index.d.ts +259 -0
- package/dist/chat/index.js +7 -7
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/next-js/index.d.ts +20 -14
- package/dist/chunk-GYLVCP7M.js +3 -0
- package/dist/chunk-GYLVCP7M.js.map +1 -0
- package/dist/index.d.ts +91 -15
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/legacy/chat/express-js/index.d.ts +20 -14
- package/dist/legacy/chat/next-js/index.d.ts +20 -14
- package/dist/legacy/index.d.ts +42 -14
- package/dist/legacy/index.js +11 -11
- package/dist/legacy/index.js.map +1 -1
- package/dist/mcp/index.d.ts +46 -20
- package/dist/mcp/index.js +5 -5
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/react.d.ts +286 -43
- package/dist/mcp/react.js +7 -7
- package/dist/mcp/react.js.map +1 -1
- package/dist/widget-client-4MBLDRHD.js +3 -0
- package/dist/widget-client-4MBLDRHD.js.map +1 -0
- package/package.json +1 -1
package/dist/legacy/index.d.ts
CHANGED
|
@@ -137,7 +137,14 @@ interface KbClient {
|
|
|
137
137
|
sources(): Promise<KbSource[]>;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
/**
|
|
141
|
+
* Every event name in the typed taxonomy, as a runtime list. Single source of
|
|
142
|
+
* truth for {@link EventType} and for surfaces that need to recognize
|
|
143
|
+
* first-class names at runtime (the widget transport passes these through
|
|
144
|
+
* verbatim instead of namespacing them as custom widget events).
|
|
145
|
+
*/
|
|
146
|
+
declare const EVENT_TYPES: readonly ["session.started", "page.viewed", "tool.called", "quote.requested", "quote.succeeded", "quote.failed", "link.clicked", "purchase.completed", "widget_render", "user.identified", "price_shown", "prices_compared", "option_selected", "lead_qualified", "converted"];
|
|
147
|
+
type EventType = (typeof EVENT_TYPES)[number];
|
|
141
148
|
/**
|
|
142
149
|
* Properties for `page.viewed` — emitted once when the chat widget initializes
|
|
143
150
|
* on a host page (the top of the funnel). Attributed to the anonymous
|
|
@@ -211,8 +218,6 @@ interface LeadQualifiedProperties {
|
|
|
211
218
|
email?: string;
|
|
212
219
|
/** The lead's name, if known. */
|
|
213
220
|
name?: string;
|
|
214
|
-
/** Acquisition source of the lead (e.g. "newsletter"). */
|
|
215
|
-
source?: string;
|
|
216
221
|
}
|
|
217
222
|
interface ConvertedProperties {
|
|
218
223
|
amount: number;
|
|
@@ -237,6 +242,13 @@ interface TrackingContext {
|
|
|
237
242
|
requestId?: string;
|
|
238
243
|
correlationId?: string;
|
|
239
244
|
externalUserId?: string;
|
|
245
|
+
/**
|
|
246
|
+
* Anonymous visitor id (the analytics "device id"). Counts as identity on
|
|
247
|
+
* its own: the ingest API accepts `sessionId`, `externalUserId`, or
|
|
248
|
+
* `visitorId`. The chat widget uses it for pre-session events like
|
|
249
|
+
* `page.viewed`.
|
|
250
|
+
*/
|
|
251
|
+
visitorId?: string;
|
|
240
252
|
/** Optional explicit envelope fields. */
|
|
241
253
|
eventId?: string;
|
|
242
254
|
timestamp?: string | Date;
|
|
@@ -272,6 +284,8 @@ type TrackEvent = ({
|
|
|
272
284
|
properties?: PurchaseCompletedProperties;
|
|
273
285
|
} & BaseTrackEvent) | ({
|
|
274
286
|
event: "user.identified";
|
|
287
|
+
} & BaseTrackEvent) | ({
|
|
288
|
+
event: "widget_render";
|
|
275
289
|
} & BaseTrackEvent) | ({
|
|
276
290
|
event: "price_shown";
|
|
277
291
|
properties?: PriceShownProperties;
|
|
@@ -313,10 +327,9 @@ interface RevenuePricesComparedInput extends TrackingContext, PricesComparedProp
|
|
|
313
327
|
interface RevenueOptionSelectedInput extends TrackingContext, OptionSelectedProperties {
|
|
314
328
|
}
|
|
315
329
|
/**
|
|
316
|
-
* Input for `track.leadQualified()
|
|
317
|
-
*
|
|
318
|
-
* envelope `source`
|
|
319
|
-
* on a lead, use the generic `track({ event: "lead_qualified", … })`.
|
|
330
|
+
* Input for `track.leadQualified()` — identity only (`externalId`, `email`,
|
|
331
|
+
* `name`) plus the shared tracking context. There is no acquisition-source
|
|
332
|
+
* property; the envelope `source` (the origin channel) is set automatically.
|
|
320
333
|
*/
|
|
321
334
|
interface RevenueLeadQualifiedInput extends TrackingContext, LeadQualifiedProperties {
|
|
322
335
|
}
|
|
@@ -340,13 +353,6 @@ interface RevenueTrackingApi {
|
|
|
340
353
|
leadQualified: (input?: RevenueLeadQualifiedInput) => Promise<{
|
|
341
354
|
eventId: string;
|
|
342
355
|
}>;
|
|
343
|
-
/**
|
|
344
|
-
* @deprecated Renamed in 0.15.0. Use `track.leadQualified()` instead; this
|
|
345
|
-
* alias emits a `lead_qualified` event and will be removed in 0.16.0.
|
|
346
|
-
*/
|
|
347
|
-
lead: (input?: RevenueLeadQualifiedInput) => Promise<{
|
|
348
|
-
eventId: string;
|
|
349
|
-
}>;
|
|
350
356
|
converted: (input: RevenueConvertedInput) => Promise<{
|
|
351
357
|
eventId: string;
|
|
352
358
|
}>;
|
|
@@ -422,6 +428,13 @@ interface TrackingClient {
|
|
|
422
428
|
* when the server is wrapped with `withWaniwani()`.
|
|
423
429
|
*/
|
|
424
430
|
interface ScopedWaniWaniClient {
|
|
431
|
+
/**
|
|
432
|
+
* The session id this request's events correlate to, resolved from the
|
|
433
|
+
* request meta. Read it to link the session to your own records (store it
|
|
434
|
+
* on a lead, then send an off-platform `converted` with the same
|
|
435
|
+
* `sessionId` later). `undefined` when the host provided no session id.
|
|
436
|
+
*/
|
|
437
|
+
readonly sessionId?: string;
|
|
425
438
|
/**
|
|
426
439
|
* Track an event — request meta is automatically merged. Also exposes the
|
|
427
440
|
* revenue helpers flat (`track.priceShown()`, `track.converted()`, …), which
|
|
@@ -1656,6 +1669,21 @@ interface ChatHandle {
|
|
|
1656
1669
|
messages: ai.UIMessage[];
|
|
1657
1670
|
/** Session ID used for event correlation. Available after the first message. */
|
|
1658
1671
|
sessionId: string | undefined;
|
|
1672
|
+
/**
|
|
1673
|
+
* Track a funnel event from the host page with the chat session attached
|
|
1674
|
+
* automatically. Same surface as the server client: callable with a typed
|
|
1675
|
+
* event, plus the flat revenue helpers (`track.converted({ ... })`, ...).
|
|
1676
|
+
* Present on `WaniwaniChat` (hosted); absent on the bare `ChatEmbed`
|
|
1677
|
+
* primitive, which has no Waniwani credential to send events with.
|
|
1678
|
+
*/
|
|
1679
|
+
track?: TrackFn;
|
|
1680
|
+
/**
|
|
1681
|
+
* Tie the visitor to a stable user id (emits `user.identified`).
|
|
1682
|
+
* Present on `WaniwaniChat` only, like `track`.
|
|
1683
|
+
*/
|
|
1684
|
+
identify?: (userId: string, traits?: Record<string, unknown>) => Promise<{
|
|
1685
|
+
eventId: string;
|
|
1686
|
+
}>;
|
|
1659
1687
|
}
|
|
1660
1688
|
|
|
1661
1689
|
/** @deprecated Use `WaniwaniChat` (hosted, React) or the `<script>` embed for new code. `ChatCard` is preserved for back-compat only and lives under `@waniwani/sdk/legacy`. */
|