@dashx/react 0.5.1 → 0.5.3

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/CHANGELOG.md ADDED
@@ -0,0 +1,109 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@dashx/react` are documented in this file. Format loosely follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), versions follow [SemVer](https://semver.org/).
4
+
5
+ ## Unreleased
6
+
7
+ ### [0.5.2] - 2026-10-07
8
+
9
+ - **Click and form submit autocapture.** `<DashXProvider autocapture={{ clicks: true }}>` records clicks on links, buttons and other interactive elements, and form submits, as `$autocapture`. `autocapture` alone still captures only page views and page leaves.
10
+
11
+ ### Changed
12
+
13
+ - **Requires `@dashx/browser` 0.14.1** (for `clicks`). The range moves from `^0.14.0` to `^0.14.1`.
14
+
15
+ ## [0.5.1] - 2026-10-07
16
+
17
+ ### Changed
18
+
19
+ - **Requires `@dashx/browser` 0.14.** The range moves from `^0.13.1` to `^0.14.0`, so an app on `@dashx/browser` 0.14 (for `loadInAppChatAgent`) and `DashXProvider` share one client instead of the provider building its own from an older copy. No API changes here.
20
+
21
+ ## [0.5.0] - 2026-10-06
22
+
23
+ ### Added
24
+
25
+ - **`DashXProvider` accepts `autocapture`.** `<DashXProvider autocapture ...>` (or `autocapture={{ pageleave: false }}`) turns on `@dashx/browser`'s page view / page leave capture for the provider's client. It is started and stopped in an effect, so StrictMode's double render does not leave a second set of listeners behind. Route changes are picked up from the History API, so no router integration is needed.
26
+
27
+ - **`DashXProvider` accepts the privacy options** `maskPersonalDataProperties`, `customPersonalDataProperties` and `beforeSend`, and passes them to the client. Changing either masking option recreates the client. `beforeSend` is read on every event, so an inline function or a changed array takes effect without recreating it.
28
+
29
+ Requires `@dashx/browser` 0.13.1 or later (`startAutocapture` and the privacy options). 0.13.0 was published from a stale build without them.
30
+
31
+ - **README** documents `DashXProvider`, autocapture and the privacy props.
32
+
33
+ ## [0.4.1] — 2026-08-05
34
+
35
+ ### Changed
36
+
37
+ - **`useInAppChatNotifications`'s `onActivate` now receives the message that raised the notification.**
38
+
39
+ ```diff
40
+ - onActivate?: () => void
41
+ + onActivate?: (message: InAppChatMessageData) => void
42
+ ```
43
+
44
+ Notifications are tagged per conversation, so a surface watching more than one thread could raise several at once — but the old zero-argument callback gave the handler no way to tell them apart, and it closed over whichever message arrived last. Clicking an older notification opened the wrong conversation.
45
+
46
+ **Backward compatible.** A `() => void` handler is still assignable and still behaves as before; take the parameter only if you need to route by `message.conversationId`. `InAppChatMessageData` is imported from `@dashx/browser`, same as the existing `renderBody` option on this hook.
47
+
48
+ ## [0.4.0] — 2026-07-29
49
+
50
+ ### Changed
51
+
52
+ - **BREAKING — In-App Chat no longer creates conversations; the caller supplies one.** `useInAppChat` and both widgets participate in an EXISTING conversation:
53
+
54
+ ```diff
55
+ - useInAppChat({ identityId, idempotencyKey, initialMessage? })
56
+ + useInAppChat({ identityId, conversationId })
57
+ ```
58
+
59
+ `idempotencyKey` and `initialMessage` are gone, along with the create-on-mount behaviour. `<InAppChat>` and `<InAppChatButton>` take a required `conversationId` prop in place of `idempotencyKey`/`initialMessage`.
60
+
61
+ **Why.** Creating a chat is now server-only in DashX: identity-token callers are rejected outright, and the operation requires an `accountUid` naming the visitor — a claim no browser should be able to make. The conversation's `data`/`issueProperties` are metadata the agent console trusts, so they must be derived server-side. `@dashx/browser@0.10.0` therefore removes `startInAppChatConversation`, which is what this hook used.
62
+
63
+ **Migration.** Create the conversation in your backend (for JVM services, `dashx-java` ≥ 1.5.0 exposes `DashX.startInAppChatConversation(input)`), return the id to your client, and pass it in:
64
+
65
+ ```tsx
66
+ const { conversationId } = useMyBackendChatSession(); // your endpoint
67
+ <InAppChatButton identityId="<chat-identity-id>" conversationId={conversationId} />
68
+ ```
69
+
70
+ `conversationId` accepts `null` while you're still fetching it — the hook stays idle (no subscription, no history fetch) rather than guessing, so you can render the widget unconditionally.
71
+ - **`conversationId` is no longer returned from the hook.** The caller now owns it, so echoing it back was noise. Everything else in the response is unchanged: `messages`, `isLoading`, `isConnected`, `error`, `sendMessage`.
72
+ - `sendMessage(text)` returns `false` when there is no `conversationId` yet (or the hook is disabled) — same contract as before, so callers that keep the composer populated on `false` need no change.
73
+ - **`@dashx/browser` dependency raised to `^0.10.0`** (a regular `dependencies` entry, as before), which is the release that removes the creation method.
74
+
75
+ ### Unchanged
76
+
77
+ - History fetch, realtime subscribe, optimistic send + reconciliation, reconnect refetch, and the notification hook all behave exactly as before. `<InAppChatButton>` still activates lazily on first open, so a launcher the visitor never opens does no chat work.
78
+
79
+ ## [0.3.0] — 2026-06-18
80
+
81
+ ### Added
82
+
83
+ - **In-App Chat hook + widgets.** A two-way in-app chat surface for visitors:
84
+ - `useInAppChat({ identityId, idempotencyKey, initialMessage? })` — manages the conversation lifecycle (start → subscribe → fetch history), exposes `messages`, `sendMessage(text)`, and loading/error state, and reconciles optimistic sends against the realtime echoes (deduping by message id and external uid). Refetches history on reconnect so a reply that landed during an outage isn't missed.
85
+ - `<InAppChat>` — the chat surface (header / message list / composer).
86
+ - `<InAppChatButton>` — a floating launcher that opens `<InAppChat>` in a popover. Props: `identityId`, `idempotencyKey`, `position` (`'bottom-right'` | `'bottom-left'` | `'top-right'` | `'top-left'`, default `'bottom-right'`), and `theme` (accent color, mode, roundness, …). The chat mounts lazily on open, so no conversation is created until the visitor opens the launcher.
87
+
88
+ In-App Chat requires a visitor identity token configured on `DashXProvider` (see below); render the chat only once that token is available.
89
+
90
+ Example — `<InAppChatButton>` with a `theme` override (all `ThemeProps` fields are optional and otherwise inherit from a surrounding `<Theme>` / `DashXProvider`):
91
+
92
+ ```tsx
93
+ <InAppChatButton
94
+ identityId="<dashx-chat-identity-id>"
95
+ idempotencyKey="main"
96
+ position="bottom-right"
97
+ theme={{
98
+ accentBaseColor: '#6d28d9',
99
+ mode: 'dark',
100
+ roundness: 'large',
101
+ }}
102
+ />
103
+ ```
104
+ - **`DashXProvider` identity props.** New optional `identityUid?` and `identityToken?`. When set, the identity is applied on both transports — the Apollo `X-Identity-Token` header and the WebSocket handshake — which is the visitor auth In-App Chat needs. Pass `null` to clear on logout; omit (`undefined`) to leave unchanged. Pair `identityUid` with `identityToken` to address the same identity on both transports.
105
+
106
+ ### Changed
107
+
108
+ - **Bumped `@dashx/browser` to `^0.8.0`** — for the In-App Chat client methods, the `subscribeToChannel` helper, and the `setIdentity` "undefined = leave unchanged" semantics this provider relies on.
109
+ - **Identity is now applied synchronously at client creation**, and the provider reconnects its own WebSocket when `identityToken` changes (so tracked chat channels re-subscribe under the new identity). Existing consumers that pass neither `identityUid` nor `identityToken` are unaffected — no extra `setIdentity` call, no reconnect, and the client is not recreated.
package/README.md CHANGED
@@ -42,6 +42,14 @@ Pass `autocapture` to record a `$pageview` on load and on every client-side navi
42
42
 
43
43
  Pass `autocapture={{ pageleave: false }}` (or `pageviews: false`) to turn either event off. Autocapture starts when the provider mounts and stops when it unmounts, so React StrictMode's double mount does not record a page twice.
44
44
 
45
+ Clicks and form submits are opt-in. Pass `clicks: true` to record them as `$autocapture`:
46
+
47
+ ```tsx
48
+ <DashXProvider publicKey="..." targetEnvironment="production" autocapture={{ clicks: true }}>
49
+ ```
50
+
51
+ Each click records the element's tag, visible text, link target, `id`, classes, `data-*` attributes and a short selector, never what was typed. Add the `dx-no-capture` class (or a `data-dx-no-capture` attribute) to an element to skip it and everything inside it.
52
+
45
53
  Events carry the page, a session id and the landing page's UTM campaign. See the `@dashx/browser` README for what each event contains.
46
54
 
47
55
  ### Privacy
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashx/react",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "license": "UNLICENSED",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/cjs/index.js",
@@ -75,7 +75,7 @@
75
75
  "clean": "rm -rf .turbo node_modules dist tokens layout *.css"
76
76
  },
77
77
  "dependencies": {
78
- "@dashx/browser": "^0.14.0",
78
+ "@dashx/browser": "^0.14.3",
79
79
  "@radix-ui/colors": "^3.0.0",
80
80
  "@radix-ui/primitive": "^1.1.3",
81
81
  "@radix-ui/react-accessible-icon": "^1.1.8",
package/styles.css CHANGED
@@ -146,6 +146,9 @@ button, input:where([type='button'], [type='reset'], [type='submit']), ::file-se
146
146
  [hidden]:where(:not([hidden='until-found'])) {
147
147
  display: none !important;
148
148
  }
149
+ .visible {
150
+ visibility: visible;
151
+ }
149
152
  .absolute {
150
153
  position: absolute;
151
154
  }
@@ -1,47 +0,0 @@
1
- import * as React from 'react';
2
- import * as PopoverPrimitive from '@radix-ui/react-popover';
3
- import type { PopoverVariantProps } from '../variants/popover.js';
4
- interface PopoverRootProps extends React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Root> {
5
- }
6
- declare const PopoverRoot: React.FC<PopoverRootProps>;
7
- interface PopoverTriggerProps extends React.PropsWithChildren<{}> {
8
- }
9
- declare const PopoverTrigger: React.ForwardRefExoticComponent<PopoverTriggerProps & React.RefAttributes<HTMLButtonElement>>;
10
- interface PopoverContentProps extends React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>, React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Portal>, PopoverVariantProps {
11
- maxWidth?: number | string;
12
- minWidth?: number | string;
13
- width?: number | string;
14
- maxHeight?: number | string;
15
- minHeight?: number | string;
16
- height?: number | string;
17
- }
18
- declare const PopoverContent: React.ForwardRefExoticComponent<PopoverContentProps & React.RefAttributes<HTMLDivElement>>;
19
- type PopoverBodyProps = React.PropsWithChildren<{
20
- asChild?: boolean;
21
- }>;
22
- declare const PopoverBody: React.ForwardRefExoticComponent<{
23
- asChild?: boolean;
24
- } & {
25
- children?: React.ReactNode | undefined;
26
- } & React.RefAttributes<HTMLDivElement>>;
27
- type PopoverHeaderProps = React.PropsWithChildren<{
28
- asChild?: boolean;
29
- }>;
30
- declare const PopoverHeader: React.ForwardRefExoticComponent<{
31
- asChild?: boolean;
32
- } & {
33
- children?: React.ReactNode | undefined;
34
- } & React.RefAttributes<HTMLDivElement>>;
35
- type PopoverFooterProps = React.PropsWithChildren<{
36
- asChild?: boolean;
37
- }>;
38
- declare const PopoverFooter: React.ForwardRefExoticComponent<{
39
- asChild?: boolean;
40
- } & {
41
- children?: React.ReactNode | undefined;
42
- } & React.RefAttributes<HTMLDivElement>>;
43
- interface PopoverCloseProps extends React.PropsWithChildren<{}> {
44
- }
45
- declare const PopoverClose: React.ForwardRefExoticComponent<PopoverCloseProps & React.RefAttributes<HTMLButtonElement>>;
46
- export { PopoverRoot as Root, PopoverContent as Content, PopoverBody as Body, PopoverHeader as Header, PopoverFooter as Footer, PopoverTrigger as Trigger, PopoverClose as Close, };
47
- export type { PopoverRootProps as RootProps, PopoverContentProps as ContentProps, PopoverBodyProps as BodyProps, PopoverHeaderProps as HeaderProps, PopoverFooterProps as FooterProps, PopoverTriggerProps as TriggerProps, PopoverCloseProps as CloseProps, };