picked 0.0.1-dev.1793761484275 → 0.0.1-dev.1793772853474

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.
@@ -0,0 +1,100 @@
1
+ ---
2
+ type: how-to
3
+ layout: docs
4
+ ---
5
+
6
+ # How to add a tool to the devtools
7
+
8
+ This guide shows you how to add a tool of your own to the Picked devtools panel. Before you start,
9
+ add `svelteDevtoolsPlugin` to your client.
10
+
11
+ ## 1. Write the tool as a component
12
+
13
+ Write the tool in the framework of your application. The tool gets the live Picked client, as an
14
+ experience component does. In React, use `usePicked()`. In Svelte, use `getPicked()`.
15
+
16
+ ## 2. Add the tool to the plugin
17
+
18
+ Adapt the component for its framework, then add it to `customTools`. Each tool has a unique `id`
19
+ and a `label`.
20
+
21
+ ```typescript
22
+ import { createClient } from 'picked'
23
+ import { adaptReactComponent } from '@picked/react'
24
+ import { reactFrameworkPlugin } from '@picked/react/plugins/framework'
25
+ import { svelteFrameworkPlugin } from '@picked/svelte/plugins/framework'
26
+ import { svelteDevtoolsPlugin } from '@picked/svelte/plugins/devtools'
27
+ import TestCustomers from './TestCustomers'
28
+
29
+ const picked = createClient({
30
+ projectId: 'your-project-id',
31
+ plugins: [
32
+ reactFrameworkPlugin({ components: {} }),
33
+ svelteFrameworkPlugin({ components: {} }),
34
+ svelteDevtoolsPlugin({
35
+ customTools: [
36
+ {
37
+ id: 'test-customers',
38
+ label: 'Test customers',
39
+ component: adaptReactComponent(TestCustomers),
40
+ },
41
+ ],
42
+ }),
43
+ ],
44
+ })
45
+ ```
46
+
47
+ The devtools panel is a Svelte application. If your tool uses a different framework, also
48
+ register the framework plugin for that framework. If the framework is not registered, the tab
49
+ shows a warning in place of the tool.
50
+
51
+ ## 3. Choose where the tool shows
52
+
53
+ By default, the tool is a tab in **Custom Tools**. To show it in a different place, set
54
+ `placement`.
55
+
56
+ | `placement` | Where the tool shows |
57
+ | --- | --- |
58
+ | Not set | A tab in **Custom Tools**. |
59
+ | `'review'` | A tab of its own in the main list, below the review tabs. |
60
+ | `'footer'` | An icon at the bottom of the menu, next to **Auto-hide button**. The label shows when the pointer is on the icon. |
61
+
62
+ For a `'review'` tool, add a `description`. It shows above the tool. For a `'review'` or a
63
+ `'footer'` tool, add a `guide`. It adds a section with the label of the tool to **How to use**.
64
+
65
+ ```typescript
66
+ {
67
+ id: 'test-customers',
68
+ label: 'Test customers',
69
+ component: adaptReactComponent(TestCustomers),
70
+ placement: 'review',
71
+ description: 'Load a test customer, then walk the journey as that customer.',
72
+ guide: {
73
+ steps: ['Open **Test customers**.', 'Click **Load** next to a customer.'],
74
+ notes: ['The customers are test data. Do not use real names.'],
75
+ },
76
+ }
77
+ ```
78
+
79
+ For a `'footer'` tool, set `icon` to `'bug'` or `'wrench'`. The default is `'wrench'`.
80
+
81
+ ## 4. Read the session
82
+
83
+ If your tool must know what the visitor did, call `getDevtoolsSession(client)`. It gives the
84
+ session record, and whether the session is read-only.
85
+
86
+ ```typescript
87
+ import { getDevtoolsSession } from '@picked/svelte/plugins/devtools'
88
+
89
+ const devtools = getDevtoolsSession(client)
90
+ const route = devtools?.session.routeStore.getState() ?? []
91
+ ```
92
+
93
+ The session record holds the screens that the visitor entered, the answers on each screen, and
94
+ the route through the journey. If `devtools.posture.readOnly` is `true`, the tool must not write.
95
+
96
+ ## Related
97
+
98
+ - [Svelte SDK](/reference/sdk/svelte#devtools-plugin) — the options of the devtools plugin.
99
+ - [How to debug with the Chrome extension](/how-to/debug-with-the-chrome-extension)
100
+ - [How to register a component](/how-to/register-a-component)
@@ -50,7 +50,8 @@ const picked = createClient({
50
50
  ```
51
51
 
52
52
  Your tools appear under a **Custom Tools** tab. In React use `usePicked()`, and in Svelte
53
- use `getPicked()`.
53
+ use `getPicked()`. To show a tool in a different place, see
54
+ [How to add a tool to the devtools](/how-to/add-a-tool-to-the-devtools).
54
55
 
55
56
  ## Related
56
57
 
@@ -54,7 +54,7 @@ const client = createClient({
54
54
  | Option | Type | Default | Description |
55
55
  | --- | --- | --- | --- |
56
56
  | `enabled` | `boolean` | `false` | When `true`, the devtools open on page load. When `false`, the Chrome extension opens them. |
57
- | `customTools` | `CustomTool[]` | `[]` | Your own tools, which show in the Custom Tools tab. |
57
+ | `customTools` | `CustomTool[]` | `[]` | Your own tools. See [How to add a tool to the devtools](/how-to/add-a-tool-to-the-devtools). |
58
58
 
59
59
  When a preview token is there, the devtools launcher shows, even if `enabled` is `false`.
60
60
  See [How to debug with the Chrome extension](/how-to/debug-with-the-chrome-extension).
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "picked",
3
3
  "description": "The Picked SDK front door: the client, the picked.config helpers, and the picked CLI in one install",
4
- "version": "0.0.1-dev.1793761484275",
4
+ "version": "0.0.1-dev.1793772853474",
5
5
  "bin": {
6
6
  "picked": "dist/esm/bin.js"
7
7
  },
8
8
  "dependencies": {
9
- "@picked/cli": "0.0.1-dev.1793761484275",
10
- "@picked/config": "0.0.1-dev.1793761484275"
9
+ "@picked/cli": "0.0.1-dev.1793772853474",
10
+ "@picked/config": "0.0.1-dev.1793772853474"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@picked/client": "workspace:*",
@@ -64,7 +64,7 @@
64
64
  "main": "./dist/cjs/index.js",
65
65
  "module": "./dist/esm/index.js",
66
66
  "peerDependencies": {
67
- "@picked/client": "0.0.1-dev.1793761484275"
67
+ "@picked/client": "0.0.1-dev.1793772853474"
68
68
  },
69
69
  "private": false,
70
70
  "publishConfig": {