@waniwani/sdk 0.12.18 → 0.13.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 +20 -3
- package/dist/chat/express-js/index.d.ts +96 -4
- package/dist/chat/next-js/index.d.ts +96 -4
- package/dist/index.d.ts +97 -5
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/legacy/chat/express-js/index.d.ts +96 -4
- package/dist/legacy/chat/next-js/index.d.ts +96 -4
- package/dist/legacy/index.d.ts +102 -8
- package/dist/legacy/index.js +11 -11
- package/dist/legacy/index.js.map +1 -1
- package/dist/mcp/index.d.ts +113 -9
- package/dist/mcp/index.js +5 -5
- package/dist/mcp/index.js.map +1 -1
- package/package.json +1 -1
package/dist/legacy/index.d.ts
CHANGED
|
@@ -132,7 +132,7 @@ interface KbClient {
|
|
|
132
132
|
sources(): Promise<KbSource[]>;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
type EventType = "session.started" | "tool.called" | "quote.requested" | "quote.succeeded" | "quote.failed" | "link.clicked" | "purchase.completed" | "widget_render" | "widget_click" | "widget_link_click" | "widget_error" | "widget_scroll" | "widget_form_field" | "widget_form_submit" | "user.identified";
|
|
135
|
+
type EventType = "session.started" | "tool.called" | "quote.requested" | "quote.succeeded" | "quote.failed" | "link.clicked" | "purchase.completed" | "widget_render" | "widget_click" | "widget_link_click" | "widget_error" | "widget_scroll" | "widget_form_field" | "widget_form_submit" | "user.identified" | "price_shown" | "prices_compared" | "option_selected" | "lead" | "converted";
|
|
136
136
|
interface ToolCalledProperties {
|
|
137
137
|
name?: string;
|
|
138
138
|
type?: "pricing" | "product_info" | "availability" | "support" | "other";
|
|
@@ -148,6 +148,34 @@ interface PurchaseCompletedProperties {
|
|
|
148
148
|
amount?: number;
|
|
149
149
|
currency?: string;
|
|
150
150
|
}
|
|
151
|
+
interface PriceShownProperties {
|
|
152
|
+
amount: number;
|
|
153
|
+
currency: string;
|
|
154
|
+
itemId?: string;
|
|
155
|
+
label?: string;
|
|
156
|
+
}
|
|
157
|
+
interface ComparedPriceOption {
|
|
158
|
+
id: string;
|
|
159
|
+
amount: number;
|
|
160
|
+
currency: string;
|
|
161
|
+
}
|
|
162
|
+
interface PricesComparedProperties {
|
|
163
|
+
options: ComparedPriceOption[];
|
|
164
|
+
}
|
|
165
|
+
interface OptionSelectedProperties {
|
|
166
|
+
id: string;
|
|
167
|
+
amount: number;
|
|
168
|
+
currency: string;
|
|
169
|
+
}
|
|
170
|
+
interface LeadProperties {
|
|
171
|
+
source?: string;
|
|
172
|
+
}
|
|
173
|
+
interface ConvertedProperties {
|
|
174
|
+
amount: number;
|
|
175
|
+
currency: string;
|
|
176
|
+
/** When the conversion actually happened — for backdated off-platform sales. */
|
|
177
|
+
occurredAt?: string;
|
|
178
|
+
}
|
|
151
179
|
interface TrackingContext {
|
|
152
180
|
/**
|
|
153
181
|
* MCP request metadata passed through to the API.
|
|
@@ -197,6 +225,21 @@ type TrackEvent = ({
|
|
|
197
225
|
properties?: PurchaseCompletedProperties;
|
|
198
226
|
} & BaseTrackEvent) | ({
|
|
199
227
|
event: "user.identified";
|
|
228
|
+
} & BaseTrackEvent) | ({
|
|
229
|
+
event: "price_shown";
|
|
230
|
+
properties?: PriceShownProperties;
|
|
231
|
+
} & BaseTrackEvent) | ({
|
|
232
|
+
event: "prices_compared";
|
|
233
|
+
properties?: PricesComparedProperties;
|
|
234
|
+
} & BaseTrackEvent) | ({
|
|
235
|
+
event: "option_selected";
|
|
236
|
+
properties?: OptionSelectedProperties;
|
|
237
|
+
} & BaseTrackEvent) | ({
|
|
238
|
+
event: "lead";
|
|
239
|
+
properties?: LeadProperties;
|
|
240
|
+
} & BaseTrackEvent) | ({
|
|
241
|
+
event: "converted";
|
|
242
|
+
properties?: ConvertedProperties;
|
|
200
243
|
} & BaseTrackEvent);
|
|
201
244
|
/**
|
|
202
245
|
* Legacy tracking shape supported for existing integrations.
|
|
@@ -216,6 +259,54 @@ interface LegacyTrackEvent extends TrackingContext {
|
|
|
216
259
|
* Public track input accepted by `client.track()`.
|
|
217
260
|
*/
|
|
218
261
|
type TrackInput = TrackEvent | LegacyTrackEvent;
|
|
262
|
+
interface RevenuePriceShownInput extends TrackingContext, PriceShownProperties {
|
|
263
|
+
}
|
|
264
|
+
interface RevenuePricesComparedInput extends TrackingContext, PricesComparedProperties {
|
|
265
|
+
}
|
|
266
|
+
interface RevenueOptionSelectedInput extends TrackingContext, OptionSelectedProperties {
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Input for `track.lead()`. `source` is the lead's acquisition source
|
|
270
|
+
* (the `lead` event property, e.g. "newsletter") — on this helper it shadows
|
|
271
|
+
* the envelope `source` from the tracking context. To set a custom envelope
|
|
272
|
+
* source on a lead, use the generic `track({ event: "lead", … })`.
|
|
273
|
+
*/
|
|
274
|
+
interface RevenueLeadInput extends TrackingContext, LeadProperties {
|
|
275
|
+
}
|
|
276
|
+
interface RevenueConvertedInput extends TrackingContext, ConvertedProperties {
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Revenue-oriented helpers, flat on `client.track.*` (e.g.
|
|
280
|
+
* `client.track.priceShown()`, `client.track.converted()`). Decoupled from
|
|
281
|
+
* product primitives — each maps to a typed first-class revenue event.
|
|
282
|
+
*/
|
|
283
|
+
interface RevenueTrackingApi {
|
|
284
|
+
priceShown: (input: RevenuePriceShownInput) => Promise<{
|
|
285
|
+
eventId: string;
|
|
286
|
+
}>;
|
|
287
|
+
pricesCompared: (input: RevenuePricesComparedInput) => Promise<{
|
|
288
|
+
eventId: string;
|
|
289
|
+
}>;
|
|
290
|
+
optionSelected: (input: RevenueOptionSelectedInput) => Promise<{
|
|
291
|
+
eventId: string;
|
|
292
|
+
}>;
|
|
293
|
+
lead: (input?: RevenueLeadInput) => Promise<{
|
|
294
|
+
eventId: string;
|
|
295
|
+
}>;
|
|
296
|
+
converted: (input: RevenueConvertedInput) => Promise<{
|
|
297
|
+
eventId: string;
|
|
298
|
+
}>;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* `client.track` — callable for generic events (`track(event)`), with the
|
|
302
|
+
* revenue helpers attached flat: `track.priceShown()`, `track.lead()`,
|
|
303
|
+
* `track.converted()`, etc.
|
|
304
|
+
*/
|
|
305
|
+
interface TrackFn extends RevenueTrackingApi {
|
|
306
|
+
(event: TrackInput): Promise<{
|
|
307
|
+
eventId: string;
|
|
308
|
+
}>;
|
|
309
|
+
}
|
|
219
310
|
interface TrackingConfig {
|
|
220
311
|
/** Events API V2 endpoint path. */
|
|
221
312
|
endpointPath?: string;
|
|
@@ -255,10 +346,11 @@ interface TrackingClient {
|
|
|
255
346
|
/**
|
|
256
347
|
* Track an event using modern or legacy input shape.
|
|
257
348
|
* Returns a deterministic event id immediately after enqueue.
|
|
349
|
+
*
|
|
350
|
+
* Also exposes the revenue helpers flat: `client.track.priceShown()`,
|
|
351
|
+
* `client.track.lead()`, `client.track.converted()`, etc.
|
|
258
352
|
*/
|
|
259
|
-
track:
|
|
260
|
-
eventId: string;
|
|
261
|
-
}>;
|
|
353
|
+
track: TrackFn;
|
|
262
354
|
/**
|
|
263
355
|
* Flush all currently buffered events.
|
|
264
356
|
*/
|
|
@@ -276,10 +368,12 @@ interface TrackingClient {
|
|
|
276
368
|
* when the server is wrapped with `withWaniwani()`.
|
|
277
369
|
*/
|
|
278
370
|
interface ScopedWaniWaniClient {
|
|
279
|
-
/**
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
371
|
+
/**
|
|
372
|
+
* Track an event — request meta is automatically merged. Also exposes the
|
|
373
|
+
* revenue helpers flat (`track.priceShown()`, `track.converted()`, …), which
|
|
374
|
+
* inherit the same scoped meta (so identity is carried from the request).
|
|
375
|
+
*/
|
|
376
|
+
track: TrackFn;
|
|
283
377
|
/** Identify a user — request meta is automatically merged. */
|
|
284
378
|
identify(userId: string, properties?: Record<string, unknown>): Promise<{
|
|
285
379
|
eventId: string;
|