@sanity/personalization-plugin 2.1.0 → 2.2.0-growthbook.1
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 +2 -0
- package/dist/index.d.mts +205 -1
- package/dist/index.d.ts +205 -1
- package/dist/index.js +131 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +133 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
- package/src/components/ExperimentContext.tsx +8 -5
- package/src/components/ExperimentField.tsx +56 -32
- package/src/components/ExperimentInput.tsx +2 -2
- package/src/components/Secrets.tsx +47 -0
- package/src/fieldExperiments.tsx +1 -0
- package/src/growthbookFieldExperiments.tsx +51 -0
- package/src/index.ts +1 -0
- package/src/types.ts +182 -1
- package/src/utils/growthbook.ts +78 -0
package/README.md
CHANGED
|
@@ -25,6 +25,8 @@ Once configured you can query the values using the ids of the experiment and var
|
|
|
25
25
|
- [Release new version](#release-new-version)
|
|
26
26
|
- [License](#license-1)
|
|
27
27
|
|
|
28
|
+
For Specific information about the growthbookFieldLevel export see its [readme](/growthbook.md)
|
|
29
|
+
|
|
28
30
|
## Installation
|
|
29
31
|
|
|
30
32
|
```sh
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {ArrayOfObjectsInputProps} from 'sanity'
|
|
2
|
+
import {Dispatch} from 'react'
|
|
2
3
|
import {FieldDefinition} from 'sanity'
|
|
3
4
|
import {ObjectField} from 'sanity'
|
|
4
5
|
import {Path} from 'sanity'
|
|
@@ -6,6 +7,7 @@ import {Plugin as Plugin_2} from 'sanity'
|
|
|
6
7
|
import {PreviewProps} from 'sanity'
|
|
7
8
|
import {SanityClient} from 'sanity'
|
|
8
9
|
import {SchemaType} from 'sanity'
|
|
10
|
+
import {SetStateAction} from 'react'
|
|
9
11
|
|
|
10
12
|
export declare type ArrayInputProps = ArrayOfObjectsInputProps & {
|
|
11
13
|
variantName: string
|
|
@@ -15,6 +17,8 @@ export declare type ArrayInputProps = ArrayOfObjectsInputProps & {
|
|
|
15
17
|
|
|
16
18
|
export declare type ExperimentContextProps = Required<FieldPluginConfig> & {
|
|
17
19
|
experiments: ExperimentType[]
|
|
20
|
+
setSecret: Dispatch<SetStateAction<string | undefined>>
|
|
21
|
+
secret: string | undefined
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
export declare type ExperimentGeneric<T> = {
|
|
@@ -42,7 +46,9 @@ export declare const fieldLevelExperiments: Plugin_2<FieldPluginConfig>
|
|
|
42
46
|
|
|
43
47
|
export declare type FieldPluginConfig = {
|
|
44
48
|
fields: (string | FieldDefinition)[]
|
|
45
|
-
experiments:
|
|
49
|
+
experiments:
|
|
50
|
+
| ExperimentType[]
|
|
51
|
+
| ((client: SanityClient, secret?: string) => Promise<ExperimentType[]>)
|
|
46
52
|
apiVersion?: string
|
|
47
53
|
experimentNameOverride?: string
|
|
48
54
|
variantNameOverride?: string
|
|
@@ -56,6 +62,204 @@ export declare type FieldPluginConfig = {
|
|
|
56
62
|
*/
|
|
57
63
|
export declare function flattenSchemaType(schemaType: SchemaType): ObjectFieldWithPath[]
|
|
58
64
|
|
|
65
|
+
export declare type GrowthbookABConfig = {
|
|
66
|
+
fields: (string | FieldDefinition)[]
|
|
67
|
+
environment: string
|
|
68
|
+
baseUrl?: string
|
|
69
|
+
project?: string
|
|
70
|
+
convertBooleans?: boolean
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export declare type GrowthbookExperiment = {
|
|
74
|
+
id: string
|
|
75
|
+
dateCreated: string
|
|
76
|
+
dateUpdated: string
|
|
77
|
+
name: string
|
|
78
|
+
project: string
|
|
79
|
+
hypothesis: string
|
|
80
|
+
description: string
|
|
81
|
+
tags: [string]
|
|
82
|
+
owner: string
|
|
83
|
+
archived: boolean
|
|
84
|
+
status: string
|
|
85
|
+
autoRefresh: boolean
|
|
86
|
+
hashAttribute: string
|
|
87
|
+
fallbackAttribute: string
|
|
88
|
+
hashVersion: number
|
|
89
|
+
disableStickyBucketing: boolean
|
|
90
|
+
bucketVersion: number
|
|
91
|
+
minBucketVersion: number
|
|
92
|
+
variations: [
|
|
93
|
+
{
|
|
94
|
+
variationId: string
|
|
95
|
+
key: string
|
|
96
|
+
name: string
|
|
97
|
+
description: string
|
|
98
|
+
screenshots: [string]
|
|
99
|
+
},
|
|
100
|
+
]
|
|
101
|
+
phases: [
|
|
102
|
+
{
|
|
103
|
+
name: string
|
|
104
|
+
dateStarted: string
|
|
105
|
+
dateEnded: string
|
|
106
|
+
reasonForStopping: string
|
|
107
|
+
seed: string
|
|
108
|
+
coverage: 0
|
|
109
|
+
trafficSplit: [
|
|
110
|
+
{
|
|
111
|
+
variationId: string
|
|
112
|
+
weight: 0
|
|
113
|
+
},
|
|
114
|
+
]
|
|
115
|
+
namespace: {
|
|
116
|
+
namespaceId: string
|
|
117
|
+
range: []
|
|
118
|
+
}
|
|
119
|
+
targetingCondition: string
|
|
120
|
+
savedGroupTargeting: [
|
|
121
|
+
{
|
|
122
|
+
matchType: string
|
|
123
|
+
savedGroups: [string]
|
|
124
|
+
},
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
]
|
|
128
|
+
settings: {
|
|
129
|
+
datasourceId: string
|
|
130
|
+
assignmentQueryId: string
|
|
131
|
+
experimentId: string
|
|
132
|
+
segmentId: string
|
|
133
|
+
queryFilter: string
|
|
134
|
+
inProgressConversions: string
|
|
135
|
+
attributionModel: string
|
|
136
|
+
statsEngine: string
|
|
137
|
+
regressionAdjustmentEnabled: boolean
|
|
138
|
+
goals: [
|
|
139
|
+
{
|
|
140
|
+
metricId: string
|
|
141
|
+
overrides: {
|
|
142
|
+
delayHours: 0
|
|
143
|
+
windowHours: 0
|
|
144
|
+
window: string
|
|
145
|
+
winRiskThreshold: 0
|
|
146
|
+
loseRiskThreshold: 0
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
]
|
|
150
|
+
secondaryMetrics: [
|
|
151
|
+
{
|
|
152
|
+
metricId: string
|
|
153
|
+
overrides: {
|
|
154
|
+
delayHours: 0
|
|
155
|
+
windowHours: 0
|
|
156
|
+
window: string
|
|
157
|
+
winRiskThreshold: 0
|
|
158
|
+
loseRiskThreshold: 0
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
]
|
|
162
|
+
guardrails: [
|
|
163
|
+
{
|
|
164
|
+
metricId: string
|
|
165
|
+
overrides: {
|
|
166
|
+
delayHours: 0
|
|
167
|
+
windowHours: 0
|
|
168
|
+
window: string
|
|
169
|
+
winRiskThreshold: 0
|
|
170
|
+
loseRiskThreshold: 0
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
]
|
|
174
|
+
activationMetric: {
|
|
175
|
+
metricId: string
|
|
176
|
+
overrides: {
|
|
177
|
+
delayHours: 0
|
|
178
|
+
windowHours: 0
|
|
179
|
+
window: string
|
|
180
|
+
winRiskThreshold: 0
|
|
181
|
+
loseRiskThreshold: 0
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
resultSummary: {
|
|
186
|
+
status: string
|
|
187
|
+
winner: string
|
|
188
|
+
conclusions: string
|
|
189
|
+
releasedVariationId: string
|
|
190
|
+
excludeFromPayload: boolean
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export declare type GrowthbookFeature = {
|
|
195
|
+
id: string
|
|
196
|
+
dateCreated: string
|
|
197
|
+
dateUpdated: string
|
|
198
|
+
archived: boolean
|
|
199
|
+
description: string
|
|
200
|
+
owner: string
|
|
201
|
+
project: string
|
|
202
|
+
valueType: string
|
|
203
|
+
defaultValue: string
|
|
204
|
+
tags: string[]
|
|
205
|
+
environments: {
|
|
206
|
+
[key: string]: {
|
|
207
|
+
enabled: boolean
|
|
208
|
+
defaultValue: string
|
|
209
|
+
rules: {
|
|
210
|
+
description: string
|
|
211
|
+
condition: string
|
|
212
|
+
savedGroupTargeting: {
|
|
213
|
+
matchType: string
|
|
214
|
+
savedGroups: string[]
|
|
215
|
+
}[]
|
|
216
|
+
id: string
|
|
217
|
+
enabled: boolean
|
|
218
|
+
type: string
|
|
219
|
+
value: string
|
|
220
|
+
variations: {
|
|
221
|
+
value: string
|
|
222
|
+
variationId: string
|
|
223
|
+
}[]
|
|
224
|
+
}[]
|
|
225
|
+
definition: string
|
|
226
|
+
draft: {
|
|
227
|
+
enabled: boolean
|
|
228
|
+
defaultValue: string
|
|
229
|
+
rules: {
|
|
230
|
+
description: string
|
|
231
|
+
condition: string
|
|
232
|
+
savedGroupTargeting: {
|
|
233
|
+
matchType: string
|
|
234
|
+
savedGroups: string[]
|
|
235
|
+
}[]
|
|
236
|
+
id: string
|
|
237
|
+
enabled: boolean
|
|
238
|
+
type: string
|
|
239
|
+
value: string
|
|
240
|
+
variations: {
|
|
241
|
+
value: string
|
|
242
|
+
variationId: string
|
|
243
|
+
}[]
|
|
244
|
+
}[]
|
|
245
|
+
definition: string
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
prerequisites: {
|
|
250
|
+
parentId: string
|
|
251
|
+
parentCondition: string
|
|
252
|
+
}[]
|
|
253
|
+
revision: {
|
|
254
|
+
version: number
|
|
255
|
+
comment: string
|
|
256
|
+
date: string
|
|
257
|
+
publishedBy: string
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export declare const growthbookFieldLevel: Plugin_2<GrowthbookABConfig>
|
|
262
|
+
|
|
59
263
|
export declare type ObjectFieldWithPath = ObjectField<SchemaType> & {
|
|
60
264
|
path: Path
|
|
61
265
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {ArrayOfObjectsInputProps} from 'sanity'
|
|
2
|
+
import {Dispatch} from 'react'
|
|
2
3
|
import {FieldDefinition} from 'sanity'
|
|
3
4
|
import {ObjectField} from 'sanity'
|
|
4
5
|
import {Path} from 'sanity'
|
|
@@ -6,6 +7,7 @@ import {Plugin as Plugin_2} from 'sanity'
|
|
|
6
7
|
import {PreviewProps} from 'sanity'
|
|
7
8
|
import {SanityClient} from 'sanity'
|
|
8
9
|
import {SchemaType} from 'sanity'
|
|
10
|
+
import {SetStateAction} from 'react'
|
|
9
11
|
|
|
10
12
|
export declare type ArrayInputProps = ArrayOfObjectsInputProps & {
|
|
11
13
|
variantName: string
|
|
@@ -15,6 +17,8 @@ export declare type ArrayInputProps = ArrayOfObjectsInputProps & {
|
|
|
15
17
|
|
|
16
18
|
export declare type ExperimentContextProps = Required<FieldPluginConfig> & {
|
|
17
19
|
experiments: ExperimentType[]
|
|
20
|
+
setSecret: Dispatch<SetStateAction<string | undefined>>
|
|
21
|
+
secret: string | undefined
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
export declare type ExperimentGeneric<T> = {
|
|
@@ -42,7 +46,9 @@ export declare const fieldLevelExperiments: Plugin_2<FieldPluginConfig>
|
|
|
42
46
|
|
|
43
47
|
export declare type FieldPluginConfig = {
|
|
44
48
|
fields: (string | FieldDefinition)[]
|
|
45
|
-
experiments:
|
|
49
|
+
experiments:
|
|
50
|
+
| ExperimentType[]
|
|
51
|
+
| ((client: SanityClient, secret?: string) => Promise<ExperimentType[]>)
|
|
46
52
|
apiVersion?: string
|
|
47
53
|
experimentNameOverride?: string
|
|
48
54
|
variantNameOverride?: string
|
|
@@ -56,6 +62,204 @@ export declare type FieldPluginConfig = {
|
|
|
56
62
|
*/
|
|
57
63
|
export declare function flattenSchemaType(schemaType: SchemaType): ObjectFieldWithPath[]
|
|
58
64
|
|
|
65
|
+
export declare type GrowthbookABConfig = {
|
|
66
|
+
fields: (string | FieldDefinition)[]
|
|
67
|
+
environment: string
|
|
68
|
+
baseUrl?: string
|
|
69
|
+
project?: string
|
|
70
|
+
convertBooleans?: boolean
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export declare type GrowthbookExperiment = {
|
|
74
|
+
id: string
|
|
75
|
+
dateCreated: string
|
|
76
|
+
dateUpdated: string
|
|
77
|
+
name: string
|
|
78
|
+
project: string
|
|
79
|
+
hypothesis: string
|
|
80
|
+
description: string
|
|
81
|
+
tags: [string]
|
|
82
|
+
owner: string
|
|
83
|
+
archived: boolean
|
|
84
|
+
status: string
|
|
85
|
+
autoRefresh: boolean
|
|
86
|
+
hashAttribute: string
|
|
87
|
+
fallbackAttribute: string
|
|
88
|
+
hashVersion: number
|
|
89
|
+
disableStickyBucketing: boolean
|
|
90
|
+
bucketVersion: number
|
|
91
|
+
minBucketVersion: number
|
|
92
|
+
variations: [
|
|
93
|
+
{
|
|
94
|
+
variationId: string
|
|
95
|
+
key: string
|
|
96
|
+
name: string
|
|
97
|
+
description: string
|
|
98
|
+
screenshots: [string]
|
|
99
|
+
},
|
|
100
|
+
]
|
|
101
|
+
phases: [
|
|
102
|
+
{
|
|
103
|
+
name: string
|
|
104
|
+
dateStarted: string
|
|
105
|
+
dateEnded: string
|
|
106
|
+
reasonForStopping: string
|
|
107
|
+
seed: string
|
|
108
|
+
coverage: 0
|
|
109
|
+
trafficSplit: [
|
|
110
|
+
{
|
|
111
|
+
variationId: string
|
|
112
|
+
weight: 0
|
|
113
|
+
},
|
|
114
|
+
]
|
|
115
|
+
namespace: {
|
|
116
|
+
namespaceId: string
|
|
117
|
+
range: []
|
|
118
|
+
}
|
|
119
|
+
targetingCondition: string
|
|
120
|
+
savedGroupTargeting: [
|
|
121
|
+
{
|
|
122
|
+
matchType: string
|
|
123
|
+
savedGroups: [string]
|
|
124
|
+
},
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
]
|
|
128
|
+
settings: {
|
|
129
|
+
datasourceId: string
|
|
130
|
+
assignmentQueryId: string
|
|
131
|
+
experimentId: string
|
|
132
|
+
segmentId: string
|
|
133
|
+
queryFilter: string
|
|
134
|
+
inProgressConversions: string
|
|
135
|
+
attributionModel: string
|
|
136
|
+
statsEngine: string
|
|
137
|
+
regressionAdjustmentEnabled: boolean
|
|
138
|
+
goals: [
|
|
139
|
+
{
|
|
140
|
+
metricId: string
|
|
141
|
+
overrides: {
|
|
142
|
+
delayHours: 0
|
|
143
|
+
windowHours: 0
|
|
144
|
+
window: string
|
|
145
|
+
winRiskThreshold: 0
|
|
146
|
+
loseRiskThreshold: 0
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
]
|
|
150
|
+
secondaryMetrics: [
|
|
151
|
+
{
|
|
152
|
+
metricId: string
|
|
153
|
+
overrides: {
|
|
154
|
+
delayHours: 0
|
|
155
|
+
windowHours: 0
|
|
156
|
+
window: string
|
|
157
|
+
winRiskThreshold: 0
|
|
158
|
+
loseRiskThreshold: 0
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
]
|
|
162
|
+
guardrails: [
|
|
163
|
+
{
|
|
164
|
+
metricId: string
|
|
165
|
+
overrides: {
|
|
166
|
+
delayHours: 0
|
|
167
|
+
windowHours: 0
|
|
168
|
+
window: string
|
|
169
|
+
winRiskThreshold: 0
|
|
170
|
+
loseRiskThreshold: 0
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
]
|
|
174
|
+
activationMetric: {
|
|
175
|
+
metricId: string
|
|
176
|
+
overrides: {
|
|
177
|
+
delayHours: 0
|
|
178
|
+
windowHours: 0
|
|
179
|
+
window: string
|
|
180
|
+
winRiskThreshold: 0
|
|
181
|
+
loseRiskThreshold: 0
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
resultSummary: {
|
|
186
|
+
status: string
|
|
187
|
+
winner: string
|
|
188
|
+
conclusions: string
|
|
189
|
+
releasedVariationId: string
|
|
190
|
+
excludeFromPayload: boolean
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export declare type GrowthbookFeature = {
|
|
195
|
+
id: string
|
|
196
|
+
dateCreated: string
|
|
197
|
+
dateUpdated: string
|
|
198
|
+
archived: boolean
|
|
199
|
+
description: string
|
|
200
|
+
owner: string
|
|
201
|
+
project: string
|
|
202
|
+
valueType: string
|
|
203
|
+
defaultValue: string
|
|
204
|
+
tags: string[]
|
|
205
|
+
environments: {
|
|
206
|
+
[key: string]: {
|
|
207
|
+
enabled: boolean
|
|
208
|
+
defaultValue: string
|
|
209
|
+
rules: {
|
|
210
|
+
description: string
|
|
211
|
+
condition: string
|
|
212
|
+
savedGroupTargeting: {
|
|
213
|
+
matchType: string
|
|
214
|
+
savedGroups: string[]
|
|
215
|
+
}[]
|
|
216
|
+
id: string
|
|
217
|
+
enabled: boolean
|
|
218
|
+
type: string
|
|
219
|
+
value: string
|
|
220
|
+
variations: {
|
|
221
|
+
value: string
|
|
222
|
+
variationId: string
|
|
223
|
+
}[]
|
|
224
|
+
}[]
|
|
225
|
+
definition: string
|
|
226
|
+
draft: {
|
|
227
|
+
enabled: boolean
|
|
228
|
+
defaultValue: string
|
|
229
|
+
rules: {
|
|
230
|
+
description: string
|
|
231
|
+
condition: string
|
|
232
|
+
savedGroupTargeting: {
|
|
233
|
+
matchType: string
|
|
234
|
+
savedGroups: string[]
|
|
235
|
+
}[]
|
|
236
|
+
id: string
|
|
237
|
+
enabled: boolean
|
|
238
|
+
type: string
|
|
239
|
+
value: string
|
|
240
|
+
variations: {
|
|
241
|
+
value: string
|
|
242
|
+
variationId: string
|
|
243
|
+
}[]
|
|
244
|
+
}[]
|
|
245
|
+
definition: string
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
prerequisites: {
|
|
250
|
+
parentId: string
|
|
251
|
+
parentCondition: string
|
|
252
|
+
}[]
|
|
253
|
+
revision: {
|
|
254
|
+
version: number
|
|
255
|
+
comment: string
|
|
256
|
+
date: string
|
|
257
|
+
publishedBy: string
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export declare const growthbookFieldLevel: Plugin_2<GrowthbookABConfig>
|
|
262
|
+
|
|
59
263
|
export declare type ObjectFieldWithPath = ObjectField<SchemaType> & {
|
|
60
264
|
path: Path
|
|
61
265
|
}
|