@sanity/personalization-plugin 2.3.0-launch-darkly.2 → 2.4.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 +2 -0
- package/dist/growthbook/index.d.mts +15 -0
- package/dist/growthbook/index.d.ts +15 -0
- package/dist/growthbook/index.js +120 -0
- package/dist/growthbook/index.js.map +1 -0
- package/dist/growthbook/index.mjs +124 -0
- package/dist/growthbook/index.mjs.map +1 -0
- package/dist/index.d.mts +188 -0
- package/dist/index.d.ts +188 -0
- package/dist/index.js +15 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/components/ExperimentField.tsx +1 -5
- package/src/components/ExperimentInput.tsx +6 -5
- package/src/fieldExperiments.tsx +6 -5
- package/src/growthbook/Components/GrowthbookContext.tsx +38 -0
- package/src/{launchDarkly/components → growthbook/Components}/Secrets.tsx +6 -5
- package/src/growthbook/index.ts +54 -0
- package/src/growthbook/types.ts +15 -0
- package/src/growthbook/utils.ts +94 -0
- package/src/types.ts +176 -0
- package/src/utils/flattenSchemaType.ts +11 -14
- package/dist/launchDarkly/index.d.mts +0 -12
- package/dist/launchDarkly/index.d.ts +0 -12
- package/dist/launchDarkly/index.js +0 -103
- package/dist/launchDarkly/index.js.map +0 -1
- package/dist/launchDarkly/index.mjs +0 -107
- package/dist/launchDarkly/index.mjs.map +0 -1
- package/src/launchDarkly/components/LaunchDarklyContext.tsx +0 -36
- package/src/launchDarkly/index.ts +0 -52
- package/src/launchDarkly/types.ts +0 -193
- package/src/launchDarkly/utils.ts +0 -54
package/dist/index.d.ts
CHANGED
|
@@ -56,6 +56,194 @@ export declare type FieldPluginConfig = {
|
|
|
56
56
|
*/
|
|
57
57
|
export declare function flattenSchemaType(schemaType: SchemaType): ObjectFieldWithPath[]
|
|
58
58
|
|
|
59
|
+
export declare type GrowthbookExperiment = {
|
|
60
|
+
id: string
|
|
61
|
+
dateCreated: string
|
|
62
|
+
dateUpdated: string
|
|
63
|
+
name: string
|
|
64
|
+
project: string
|
|
65
|
+
hypothesis: string
|
|
66
|
+
description: string
|
|
67
|
+
tags: [string]
|
|
68
|
+
owner: string
|
|
69
|
+
archived: boolean
|
|
70
|
+
status: string
|
|
71
|
+
autoRefresh: boolean
|
|
72
|
+
hashAttribute: string
|
|
73
|
+
fallbackAttribute: string
|
|
74
|
+
hashVersion: number
|
|
75
|
+
disableStickyBucketing: boolean
|
|
76
|
+
bucketVersion: number
|
|
77
|
+
minBucketVersion: number
|
|
78
|
+
variations: [
|
|
79
|
+
{
|
|
80
|
+
variationId: string
|
|
81
|
+
key: string
|
|
82
|
+
name: string
|
|
83
|
+
description: string
|
|
84
|
+
screenshots: [string]
|
|
85
|
+
},
|
|
86
|
+
]
|
|
87
|
+
phases: [
|
|
88
|
+
{
|
|
89
|
+
name: string
|
|
90
|
+
dateStarted: string
|
|
91
|
+
dateEnded: string
|
|
92
|
+
reasonForStopping: string
|
|
93
|
+
seed: string
|
|
94
|
+
coverage: 0
|
|
95
|
+
trafficSplit: [
|
|
96
|
+
{
|
|
97
|
+
variationId: string
|
|
98
|
+
weight: 0
|
|
99
|
+
},
|
|
100
|
+
]
|
|
101
|
+
namespace: {
|
|
102
|
+
namespaceId: string
|
|
103
|
+
range: []
|
|
104
|
+
}
|
|
105
|
+
targetingCondition: string
|
|
106
|
+
savedGroupTargeting: [
|
|
107
|
+
{
|
|
108
|
+
matchType: string
|
|
109
|
+
savedGroups: [string]
|
|
110
|
+
},
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
]
|
|
114
|
+
settings: {
|
|
115
|
+
datasourceId: string
|
|
116
|
+
assignmentQueryId: string
|
|
117
|
+
experimentId: string
|
|
118
|
+
segmentId: string
|
|
119
|
+
queryFilter: string
|
|
120
|
+
inProgressConversions: string
|
|
121
|
+
attributionModel: string
|
|
122
|
+
statsEngine: string
|
|
123
|
+
regressionAdjustmentEnabled: boolean
|
|
124
|
+
goals: [
|
|
125
|
+
{
|
|
126
|
+
metricId: string
|
|
127
|
+
overrides: {
|
|
128
|
+
delayHours: 0
|
|
129
|
+
windowHours: 0
|
|
130
|
+
window: string
|
|
131
|
+
winRiskThreshold: 0
|
|
132
|
+
loseRiskThreshold: 0
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
]
|
|
136
|
+
secondaryMetrics: [
|
|
137
|
+
{
|
|
138
|
+
metricId: string
|
|
139
|
+
overrides: {
|
|
140
|
+
delayHours: 0
|
|
141
|
+
windowHours: 0
|
|
142
|
+
window: string
|
|
143
|
+
winRiskThreshold: 0
|
|
144
|
+
loseRiskThreshold: 0
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
]
|
|
148
|
+
guardrails: [
|
|
149
|
+
{
|
|
150
|
+
metricId: string
|
|
151
|
+
overrides: {
|
|
152
|
+
delayHours: 0
|
|
153
|
+
windowHours: 0
|
|
154
|
+
window: string
|
|
155
|
+
winRiskThreshold: 0
|
|
156
|
+
loseRiskThreshold: 0
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
]
|
|
160
|
+
activationMetric: {
|
|
161
|
+
metricId: string
|
|
162
|
+
overrides: {
|
|
163
|
+
delayHours: 0
|
|
164
|
+
windowHours: 0
|
|
165
|
+
window: string
|
|
166
|
+
winRiskThreshold: 0
|
|
167
|
+
loseRiskThreshold: 0
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
resultSummary: {
|
|
172
|
+
status: string
|
|
173
|
+
winner: string
|
|
174
|
+
conclusions: string
|
|
175
|
+
releasedVariationId: string
|
|
176
|
+
excludeFromPayload: boolean
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export declare type GrowthbookFeature = {
|
|
181
|
+
id: string
|
|
182
|
+
dateCreated: string
|
|
183
|
+
dateUpdated: string
|
|
184
|
+
archived: boolean
|
|
185
|
+
description: string
|
|
186
|
+
owner: string
|
|
187
|
+
project: string
|
|
188
|
+
valueType: string
|
|
189
|
+
defaultValue: string
|
|
190
|
+
tags: string[]
|
|
191
|
+
environments: {
|
|
192
|
+
[key: string]: {
|
|
193
|
+
enabled: boolean
|
|
194
|
+
defaultValue: string
|
|
195
|
+
rules: {
|
|
196
|
+
description: string
|
|
197
|
+
condition: string
|
|
198
|
+
savedGroupTargeting: {
|
|
199
|
+
matchType: string
|
|
200
|
+
savedGroups: string[]
|
|
201
|
+
}[]
|
|
202
|
+
id: string
|
|
203
|
+
enabled: boolean
|
|
204
|
+
type: string
|
|
205
|
+
value: string
|
|
206
|
+
variations: {
|
|
207
|
+
value: string
|
|
208
|
+
variationId: string
|
|
209
|
+
}[]
|
|
210
|
+
}[]
|
|
211
|
+
definition: string
|
|
212
|
+
draft: {
|
|
213
|
+
enabled: boolean
|
|
214
|
+
defaultValue: string
|
|
215
|
+
rules: {
|
|
216
|
+
description: string
|
|
217
|
+
condition: string
|
|
218
|
+
savedGroupTargeting: {
|
|
219
|
+
matchType: string
|
|
220
|
+
savedGroups: string[]
|
|
221
|
+
}[]
|
|
222
|
+
id: string
|
|
223
|
+
enabled: boolean
|
|
224
|
+
type: string
|
|
225
|
+
value: string
|
|
226
|
+
variations: {
|
|
227
|
+
value: string
|
|
228
|
+
variationId: string
|
|
229
|
+
}[]
|
|
230
|
+
}[]
|
|
231
|
+
definition: string
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
prerequisites: {
|
|
236
|
+
parentId: string
|
|
237
|
+
parentCondition: string
|
|
238
|
+
}[]
|
|
239
|
+
revision: {
|
|
240
|
+
version: number
|
|
241
|
+
comment: string
|
|
242
|
+
date: string
|
|
243
|
+
publishedBy: string
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
59
247
|
export declare type ObjectFieldWithPath = ObjectField<SchemaType> & {
|
|
60
248
|
path: Path
|
|
61
249
|
}
|
package/dist/index.js
CHANGED
|
@@ -6504,20 +6504,20 @@ const useAddExperimentAction = (props) => {
|
|
|
6504
6504
|
title: experiment.label,
|
|
6505
6505
|
value: experiment.id
|
|
6506
6506
|
})), ExperimentInput = (props) => {
|
|
6507
|
-
const { experiments } = useExperimentContext(), id = sanity.useFormValue(["_id"]),
|
|
6507
|
+
const { experiments } = useExperimentContext(), id = sanity.useFormValue(["_id"]), additionalChangePath = react.useMemo(
|
|
6508
6508
|
() => [...props.path.slice(0, -1), `${props.variantNameOverride}s`],
|
|
6509
6509
|
[props.variantNameOverride, props.path]
|
|
6510
|
-
), subValues = sanity.useFormValue(
|
|
6510
|
+
), subValues = sanity.useFormValue(additionalChangePath), { patch } = sanity.useDocumentOperation(sanity.getPublishedId(id), props.schemaType.name), handleChange = react.useCallback(
|
|
6511
6511
|
(event, onChange) => {
|
|
6512
6512
|
const inputValue = event.currentTarget.value;
|
|
6513
6513
|
if (onChange(inputValue ? sanity.set(inputValue) : sanity.unset()), subValues) {
|
|
6514
6514
|
const patchEvent = {
|
|
6515
|
-
unset: [
|
|
6515
|
+
unset: [additionalChangePath.join(".")]
|
|
6516
6516
|
};
|
|
6517
6517
|
patch.execute([patchEvent]);
|
|
6518
6518
|
}
|
|
6519
6519
|
},
|
|
6520
|
-
[patch, subValues,
|
|
6520
|
+
[patch, subValues, additionalChangePath]
|
|
6521
6521
|
);
|
|
6522
6522
|
return experiments.length ? /* @__PURE__ */ jsxRuntime.jsx(Select, { ...props, listOptions: formatlistOptions(experiments), handleChange }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { padding: [3, 3, 4], radius: 2, shadow: 1, tone: "caution", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { align: "center", size: [2, 2, 3], children: [
|
|
6523
6523
|
"There are no defined ",
|
|
@@ -6559,7 +6559,7 @@ const useAddExperimentAction = (props) => {
|
|
|
6559
6559
|
return props.renderDefault(previewProps);
|
|
6560
6560
|
};
|
|
6561
6561
|
function flattenSchemaType(schemaType) {
|
|
6562
|
-
return sanity.isDocumentSchemaType(schemaType) ? extractInnerFields(schemaType.fields, [],
|
|
6562
|
+
return sanity.isDocumentSchemaType(schemaType) ? extractInnerFields(schemaType.fields, [], 5) : (console.error("Schema type is not a document"), []);
|
|
6563
6563
|
}
|
|
6564
6564
|
function extractInnerFields(fields, path, maxDepth) {
|
|
6565
6565
|
return path.length >= maxDepth ? [] : fields.reduce((acc, field) => {
|
|
@@ -6567,13 +6567,14 @@ function extractInnerFields(fields, path, maxDepth) {
|
|
|
6567
6567
|
if (field.type.jsonType === "object") {
|
|
6568
6568
|
const innerFields = extractInnerFields(field.type.fields, [...path, field.name], maxDepth);
|
|
6569
6569
|
return [...acc, thisFieldWithPath, ...innerFields];
|
|
6570
|
-
} else if (field.type.jsonType === "array"
|
|
6571
|
-
const innerFields =
|
|
6572
|
-
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
|
|
6570
|
+
} else if (field.type.jsonType === "array") {
|
|
6571
|
+
const innerFields = (field.type.of || []).reduce((arrayAcc, arrayType) => {
|
|
6572
|
+
if ("fields" in arrayType) {
|
|
6573
|
+
const typeFields = extractInnerFields(arrayType.fields, [...path, field.name], maxDepth);
|
|
6574
|
+
return [...arrayAcc, ...typeFields];
|
|
6575
|
+
}
|
|
6576
|
+
return arrayAcc;
|
|
6577
|
+
}, []);
|
|
6577
6578
|
return [...acc, thisFieldWithPath, ...innerFields];
|
|
6578
6579
|
}
|
|
6579
6580
|
return [...acc, thisFieldWithPath];
|
|
@@ -6748,10 +6749,8 @@ const createExperimentType = ({
|
|
|
6748
6749
|
form: {
|
|
6749
6750
|
components: {
|
|
6750
6751
|
input: (props) => {
|
|
6751
|
-
if (!(props.id === "root" && sanity.isObjectInputProps(props)) || !flattenSchemaType(props.schemaType).
|
|
6752
|
-
(field) => field.type.name
|
|
6753
|
-
).some(
|
|
6754
|
-
(name) => name.startsWith(experimentNameOverride)
|
|
6752
|
+
if (!(props.id === "root" && sanity.isObjectInputProps(props)) || !flattenSchemaType(props.schemaType).some(
|
|
6753
|
+
(field) => field.type.name.startsWith(experimentNameOverride) || field.name.startsWith(experimentNameOverride)
|
|
6755
6754
|
))
|
|
6756
6755
|
return props.renderDefault(props);
|
|
6757
6756
|
const providerProps = {
|