@helpai/elements 0.21.1 → 0.23.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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as Asset, B as BlocksConfig, C as ConnectionConfig, a as ConnectionConfigPartial, L as Link, S as ServerConfig, b as SiteConfig, c as StartConversationResponse, W as WidgetConfig, d as WidgetConfigPartial, e as WidgetSettings, f as WidgetSettingsPartial } from './deployment-B8UxV4b5.js';
1
+ export { A as Asset, B as BlocksConfig, C as ConnectionConfig, a as ConnectionConfigPartial, L as Link, S as ServerConfig, b as SiteConfig, c as StartConversationResponse, W as WidgetConfig, d as WidgetConfigPartial, e as WidgetSettings, f as WidgetSettingsPartial } from './deployment-D7_pjSGq.js';
2
2
  import 'zod';
3
3
 
4
4
  /**
@@ -40,7 +40,7 @@ interface ClientStorage {
40
40
  * populated {@link Strings} map. UI components then read `strings.send` as a
41
41
  * normal property access — no per-render lookup, no per-render allocation.
42
42
  */
43
- type StringKey = "launcherOpen" | "panelTitle" | "composerPlaceholder" | "send" | "stop" | "attach" | "micStart" | "micStop" | "micUnsupported" | "expand" | "collapse" | "fullscreen" | "exitFullscreen" | "resizeHandle" | "scrollToBottom" | "popOut" | "close" | "moreActions" | "soundOn" | "soundOff" | "language" | "theme" | "themeAuto" | "themeLight" | "themeDark" | "textSize" | "textSizeSmall" | "textSizeNormal" | "textSizeLarge" | "history" | "historyTitle" | "historyEmpty" | "historyLoading" | "historyBack" | "conversationLoading" | "conversationClosed" | "startNewConversation" | "dateToday" | "dateYesterday" | "dateLastWeek" | "dateOlder" | "newConversation" | "dropZone" | "attachmentTooLarge" | "attachmentTooMany" | "attachmentMimeRejected" | "errorRetry" | "errorGeneric" | "errorRateLimited" | "loading" | "thinking" | "thoughts" | "usedTool" | "collapseSidebar" | "expandSidebar" | "formSubmit" | "formSkip" | "formSubmitted" | "formSkipped" | "formRequired" | "formInvalidEmail" | "formInvalidTel" | "formInvalidUrl" | "formInvalidNumber" | "formTooShort" | "formTooLong" | "formNumberTooSmall" | "formNumberTooLarge" | "formPatternMismatch" | "formChooseAtLeast" | "formChooseAtMost" | "formOther" | "formOtherPlaceholder" | "inputRequired" | "inputSubmit" | "inputSkip" | "inputSubmitted" | "approvalRequired" | "approve" | "reject" | "approved" | "rejected" | "approvalReason" | "stepNoLongerActive" | "tabHome" | "tabConversations" | "tabHelp" | "tabNews" | "modulesEmpty" | "moduleBack" | "contentLoading" | "homeGreeting" | "homeGreetingNamed" | "homeGreetingLead" | "homeSearchPlaceholder" | "homeContentTitle" | "helpTitle" | "helpSearchPlaceholder" | "helpEmpty" | "helpLoading" | "helpSearchEmpty" | "newsTitle" | "newsEmpty" | "newsLoading" | "newsBack" | "newsPublishedAt";
43
+ type StringKey = "launcherOpen" | "panelTitle" | "composerPlaceholder" | "send" | "stop" | "attach" | "micStart" | "micStop" | "micUnsupported" | "expand" | "collapse" | "fullscreen" | "exitFullscreen" | "resizeHandle" | "scrollToBottom" | "popOut" | "close" | "moreActions" | "soundOn" | "soundOff" | "language" | "theme" | "themeAuto" | "themeLight" | "themeDark" | "textSize" | "textSizeSmall" | "textSizeNormal" | "textSizeLarge" | "history" | "historyTitle" | "historyEmpty" | "historyLoading" | "historyBack" | "conversationLoading" | "conversationClosed" | "startNewConversation" | "dateToday" | "dateYesterday" | "dateLastWeek" | "dateOlder" | "newConversation" | "dropZone" | "attachmentTooLarge" | "attachmentTooMany" | "attachmentMimeRejected" | "errorRetry" | "errorGeneric" | "errorRateLimited" | "loading" | "thinking" | "thoughts" | "usedTool" | "collapseSidebar" | "expandSidebar" | "formSubmit" | "formSkip" | "formSubmitted" | "formSkipped" | "formFillOut" | "formRequired" | "formInvalidEmail" | "formInvalidTel" | "formInvalidUrl" | "formInvalidNumber" | "formTooShort" | "formTooLong" | "formNumberTooSmall" | "formNumberTooLarge" | "formPatternMismatch" | "formChooseAtLeast" | "formChooseAtMost" | "formOther" | "formOtherPlaceholder" | "inputRequired" | "inputSubmit" | "inputSkip" | "inputSubmitted" | "approvalRequired" | "approve" | "reject" | "approved" | "rejected" | "approvalReason" | "stepNoLongerActive" | "tabHome" | "tabConversations" | "tabHelp" | "tabNews" | "modulesEmpty" | "moduleBack" | "contentLoading" | "homeGreeting" | "homeGreetingNamed" | "homeGreetingLead" | "homeSearchPlaceholder" | "homeContentTitle" | "helpTitle" | "helpSearchPlaceholder" | "helpEmpty" | "helpLoading" | "helpSearchEmpty" | "newsTitle" | "newsEmpty" | "newsLoading" | "newsBack" | "newsPublishedAt";
44
44
  /** A partial map for one locale — what overrides look like on the wire. */
45
45
  type LocaleStrings = Partial<Record<StringKey, string>>;
46
46
  /**
@@ -182,9 +182,8 @@ type WirePart = {
182
182
  };
183
183
  /**
184
184
  * One recorded form submission, returned on `/ai/agent/start-conversation`
185
- * (alongside `messages`) so the widget can re-place the collapsed
186
- * "form submitted" marker at its chronological spot in the timeline.
187
- * Values are NOT echoed back — the marker is pure indication.
185
+ * (alongside `messages`) so the widget can re-place the "form submitted /
186
+ * skipped" marker at its chronological spot in the timeline.
188
187
  */
189
188
  interface FormSubmissionRecord {
190
189
  formId: string;
@@ -194,6 +193,13 @@ interface FormSubmissionRecord {
194
193
  skipped?: boolean;
195
194
  /** ISO-8601 — same format + name as {@link WireMessage.createdAt}. */
196
195
  createdAt?: string;
196
+ /**
197
+ * The visitor's own answers, echoed back so the submitted marker can offer
198
+ * a read-only review after a reload. Scoped to the same `visitorId` that
199
+ * submitted them — this is the visitor seeing their own data, independent
200
+ * of `submit.toContext` (which governs mirroring into request context).
201
+ */
202
+ values?: Record<string, string>;
197
203
  }
198
204
  /** One-shot bot persona shown in the panel header. */
199
205
  interface ConversationAgent {
@@ -978,6 +984,54 @@ interface Endpoints {
978
984
  submitForm?: string;
979
985
  }
980
986
 
987
+ /**
988
+ * Built-in anonymous usage tracking — utm.gif-style pixel hits that give
989
+ * the widget OWNER (the site embedding it) insights about how visitors
990
+ * use the widget: events, pages, devices, locales, funnels.
991
+ *
992
+ * Privacy contract (enforced in `src/core/tracking.ts`):
993
+ * - never sends message text, form values, or any user content —
994
+ * event payloads pass through a static per-event allowlist;
995
+ * - the only identifier is the widget's existing anonymous `visitorId`;
996
+ * - geo + browser are derived server-side (IP + User-Agent header),
997
+ * never collected client-side;
998
+ * - `navigator.globalPrivacyControl` / Do-Not-Track force it off
999
+ * regardless of config.
1000
+ */
1001
+ /** Section: anonymous owner-facing usage tracking. */
1002
+ interface TrackingOptions {
1003
+ /**
1004
+ * Master switch. Default `false` — tracking stays off until the
1005
+ * deployment (or the embedding page) explicitly turns it on.
1006
+ */
1007
+ enabled?: boolean;
1008
+ /**
1009
+ * Pixel collector URL. Default: `https://t.<brand domain>/api/ai-elements/px.gif`
1010
+ * (e.g. `https://t.help.ai/api/ai-elements/px.gif`).
1011
+ */
1012
+ endpoint?: string;
1013
+ /**
1014
+ * Per-visitor sampling 0..1. `0.25` tracks ~a quarter of visitors
1015
+ * (decided once per page load, so funnels stay intact). Default `1`.
1016
+ */
1017
+ sampleRate?: number;
1018
+ /**
1019
+ * Anti-forgery token, echoed as `tk=` on every hit. **Server-issued,
1020
+ * never set by hand** — the backend mints it in the
1021
+ * `/start-conversation` response (HMAC over `pk`/`vid`/expiry with a
1022
+ * server-side secret; see `docs/api/tracking-collector.md`) and the
1023
+ * collector verifies it statelessly. Opaque to the client.
1024
+ */
1025
+ token?: string;
1026
+ }
1027
+ /** Post-resolve shape — every field concrete (token stays optional: absent until the handshake delivers it). */
1028
+ interface ResolvedTracking {
1029
+ enabled: boolean;
1030
+ endpoint: string;
1031
+ sampleRate: number;
1032
+ token?: string;
1033
+ }
1034
+
981
1035
  /**
982
1036
  * The three composing roots: raw input ({@link ChatWidgetOptions}),
983
1037
  * post-normalisation runtime shape ({@link ResolvedOptions}), and the
@@ -1049,6 +1103,8 @@ interface ChatWidgetOptions {
1049
1103
  forms?: FormsOptions;
1050
1104
  /** Messenger modules (Chat / Home / Messages / Help / News tabs). Server-pushable. */
1051
1105
  modules?: ModulesOptions;
1106
+ /** Anonymous owner-facing usage tracking (pixel hits). Server-pushable. */
1107
+ tracking?: TrackingOptions;
1052
1108
  /**
1053
1109
  * Custom client-side storage adapter. Implements the {@link ClientStorage}
1054
1110
  * interface (`get` / `set` / `remove` / `clear`).
@@ -1148,6 +1204,8 @@ interface ResolvedOptions {
1148
1204
  };
1149
1205
  /** Resolved messenger modules — per-module config + ordered enabled list + default tab. */
1150
1206
  modules: ResolvedModules;
1207
+ /** Resolved anonymous usage tracking. */
1208
+ tracking: ResolvedTracking;
1151
1209
  /** Resolved storage adapter — defaults to `LocalStorageAdapter`. */
1152
1210
  storage: ClientStorage;
1153
1211
  onMessage?: ChatWidgetOptions["onMessage"];
@@ -1175,6 +1233,7 @@ interface ServerConfig {
1175
1233
  features?: FeatureFlags;
1176
1234
  forms?: FormsOptions;
1177
1235
  modules?: ModulesOptions;
1236
+ tracking?: TrackingOptions;
1178
1237
  endpoints?: Endpoints;
1179
1238
  }
1180
1239