@constructor-io/constructorio-ui-pia 2.13.1 → 2.14.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
@@ -76,6 +76,46 @@ The component supports multiple display modes via the `displayConfigs` prop:
76
76
  />
77
77
  ```
78
78
 
79
+ #### A/B Testing
80
+
81
+ Attach test cells to PIA tracking events, and track the control group without showing the widget:
82
+
83
+ ```jsx
84
+ // Test arm: the widget renders, events carry ef-constructorio=variant_a
85
+ <CioPia
86
+ apiKey="key_XXXXXXXX"
87
+ itemId={itemId}
88
+ itemName={itemName}
89
+ abTest={{ testCells: { constructorio: 'variant_a', your_other_test: 'variant_b' }, isControl: false }}
90
+ />
91
+
92
+ // Control arm: nothing visible renders, but the view event still fires with the control cell
93
+ <CioPia
94
+ apiKey="key_XXXXXXXX"
95
+ itemId={itemId}
96
+ itemName={itemName}
97
+ abTest={{ testCells: { constructorio: 'control' }, isControl: true }}
98
+ />
99
+ ```
100
+
101
+ Mount `CioPia` on every PDP and switch `isControl` per shopper — no placeholder markup of your own
102
+ is required.
103
+
104
+ `testCells` is `{ [testName]: cellName }`, and both halves are yours: the keys are your own test
105
+ names, not values Constructor defines. Each entry is sent as its own `ef-<testName>` parameter, so
106
+ a shopper in several concurrent tests carries every cell. Empty or non-string values are dropped,
107
+ so a cell read from a global that resolves to `undefined` is simply not sent.
108
+
109
+ Both arms fire the same `product_insights_agent.view` event through the same viewport tracking,
110
+ so the control group is measured the same way as the test group.
111
+
112
+ If you supply your own `cioClient`, that client owns its own options: set `testCells` there
113
+ instead, as a `ConstructorIOClient` constructor option. `abTest.testCells` is ignored in that
114
+ case, and passing both logs a warning rather than dropping the value silently.
115
+
116
+ `isControl` is required. Stating the arm per shopper is the one thing only you can know, and
117
+ omitting it would quietly put everyone in the test arm with no control group to compare against.
118
+
79
119
  #### Configuration Options
80
120
 
81
121
  | Prop | Type | Description |
@@ -89,12 +129,13 @@ The component supports multiple display modes via the `displayConfigs` prop:
89
129
  | `callbacks` | `object` | Callback handlers for user interactions |
90
130
  | `translations` | `object` | UI string translations for internationalization |
91
131
  | `componentOverrides` | `object` | Custom component overrides |
132
+ | `abTest` | `object` | A/B test configuration — test cells for tracking, and a control-group placeholder (see below) |
92
133
 
93
134
  **Display Configs:**
94
135
 
95
136
  | Option | Type | Default | Description |
96
137
  |--------|------|---------|-------------|
97
- | `mode` | `'default' \| 'conversation'` | `'default'` | Display mode |
138
+ | `mode` | `'default' \| 'conversation' \| 'recommendations'` | `'default'` | Display mode. `'recommendations'` is accepted by the type but not yet available — it renders nothing. |
98
139
  | `type` | `'inline' \| 'modal'` | `'inline'` | Component type |
99
140
  | `showFeedback` | `boolean` | `false` | Show feedback controls on answers |
100
141
  | `showPreviousItems` | `boolean` | `true` | Show product carousels from previous conversation entries |
@@ -106,6 +147,13 @@ The component supports multiple display modes via the `displayConfigs` prop:
106
147
  |--------|------|---------|-------------|
107
148
  | `viewThreshold` | `number` | `0.5` | Fraction of the container (0–1) that must be visible before the `product_insights_agent.view` event fires. Lower it (e.g. `0.01`) to have the view event fire on minimal visibility. |
108
149
 
150
+ **AB Test:**
151
+
152
+ | Option | Type | Default | Description |
153
+ |--------|------|---------|-------------|
154
+ | `testCells` | `Record<string, string>` | - | `{ [testName]: cellName }`, each sent as an `ef-<testName>` tracking parameter. Ignored when you supply your own `cioClient`. |
155
+ | `isControl` | `boolean` | required | Renders an invisible, tracking-only placeholder instead of the widget, so the control arm still records a view event. Takes precedence over `displayConfigs.mode`. |
156
+
109
157
  **Callbacks:**
110
158
 
111
159
  | Option | Type | Description |