@constructor-io/constructorio-ui-asa 1.6.1 → 1.7.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 CHANGED
@@ -81,6 +81,7 @@ function ShoppingAgent() {
81
81
  |------|------|-------------|
82
82
  | `apiKey` | `string` | Your Constructor index key. Required unless you pass your own `cioClient`. |
83
83
  | `cioClient` | `ConstructorIOClient` | A pre-configured Constructor client. Provide this instead of `apiKey` when you need to customize client options (e.g. `serviceUrl`, `segments`, `userId`). |
84
+ | `testCells` | `Record<string, string>` | A/B test cells to attach to tracking events, as `{ [testName]: cellName }`. See [A/B Testing](#ab-testing). |
84
85
  | `staticRequestConfigs` | `RequestConfigs` | Request-level config passed to the ASA agent. Defaults to `{ domain: 'chatbot' }`. |
85
86
  | `formatters` | `Formatters` | Override built-in formatters (e.g. `formatPrice`). Merged over the defaults. |
86
87
  | `urlHelpers` | `UrlHelpers` | Override built-in URL read/write helpers. Merged over the defaults. |
@@ -89,6 +90,34 @@ function ShoppingAgent() {
89
90
 
90
91
  > **Server-side rendering.** The Constructor client is only instantiated in the browser, so `Chat` and `useAsaResults` must run client-side only. In Next.js App Router, add `'use client'` and defer rendering until mounted (or load with `next/dynamic` and `{ ssr: false }`). See the [Integration Guide](https://constructor-io.github.io/constructorio-ui-asa/?path=/docs/general-integration-guide--variants) for a full example.
91
92
 
93
+ ### A/B Testing
94
+
95
+ Attach test cells so ASA's tracking events can be attributed to a cell. Each entry is sent as its
96
+ own `ef-<testName>` parameter, so a shopper in several concurrent tests carries every cell:
97
+
98
+ ```jsx
99
+ <CioAsa
100
+ apiKey='YOUR_API_KEY'
101
+ testCells={{ constructorio: 'variant_a', your_other_test: 'variant_b' }}
102
+ />
103
+ ```
104
+
105
+ The keys are your own test names, not values Constructor defines. Constructor's docs have the page
106
+ set `window.cnstrc.testCell` to a bare cell name, which carries no test name of its own, so label
107
+ it with yours:
108
+
109
+ ```jsx
110
+ <CioAsa apiKey='YOUR_API_KEY' testCells={{ constructorio: window.cnstrc.testCell }} />
111
+ ```
112
+
113
+ Some integrations expose a `window.cnstrc.testCells` map instead, which you can pass straight
114
+ through. Empty and non-string values are dropped, so a cell read from a global that resolves to
115
+ `undefined` is simply not sent.
116
+
117
+ If you supply your own `cioClient`, that client owns its own options: set `testCells` there
118
+ instead, as a `ConstructorIOClient` constructor option. `testCells` is ignored in that case, and
119
+ passing both logs a warning rather than dropping the value silently.
120
+
92
121
  ### Using the Hook Directly
93
122
 
94
123
  For custom UI implementations, use the `useAsaResults` hook. It takes no arguments — all configuration comes from the surrounding `CioAsaProvider`.