@picked/client 0.0.1-dev.1787543060859 → 0.0.1-dev.1788925875333

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.
Files changed (70) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/api-DbMJli3H.js +22 -0
  3. package/dist/api-qiqq8lgz.cjs +1 -0
  4. package/dist/cjs/index.js +2 -2
  5. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  6. package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
  7. package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
  8. package/dist/cjs/plugins/telemetry/index.js +1 -1
  9. package/dist/cjs/server/index.js +1 -1
  10. package/dist/docs/how-to/fill-and-publish-a-page.md +18 -2
  11. package/dist/docs/reference/dashboard/content/pages.mdx +25 -0
  12. package/dist/docs/reference/dashboard/fields.mdx +17 -11
  13. package/dist/docs/reference/delivery-api/preview-caching-crawling.md +1 -1
  14. package/dist/docs/reference/sdk/features.md +5 -0
  15. package/dist/docs/reference/sdk/fields.md +62 -16
  16. package/dist/docs/reference/sdk/type-generation.md +18 -7
  17. package/dist/docs/reference/tools/mcp.md +3 -1
  18. package/dist/esm/index.js +468 -439
  19. package/dist/esm/plugins/dynamic-experiences/index.js +2 -2
  20. package/dist/esm/plugins/responses-browser-storage/index.js +50 -16
  21. package/dist/esm/plugins/responses-indexeddb/index.js +1 -1
  22. package/dist/esm/plugins/telemetry/index.js +46 -47
  23. package/dist/esm/server/index.js +1 -1
  24. package/dist/{plugin-BcFzHPC7.cjs → plugin-BcLaCLm1.cjs} +1 -1
  25. package/dist/{plugin-L5y4NdFX.js → plugin-De_BJSwE.js} +3 -2
  26. package/dist/provider-C_9u0yGJ.cjs +1 -0
  27. package/dist/provider-ovM-CBX_.js +98 -0
  28. package/dist/types/client.d.ts +21 -0
  29. package/dist/types/client.d.ts.map +1 -1
  30. package/dist/types/data-source/api.d.ts.map +1 -1
  31. package/dist/types/data-source/provider.d.ts +3 -0
  32. package/dist/types/data-source/provider.d.ts.map +1 -1
  33. package/dist/types/data-source/request-observer.d.ts +38 -22
  34. package/dist/types/data-source/request-observer.d.ts.map +1 -1
  35. package/dist/types/entities/feature/feature.d.ts.map +1 -1
  36. package/dist/types/entities/field/field.d.ts +29 -4
  37. package/dist/types/entities/field/field.d.ts.map +1 -1
  38. package/dist/types/entities/field/policies.d.ts +35 -0
  39. package/dist/types/entities/field/policies.d.ts.map +1 -0
  40. package/dist/types/entities/plugin/plugin.d.ts +3 -3
  41. package/dist/types/index.d.ts +1 -0
  42. package/dist/types/index.d.ts.map +1 -1
  43. package/dist/types/lifecycle/lifecycle.d.ts +1 -1
  44. package/dist/types/lifecycle/lifecycle.d.ts.map +1 -1
  45. package/dist/types/picked.d.ts +9 -11
  46. package/dist/types/picked.d.ts.map +1 -1
  47. package/dist/types/plugins/create-experience/create-experience.d.ts +3 -8
  48. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  49. package/dist/types/plugins/responses-browser-storage/plugin.d.ts +11 -0
  50. package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
  51. package/dist/types/plugins/responses-indexeddb/plugin.d.ts.map +1 -1
  52. package/dist/types/plugins/telemetry/emit.d.ts +3 -3
  53. package/dist/types/plugins/telemetry/emit.d.ts.map +1 -1
  54. package/dist/types/plugins/telemetry/plugin.d.ts +10 -1
  55. package/dist/types/plugins/telemetry/plugin.d.ts.map +1 -1
  56. package/dist/types/utils/client-telemetry.d.ts +25 -0
  57. package/dist/types/utils/client-telemetry.d.ts.map +1 -0
  58. package/dist/types/utils/user-timing.d.ts +16 -13
  59. package/dist/types/utils/user-timing.d.ts.map +1 -1
  60. package/dist/{version-BqU6f22c.cjs → version-BvLZaTMC.cjs} +1 -1
  61. package/dist/{version-DAFO6eas.js → version-VvasRUfR.js} +2 -2
  62. package/package.json +3 -3
  63. package/dist/api-CahTmEWe.cjs +0 -1
  64. package/dist/api-DwTNwuWK.js +0 -33
  65. package/dist/provider-BLDm3i8g.cjs +0 -1
  66. package/dist/provider-Dx6VjvZg.js +0 -69
  67. package/dist/request-observer-BXDfOU0V.cjs +0 -1
  68. package/dist/request-observer-DtG0cRfz.js +0 -19
  69. package/dist/types/ping.d.ts +0 -11
  70. package/dist/types/ping.d.ts.map +0 -1
@@ -74,21 +74,27 @@ a visitor who matches the condition. See
74
74
 
75
75
  ## Privacy
76
76
 
77
- Two policies control where the value of a field can go. They are independent, and a
78
- sensitive field usually needs both.
77
+ A field captures nothing until you permit it. Two checkboxes control where the value of
78
+ a field can go. Both start off.
79
79
 
80
- | Policy | What it does |
80
+ | Checkbox | What it does when you turn it on |
81
81
  | --- | --- |
82
- | **Do Not Track** | Picked keeps the value out of your analytics events. The events carry the field ID only. |
83
- | **Do Not Store** | The SDK reads the value but does not put it in browser storage. |
82
+ | **Remember in the browser** | The SDK keeps the value on the device of the visitor. The value is available after a page load. |
83
+ | **Send to analytics** | Picked puts the value in your analytics events. |
84
84
 
85
- Neither policy stops the flow from the use of the value inside the page. A field with both
86
- policies set still holds its value there. The flow validates the step with it, and it
87
- evaluates the conditions after the step with it. The policies control what leaves the
88
- page.
85
+ Each checkbox is independent of the other.
86
+
87
+ A new field that you leave alone sends no value to your analytics. It writes no value to
88
+ the browser. Keep both checkboxes off for sensitive data such as a password, a tax
89
+ number, or a payment detail.
89
90
 
90
- Set both for a password, a tax number, or a payment detail. A field that only takes a
91
- branch in a flow needs neither.
91
+ Never turn on **Send to analytics** for personal data. A name, an email address, a phone
92
+ number, a home address, or an identity number must not reach your analytics.
93
+
94
+ Neither checkbox stops the flow from the use of the value inside the page. A field that
95
+ captures nothing still holds its value there. The flow validates the step with it, and it
96
+ evaluates the conditions after the step with it. The checkboxes control what leaves the
97
+ page.
92
98
 
93
99
  ## Related
94
100
 
@@ -30,7 +30,7 @@ SDK sends a `Picked-Client: sdk` request header:
30
30
 
31
31
  | Request | `Cache-Control` |
32
32
  | --- | --- |
33
- | Published, `Picked-Client: sdk` | `public, s-maxage=60, stale-while-revalidate=86400` |
33
+ | Published, `Picked-Client: sdk` | `public, s-maxage=10` |
34
34
  | Published, other clients | `private, no-store` |
35
35
  | Preview | `no-store` |
36
36
 
@@ -119,6 +119,11 @@ This is useful for QA, because you can test one bucket value and change no code.
119
119
  SDK keeps the override value in session storage. The browser clears it when you close
120
120
  the tab.
121
121
 
122
+ When a URL parameter overrides a feature flag, the SDK registers that feature flag as
123
+ enabled. Therefore `useFeatureEnabled` and `getFeatureEnabled` give `true`. A URL
124
+ parameter can also override a feature flag that the dashboard **Enabled** toggle keeps
125
+ off.
126
+
122
127
  ## Use a feature flag in an experience condition
123
128
 
124
129
  You can use a feature flag in an experience condition through JSON logic:
@@ -56,6 +56,38 @@ export const communicationMethods = createField({
56
56
  })
57
57
  ```
58
58
 
59
+ ## Register fields on the client
60
+
61
+ Register fields when you create the Picked client. Pass a `fields` object. The key of an
62
+ entry becomes the field `key` when the definition does not set one. A definition with its
63
+ own `key` keeps it. Pass a function to build a definition once during the client setup:
64
+
65
+ ```ts
66
+ import { createClient } from 'picked'
67
+
68
+ const client = createClient({
69
+ projectId: 'your-project-id',
70
+ fields: {
71
+ email: {
72
+ id: 'email',
73
+ name: 'email',
74
+ label: 'Email Address',
75
+ type: 'text',
76
+ multiple: false,
77
+ required: true,
78
+ },
79
+ age: () => ({
80
+ id: 'age',
81
+ name: 'age',
82
+ label: 'Age',
83
+ type: 'number',
84
+ multiple: false,
85
+ required: false,
86
+ }),
87
+ },
88
+ })
89
+ ```
90
+
59
91
  ## Field types
60
92
 
61
93
  A field has one of four basic types: `text`, `number`, `boolean`, or `object`.
@@ -124,36 +156,50 @@ const conditionalField = createField({
124
156
 
125
157
  ## Field policies
126
158
 
127
- Use a privacy policy to control how Picked tracks and stores the data of a field:
159
+ A field captures nothing until you permit it. Use a privacy policy to let Picked track
160
+ or store the data of a field:
128
161
 
129
162
  ```ts
130
- const sensitiveField = createField({
131
- id: 'ssn',
132
- name: 'ssn',
163
+ const colourField = createField({
164
+ id: 'favourite-colour',
165
+ name: 'favourite-colour',
133
166
  type: 'text',
134
- label: 'Social Security Number',
167
+ label: 'Favourite colour',
135
168
  multiple: false,
136
169
  required: true,
137
170
  policies: {
138
- doNotTrackValue: true, // Do not send the value to analytics.
139
- doNotStoreValue: true, // Do not keep the value in browser storage.
171
+ trackValue: true, // Send the value to analytics.
172
+ storeValue: true, // Keep the value in browser storage.
140
173
  },
141
174
  })
142
175
  ```
143
176
 
144
177
  **Privacy policies**:
145
178
 
146
- - `doNotTrackValue`: keeps the value of the field out of your analytics events. The
147
- events carry the field ID only.
148
- - `doNotStoreValue`: stops the SDK, so that it does not put the value in browser
149
- storage.
179
+ - `trackValue`: set it to `true` to put the value of the field in your analytics events.
180
+ At `false`, and when the policy is absent, the events carry the field ID only.
181
+ - `storeValue`: set it to `true` to let the SDK put the value in browser storage. At
182
+ `false`, and when the policy is absent, the SDK keeps the value out of storage.
183
+
184
+ Both policies keep the value in the browser by default. A field with no `policies`
185
+ object sends no value to your analytics and writes no value to browser storage. Keep
186
+ the default for sensitive data such as a tax number, a credit card number, or a
187
+ password. That data stays in the browser:
150
188
 
151
- Use these policies for sensitive data such as a tax number, a credit card number, or
152
- a password. That data must stay in the browser.
189
+ ```ts
190
+ const sensitiveField = createField({
191
+ id: 'ssn',
192
+ name: 'ssn',
193
+ type: 'text',
194
+ label: 'Social Security Number',
195
+ multiple: false,
196
+ required: true,
197
+ })
198
+ ```
153
199
 
154
- Neither policy stops the flow from the use of the value inside the page. A field with both
155
- policies set still holds its value there, for step validation and for the conditions after
156
- the step. The policies control what leaves the page: your analytics, and browser
200
+ Neither policy stops the flow from the use of the value inside the page. A field that
201
+ captures nothing still holds its value there, for step validation and for the conditions
202
+ after the step. The policies control what leaves the page: your analytics, and browser
157
203
  storage.
158
204
 
159
205
  ## Field metadata
@@ -119,20 +119,31 @@ The generated `picked-env.d.ts` file looks like:
119
119
 
120
120
  ```typescript
121
121
  // GENERATED by `@picked/typegen` — do not edit by hand.
122
- // source: published `x-picked-version-id`: `ver_456`
123
122
  // Reference: `https://docs.picked.app/reference/sdk/type-generation`
124
123
 
125
- export interface WelcomePage { /* ... */ }
126
- export interface FieldValues { /* ... */ }
127
- export type FeatureKey = 'default' | 'hero' | 'winter-sale'
124
+ export type WelcomePage = { /* ... */ }
125
+ export type FieldValues = { /* ... */ }
126
+ export type FeatureKey =
127
+ | 'default'
128
+ | 'hero'
129
+ | 'winter-sale'
128
130
 
129
131
  declare module '@picked/client' {
130
132
  interface PickedSchemaRegistry {
131
- contentModels: { 'welcome-page': WelcomePage }
132
- stepContentModels: { intro: 'welcome-page' }
133
+ contentModels: {
134
+ 'welcome-page': WelcomePage
135
+ }
136
+ stepContentModels: {
137
+ 'intro': 'welcome-page'
138
+ }
139
+ featureValues: {
140
+ 'hero':
141
+ | false
142
+ | 'hero-a'
143
+ | 'hero-b'
144
+ }
133
145
  fieldValues: FieldValues
134
146
  featureKeys: FeatureKey
135
- featureValues: { hero: false | 'hero-a' | 'hero-b' }
136
147
  }
137
148
  }
138
149
  ```
@@ -15,9 +15,11 @@ Context Protocol (MCP).
15
15
  | Tool | Description |
16
16
  | ------------------------ | ------------------------------------------------------------ |
17
17
  | `list_projects` | Lists your organizations and projects |
18
+ | `list_workspaces` | Lists the workspaces in a project |
18
19
  | `get_workspace_overview` | Reads the full workspace state |
19
20
  | `get_schema_info` | Reads the documentation for Picked concepts and the data model |
20
- | `get_picked_docs` | Reads the complete Picked documentation, as text for an agent |
21
+ | `list_picked_docs` | Lists every Picked documentation page with its URL |
22
+ | `read_picked_doc` | Reads one documentation page, or one section of it |
21
23
 
22
24
  ### Experiences
23
25