@sanity/personalization-plugin 2.2.0-growthbook.1 → 2.2.0
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 +0 -2
- package/dist/index.d.mts +1 -205
- package/dist/index.d.ts +1 -205
- package/dist/index.js +42 -133
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -137
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -3
- package/src/components/ExperimentContext.tsx +5 -8
- package/src/components/ExperimentField.tsx +32 -56
- package/src/components/ExperimentInput.tsx +14 -4
- package/src/fieldExperiments.tsx +5 -2
- package/src/index.ts +0 -1
- package/src/types.ts +1 -182
- package/src/components/Secrets.tsx +0 -47
- package/src/growthbookFieldExperiments.tsx +0 -51
- package/src/utils/growthbook.ts +0 -78
package/README.md
CHANGED
|
@@ -25,8 +25,6 @@ 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
|
-
|
|
30
28
|
## Installation
|
|
31
29
|
|
|
32
30
|
```sh
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {ArrayOfObjectsInputProps} from 'sanity'
|
|
2
|
-
import {Dispatch} from 'react'
|
|
3
2
|
import {FieldDefinition} from 'sanity'
|
|
4
3
|
import {ObjectField} from 'sanity'
|
|
5
4
|
import {Path} from 'sanity'
|
|
@@ -7,7 +6,6 @@ import {Plugin as Plugin_2} from 'sanity'
|
|
|
7
6
|
import {PreviewProps} from 'sanity'
|
|
8
7
|
import {SanityClient} from 'sanity'
|
|
9
8
|
import {SchemaType} from 'sanity'
|
|
10
|
-
import {SetStateAction} from 'react'
|
|
11
9
|
|
|
12
10
|
export declare type ArrayInputProps = ArrayOfObjectsInputProps & {
|
|
13
11
|
variantName: string
|
|
@@ -17,8 +15,6 @@ export declare type ArrayInputProps = ArrayOfObjectsInputProps & {
|
|
|
17
15
|
|
|
18
16
|
export declare type ExperimentContextProps = Required<FieldPluginConfig> & {
|
|
19
17
|
experiments: ExperimentType[]
|
|
20
|
-
setSecret: Dispatch<SetStateAction<string | undefined>>
|
|
21
|
-
secret: string | undefined
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
export declare type ExperimentGeneric<T> = {
|
|
@@ -46,9 +42,7 @@ export declare const fieldLevelExperiments: Plugin_2<FieldPluginConfig>
|
|
|
46
42
|
|
|
47
43
|
export declare type FieldPluginConfig = {
|
|
48
44
|
fields: (string | FieldDefinition)[]
|
|
49
|
-
experiments:
|
|
50
|
-
| ExperimentType[]
|
|
51
|
-
| ((client: SanityClient, secret?: string) => Promise<ExperimentType[]>)
|
|
45
|
+
experiments: ExperimentType[] | ((client: SanityClient) => Promise<ExperimentType[]>)
|
|
52
46
|
apiVersion?: string
|
|
53
47
|
experimentNameOverride?: string
|
|
54
48
|
variantNameOverride?: string
|
|
@@ -62,204 +56,6 @@ export declare type FieldPluginConfig = {
|
|
|
62
56
|
*/
|
|
63
57
|
export declare function flattenSchemaType(schemaType: SchemaType): ObjectFieldWithPath[]
|
|
64
58
|
|
|
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
|
-
|
|
263
59
|
export declare type ObjectFieldWithPath = ObjectField<SchemaType> & {
|
|
264
60
|
path: Path
|
|
265
61
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {ArrayOfObjectsInputProps} from 'sanity'
|
|
2
|
-
import {Dispatch} from 'react'
|
|
3
2
|
import {FieldDefinition} from 'sanity'
|
|
4
3
|
import {ObjectField} from 'sanity'
|
|
5
4
|
import {Path} from 'sanity'
|
|
@@ -7,7 +6,6 @@ import {Plugin as Plugin_2} from 'sanity'
|
|
|
7
6
|
import {PreviewProps} from 'sanity'
|
|
8
7
|
import {SanityClient} from 'sanity'
|
|
9
8
|
import {SchemaType} from 'sanity'
|
|
10
|
-
import {SetStateAction} from 'react'
|
|
11
9
|
|
|
12
10
|
export declare type ArrayInputProps = ArrayOfObjectsInputProps & {
|
|
13
11
|
variantName: string
|
|
@@ -17,8 +15,6 @@ export declare type ArrayInputProps = ArrayOfObjectsInputProps & {
|
|
|
17
15
|
|
|
18
16
|
export declare type ExperimentContextProps = Required<FieldPluginConfig> & {
|
|
19
17
|
experiments: ExperimentType[]
|
|
20
|
-
setSecret: Dispatch<SetStateAction<string | undefined>>
|
|
21
|
-
secret: string | undefined
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
export declare type ExperimentGeneric<T> = {
|
|
@@ -46,9 +42,7 @@ export declare const fieldLevelExperiments: Plugin_2<FieldPluginConfig>
|
|
|
46
42
|
|
|
47
43
|
export declare type FieldPluginConfig = {
|
|
48
44
|
fields: (string | FieldDefinition)[]
|
|
49
|
-
experiments:
|
|
50
|
-
| ExperimentType[]
|
|
51
|
-
| ((client: SanityClient, secret?: string) => Promise<ExperimentType[]>)
|
|
45
|
+
experiments: ExperimentType[] | ((client: SanityClient) => Promise<ExperimentType[]>)
|
|
52
46
|
apiVersion?: string
|
|
53
47
|
experimentNameOverride?: string
|
|
54
48
|
variantNameOverride?: string
|
|
@@ -62,204 +56,6 @@ export declare type FieldPluginConfig = {
|
|
|
62
56
|
*/
|
|
63
57
|
export declare function flattenSchemaType(schemaType: SchemaType): ObjectFieldWithPath[]
|
|
64
58
|
|
|
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
|
-
|
|
263
59
|
export declare type ObjectFieldWithPath = ObjectField<SchemaType> & {
|
|
264
60
|
path: Path
|
|
265
61
|
}
|