@picked/client 0.0.1-dev.1785305085063 → 0.0.1-dev.1785908062293

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 (291) hide show
  1. package/dist/.tsbuildinfo +1 -0
  2. package/dist/api-03c5jvVk.js +38 -0
  3. package/dist/api-CQxCVIrm.cjs +1 -0
  4. package/dist/cjs/form/index.js +1 -1
  5. package/dist/cjs/index.js +2 -2
  6. package/dist/cjs/plugins/dom-observer/index.js +1 -1
  7. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  8. package/dist/cjs/server/index.js +1 -1
  9. package/dist/docs/explanation/conditions-and-the-logic-engine.md +94 -0
  10. package/dist/docs/explanation/feature-flag-allocation.md +176 -0
  11. package/dist/docs/explanation/how-picked-works.md +124 -0
  12. package/dist/docs/explanation/how-pickedql-works.md +76 -0
  13. package/dist/docs/explanation/pages-and-flows.md +64 -0
  14. package/dist/docs/explanation/the-content-model.md +77 -0
  15. package/dist/docs/explanation/the-two-apis.md +68 -0
  16. package/dist/docs/explanation/why-server-side-rendering.md +76 -0
  17. package/dist/docs/explanation/workspaces-and-versions.md +71 -0
  18. package/dist/docs/how-to/add-a-step-field-or-action.md +43 -0
  19. package/dist/docs/{pickedql/examples.md → how-to/analytics/index.md} +53 -28
  20. package/dist/docs/how-to/archive-or-delete-a-workspace.md +46 -0
  21. package/dist/docs/how-to/authenticate-with-a-magic-link.md +40 -0
  22. package/dist/docs/how-to/authenticate-with-a-password.md +51 -0
  23. package/dist/docs/how-to/authenticate-with-an-api-key.md +51 -0
  24. package/dist/docs/how-to/authenticate-with-oauth.md +40 -0
  25. package/dist/docs/how-to/build-a-flow.md +83 -0
  26. package/dist/docs/how-to/connect-the-mcp-server.md +38 -0
  27. package/dist/docs/how-to/create-a-project.md +29 -0
  28. package/dist/docs/how-to/create-an-experience.md +42 -0
  29. package/dist/docs/how-to/create-and-revoke-an-api-key.md +37 -0
  30. package/dist/docs/how-to/debug-with-the-chrome-extension.md +57 -0
  31. package/dist/docs/how-to/define-a-page-layout.md +39 -0
  32. package/dist/docs/how-to/fill-and-publish-a-page.md +50 -0
  33. package/dist/docs/how-to/install-the-gtm-template.md +84 -0
  34. package/dist/docs/how-to/install-the-sdk.md +68 -0
  35. package/dist/docs/how-to/install-the-vite-plugin.md +56 -0
  36. package/dist/docs/how-to/invite-and-remove-members.md +34 -0
  37. package/dist/docs/how-to/preview-a-workspace.md +28 -0
  38. package/dist/docs/how-to/publish-a-workspace.md +30 -0
  39. package/dist/docs/how-to/read-a-feature-flag.md +101 -0
  40. package/dist/docs/how-to/register-a-component.md +55 -0
  41. package/dist/docs/how-to/register-an-action-handler.md +67 -0
  42. package/dist/docs/how-to/render-a-step-form.md +132 -0
  43. package/dist/docs/how-to/render-an-unpublished-preview.md +41 -0
  44. package/dist/docs/how-to/reuse-a-section.md +37 -0
  45. package/dist/docs/how-to/reuse-a-step-field-or-action.md +28 -0
  46. package/dist/docs/how-to/roll-back-a-published-version.md +26 -0
  47. package/dist/docs/how-to/run-an-ab-test.md +49 -0
  48. package/dist/docs/how-to/run-code-on-a-form-submission.md +125 -0
  49. package/dist/docs/how-to/server-render-a-page.md +81 -0
  50. package/dist/docs/how-to/set-a-content-security-policy.md +32 -0
  51. package/dist/docs/how-to/set-up-mfa.md +69 -0
  52. package/dist/docs/how-to/upload-and-use-an-asset.mdx +73 -0
  53. package/dist/docs/how-to/validate-a-field.md +52 -0
  54. package/dist/docs/how-to/write-a-condition.md +45 -0
  55. package/dist/docs/how-to/write-a-predicate.md +60 -0
  56. package/dist/docs/index.md +41 -59
  57. package/dist/docs/reference/dashboard/actions.mdx +53 -0
  58. package/dist/docs/reference/dashboard/api-keys.mdx +37 -0
  59. package/dist/docs/reference/dashboard/conditions.mdx +42 -0
  60. package/dist/docs/reference/dashboard/content/asset-library.mdx +63 -0
  61. package/dist/docs/reference/dashboard/content/content-entries.mdx +44 -0
  62. package/dist/docs/reference/dashboard/content/layouts.mdx +62 -0
  63. package/dist/docs/reference/dashboard/content/pages.mdx +35 -0
  64. package/dist/docs/reference/dashboard/content/sections.mdx +28 -0
  65. package/dist/docs/reference/dashboard/experiences.mdx +51 -0
  66. package/dist/docs/reference/dashboard/features.mdx +114 -0
  67. package/dist/docs/reference/dashboard/fields.mdx +100 -0
  68. package/dist/docs/reference/dashboard/flow-builder/canvas.mdx +58 -0
  69. package/dist/docs/reference/dashboard/flow-builder/condition-builder.md +57 -0
  70. package/dist/docs/reference/dashboard/flow-builder/keyboard-shortcuts.md +72 -0
  71. package/dist/docs/reference/dashboard/flow-builder/nodes.md +63 -0
  72. package/dist/docs/reference/dashboard/projects.mdx +44 -0
  73. package/dist/docs/reference/dashboard/reports.mdx +43 -0
  74. package/dist/docs/reference/dashboard/steps.mdx +37 -0
  75. package/dist/docs/reference/dashboard/team-management.md +29 -0
  76. package/dist/docs/reference/dashboard/workspace-versioning.mdx +30 -0
  77. package/dist/docs/reference/dashboard/workspaces.mdx +76 -0
  78. package/dist/docs/{delivery-api → reference/delivery-api}/experience-content.md +17 -5
  79. package/dist/docs/reference/delivery-api/index.md +45 -0
  80. package/dist/docs/reference/delivery-api/preview-caching-crawling.md +79 -0
  81. package/dist/docs/{delivery-api → reference/delivery-api}/project-config.md +15 -6
  82. package/dist/docs/reference/glossary.md +173 -0
  83. package/dist/docs/reference/management-api/authentication.md +74 -0
  84. package/dist/docs/{api → reference/management-api}/authorization-and-scopes.md +70 -47
  85. package/dist/docs/reference/management-api/error-handling.md +233 -0
  86. package/dist/docs/{api → reference/management-api}/pagination.md +36 -20
  87. package/dist/docs/reference/pickedql/data-sources.md +174 -0
  88. package/dist/docs/reference/pickedql/dimensions.md +87 -0
  89. package/dist/docs/{pickedql → reference/pickedql}/filtering.md +17 -6
  90. package/dist/docs/reference/pickedql/index.md +18 -0
  91. package/dist/docs/reference/pickedql/schema.md +172 -0
  92. package/dist/docs/reference/pickedql/virtual-functions.md +237 -0
  93. package/dist/docs/reference/sdk/actions.md +30 -0
  94. package/dist/docs/{sdk → reference/sdk}/conditions.md +15 -5
  95. package/dist/docs/reference/sdk/content-security-policy.md +21 -0
  96. package/dist/docs/reference/sdk/experiences.md +51 -0
  97. package/dist/docs/reference/sdk/features.md +233 -0
  98. package/dist/docs/reference/sdk/fields.md +209 -0
  99. package/dist/docs/reference/sdk/index.md +68 -0
  100. package/dist/docs/{sdk → reference/sdk}/plugins/create-experience.md +25 -34
  101. package/dist/docs/reference/sdk/plugins/dynamic-experiences.md +74 -0
  102. package/dist/docs/reference/sdk/plugins/index.md +29 -0
  103. package/dist/docs/{sdk → reference/sdk}/plugins/window-object.md +6 -0
  104. package/dist/docs/reference/sdk/predicates.md +43 -0
  105. package/dist/docs/reference/sdk/ssr/index.md +33 -0
  106. package/dist/docs/reference/sdk/ssr/rendering-and-hydration.md +103 -0
  107. package/dist/docs/reference/sdk/ssr/serialize.md +77 -0
  108. package/dist/docs/reference/sdk/ssr/slots-and-placements.md +59 -0
  109. package/dist/docs/reference/sdk/steps.md +87 -0
  110. package/dist/docs/reference/tools/chrome-extension.md +16 -0
  111. package/dist/docs/reference/tools/image-optimisation-service.md +104 -0
  112. package/dist/docs/reference/tools/mcp.md +88 -0
  113. package/dist/docs/reference/tools/vite-plugin.md +88 -0
  114. package/dist/docs/tutorials/first-api-call.md +228 -0
  115. package/dist/docs/tutorials/first-experience-in-the-dashboard.mdx +143 -0
  116. package/dist/docs/tutorials/first-experience.mdx +255 -0
  117. package/dist/docs/tutorials/first-server-rendered-page.mdx +186 -0
  118. package/dist/{dom-BwmTHeT7.js → dom-BqcToNL0.js} +1 -3
  119. package/dist/{dom-CDrHc_j9.cjs → dom-DlLH3FxV.cjs} +1 -1
  120. package/dist/esm/form/index.js +2 -4
  121. package/dist/esm/index.js +225 -186
  122. package/dist/esm/plugins/dom-observer/index.js +1 -1
  123. package/dist/esm/plugins/dynamic-experiences/index.js +3 -3
  124. package/dist/esm/preview/index.js +1 -1
  125. package/dist/esm/server/index.js +33 -31
  126. package/dist/{experience-instance-DOJShRk5.js → experience-instance-DGk11d8a.js} +3 -3
  127. package/dist/experience-instance-Dej3P1sE.cjs +1 -0
  128. package/dist/plugin-CHOVsx7Z.js +287 -0
  129. package/dist/plugin-DsaGXQHx.cjs +1 -0
  130. package/dist/{preview-channel-DW9J8t4B.js → preview-channel-CSr96XAo.js} +1 -1
  131. package/dist/{protocol-DSqOlW2r.js → protocol-C5KkkiZc.js} +1 -1
  132. package/dist/types/client.d.ts +7 -6
  133. package/dist/types/data-source/api.d.ts +60 -0
  134. package/dist/types/data-source/api.d.ts.map +1 -0
  135. package/dist/types/data-source/provider.d.ts +97 -0
  136. package/dist/types/data-source/provider.d.ts.map +1 -0
  137. package/dist/types/entities/action/action.d.ts +5 -4
  138. package/dist/types/entities/action/action.d.ts.map +1 -1
  139. package/dist/types/entities/component/component.d.ts +6 -5
  140. package/dist/types/entities/component/component.d.ts.map +1 -1
  141. package/dist/types/entities/condition/condition.d.ts +5 -5
  142. package/dist/types/entities/content/content.d.ts +4 -3
  143. package/dist/types/entities/experience/experience.d.ts +11 -10
  144. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  145. package/dist/types/entities/experience-instance/experience-instance.d.ts +10 -9
  146. package/dist/types/entities/feature/feature.d.ts +19 -2
  147. package/dist/types/entities/feature/feature.d.ts.map +1 -1
  148. package/dist/types/entities/field/field.d.ts +7 -6
  149. package/dist/types/entities/framework/framework.d.ts +7 -6
  150. package/dist/types/entities/framework/framework.d.ts.map +1 -1
  151. package/dist/types/entities/history/history.d.ts +6 -6
  152. package/dist/types/entities/plugin/plugin.d.ts +3 -2
  153. package/dist/types/entities/plugin/plugin.d.ts.map +1 -1
  154. package/dist/types/entities/predicate/predicate.d.ts +4 -3
  155. package/dist/types/entities/predicate/predicate.d.ts.map +1 -1
  156. package/dist/types/entities/response/response-validation.d.ts +3 -2
  157. package/dist/types/entities/response/response.d.ts +12 -11
  158. package/dist/types/entities/session/session.d.ts +2 -1
  159. package/dist/types/entities/step/step.d.ts +6 -5
  160. package/dist/types/exports.d.ts +2 -1
  161. package/dist/types/exports.d.ts.map +1 -1
  162. package/dist/types/form/build-responses.d.ts +2 -1
  163. package/dist/types/form/create-field-evaluator.d.ts +4 -3
  164. package/dist/types/form/create-field-validation.d.ts +5 -4
  165. package/dist/types/form/create-form.d.ts +7 -6
  166. package/dist/types/form/create-submit-pipeline.d.ts +7 -6
  167. package/dist/types/form/get-step-fields.d.ts +3 -2
  168. package/dist/types/lifecycle/condition-selection.d.ts +14 -4
  169. package/dist/types/lifecycle/lifecycle.d.ts +4 -3
  170. package/dist/types/lifecycle/rules-logic.d.ts +4 -3
  171. package/dist/types/lifecycle/state-snapshot.d.ts +4 -3
  172. package/dist/types/picked.d.ts +79 -62
  173. package/dist/types/picked.d.ts.map +1 -1
  174. package/dist/types/ping.d.ts +1 -1
  175. package/dist/types/ping.d.ts.map +1 -1
  176. package/dist/types/plugins/create-experience/create-experience.d.ts +9 -8
  177. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  178. package/dist/types/plugins/create-experience/plugin.d.ts +3 -2
  179. package/dist/types/plugins/create-experience/plugin.d.ts.map +1 -1
  180. package/dist/types/plugins/create-experience/serialization.d.ts.map +1 -1
  181. package/dist/types/plugins/dom-observer/plugin.d.ts +1 -1
  182. package/dist/types/plugins/dynamic-experiences/hash.d.ts +40 -5
  183. package/dist/types/plugins/dynamic-experiences/hash.d.ts.map +1 -1
  184. package/dist/types/plugins/dynamic-experiences/index.d.ts +2 -0
  185. package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
  186. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +4 -36
  187. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
  188. package/dist/types/plugins/dynamic-experiences/types.d.ts +42 -11
  189. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
  190. package/dist/types/plugins/experience-browser-storage/plugin.d.ts +1 -1
  191. package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
  192. package/dist/types/plugins/history-browser-storage/plugin.d.ts +1 -1
  193. package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
  194. package/dist/types/plugins/responses-browser-storage/plugin.d.ts +1 -1
  195. package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
  196. package/dist/types/plugins/responses-indexeddb/plugin.d.ts +1 -1
  197. package/dist/types/plugins/single-page-app/plugin.d.ts +1 -1
  198. package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
  199. package/dist/types/plugins/web-components/plugin.d.ts +2 -1
  200. package/dist/types/plugins/window-object/plugin.d.ts +2 -2
  201. package/dist/types/preview-channel.d.ts +5 -1
  202. package/dist/types/preview-receiver/index.d.ts +18 -1
  203. package/dist/types/preview-receiver/protocol.d.ts +10 -1
  204. package/dist/types/server/index.d.ts +3 -3
  205. package/dist/types/server/serialize.d.ts +8 -2
  206. package/dist/types/server/serialize.d.ts.map +1 -1
  207. package/dist/types/utils/dom.d.ts +2 -1
  208. package/dist/types/utils/events.d.ts +6 -6
  209. package/dist/types/utils/events.d.ts.map +1 -1
  210. package/dist/types/utils/global-obj.d.ts +1 -1
  211. package/dist/types/utils/global-obj.d.ts.map +1 -1
  212. package/dist/types/utils/id.d.ts.map +1 -1
  213. package/dist/types/utils/logger.d.ts +2 -1
  214. package/dist/types/utils/logger.d.ts.map +1 -1
  215. package/dist/types/utils/node-tree/get-next-node-from-action.d.ts +2 -1
  216. package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts +2 -1
  217. package/dist/types/utils/node-tree/get-next-node.d.ts +1 -1
  218. package/dist/types/utils/node-tree/get-next-node.d.ts.map +1 -1
  219. package/dist/types/utils/node-tree/get-origin-node.d.ts +1 -1
  220. package/dist/types/utils/node-tree/get-origin-node.d.ts.map +1 -1
  221. package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts +1 -1
  222. package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts.map +1 -1
  223. package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts +1 -1
  224. package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts.map +1 -1
  225. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts +1 -1
  226. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
  227. package/dist/types/utils/nodes.d.ts +1 -1
  228. package/dist/types/utils/picked-config.d.ts +2 -1
  229. package/dist/types/utils/rehydrate-scripts.d.ts +6 -0
  230. package/dist/types/utils/rehydrate-scripts.d.ts.map +1 -1
  231. package/dist/types/utils/rules-logic.d.ts +6 -2
  232. package/dist/types/utils/storage.d.ts +1 -1
  233. package/dist/types/utils/storage.d.ts.map +1 -1
  234. package/package.json +22 -23
  235. package/dist/api-CPL40b7A.js +0 -40
  236. package/dist/api-Dz5rgRgQ.cjs +0 -1
  237. package/dist/docs/actions.mdx +0 -78
  238. package/dist/docs/api/authentication.md +0 -376
  239. package/dist/docs/api/error-handling.md +0 -211
  240. package/dist/docs/api/index.md +0 -197
  241. package/dist/docs/api-keys.mdx +0 -40
  242. package/dist/docs/chrome-extension.md +0 -51
  243. package/dist/docs/conditions.mdx +0 -59
  244. package/dist/docs/content/asset-library.mdx +0 -93
  245. package/dist/docs/content/content-entries.mdx +0 -30
  246. package/dist/docs/content/layouts.mdx +0 -70
  247. package/dist/docs/content/pages.mdx +0 -67
  248. package/dist/docs/content/sections.mdx +0 -33
  249. package/dist/docs/delivery-api/index.md +0 -46
  250. package/dist/docs/delivery-api/preview-caching-crawling.md +0 -59
  251. package/dist/docs/experiences.mdx +0 -42
  252. package/dist/docs/features.mdx +0 -58
  253. package/dist/docs/fields.mdx +0 -79
  254. package/dist/docs/flow-builder/building-flows.md +0 -61
  255. package/dist/docs/flow-builder/condition-builder.md +0 -54
  256. package/dist/docs/flow-builder/keyboard-shortcuts.md +0 -66
  257. package/dist/docs/flow-builder/nodes.md +0 -43
  258. package/dist/docs/flow-builder/overview.mdx +0 -50
  259. package/dist/docs/gtm-template.md +0 -69
  260. package/dist/docs/guides/build-a-personalized-page.mdx +0 -143
  261. package/dist/docs/image-optimisation-service.md +0 -80
  262. package/dist/docs/mcp.md +0 -120
  263. package/dist/docs/pickedql/data-sources.md +0 -145
  264. package/dist/docs/pickedql/dimensions.md +0 -65
  265. package/dist/docs/pickedql/index.md +0 -36
  266. package/dist/docs/pickedql/schema.md +0 -156
  267. package/dist/docs/pickedql/virtual-functions.md +0 -204
  268. package/dist/docs/projects.mdx +0 -37
  269. package/dist/docs/reports.mdx +0 -18
  270. package/dist/docs/sdk/actions.md +0 -66
  271. package/dist/docs/sdk/content-security-policy.md +0 -32
  272. package/dist/docs/sdk/experiences.md +0 -46
  273. package/dist/docs/sdk/features.md +0 -212
  274. package/dist/docs/sdk/fields.md +0 -263
  275. package/dist/docs/sdk/index.md +0 -83
  276. package/dist/docs/sdk/plugins/dynamic-experiences.md +0 -58
  277. package/dist/docs/sdk/plugins/index.md +0 -9
  278. package/dist/docs/sdk/predicates.md +0 -112
  279. package/dist/docs/sdk/ssr/index.md +0 -62
  280. package/dist/docs/sdk/ssr/rendering-and-hydration.md +0 -141
  281. package/dist/docs/sdk/ssr/serialize.md +0 -86
  282. package/dist/docs/sdk/ssr/slots-and-placements.md +0 -35
  283. package/dist/docs/sdk/steps.md +0 -434
  284. package/dist/docs/steps.mdx +0 -44
  285. package/dist/docs/team-management.md +0 -40
  286. package/dist/docs/vite-plugin.md +0 -82
  287. package/dist/docs/workspace-versioning.mdx +0 -28
  288. package/dist/docs/workspaces.mdx +0 -102
  289. package/dist/experience-instance-DurC3pE-.cjs +0 -1
  290. package/dist/plugin-CFXwbXeM.js +0 -247
  291. package/dist/plugin-m4qekgtA.cjs +0 -1
@@ -0,0 +1,176 @@
1
+ ---
2
+ type: explanation
3
+ layout: docs
4
+ ---
5
+
6
+ # About feature flag allocation
7
+
8
+ When does a visitor enter a test, and what decides the group they land in? The answer is
9
+ not "when you create the feature flag" and not "when the page loads". It is the moment something
10
+ reads the bucket, and that moment is yours to choose.
11
+
12
+ ## A registration is not a decision
13
+
14
+ The SDK loads every feature flag in your project at startup. It allocates nobody then. A feature flag
15
+ stays undecided until something reads its bucket. The first read runs the `decide`
16
+ function, stores the result, and reports the decision.
17
+
18
+ You therefore choose when Picked commits a visitor to a feature flag. You choose it by the point
19
+ at which you read the feature flag.
20
+
21
+ ## A read of the bucket records an exposure
22
+
23
+ The first read is the decision, so it is also the moment the visitor enters the test. If
24
+ you read every feature flag at startup, every visitor counts as exposed to every test. That
25
+ includes a test the visitor never reached.
26
+
27
+ Read a feature flag where the decision matters: after the cart loads, after the quote returns, or
28
+ after you know who the visitor is. A feature flag that you read before that point puts a visitor in
29
+ a test they never saw, and the uplift number then means nothing.
30
+
31
+ ## A condition reads the bucket, so a condition allocates
32
+
33
+ Most reads are not calls that you write. They come from a condition. A condition that
34
+ points at a feature flag with `invoke: { var: 'features.<id>' }` must have the bucket
35
+ before it can compare it. That read allocates the visitor, exactly as a call in your own
36
+ code does.
37
+
38
+ Where the condition sits therefore decides who enters the test:
39
+
40
+ | The condition is | It runs | Who enters the test |
41
+ | --- | --- | --- |
42
+ | An experience condition | When Picked evaluates that experience | Only a visitor who reaches the experience |
43
+ | A precondition | At startup, before anything else | Every visitor who loads the page |
44
+
45
+ A precondition that points at a feature flag allocates every visitor on your site, and it
46
+ does so before the visitor sees anything. Keep a feature flag out of a precondition unless
47
+ it truly controls whether Picked starts at all.
48
+
49
+ Keep each `decide` function fast for the same reason. Everything that waits for the
50
+ condition waits for `decide`, and that includes the experience itself. A network call
51
+ inside `decide` delays what the visitor sees.
52
+
53
+ ## How Picked chooses
54
+
55
+ For a feature flag you control from the dashboard the choice is deterministic. Picked
56
+ gives each visitor a stable value for each feature flag. It derives that value from the
57
+ visitor ID and from the ID of the feature flag, and it compares the value against the
58
+ weight. Picked allocates the visitor when the value is below the weight.
59
+
60
+ The same visitor gets the same result for one feature flag on every visit, while the
61
+ weight stays the same.
62
+
63
+ That is also why a feature flag you control from the dashboard cannot use the data of
64
+ your application in its decision. The value comes from the visitor ID, the feature flag
65
+ ID, and the weight, and from nothing else. Define the feature flag in SDK code when the
66
+ decision needs a cart, a quote, or a profile.
67
+
68
+ ## Each feature flag is independent
69
+
70
+ Picked builds that value from the visitor ID together with the ID of the feature flag.
71
+ Each feature flag therefore gets its own value, and tests that run at the same time are
72
+ independent of each other.
73
+
74
+ Two feature flags, both at weight 50, split your visitors into four equal parts:
75
+ allocated to both, to one, to the other, or to neither. Three feature flags at weight 50
76
+ give eight groups of 12.5%. Add a feature flag and the groups divide again.
77
+
78
+ This is what lets you read two experiments separately. Give every feature flag the same
79
+ value, and two feature flags at weight 50 hold exactly the same visitors. Your analytics
80
+ then never sees the mixed groups that tell one result from the other.
81
+
82
+ ## The allocation ratchets
83
+
84
+ Inside one feature flag, a larger weight only adds visitors. Everybody allocated at
85
+ weight 30 is still allocated at weight 50. The allocation is a **ratchet**: it turns one
86
+ way, and a larger weight never moves a visitor back out.
87
+
88
+ That property is what makes a staged release safe. A visitor who sees the change at 10%
89
+ still sees it at 20%. A smaller weight is the reverse turn. It removes visitors from the
90
+ top of the range, and every visitor below the new weight keeps what they had.
91
+
92
+ ## A disabled feature flag records nothing
93
+
94
+ A disabled feature flag allocates nobody, and the difference from a weight of 0
95
+ matters for your reports. At weight 0 the visitor is in the test, and in the
96
+ control group. When the feature flag is disabled, the visitor is not in the test at all.
97
+
98
+ The SDK does not evaluate a disabled feature flag. It writes no decision to browser
99
+ storage and it reports no decision. The feature flag is also absent from the feature
100
+ list on every analytics event. Expect a step change in your reports when you disable
101
+ one: fewer feature flags for each visitor, and fewer decision events.
102
+
103
+ This state is temporary. A visitor allocated before you disabled the feature flag keeps
104
+ that bucket in the browser. When you enable the feature flag again, that visitor continues
105
+ in the same group.
106
+
107
+ ## What a version does, and what it does not
108
+
109
+ Each feature flag carries a version, and it starts at 1. The SDK caches the bucket in
110
+ browser storage under a key that holds the feature flag ID and the version. A visitor
111
+ therefore keeps the same bucket across page loads.
112
+
113
+ Change a weight and leave the version as it is, and that cache decides the result. A
114
+ visitor who has a cached bucket keeps it. The new weight reaches only a visitor who has no
115
+ cache. Your reports then hold two groups of visitors at the same time, one measured
116
+ against the old weight and one against the new.
117
+
118
+ Increment the version and the old cache key no longer matches. The feature flag counts as
119
+ undecided, `decide` runs again on the next page load, and every visitor is measured
120
+ against the new weight. Increment it after each weight change, unless you intend the
121
+ change to reach new visitors only.
122
+
123
+ **The version affects the cache only. It is not part of the allocation.** The ratchet
124
+ still holds after you increment the version: a visitor allocated at weight 30 is allocated
125
+ again at weight 50. You cannot decrement a version.
126
+
127
+ ## When the SDK reports a decision
128
+
129
+ The SDK sends `feature_decide` the first time that it allocates a visitor to a bucket,
130
+ and only then. On a later page load it restores that bucket from browser storage and sends
131
+ nothing. A visitor who returns therefore produces no `feature_decide` event, although that
132
+ visitor is still in the group they went into the first time.
133
+
134
+ An integration that listens only for `feature_decide` under-reports every visitor who
135
+ returns. Choose the source that matches your question:
136
+
137
+ | Question | Source |
138
+ | --- | --- |
139
+ | Which bucket is this visitor in now? | [`client.features.listStore`](/how-to/read-a-feature-flag#1-choose-an-accessor) |
140
+ | Did the SDK allocate a visitor now? | [`feature_decide` on `client.eventBus`](/reference/sdk/features#watch-for-feature-flag-decisions) |
141
+ | Which allocations happened before I subscribed? | [`client.events`](/reference/sdk/features#read-the-events-that-already-happened) |
142
+
143
+ `listStore` updates each time that a feature flag resolves. It does this whether the SDK
144
+ restored the bucket from storage or allocated the visitor now. A watch on it therefore
145
+ always gives the current state.
146
+ Use `feature_decide` only when you need to know that Picked allocated a visitor at that
147
+ moment.
148
+
149
+ ## What Picked reports for you
150
+
151
+ Every Picked analytics event carries a `feature_list` context, and a report of your own
152
+ can use it. The context describes each feature flag that this visitor resolved: the
153
+ feature flag ID, the name, the version key, and the bucket. Only a resolved feature flag
154
+ appears there, so the context shows what the visitor was exposed to at the time when the
155
+ event fired.
156
+
157
+ The optional [Sentry plugin](https://www.npmjs.com/package/@picked/sentry) also tags each
158
+ allocation onto the Sentry scope as `picked.feature.<id>`, with the bucket as the value.
159
+ You can then filter your errors by the variant.
160
+
161
+ ## Preview mode
162
+
163
+ In preview mode the SDK stores the bucket in session storage and not in local storage. The
164
+ bucket does not stay after you close the tab, and Picked can allocate a preview visitor
165
+ differently from a production visitor. Treat a preview allocation as disposable.
166
+
167
+ A feature flag that you define in SDK code can ask for the same thing in production with
168
+ `storage: 'session'`. Use it for a short test that must not last across browser sessions.
169
+
170
+ ## Related
171
+
172
+ - [How to read a feature flag](/how-to/read-a-feature-flag) — the accessors, and which
173
+ ones resolve the feature flag.
174
+ - [Feature flags](/reference/dashboard/features) — the dashboard controls.
175
+ - [SDK feature flags](/reference/sdk/features) — the definition shape and the accessor
176
+ table.
@@ -0,0 +1,124 @@
1
+ ---
2
+ type: explanation
3
+ layout: docs
4
+ ---
5
+
6
+ # About how Picked works
7
+
8
+ What happens between the moment an editor clicks **Publish** and the moment a visitor
9
+ sees the result? This page follows one change through the whole system.
10
+
11
+ ## The shape of it
12
+
13
+ Picked splits into two parts that meet at a published snapshot.
14
+
15
+ ```
16
+ Author (dashboard) -> Publish -> Delivery API (config + content)
17
+ -> SDK reads it -> conditions decide -> component renders
18
+ ```
19
+
20
+ On the left, an editor works in a workspace. Nothing they do reaches a visitor. On the
21
+ right, the SDK in your application reads what was published and renders it. The snapshot
22
+ between them is immutable, so each part moves at its own speed. An editor publishes with
23
+ no deployment, and you deploy with no change to the content.
24
+
25
+ ## What happens when you publish
26
+
27
+ Picked takes the current workspace and makes an immutable snapshot of it. The result is a
28
+ version, and a project serves exactly one version at a time, the live one. Nothing in a
29
+ published version can change later. A roll-back moves the live pointer of the project to
30
+ an earlier version, and it changes no data.
31
+
32
+ That is why the dashboard has a draft state at all. The workspace holds the work that is
33
+ still in progress. The version holds what your visitors get.
34
+
35
+ ## What the SDK does at startup
36
+
37
+ `createClient()` builds the client, and `client.start()` runs it. Between those two calls
38
+ nothing happens yet.
39
+
40
+ 1. **Options resolve.** The dynamic experiences plugin reads the configuration of your
41
+ project from the source that its `mode` names. That is the data in your bundle, or a
42
+ request to the Delivery API. A preview token replaces both.
43
+ 2. **Everything registers.** The plugin registers every feature flag, condition, field,
44
+ step, and experience from that configuration. You declare none of them in code.
45
+ 3. **Preconditions run.** A precondition asks whether Picked should start at all. A
46
+ condition asks whether this visitor is eligible.
47
+ 4. **Experiences resolve.** Each experience evaluates its condition and looks for its
48
+ target element in the page.
49
+ 5. **Components render.** An experience whose condition is true, and whose target exists,
50
+ renders the component you registered under its component name.
51
+
52
+ Step 1 is why the [Vite plugin](/reference/tools/vite-plugin) exists: it embeds the
53
+ options at build time, so production makes no request at startup.
54
+
55
+ ## Why the browser and the server can read from different places
56
+
57
+ The two ends of a server-rendered page want different things. Your server wants a new
58
+ version to reach visitors at once. That needs a request to the API. The browser wants no
59
+ request at all. That needs the data in your bundle.
60
+
61
+ The `mode` option belongs to one end only, so you can have both. Give `'api'` to your
62
+ server and `'bundle'` to your browser.
63
+
64
+ Each end stays consistent with itself. The configuration and the content that one end
65
+ reads always come from the same source. Picked gives them the same version.
66
+
67
+ The two ends can still hold different versions. An editor publishes a workspace between
68
+ your build and the request, which moves the server to a newer version than the bundle.
69
+ The snapshot from the server then wins. The browser keeps it, and drops the configuration
70
+ that it read.
71
+
72
+ The reason is that the server made the page from that snapshot. To register a different
73
+ configuration over the top makes the page and the client show different data. One
74
+ version behind is the safer of the two results. The client records the two version IDs on
75
+ `client.versionSkew`, and the [devtools](/reference/tools/chrome-extension) show them.
76
+
77
+ ## Why the flow is a graph
78
+
79
+ An experience is not a list of screens. It is a directed graph, and the SDK walks it.
80
+
81
+ The origin node is the entry point. From there each edge leads to a step, an action, or a
82
+ condition. A step waits for the visitor. An action runs a side effect and does not
83
+ interrupt them. A condition evaluates a rule and sends the flow down one of two paths.
84
+
85
+ The walk is what makes a branch cost so little. To show a different screen to a different
86
+ visitor you add a condition node, and not a second copy of the flow. The same step can
87
+ appear in several flows, because a step belongs to the project and the graph only
88
+ points at it.
89
+
90
+ ## How an action decides which way to go
91
+
92
+ An action node can carry a success branch and a failure branch, and the SDK picks between
93
+ them from the outcome of your handler:
94
+
95
+ - The handler **throws**, or its promise rejects: the flow takes the failure branch.
96
+ - The handler **resolves** to any value at all, and that includes `false`: the flow takes
97
+ the success branch.
98
+
99
+ This difference matters more than it looks. A valid negative result is not a failure. An
100
+ endpoint that answers `200` with `{ serviced: false }` succeeded — it told you something
101
+ true. Record that value as a response and branch on it with a condition. Keep the failure
102
+ branch for a request that did not complete.
103
+
104
+ Get this wrong and your failure branch holds two different things at once: a network
105
+ error, and a visitor who lives outside your service area.
106
+
107
+ ## Where content comes in
108
+
109
+ A flow renders in the browser. A page renders on your server, from content held in the
110
+ Picked CMS, so a search engine reads it in the first response. Both are experiences, and
111
+ both go through the same publish.
112
+
113
+ The difference is only the place where each one renders, and that follows from what the
114
+ content is for. See [About pages and flows](/explanation/pages-and-flows) and
115
+ [About server-side rendering](/explanation/why-server-side-rendering).
116
+
117
+ ## Related
118
+
119
+ - [Add Picked to your application](/tutorials/first-experience) — the whole path, in
120
+ practice.
121
+ - [About workspaces and versions](/explanation/workspaces-and-versions) — draft, live,
122
+ and roll-back.
123
+ - [Delivery API](/reference/delivery-api) — what the published snapshot looks like on the
124
+ wire.
@@ -0,0 +1,76 @@
1
+ ---
2
+ type: explanation
3
+ layout: docs
4
+ ---
5
+
6
+ # About PickedQL
7
+
8
+ PickedQL is SQL over your Picked analytics data, but it is not only SQL. It expands what
9
+ you write before it runs. Why add a layer at all, and not give you the tables?
10
+
11
+ ## The problem it answers
12
+
13
+ An A/B test question is short to ask, and the SQL behind it is not. Take one question:
14
+ "How many users are in the control group?" It needs four things. It needs a filter on the
15
+ variant, a count of distinct users, a join to each dimension in the group, and a tenant
16
+ filter.
17
+
18
+ Write that by hand for every question, and most of each query is the same text again.
19
+
20
+ PickedQL lets you write the short version:
21
+
22
+ ```sql
23
+ SELECT control_users(), variant_users()
24
+ FROM metrics
25
+ WHERE project_id = 'your-project-id'
26
+ ```
27
+
28
+ ## What it expands
29
+
30
+ **Virtual tables.** A name such as `metrics` maps to the real tables below it. You name
31
+ the thing that you ask about, and not the storage.
32
+
33
+ **Virtual functions.** `control_users()` expands to a full aggregate expression. The
34
+ definition lives in one place, so every report that counts control users counts them the
35
+ same way.
36
+
37
+ **Automatic joins.** Point at a dimension column such as `device_category` or
38
+ `country_code` and PickedQL adds the `LEFT JOIN` for you. This gives you the most: a
39
+ dimension that you did not join is the most common reason for a wrong answer that looks
40
+ correct.
41
+
42
+ **SQL passthrough.** Standard SQL still works next to a virtual function, and that
43
+ includes `CASE WHEN`, window functions, and subqueries. The layer adds; it does not
44
+ restrict.
45
+
46
+ ## Why every query must carry a tenant filter
47
+
48
+ Every query must carry a tenant filter in its `WHERE` clause. That filter is `project_id`
49
+ for most tables. The `projects` table uses `id` instead, because there the row ID *is* the
50
+ project ID.
51
+
52
+ PickedQL reads that filter and checks your permission for that project. The filter is
53
+ therefore not a convention that you can forget. Without one, the query does not run.
54
+ The isolation is a property of the language, and not of each author.
55
+
56
+ ## Which table to reach for
57
+
58
+ | Table | Use it for |
59
+ | --- | --- |
60
+ | `metrics` | A dashboard. The data is aggregated first, so it is much faster than raw events. |
61
+ | `events` | Anything deeper. Raw events let you build any breakdown or funnel. |
62
+ | `experience_journey` | A sankey or a funnel chart. One line of SQL returns `source, target, users`. |
63
+
64
+ Note what `experience_journey` does for you. It builds the eight common table expressions
65
+ that a path analysis needs. Those remove the duplicates, rank the top paths, and call
66
+ `lagInFrame`. You pass your parameters in the `WHERE` clause.
67
+
68
+ Some reference columns are free on `events`. `step_title`, `experience_title`, and
69
+ `project_name` come from reference tables that PickedQL joins for you.
70
+
71
+ ## Related
72
+
73
+ - [PickedQL](/reference/pickedql) — the language surface.
74
+ - [Data sources](/reference/pickedql/data-sources) — every table.
75
+ - [Virtual functions](/reference/pickedql/virtual-functions) — every function.
76
+ - [How to run an analytics query](/how-to/analytics) — worked examples.
@@ -0,0 +1,64 @@
1
+ ---
2
+ type: explanation
3
+ layout: docs
4
+ ---
5
+
6
+ # About pages and flows
7
+
8
+ An experience has two kinds, and the dashboard makes you choose
9
+ between them when you create one. Why two, and how do you know which one a piece of work needs?
10
+
11
+ ## The two kinds
12
+
13
+ | | Page | Flow |
14
+ | --- | --- | --- |
15
+ | What it is | A standalone experience that your server renders from a content entry. | An interactive experience of more than one step, which the browser renders. |
16
+ | Use it for | A landing page or a campaign page where the search rank matters. | A quiz, a survey, a product finder, onboarding of more than one step. |
17
+
18
+ The split is not about how complex the content is. It is about **who has to read it**.
19
+
20
+ ## Why the split exists
21
+
22
+ A crawler and a social preview read the HTML your server returns. Neither waits for
23
+ JavaScript in the browser. Content that a search engine must find is therefore
24
+ content that must be in the first response. Only a server render puts it there.
25
+
26
+ A flow has the reverse constraint. Its value is in the interaction: a visitor answers,
27
+ the flow branches, the next screen depends on what came before. None of that can be in the
28
+ first response, because none of it exists until the visitor acts.
29
+
30
+ Choose a Page when the content must reach a search engine. Choose a Flow when the value is
31
+ in the interaction and a browser render is acceptable.
32
+
33
+ ## What backs a page
34
+
35
+ Four pieces sit behind every Page, and they are separate on purpose:
36
+
37
+ 1. A **page layout** sets the shape: which fields the page can hold.
38
+ 2. A **content entry** fills that shape with real data.
39
+ 3. A **Page** binds one entry, so the SDK can render it.
40
+ 4. The **SDK** reads the entry and renders it on your server.
41
+
42
+ Layout and entry are separate because one layout backs many entries. Describe a campaign
43
+ page one time, then make many pages from it. Change the layout and you must check every
44
+ entry again. That is why the dashboard reports an invalid entry and does not serve it.
45
+
46
+ A step layout does the same thing for one step inside a flow. The parts behave the same
47
+ way. Only the thing that they give shape to is different.
48
+
49
+ ## They meet at the same publish
50
+
51
+ Both kinds are experiences. Both live in a workspace, both go into the same immutable
52
+ version, and both come out of the same Delivery API. The SDK decides where to render each
53
+ one, and every step before that treats them the same way.
54
+
55
+ This matters, because it means a project mixes them freely. A server-rendered
56
+ landing page can carry a browser-rendered quiz inside it.
57
+
58
+ ## Related
59
+
60
+ - [About how Picked works](/explanation/how-picked-works) — the path that both kinds take.
61
+ - [About server-side rendering](/explanation/why-server-side-rendering) — how a Page
62
+ reaches the browser.
63
+ - [Pages](/reference/dashboard/content/pages) — the page editor.
64
+ - [Experiences](/reference/dashboard/experiences) — the flow options.
@@ -0,0 +1,77 @@
1
+ ---
2
+ type: explanation
3
+ layout: docs
4
+ ---
5
+
6
+ # About the content model
7
+
8
+ Picked splits your content into three pieces: a layout, a section, and a content entry.
9
+ Why three, when a page editor needs only one?
10
+
11
+ ## Schema and data are separate
12
+
13
+ A **layout** is a schema. It sets which fields a piece of content can hold, and it holds
14
+ no data itself. A **content entry** is one instance of that schema, filled with real
15
+ values.
16
+
17
+ One layout backs many entries. Describe a campaign page one time, then make many pages
18
+ from it. Each entry carries its own title, its own body, and its own image, but they all
19
+ share the shape.
20
+
21
+ That split is also what lets your code depend on content that it never saw. Your component
22
+ reads `content.title` because the layout promises a `title`. It works for every entry that
23
+ comes from that layout.
24
+
25
+ ## A layout has a fixed category
26
+
27
+ Each layout is a **page layout** or a **step layout**, and you choose which when you
28
+ create it. The category cannot change later.
29
+
30
+ | Layout | It gives shape to | Who renders it |
31
+ | --- | --- | --- |
32
+ | Page layout | A standalone [Page](/reference/dashboard/content/pages). | The SDK renders the entry on your server. |
33
+ | Step layout | One [Step](/reference/dashboard/steps) inside a Flow. | The Step renders the entry in the browser. |
34
+
35
+ The category is fixed because it decides where the SDK renders the entry. That is not a
36
+ property you can change under an entry that exists already. See
37
+ [About pages and flows](/explanation/pages-and-flows).
38
+
39
+ ## A section is a schema fragment
40
+
41
+ A layout gives shape to a whole page or a whole step. A **section** is a part that you put
42
+ inside one or more layouts.
43
+
44
+ Define a hero one time as a section, then point at it from every page layout that needs
45
+ one. Change the section and every layout that holds it changes with it.
46
+
47
+ This is the reason sections exist at all. Without them you must describe a common
48
+ structure again in each layout, and the copies then become different. It is the same
49
+ argument for one fact in one place that runs through the rest of this documentation.
50
+
51
+ ## Why a schema change does not migrate your data
52
+
53
+ Change a layout or a section, and Picked does not rewrite the entries behind it. An entry
54
+ that no longer matches its schema becomes invalid, and the dashboard shows an error on
55
+ each field that does not fit.
56
+
57
+ That is deliberate. An automatic change must decide what a new required field holds for
58
+ every entry that came before it. Any value that it chooses is content that nobody wrote.
59
+ Picked reports the error instead, and you correct it.
60
+
61
+ The cost is real. After a schema change, check every entry that uses that layout and fix
62
+ each error before you publish. Picked serves valid content only, so an entry with an error
63
+ does not reach a visitor.
64
+
65
+ ## An error points at the exact field
66
+
67
+ A validation error carries a path in JSON style, such as `sections[0].data.title`. The
68
+ path holds through nested groups, repeated fields, and sections. An error inside a
69
+ repeated group therefore tells you which item in that group holds it.
70
+
71
+ ## Related
72
+
73
+ - [Page and step layouts](/reference/dashboard/content/layouts) — every field type.
74
+ - [Sections](/reference/dashboard/content/sections) — the reusable fragments.
75
+ - [Content entries](/reference/dashboard/content/content-entries) — the editor and the
76
+ validation.
77
+ - [About pages and flows](/explanation/pages-and-flows) — which layout category you need.
@@ -0,0 +1,68 @@
1
+ ---
2
+ type: explanation
3
+ layout: docs
4
+ ---
5
+
6
+ # About the two APIs
7
+
8
+ Picked has two HTTP APIs, and a new reader often reaches for the wrong one. This page
9
+ covers which is which and why they are separate.
10
+
11
+ ## The split
12
+
13
+ | | Delivery API | Management API |
14
+ | --- | --- | --- |
15
+ | Style | REST | GraphQL |
16
+ | Access | Public, anonymous | Authenticated |
17
+ | Operations | Read-only | Read and write |
18
+ | Base | `https://api.picked.app/api/v1` | `POST https://api.picked.app/api/graphql` |
19
+ | Use it to | Serve published configuration and content to your application | Control your projects, experiences, and content |
20
+
21
+ The short rule is this: **the Delivery API serves your visitors, and the management API
22
+ serves you.**
23
+
24
+ ## Why they are not one API
25
+
26
+ Three properties of the delivery path make it a different kind of API.
27
+
28
+ **It is anonymous.** A crawler must read your published page content with no credential at
29
+ all. An API that requires a token cannot serve a search engine, and an API that serves a
30
+ search engine cannot require one.
31
+
32
+ **It is cacheable.** A published response is the same for every reader, so a shared cache
33
+ can hold it. The Delivery API sends `s-maxage` for an SDK request, and it sends
34
+ `Vary: Picked-Client`. A GraphQL endpoint that takes any query over a `POST` has none of
35
+ those properties.
36
+
37
+ **It is read-only.** Nothing that a reader reaches without a credential can change your
38
+ data. Every write stays on a separate authenticated surface, so that property holds by
39
+ design.
40
+
41
+ ## What the Delivery API serves
42
+
43
+ Two endpoints, and the SDK calls both:
44
+
45
+ - **Project config** returns the published configuration of a project: its experiences and
46
+ steps, and the content link on each step.
47
+ - **Experience content** returns the content entries behind an experience.
48
+
49
+ Your server usually calls the first and lets `serialize()` call the second. See
50
+ [About server-side rendering](/explanation/why-server-side-rendering).
51
+
52
+ ## How a preview stays out of the search index
53
+
54
+ A preview needs unpublished content, and by the definition of it that content is not
55
+ public. The Delivery API takes a `preview_token` query parameter for exactly that. It then
56
+ treats the result differently. `versionId` comes back `null`, the response is `no-store`,
57
+ and `robots.txt` does not allow the preview path.
58
+
59
+ That last part matters more than it looks. A draft that anybody can read over an anonymous
60
+ URL is a draft that a search engine can find. A campaign page that is only part complete
61
+ can then appear in the search results of a customer.
62
+
63
+ ## Related
64
+
65
+ - [Delivery API](/reference/delivery-api) — the endpoints and their responses.
66
+ - [Management API](/reference/management-api/authentication) — authentication and scopes.
67
+ - [Preview, cache, and crawlers](/reference/delivery-api/preview-caching-crawling) — the
68
+ exact cache rules and `robots.txt` rules.
@@ -0,0 +1,76 @@
1
+ ---
2
+ type: explanation
3
+ layout: docs
4
+ ---
5
+
6
+ # About server-side rendering
7
+
8
+ Why does a Page need a snapshot, when the SDK can fetch its content in the browser?
9
+ Because the reader that matters most does not run JavaScript.
10
+
11
+ ## The constraint
12
+
13
+ A crawler and a social preview read the HTML your server returns, and they do not wait for
14
+ the browser to fetch anything. If the content of a Page arrives after the first response,
15
+ those readers never see it.
16
+
17
+ So the content has to be in the HTML. That means your server has to know, before it
18
+ answers, which experiences match this URL and what their content is.
19
+
20
+ ## What the snapshot is for
21
+
22
+ `serialize()` answers that question on the server. It registers your project configuration and
23
+ evaluates each experience condition against the URL. It then reads the content for each
24
+ experience that matches, and returns a `PickedSnapshot` as plain JSON.
25
+
26
+ ```
27
+ projectConfig (Delivery API)
28
+ -> serialize(client, params) on the server -> PickedSnapshot
29
+ -> embed snapshot in HTML
30
+ -> client seeds from snapshot -> renders the same markup -> hydrates
31
+ ```
32
+
33
+ The snapshot carries the exact options the server chose with, and the condition results it
34
+ reached. The first render in the browser therefore reuses the decisions of the server. It
35
+ does not evaluate them a second time.
36
+
37
+ That last point is the whole reason the snapshot holds condition results and not only
38
+ content. A browser that evaluates the conditions itself can reach a different answer. A different URL shape, a
39
+ different time, or a different flag value each give a different result. The markup then does not
40
+ match what the server sent, and hydration discards the server HTML. That failure is the
41
+ one server-side rendering exists to prevent.
42
+
43
+ ## Why a slot instead of a selector
44
+
45
+ A browser-rendered flow points at a DOM selector, and the SDK inserts the component next
46
+ to the element that it finds. That cannot work on a server, because a server has no DOM
47
+ to search.
48
+
49
+ A slot reverses that. `<ExperienceSlot name="page" />` is a mount point that you place in
50
+ your own markup. An experience joins it when its target selector is `.picked-slot-<name>`.
51
+ Your component tree decides where the content goes, so the server renders it in one pass.
52
+
53
+ ## Why placements have an order
54
+
55
+ More than one experience can point at the same slot, so the slot needs a rule. The order
56
+ is:
57
+
58
+ ```
59
+ replace -> before -> prepend -> append -> after
60
+ ```
61
+
62
+ `replace` wins: an active experience with that placement renders alone. Every other active
63
+ experience renders in the order above.
64
+
65
+ The rule exists so the outcome does not depend on which experience came first. Two editors
66
+ can add an experience to the same slot on the same day. The result then follows from the
67
+ placements, and not from the database.
68
+
69
+ ## Related
70
+
71
+ - [Your first server-rendered page](/tutorials/first-server-rendered-page) — the whole
72
+ path, in practice.
73
+ - [Server snapshot](/reference/sdk/ssr/serialize) — every `serialize()` parameter.
74
+ - [Slots and placements](/reference/sdk/ssr/slots-and-placements) — the exact rules for
75
+ the order.
76
+ - [About pages and flows](/explanation/pages-and-flows) — which kind you need.