@constructor-io/constructorio-ui-pia 2.13.1 → 2.15.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 +76 -30
- package/dist/constructorio-ui-pia-bundled.js +39 -39
- package/lib/cjs/components/CioPia/CheckoutTriggerBar.js +25 -0
- package/lib/cjs/components/CioPia/CioPia.js +6 -1
- package/lib/cjs/components/CioPia/CioPiaQna.js +7 -2
- package/lib/cjs/components/CioPia/CioPiaStyles.css +33 -0
- package/lib/cjs/components/CioPiaControl/CioPiaControl.js +38 -0
- package/lib/cjs/components/CioPiaRecs/CioPiaRecs.js +3 -1
- package/lib/cjs/components/PiaConversation/PiaConversation.js +2 -1
- package/lib/cjs/components/PiaConversation/PiaConversationStyles.css +5 -0
- package/lib/cjs/hooks/useCioPia.js +2 -1
- package/lib/cjs/hooks/usePiaClient.js +14 -7
- package/lib/cjs/hooks/useViewportTracking.js +9 -4
- package/lib/cjs/stories/assets/storybook-styles.css +12 -10
- package/lib/cjs/version.js +1 -1
- package/lib/mjs/components/CioPia/CheckoutTriggerBar.js +20 -0
- package/lib/mjs/components/CioPia/CioPia.js +5 -0
- package/lib/mjs/components/CioPia/CioPiaQna.js +7 -2
- package/lib/mjs/components/CioPia/CioPiaStyles.css +33 -0
- package/lib/mjs/components/CioPiaControl/CioPiaControl.js +34 -0
- package/lib/mjs/components/CioPiaRecs/CioPiaRecs.js +3 -1
- package/lib/mjs/components/PiaConversation/PiaConversation.js +2 -1
- package/lib/mjs/components/PiaConversation/PiaConversationStyles.css +5 -0
- package/lib/mjs/hooks/useCioPia.js +2 -1
- package/lib/mjs/hooks/usePiaClient.js +15 -3
- package/lib/mjs/hooks/useViewportTracking.js +9 -4
- package/lib/mjs/stories/assets/storybook-styles.css +12 -10
- package/lib/mjs/version.js +1 -1
- package/lib/types/components/CioPia/CheckoutTriggerBar.d.ts +11 -0
- package/lib/types/components/CioPia/index.d.ts +1 -1
- package/lib/types/components/CioPia/types.d.ts +45 -1
- package/lib/types/components/CioPiaControl/CioPiaControl.d.ts +9 -0
- package/lib/types/components/PiaConversation/PiaConversation.d.ts +3 -2
- package/lib/types/hooks/useCioPia.d.ts +2 -0
- package/lib/types/hooks/usePiaClient.d.ts +2 -1
- package/lib/types/hooks/useViewportTracking.d.ts +6 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/types.d.ts +33 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,9 +47,7 @@ import CioPia from '@constructor-io/constructorio-ui-pia';
|
|
|
47
47
|
import '@constructor-io/constructorio-ui-pia/styles.css';
|
|
48
48
|
|
|
49
49
|
function YourComponent() {
|
|
50
|
-
return
|
|
51
|
-
<CioPia apiKey='YOUR_API_KEY' itemId='PRODUCT_ITEM_ID' />
|
|
52
|
-
);
|
|
50
|
+
return <CioPia apiKey='YOUR_API_KEY' itemId='PRODUCT_ITEM_ID' />;
|
|
53
51
|
}
|
|
54
52
|
```
|
|
55
53
|
|
|
@@ -76,44 +74,92 @@ The component supports multiple display modes via the `displayConfigs` prop:
|
|
|
76
74
|
/>
|
|
77
75
|
```
|
|
78
76
|
|
|
77
|
+
#### A/B Testing
|
|
78
|
+
|
|
79
|
+
Attach test cells to PIA tracking events, and track the control group without showing the widget:
|
|
80
|
+
|
|
81
|
+
```jsx
|
|
82
|
+
// Test arm: the widget renders, events carry ef-constructorio=variant_a
|
|
83
|
+
<CioPia
|
|
84
|
+
apiKey="key_XXXXXXXX"
|
|
85
|
+
itemId={itemId}
|
|
86
|
+
itemName={itemName}
|
|
87
|
+
abTest={{ testCells: { constructorio: 'variant_a', your_other_test: 'variant_b' }, isControl: false }}
|
|
88
|
+
/>
|
|
89
|
+
|
|
90
|
+
// Control arm: nothing visible renders, but the view event still fires with the control cell
|
|
91
|
+
<CioPia
|
|
92
|
+
apiKey="key_XXXXXXXX"
|
|
93
|
+
itemId={itemId}
|
|
94
|
+
itemName={itemName}
|
|
95
|
+
abTest={{ testCells: { constructorio: 'control' }, isControl: true }}
|
|
96
|
+
/>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Mount `CioPia` on every PDP and switch `isControl` per shopper — no placeholder markup of your own
|
|
100
|
+
is required.
|
|
101
|
+
|
|
102
|
+
`testCells` is `{ [testName]: cellName }`, and both halves are yours: the keys are your own test
|
|
103
|
+
names, not values Constructor defines. Each entry is sent as its own `ef-<testName>` parameter, so
|
|
104
|
+
a shopper in several concurrent tests carries every cell. Empty or non-string values are dropped,
|
|
105
|
+
so a cell read from a global that resolves to `undefined` is simply not sent.
|
|
106
|
+
|
|
107
|
+
Both arms fire the same `product_insights_agent.view` event through the same viewport tracking,
|
|
108
|
+
so the control group is measured the same way as the test group.
|
|
109
|
+
|
|
110
|
+
If you supply your own `cioClient`, that client owns its own options: set `testCells` there
|
|
111
|
+
instead, as a `ConstructorIOClient` constructor option. `abTest.testCells` is ignored in that
|
|
112
|
+
case, and passing both logs a warning rather than dropping the value silently.
|
|
113
|
+
|
|
114
|
+
`isControl` is required. Stating the arm per shopper is the one thing only you can know, and
|
|
115
|
+
omitting it would quietly put everyone in the test arm with no control group to compare against.
|
|
116
|
+
|
|
79
117
|
#### Configuration Options
|
|
80
118
|
|
|
81
|
-
| Prop
|
|
82
|
-
|
|
83
|
-
| `apiKey`
|
|
84
|
-
| `itemId`
|
|
85
|
-
| `variationId`
|
|
86
|
-
| `threadId`
|
|
87
|
-
| `displayConfigs`
|
|
88
|
-
| `trackingConfigs`
|
|
89
|
-
| `callbacks`
|
|
90
|
-
| `translations`
|
|
91
|
-
| `componentOverrides` | `object` | Custom component overrides
|
|
119
|
+
| Prop | Type | Description |
|
|
120
|
+
| -------------------- | -------- | --------------------------------------------------------------------------------------------- |
|
|
121
|
+
| `apiKey` | `string` | Your Constructor.io API key (required) |
|
|
122
|
+
| `itemId` | `string` | The product item ID (required) |
|
|
123
|
+
| `variationId` | `string` | Optional variation ID |
|
|
124
|
+
| `threadId` | `string` | Optional thread ID for conversation context (must be a valid UUID) |
|
|
125
|
+
| `displayConfigs` | `object` | Display configuration options (see below) |
|
|
126
|
+
| `trackingConfigs` | `object` | Tracking configuration options (see below) |
|
|
127
|
+
| `callbacks` | `object` | Callback handlers for user interactions |
|
|
128
|
+
| `translations` | `object` | UI string translations for internationalization |
|
|
129
|
+
| `componentOverrides` | `object` | Custom component overrides |
|
|
130
|
+
| `abTest` | `object` | A/B test configuration — test cells for tracking, and a control-group placeholder (see below) |
|
|
92
131
|
|
|
93
132
|
**Display Configs:**
|
|
94
133
|
|
|
95
|
-
| Option
|
|
96
|
-
|
|
97
|
-
| `mode`
|
|
98
|
-
| `type`
|
|
99
|
-
| `showFeedback`
|
|
100
|
-
| `showPreviousItems` | `boolean`
|
|
101
|
-
| `learnMoreUrl`
|
|
134
|
+
| Option | Type | Default | Description |
|
|
135
|
+
| ------------------- | -------------------------------------------------- | ----------- | ----------------------------------------------------------------------------------------------------- |
|
|
136
|
+
| `mode` | `'default' \| 'conversation' \| 'recommendations'` | `'default'` | Display mode. `'recommendations'` is accepted by the type but not yet available — it renders nothing. |
|
|
137
|
+
| `type` | `'inline' \| 'modal'` | `'inline'` | Component type |
|
|
138
|
+
| `showFeedback` | `boolean` | `false` | Show feedback controls on answers |
|
|
139
|
+
| `showPreviousItems` | `boolean` | `true` | Show product carousels from previous conversation entries |
|
|
140
|
+
| `learnMoreUrl` | `string` | - | URL for the "Learn More" disclaimer link |
|
|
102
141
|
|
|
103
142
|
**Tracking Configs:**
|
|
104
143
|
|
|
105
|
-
| Option
|
|
106
|
-
|
|
107
|
-
| `viewThreshold` | `number` | `0.5`
|
|
144
|
+
| Option | Type | Default | Description |
|
|
145
|
+
| --------------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
146
|
+
| `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. |
|
|
147
|
+
|
|
148
|
+
**AB Test:**
|
|
149
|
+
|
|
150
|
+
| Option | Type | Default | Description |
|
|
151
|
+
| ----------- | ------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
152
|
+
| `testCells` | `Record<string, string>` | - | `{ [testName]: cellName }`, each sent as an `ef-<testName>` tracking parameter. Ignored when you supply your own `cioClient`. |
|
|
153
|
+
| `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`. |
|
|
108
154
|
|
|
109
155
|
**Callbacks:**
|
|
110
156
|
|
|
111
|
-
| Option
|
|
112
|
-
|
|
113
|
-
| `onQuestionSubmit`
|
|
114
|
-
| `onProductCardClick` | `(item: Item) => void`
|
|
115
|
-
| `onAddToCart`
|
|
116
|
-
| `onFeedback`
|
|
157
|
+
| Option | Type | Description |
|
|
158
|
+
| -------------------- | ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
159
|
+
| `onQuestionSubmit` | `(question: string) => void` | Called when a question is submitted (via Enter key, Send button, or suggested question click) |
|
|
160
|
+
| `onProductCardClick` | `(item: Item) => void` | Called when a product card in the carousel is clicked |
|
|
161
|
+
| `onAddToCart` | `(item: Item, event: React.MouseEvent) => void` | Called when the "Add to Cart" button on a product card is clicked. Passing this callback is what renders the button; without it no cart control is shown |
|
|
162
|
+
| `onFeedback` | `(type: 'up' \| 'down') => void` | Called when the user submits positive or negative feedback on an answer |
|
|
117
163
|
|
|
118
164
|
### Using the JavaScript Bundle
|
|
119
165
|
|