@picked/client 0.0.101-next.2 → 0.0.101-next.3
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 +34 -158
- package/dist/{api-AaQeg3Ij.cjs → api-9o_emCM5.cjs} +1 -1
- package/dist/{api-BlRFU0Fi.js → api-BbQt8aW3.js} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/plugins/dynamic-experiences/index.js +2 -2
- package/dist/esm/server/index.js +2 -2
- package/dist/{plugin-CVD2TnRC.cjs → plugin-I8_6ncy_.cjs} +1 -1
- package/dist/{plugin-DhznDG-h.js → plugin-uZJ45vK6.js} +2 -2
- package/dist/{preview-unavailable-xWLCr93y.cjs → preview-unavailable-BUNxTYLe.cjs} +1 -1
- package/dist/{preview-unavailable-mW4Pj3Ph.js → preview-unavailable-BYFD2a58.js} +1 -1
- package/dist/{provider-zag5m5GH.cjs → provider-Bzi_Kb-n.cjs} +1 -1
- package/dist/{provider-COb_V-yq.js → provider-CQKp0iUJ.js} +1 -1
- package/package.json +5 -5
- package/dist/docs/_root.css +0 -101
- package/dist/docs/explanation/conditions-and-the-logic-engine.md +0 -94
- package/dist/docs/explanation/content-references.md +0 -99
- package/dist/docs/explanation/feature-flag-allocation.md +0 -218
- package/dist/docs/explanation/how-picked-works.md +0 -124
- package/dist/docs/explanation/how-pickedql-works.md +0 -76
- package/dist/docs/explanation/pages-and-flows.md +0 -64
- package/dist/docs/explanation/the-content-model.md +0 -87
- package/dist/docs/explanation/the-two-apis.md +0 -68
- package/dist/docs/explanation/why-server-side-rendering.md +0 -76
- package/dist/docs/explanation/workspaces-and-versions.md +0 -71
- package/dist/docs/how-to/add-a-step-field-or-action.md +0 -43
- package/dist/docs/how-to/analytics/index.md +0 -316
- package/dist/docs/how-to/archive-or-delete-a-workspace.md +0 -46
- package/dist/docs/how-to/authenticate-the-cli.md +0 -101
- package/dist/docs/how-to/authenticate-with-a-magic-link.md +0 -47
- package/dist/docs/how-to/authenticate-with-a-password.md +0 -59
- package/dist/docs/how-to/authenticate-with-an-api-key.md +0 -51
- package/dist/docs/how-to/authenticate-with-oauth.md +0 -40
- package/dist/docs/how-to/build-a-flow.md +0 -93
- package/dist/docs/how-to/call-an-external-api-from-a-workflow.md +0 -102
- package/dist/docs/how-to/connect-the-mcp-server.md +0 -46
- package/dist/docs/how-to/create-a-content-entry.md +0 -48
- package/dist/docs/how-to/create-a-project.md +0 -29
- package/dist/docs/how-to/create-an-experience.md +0 -42
- package/dist/docs/how-to/create-and-revoke-an-api-key.md +0 -42
- package/dist/docs/how-to/debug-with-the-chrome-extension.md +0 -57
- package/dist/docs/how-to/define-a-page-layout.md +0 -46
- package/dist/docs/how-to/fill-and-publish-a-page.md +0 -66
- package/dist/docs/how-to/install-the-gtm-template.md +0 -84
- package/dist/docs/how-to/install-the-sdk.md +0 -93
- package/dist/docs/how-to/install-the-vite-plugin.md +0 -69
- package/dist/docs/how-to/invite-and-remove-members.md +0 -35
- package/dist/docs/how-to/point-one-entry-at-another.md +0 -61
- package/dist/docs/how-to/preview-a-workspace.md +0 -28
- package/dist/docs/how-to/publish-a-workspace.md +0 -30
- package/dist/docs/how-to/read-a-feature-flag.md +0 -113
- package/dist/docs/how-to/read-a-referenced-entry.md +0 -109
- package/dist/docs/how-to/register-a-component.md +0 -55
- package/dist/docs/how-to/register-an-action-handler.md +0 -85
- package/dist/docs/how-to/register-an-api-that-uses-oauth2.md +0 -107
- package/dist/docs/how-to/render-a-step-form.md +0 -131
- package/dist/docs/how-to/render-an-unpublished-preview.md +0 -41
- package/dist/docs/how-to/retry-a-failed-call-with-a-loop.md +0 -81
- package/dist/docs/how-to/reuse-a-section.md +0 -53
- package/dist/docs/how-to/reuse-a-step-field-or-action.md +0 -28
- package/dist/docs/how-to/roll-back-a-published-version.md +0 -26
- package/dist/docs/how-to/run-an-ab-test.md +0 -49
- package/dist/docs/how-to/run-code-on-a-form-submission.md +0 -125
- package/dist/docs/how-to/server-render-a-page.md +0 -81
- package/dist/docs/how-to/set-a-content-security-policy.md +0 -32
- package/dist/docs/how-to/set-up-mfa.md +0 -113
- package/dist/docs/how-to/switch-workspaces.md +0 -122
- package/dist/docs/how-to/upload-and-use-an-asset.mdx +0 -73
- package/dist/docs/how-to/validate-a-field.md +0 -52
- package/dist/docs/how-to/wait-for-an-action-response.md +0 -182
- package/dist/docs/how-to/write-a-condition.md +0 -45
- package/dist/docs/how-to/write-a-predicate.md +0 -60
- package/dist/docs/index.md +0 -59
- package/dist/docs/reference/dashboard/actions.mdx +0 -56
- package/dist/docs/reference/dashboard/api-keys.mdx +0 -38
- package/dist/docs/reference/dashboard/conditions.mdx +0 -42
- package/dist/docs/reference/dashboard/content/asset-library.mdx +0 -63
- package/dist/docs/reference/dashboard/content/blocks.mdx +0 -57
- package/dist/docs/reference/dashboard/content/content-entries.mdx +0 -95
- package/dist/docs/reference/dashboard/content/models.mdx +0 -108
- package/dist/docs/reference/dashboard/content/pages.mdx +0 -61
- package/dist/docs/reference/dashboard/experiences.mdx +0 -51
- package/dist/docs/reference/dashboard/external-apis.md +0 -169
- package/dist/docs/reference/dashboard/features.mdx +0 -154
- package/dist/docs/reference/dashboard/fields.mdx +0 -106
- package/dist/docs/reference/dashboard/flow-builder/canvas.mdx +0 -58
- package/dist/docs/reference/dashboard/flow-builder/condition-builder.md +0 -57
- package/dist/docs/reference/dashboard/flow-builder/keyboard-shortcuts.md +0 -72
- package/dist/docs/reference/dashboard/flow-builder/nodes.md +0 -63
- package/dist/docs/reference/dashboard/labels.md +0 -321
- package/dist/docs/reference/dashboard/lead-search.md +0 -224
- package/dist/docs/reference/dashboard/projects.mdx +0 -44
- package/dist/docs/reference/dashboard/reports.mdx +0 -43
- package/dist/docs/reference/dashboard/steps.mdx +0 -37
- package/dist/docs/reference/dashboard/team-management.md +0 -29
- package/dist/docs/reference/dashboard/workflow-runs.md +0 -142
- package/dist/docs/reference/dashboard/workflow-templates.md +0 -182
- package/dist/docs/reference/dashboard/workflow-test-runs.md +0 -77
- package/dist/docs/reference/dashboard/workspace-versioning.mdx +0 -30
- package/dist/docs/reference/dashboard/workspaces.mdx +0 -76
- package/dist/docs/reference/delivery-api/experience-content.md +0 -152
- package/dist/docs/reference/delivery-api/index.md +0 -45
- package/dist/docs/reference/delivery-api/preview-caching-crawling.md +0 -79
- package/dist/docs/reference/delivery-api/project-config.md +0 -65
- package/dist/docs/reference/delivery-api/workspace-schema.md +0 -107
- package/dist/docs/reference/glossary.md +0 -201
- package/dist/docs/reference/management-api/authentication.md +0 -87
- package/dist/docs/reference/management-api/authorization-and-scopes.md +0 -291
- package/dist/docs/reference/management-api/error-handling.md +0 -232
- package/dist/docs/reference/management-api/pagination.md +0 -192
- package/dist/docs/reference/pickedql/data-sources.md +0 -174
- package/dist/docs/reference/pickedql/dimensions.md +0 -103
- package/dist/docs/reference/pickedql/filtering.md +0 -64
- package/dist/docs/reference/pickedql/index.md +0 -18
- package/dist/docs/reference/pickedql/schema.md +0 -172
- package/dist/docs/reference/pickedql/virtual-functions.md +0 -248
- package/dist/docs/reference/sdk/actions.md +0 -154
- package/dist/docs/reference/sdk/analytics-events.md +0 -453
- package/dist/docs/reference/sdk/conditions.md +0 -147
- package/dist/docs/reference/sdk/content-security-policy.md +0 -21
- package/dist/docs/reference/sdk/content.md +0 -253
- package/dist/docs/reference/sdk/experiences.md +0 -51
- package/dist/docs/reference/sdk/features.md +0 -256
- package/dist/docs/reference/sdk/fields.md +0 -255
- package/dist/docs/reference/sdk/index.md +0 -68
- package/dist/docs/reference/sdk/plugins/create-experience.md +0 -123
- package/dist/docs/reference/sdk/plugins/dynamic-experiences.md +0 -74
- package/dist/docs/reference/sdk/plugins/index.md +0 -29
- package/dist/docs/reference/sdk/plugins/window-object.md +0 -25
- package/dist/docs/reference/sdk/predicates.md +0 -43
- package/dist/docs/reference/sdk/ssr/index.md +0 -33
- package/dist/docs/reference/sdk/ssr/rendering-and-hydration.md +0 -103
- package/dist/docs/reference/sdk/ssr/serialize.md +0 -80
- package/dist/docs/reference/sdk/ssr/slots-and-placements.md +0 -113
- package/dist/docs/reference/sdk/steps.md +0 -86
- package/dist/docs/reference/sdk/type-generation.md +0 -265
- package/dist/docs/reference/tools/chrome-extension.md +0 -16
- package/dist/docs/reference/tools/cli.md +0 -292
- package/dist/docs/reference/tools/image-optimisation-service.md +0 -104
- package/dist/docs/reference/tools/mcp.md +0 -136
- package/dist/docs/reference/tools/vite-plugin.md +0 -163
- package/dist/docs/tutorials/first-api-call.md +0 -235
- package/dist/docs/tutorials/first-experience-in-the-dashboard.mdx +0 -143
- package/dist/docs/tutorials/first-experience.mdx +0 -254
- package/dist/docs/tutorials/first-server-rendered-page.mdx +0 -186
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
type: reference
|
|
3
|
-
layout: docs
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Vite Plugin
|
|
7
|
-
|
|
8
|
-
`@picked/vite-plugin-picked` adds Picked to your Vite project. It reads the options
|
|
9
|
-
of your project at build time. It then puts them in a module that gives them to the
|
|
10
|
-
SDK, so the SDK makes no API request at runtime. In development it also serves a
|
|
11
|
-
launcher page. On that page you can see a preview of an experience with your own
|
|
12
|
-
feature flag values.
|
|
13
|
-
|
|
14
|
-
## How it works
|
|
15
|
-
|
|
16
|
-
### Build-time config injection
|
|
17
|
-
|
|
18
|
-
When Vite starts, in both `dev` and `build`, the plugin does this:
|
|
19
|
-
|
|
20
|
-
1. It reads the configuration of your project from the Picked API.
|
|
21
|
-
2. It embeds those options in your bundle.
|
|
22
|
-
3. The module gives the options to the SDK as the browser loads it.
|
|
23
|
-
4. The SDK reads the embedded configuration at runtime and makes no network request.
|
|
24
|
-
|
|
25
|
-
Step 3 is a function call. The module gives the options to the SDK as it loads, and does
|
|
26
|
-
not wait for the SDK to ask.
|
|
27
|
-
|
|
28
|
-
When a preview token is there at runtime, the SDK ignores the embedded configuration and
|
|
29
|
-
reads fresh data from the API.
|
|
30
|
-
|
|
31
|
-
### Preload of the data file
|
|
32
|
-
|
|
33
|
-
Vite puts the options of your project in their own JavaScript file. For each HTML page
|
|
34
|
-
in your build, the plugin adds a `<link rel="modulepreload">` for that file. The
|
|
35
|
-
browser then gets it while it reads the page, and not later when the SDK starts.
|
|
36
|
-
|
|
37
|
-
The CMS content of an experience stays in its own file and gets no preload. The
|
|
38
|
-
browser gets it only when an experience needs it.
|
|
39
|
-
|
|
40
|
-
Some applications make their HTML from the code, and not from an HTML file in your
|
|
41
|
-
project. React Router in server mode is one of these. Such a build has no page for the
|
|
42
|
-
plugin to add the link to. Add this line to the code that runs in the browser instead:
|
|
43
|
-
|
|
44
|
-
:::code-group
|
|
45
|
-
|
|
46
|
-
```ts [entry.client.ts]
|
|
47
|
-
import 'virtual:picked/data'
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
:::
|
|
51
|
-
|
|
52
|
-
Your framework then sees the file in its own list and adds the preload for you.
|
|
53
|
-
|
|
54
|
-
The line reads no value from the module. It is there for the work the module does as it
|
|
55
|
-
loads. A bundler removes a module that only declares values, and removes the line with
|
|
56
|
-
it. This module gives your project options to the SDK, which is work, so the bundler
|
|
57
|
-
keeps both.
|
|
58
|
-
|
|
59
|
-
Your application is correct without this line. The SDK gets the same data later, as it
|
|
60
|
-
starts. The line moves that work earlier.
|
|
61
|
-
|
|
62
|
-
### Types for the data file
|
|
63
|
-
|
|
64
|
-
The plugin makes `virtual:picked/data` at build time. Because the module is not a file in
|
|
65
|
-
your project, TypeScript cannot find its types. The plugin gives you a type file for the
|
|
66
|
-
module. Point your project at that type file to import from the module:
|
|
67
|
-
|
|
68
|
-
:::code-group
|
|
69
|
-
|
|
70
|
-
```json [tsconfig.json]
|
|
71
|
-
{
|
|
72
|
-
"compilerOptions": {
|
|
73
|
-
"types": ["@picked/vite-plugin-picked/client"]
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
```ts [picked-data.ts]
|
|
79
|
-
/// <reference types="@picked/vite-plugin-picked/client" />
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
:::
|
|
83
|
-
|
|
84
|
-
Use one of the two. The `types` option applies to all files in your project. The
|
|
85
|
-
`reference` comment applies to one file.
|
|
86
|
-
|
|
87
|
-
The module gives three values: `projectConfig`, `experienceContent` and
|
|
88
|
-
`manifestMetadata`. You do not give these values to the SDK. The module gives them to
|
|
89
|
-
the SDK itself as the browser loads it.
|
|
90
|
-
|
|
91
|
-
### Dev launcher
|
|
92
|
-
|
|
93
|
-
In development, the plugin serves an HTML page at `/`. On that page you can:
|
|
94
|
-
|
|
95
|
-
- see every feature flag in your project with its current state;
|
|
96
|
-
- turn a feature flag on or off for a local test;
|
|
97
|
-
- see a preview of an experience with your own feature flag values.
|
|
98
|
-
|
|
99
|
-
After the dev server starts, the launcher URL appears next to the Vite output:
|
|
100
|
-
|
|
101
|
-
```
|
|
102
|
-
➜ Picked: http://localhost:5173/
|
|
103
|
-
➜ Local: http://localhost:5173/
|
|
104
|
-
➜ Network: use --host to expose
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
## Options
|
|
108
|
-
|
|
109
|
-
Project identity belongs in [`picked.config.ts`](/reference/sdk/type-generation). The two
|
|
110
|
-
options that carry it are deprecated, and the table marks them.
|
|
111
|
-
|
|
112
|
-
| Option | Type | Default | Description |
|
|
113
|
-
| ---------------- | --------------------- | ------------------------ | ---------------------------------------------------------- |
|
|
114
|
-
| `disableLauncher`| `boolean` | `false` | Turns the launcher page off in both dev and build output. |
|
|
115
|
-
| `generateTypes` | `boolean` | `true` | Whether the plugin writes types from the workspace schema. |
|
|
116
|
-
| `mode` | `'bundle' \| 'api'` | `'bundle'` | Whether the build carries your project data. |
|
|
117
|
-
| `projectId` | `string` | — | **Deprecated.** Use `picked.config.ts`. |
|
|
118
|
-
| `apiUrl` | `string` | — | **Deprecated.** Use `picked.config.ts`. |
|
|
119
|
-
|
|
120
|
-
### projectId and apiUrl
|
|
121
|
-
|
|
122
|
-
These two options moved to [`picked.config.ts`](/reference/sdk/type-generation), which the
|
|
123
|
-
`picked` command and type generation also read. A later release removes them.
|
|
124
|
-
|
|
125
|
-
The plugin still reads an option for a field that `picked.config.ts` leaves out, so a
|
|
126
|
-
project that has yet to move needs no change. It stops when the two values are different,
|
|
127
|
-
rather than choose one for you.
|
|
128
|
-
|
|
129
|
-
### generateTypes
|
|
130
|
-
|
|
131
|
-
The plugin reads the workspace schema and writes `picked-env.d.ts`, on `vite dev` and on
|
|
132
|
-
`vite build`. [Type generation](/reference/sdk/type-generation) describes the output and
|
|
133
|
-
the `picked.config.ts` options that control it.
|
|
134
|
-
|
|
135
|
-
A failure stops the run. Set `generateTypes: false` for a build that must not write types,
|
|
136
|
-
such as a build for one more entry point.
|
|
137
|
-
|
|
138
|
-
### mode
|
|
139
|
-
|
|
140
|
-
`'bundle'` reads your project options at build time and puts them in your bundle.
|
|
141
|
-
|
|
142
|
-
`'api'` does not read them. Your build then makes no request to the Picked API, and
|
|
143
|
-
writes no `.picked` directory. The SDK reads your project options from the API at
|
|
144
|
-
runtime instead. Use this when your build must not depend on the Picked API.
|
|
145
|
-
|
|
146
|
-
The SDK has no equivalent option. It uses the data your build gives it, and the API when
|
|
147
|
-
your build gives none.
|
|
148
|
-
|
|
149
|
-
## Build output
|
|
150
|
-
|
|
151
|
-
For a production build, `vite build`, the plugin writes an `index.html` file that
|
|
152
|
-
holds the launcher page. Set `disableLauncher` to stop this. The file lets you deploy
|
|
153
|
-
the launcher next to your application, so that a stakeholder can see a preview.
|
|
154
|
-
|
|
155
|
-
The plugin writes that file only when your build made no `index.html` of its own. An
|
|
156
|
-
application that has an HTML entry keeps its own page at the root of the output.
|
|
157
|
-
|
|
158
|
-
The plugin also writes a `.picked` directory next to your Vite `root`. It holds the
|
|
159
|
-
options of your project and the CMS content of each experience.
|
|
160
|
-
|
|
161
|
-
## Related
|
|
162
|
-
|
|
163
|
-
- [How to install the Vite plugin](/how-to/install-the-vite-plugin)
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
type: tutorial
|
|
3
|
-
layout: docs
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Your first API call
|
|
7
|
-
|
|
8
|
-
In this tutorial we make your first calls to the Picked management API. We start with a
|
|
9
|
-
ping, then authenticate, then read your user and make an organization.
|
|
10
|
-
|
|
11
|
-
At the end you have an access token and two answers from the API.
|
|
12
|
-
|
|
13
|
-
## Before you start
|
|
14
|
-
|
|
15
|
-
- A Picked account, with an email address and a password.
|
|
16
|
-
- `curl`, or any HTTP client.
|
|
17
|
-
|
|
18
|
-
:::note
|
|
19
|
-
This tutorial covers the GraphQL management API, which needs authentication. To serve
|
|
20
|
-
published configuration and page content to your application, use the read-only
|
|
21
|
-
[Delivery API](/reference/delivery-api) instead.
|
|
22
|
-
:::
|
|
23
|
-
|
|
24
|
-
## Playground
|
|
25
|
-
|
|
26
|
-
Read the API and run a query in the
|
|
27
|
-
[GraphQL Playground](https://api.picked.app/api/graphql).
|
|
28
|
-
|
|
29
|
-
## API endpoint
|
|
30
|
-
|
|
31
|
-
All requests go to a single endpoint:
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
POST https://api.picked.app/api/graphql
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Every request must use the `POST` method. The JSON body must hold a `query` field,
|
|
38
|
-
and it can also hold a `variables` field:
|
|
39
|
-
|
|
40
|
-
```json
|
|
41
|
-
{
|
|
42
|
-
"query": "query { ... }",
|
|
43
|
-
"variables": { }
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
Set the `Content-Type` header to `application/json` on every request.
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
curl -X POST https://api.picked.app/api/graphql \
|
|
51
|
-
-H "Content-Type: application/json" \
|
|
52
|
-
-d '{"query": "{ ping }"}'
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Ping the API
|
|
56
|
-
|
|
57
|
-
Check that the API is reachable with the `ping` query. This query needs no
|
|
58
|
-
authentication.
|
|
59
|
-
|
|
60
|
-
```graphql
|
|
61
|
-
query {
|
|
62
|
-
ping
|
|
63
|
-
}
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
Response:
|
|
67
|
-
|
|
68
|
-
```json
|
|
69
|
-
{
|
|
70
|
-
"data": {
|
|
71
|
-
"ping": "pong"
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
This response means that the API is ready.
|
|
77
|
-
|
|
78
|
-
## Authenticate
|
|
79
|
-
|
|
80
|
-
Most operations need an access token. To get one, create a session with your email
|
|
81
|
-
address and your password.
|
|
82
|
-
|
|
83
|
-
```graphql
|
|
84
|
-
mutation {
|
|
85
|
-
sessionCreate(input: {
|
|
86
|
-
email: "you@example.com"
|
|
87
|
-
password: "your-password"
|
|
88
|
-
}) {
|
|
89
|
-
session {
|
|
90
|
-
accessToken
|
|
91
|
-
refreshToken
|
|
92
|
-
expiresAt
|
|
93
|
-
aal
|
|
94
|
-
user {
|
|
95
|
-
mfa { required enrolled }
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
A successful response returns a `Session` with an `accessToken` and a
|
|
103
|
-
`refreshToken`:
|
|
104
|
-
|
|
105
|
-
```json
|
|
106
|
-
{
|
|
107
|
-
"data": {
|
|
108
|
-
"sessionCreate": {
|
|
109
|
-
"session": {
|
|
110
|
-
"accessToken": "eyJhbGciOiJIUzI1NiIs...",
|
|
111
|
-
"refreshToken": "v1.refresh-token...",
|
|
112
|
-
"expiresAt": "2025-01-15T12:00:00Z",
|
|
113
|
-
"aal": "AAL1",
|
|
114
|
-
"user": {
|
|
115
|
-
"mfa": { "required": false, "enrolled": false }
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
When `required` is `true`, the token can only read `user` and call the MFA mutations
|
|
124
|
-
until you verify a code from an authenticator app. See
|
|
125
|
-
[How to set up MFA](/how-to/set-up-mfa).
|
|
126
|
-
|
|
127
|
-
For a server-to-server integration, use
|
|
128
|
-
[API key authentication](/how-to/authenticate-with-an-api-key) and not a
|
|
129
|
-
session token.
|
|
130
|
-
|
|
131
|
-
## Make an authenticated query
|
|
132
|
-
|
|
133
|
-
Pass the access token in the `Authorization` header as a Bearer token:
|
|
134
|
-
|
|
135
|
-
```
|
|
136
|
-
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
You can now query a resource that needs authentication. This example reads your user
|
|
140
|
-
profile:
|
|
141
|
-
|
|
142
|
-
```graphql
|
|
143
|
-
query {
|
|
144
|
-
user {
|
|
145
|
-
id
|
|
146
|
-
email
|
|
147
|
-
createdAt
|
|
148
|
-
organizations(first: 5) {
|
|
149
|
-
edges {
|
|
150
|
-
node {
|
|
151
|
-
id
|
|
152
|
-
name
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
## Make a mutation
|
|
161
|
-
|
|
162
|
-
A mutation follows the same pattern. Send a `POST` request with the `Authorization`
|
|
163
|
-
header. This example creates an organization:
|
|
164
|
-
|
|
165
|
-
```graphql
|
|
166
|
-
mutation {
|
|
167
|
-
organizationCreate(input: {
|
|
168
|
-
name: "My Company"
|
|
169
|
-
slug: "my-company"
|
|
170
|
-
}) {
|
|
171
|
-
organization {
|
|
172
|
-
id
|
|
173
|
-
name
|
|
174
|
-
slug
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
Response:
|
|
181
|
-
|
|
182
|
-
```json
|
|
183
|
-
{
|
|
184
|
-
"data": {
|
|
185
|
-
"organizationCreate": {
|
|
186
|
-
"organization": {
|
|
187
|
-
"id": "org_abc123",
|
|
188
|
-
"name": "My Company",
|
|
189
|
-
"slug": "my-company"
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
Every mutation takes an `input` argument and returns a payload object. On success the
|
|
197
|
-
payload holds the resource that the mutation created or updated. On failure the
|
|
198
|
-
`errors` array at the top level holds the errors.
|
|
199
|
-
|
|
200
|
-
## Errors
|
|
201
|
-
|
|
202
|
-
When something goes wrong, the API returns the errors in the standard GraphQL
|
|
203
|
-
`errors` array:
|
|
204
|
-
|
|
205
|
-
```json
|
|
206
|
-
{
|
|
207
|
-
"data": null,
|
|
208
|
-
"errors": [
|
|
209
|
-
{
|
|
210
|
-
"message": "Invalid credentials",
|
|
211
|
-
"extensions": {
|
|
212
|
-
"code": "INVALID_CREDENTIALS"
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
]
|
|
216
|
-
}
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
Read the `extensions.code` field. It holds an error code that your code can act on.
|
|
220
|
-
See the [Errors](/reference/management-api/error-handling) guide for the full list of codes.
|
|
221
|
-
|
|
222
|
-
## What you built
|
|
223
|
-
|
|
224
|
-
You authenticated against the management API, read your own user, and created an
|
|
225
|
-
organization. Every other operation follows the same shape: a `POST` to one endpoint,
|
|
226
|
-
with your token in the `Authorization` header.
|
|
227
|
-
|
|
228
|
-
## Where to go next
|
|
229
|
-
|
|
230
|
-
- [Authentication](/reference/management-api/authentication) — an email address and a password, OAuth,
|
|
231
|
-
magic links, MFA, API keys, and how to control a session.
|
|
232
|
-
- [Authorization and Scopes](/reference/management-api/authorization-and-scopes) — what each role can
|
|
233
|
-
reach, and how a scope controls a permission.
|
|
234
|
-
- [Pagination](/reference/management-api/pagination) — how to move through a large result with a cursor.
|
|
235
|
-
- [Errors](/reference/management-api/error-handling) — every error code that the API can return.
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
type: tutorial
|
|
3
|
-
layout: docs
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
import { Screenshot } from '../../../components/Screenshot'
|
|
7
|
-
|
|
8
|
-
# Build your first experience
|
|
9
|
-
|
|
10
|
-
In this tutorial we build a survey and show it to your visitors. We do all of it in the
|
|
11
|
-
Picked dashboard.
|
|
12
|
-
|
|
13
|
-
At the end you have one experience, one step, one field, and a preview of the survey on
|
|
14
|
-
your own site.
|
|
15
|
-
|
|
16
|
-
## You will need
|
|
17
|
-
|
|
18
|
-
**A Picked account, in an organization.** An organization holds your projects and the
|
|
19
|
-
people who work on them. If you have an invitation, accept it and sign in. If nobody made
|
|
20
|
-
an organization yet, make one from the dashboard home page.
|
|
21
|
-
|
|
22
|
-
**A project.** A project is one site or one application. See
|
|
23
|
-
[How to create a project](/how-to/create-a-project). Keep the project home page open,
|
|
24
|
-
because it shows the SDK snippet that the next item needs.
|
|
25
|
-
|
|
26
|
-
**The URL of your site**, such as `https://www.example.com`. Step 5 opens it to show you
|
|
27
|
-
the survey. It can be a test site.
|
|
28
|
-
|
|
29
|
-
## What a developer must do first
|
|
30
|
-
|
|
31
|
-
The SDK must be on your site before step 1. This happens one time, and after it you need
|
|
32
|
-
no developer again. Send them these four tasks:
|
|
33
|
-
|
|
34
|
-
1. Add the SDK to the site. The snippet and the project ID are on the project home page.
|
|
35
|
-
See [How to install the SDK](/how-to/install-the-sdk).
|
|
36
|
-
2. Make a component that renders a step form.
|
|
37
|
-
3. [Register that component](/how-to/register-a-component) under the name `ColorSurvey`.
|
|
38
|
-
Step 3 enters the same name in the dashboard, and the two names must match.
|
|
39
|
-
4. Tell you which site the SDK runs on, so you can open a preview against it.
|
|
40
|
-
|
|
41
|
-
[Add Picked to your application](/tutorials/first-experience) walks a developer through
|
|
42
|
-
all of it.
|
|
43
|
-
|
|
44
|
-
## 1. Make a field
|
|
45
|
-
|
|
46
|
-
A field collects one answer from your visitor.
|
|
47
|
-
|
|
48
|
-
1. Open your project.
|
|
49
|
-
2. Click **Fields** in the sidebar.
|
|
50
|
-
3. Click **New field**.
|
|
51
|
-
4. Enter the name `Color`. The dashboard fills in the label and the key for you.
|
|
52
|
-
5. Change the label to `Which color do you like most?`. Your visitors read the label, and
|
|
53
|
-
they never see the name or the key.
|
|
54
|
-
6. Leave the key as `color`. You cannot change it later.
|
|
55
|
-
7. Choose the type **Text**.
|
|
56
|
-
8. Click **Create field**.
|
|
57
|
-
|
|
58
|
-
<Screenshot
|
|
59
|
-
route="/{orgSlug}/{projectId}/workspaces/{workspaceId}/fields/new"
|
|
60
|
-
alt="The new field form, with a name, a label, and a key entered"
|
|
61
|
-
fill={{ 'input[name="name"]': 'Color', 'input[name="label"]': 'Which color do you like most?' }}
|
|
62
|
-
/>
|
|
63
|
-
|
|
64
|
-
<Screenshot
|
|
65
|
-
route="/{orgSlug}/{projectId}/workspaces/{workspaceId}/fields"
|
|
66
|
-
alt="The fields list for a workspace on the Picked dashboard"
|
|
67
|
-
/>
|
|
68
|
-
|
|
69
|
-
Your field appears in the fields list.
|
|
70
|
-
|
|
71
|
-
## 2. Make the experience
|
|
72
|
-
|
|
73
|
-
1. Click **Flows** in the sidebar. The experiences list opens.
|
|
74
|
-
2. Click **New experience**.
|
|
75
|
-
3. Enter the name `Color survey`.
|
|
76
|
-
4. Leave **Type** on the **Flow** option. A flow is the interactive kind, and it is what
|
|
77
|
-
this tutorial builds. See [About pages and flows](/explanation/pages-and-flows) for the
|
|
78
|
-
other kind.
|
|
79
|
-
5. Open **Advanced**.
|
|
80
|
-
6. Enter the component name `ColorSurvey`. This is the name your developer registered.
|
|
81
|
-
7. Click **Create flow**.
|
|
82
|
-
|
|
83
|
-
The flow builder opens with an empty canvas. One gray circle sits on the left. That
|
|
84
|
-
circle is the origin, and every flow starts there.
|
|
85
|
-
|
|
86
|
-
## 3. Make a step
|
|
87
|
-
|
|
88
|
-
A step is one screen that your visitor sees. It holds your field. You make one from the
|
|
89
|
-
library, on the left of the flow builder.
|
|
90
|
-
|
|
91
|
-
1. Find the **Steps** section in the library.
|
|
92
|
-
2. Click the **+** next to it.
|
|
93
|
-
3. Enter the name `Question`. The key fills in as `question`.
|
|
94
|
-
4. Click **Create step**.
|
|
95
|
-
|
|
96
|
-
The flow builder opens again, and your step is in the library.
|
|
97
|
-
|
|
98
|
-
## 4. Build the flow
|
|
99
|
-
|
|
100
|
-
1. Find your `Question` step under **Steps** in the library.
|
|
101
|
-
2. Drag it onto the canvas.
|
|
102
|
-
3. Drag from the output handle of the origin to the input handle of your step. An arrow
|
|
103
|
-
joins them.
|
|
104
|
-
4. Drag your `Color` field from the library onto the step node.
|
|
105
|
-
5. Click **Save** in the toolbar.
|
|
106
|
-
|
|
107
|
-
<Screenshot
|
|
108
|
-
route="/{orgSlug}/{projectId}/workspaces/{workspaceId}/experiences/{experienceId}"
|
|
109
|
-
alt="The flow builder with the library, canvas, and inspector panels"
|
|
110
|
-
/>
|
|
111
|
-
|
|
112
|
-
The subtitle of the step node now reads one field. Your flow is one step long, and it
|
|
113
|
-
starts at the origin.
|
|
114
|
-
|
|
115
|
-
## 5. Preview it
|
|
116
|
-
|
|
117
|
-
A preview opens your own site with this workspace applied. Your visitors see no change.
|
|
118
|
-
|
|
119
|
-
1. Click **Preview** in the workspace toolbar.
|
|
120
|
-
2. Enter the URL of your site.
|
|
121
|
-
3. Click **Open preview**.
|
|
122
|
-
|
|
123
|
-
Your site opens in a new tab, and your survey is on it. Enter a color and continue.
|
|
124
|
-
|
|
125
|
-
## 6. Publish it
|
|
126
|
-
|
|
127
|
-
1. Click **Publish** in the workspace toolbar.
|
|
128
|
-
2. Read the change preview. It lists what your visitors get.
|
|
129
|
-
3. Click **Publish** to confirm.
|
|
130
|
-
|
|
131
|
-
Your survey is live.
|
|
132
|
-
|
|
133
|
-
## What you built
|
|
134
|
-
|
|
135
|
-
You have an experience that your visitors see. The dashboard holds the flow, the step, and
|
|
136
|
-
the field, so you change any of them and publish again without a deployment.
|
|
137
|
-
|
|
138
|
-
## Where to go next
|
|
139
|
-
|
|
140
|
-
- [How to build a flow](/how-to/build-a-flow) — branches, actions, and conditions.
|
|
141
|
-
- [How to run an A/B test](/how-to/run-an-ab-test) — show a change to some visitors.
|
|
142
|
-
- [About how Picked works](/explanation/how-picked-works) — what happens when you
|
|
143
|
-
publish.
|