@naturalcycles/abba 1.19.0 → 1.21.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/readme.md +0 -302
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/abba",
3
- "version": "1.19.0",
3
+ "version": "1.21.0",
4
4
  "scripts": {
5
5
  "prepare": "husky"
6
6
  },
package/readme.md DELETED
@@ -1,302 +0,0 @@
1
- <div id="top"></div>
2
-
3
- <!-- PROJECT LOGO -->
4
- <br />
5
- <div align="center">
6
- <h3 align="center">ABBA</h3>
7
-
8
- <p align="center">
9
- A tool for generating and persisting AB test assignments
10
- <br />
11
- </p>
12
- </div>
13
-
14
- <!-- TABLE OF CONTENTS -->
15
- <details>
16
- <summary>Table of Contents</summary>
17
- <ol>
18
- <li>
19
- <a href="#concepts">Concepts</a>
20
- </li>
21
- <li>
22
- <a href="#getting-started">Getting Started</a>
23
- <ul>
24
- <li><a href="#prerequisites">Prerequisites</a></li>
25
- <li><a href="#installation">Installation</a></li>
26
- </ul>
27
- </li>
28
- <li><a href="#usage">Usage</a></li>
29
- <li><a href="#segmentation">Segmentation</a></li>
30
- <li><a href="#exclusion">Mutual Exclusion</a></li>
31
- </ol>
32
- </details>
33
-
34
- <!-- CONCEPTS -->
35
-
36
- ## Concepts
37
-
38
- - **Experiment:** An individual experiment that will test a hypothesis
39
- - **Segmentation:** The target audience for the experiment
40
- - **Sampling:** Restrictions on what proportion of the target audience will be involved in the
41
- experiment
42
- - **Bucket:** An allocation that defines what variant of a particular experience the user will have
43
- - **Start/End dates:** The timeframe that assignments will be generated for this experiment when
44
- active
45
- - **Mutual Exclusion:**
46
- [See here](https://docs.developers.optimizely.com/full-stack-experimentation/docs/mutually-exclusive-experiments)
47
-
48
- <!-- BUILTWITH -->
49
-
50
- ### Built With
51
-
52
- - [@naturalcycles/db-lib](https://github.com/NaturalCycles/db-lib)
53
-
54
- <p align="right">(<a href="#top">back to top</a>)</p>
55
-
56
- <!-- GETTING STARTED -->
57
-
58
- ## Getting Started
59
-
60
- <div id="gettingStarted"></div>
61
-
62
- ### Prerequisites
63
-
64
- <div id="prerequisites"></div>
65
-
66
- - A running MYSQL instance
67
-
68
- ### Installation
69
-
70
- <div id="installation"></div>
71
-
72
- _Below is an example of how you can instruct your audience on installing and setting up your app.
73
- This template doesn't rely on any external dependencies or services._
74
-
75
- 1. Install NPM packages<br/>
76
-
77
- ```sh
78
- yarn add @naturalcyles/abba
79
-
80
- or
81
-
82
- npm install @naturalcyles/abba
83
- ```
84
-
85
- 2. Install the schema into your MySQL db instance using the migration script found
86
- [here](https://github.com/NaturalCycles/abba/blob/master/src/migrations/init.sql).
87
-
88
- <p align="right">(<a href="#top">back to top</a>)</p>
89
-
90
- <!-- USAGE EXAMPLES -->
91
-
92
- ## Usage
93
-
94
- <div id="usage"></div>
95
-
96
- ### Create an instance of Abba
97
-
98
- (Currently supports MySQL, probably all DocumentDBs but not verified.)
99
-
100
- ```js
101
- type AbbaConfig = {
102
- db: CommonDB // from @naturalcycles/db-lib
103
- }
104
-
105
- const abba = new Abba(config: AbbaConfig)
106
- ```
107
-
108
- ### Create a new experiment
109
-
110
- Creates a new experiment
111
-
112
- ```js
113
- async createExperiment(
114
- input: ExperimentInput,
115
- buckets: BucketInput[]
116
- ): Promise<Saved<Experiment>>
117
- ```
118
-
119
- ### Update an experiment
120
-
121
- Updates an existing experiment.
122
-
123
- ```js
124
- async updateExperiment(
125
- id: number,
126
- input: ExperimentInput,
127
- buckets: BucketInput[]
128
- ): Promise<Saved<Experiment>>
129
- ```
130
-
131
- ### Delete an experiment
132
-
133
- Delete an experiment. Removes all users assignments and buckets
134
-
135
- ```js
136
- async deleteExperiment(
137
- id: number
138
- ): Promise<void>
139
- ```
140
-
141
- ### Get all existing user assignments
142
-
143
- Gets all existing user assignments
144
-
145
- ```js
146
- async getAllExistingUserAssignments(
147
- userId: string
148
- ): Promise<Saved<UserAssignment>[]>
149
- ```
150
-
151
- ### Get a users assignment
152
-
153
- Get an assignment for a given user. If `existingOnly` is false, it will attempt generate a new
154
- assignment. `segmentationData` becomse required when `existingOnly` is false
155
-
156
- ```js
157
- async getUserAssignment(
158
- experimentId: number,
159
- userId: string,
160
- existingOnly: boolean,
161
- segmentationData?: SegmentationData,
162
- ): Promise<GeneratedUserAssignment | null>
163
- ```
164
-
165
- ### Generate user assignments
166
-
167
- Generate user assignments for all active experiments. Will return any existing assignments and
168
- attempt to generate new assignments.
169
-
170
- ```js
171
- async generateUserAssignments(
172
- userId: string,
173
- segmentationData: SegmentationData,
174
- ): Promise<GeneratedUserAssignment[]>
175
- ```
176
-
177
- ### Getting assignment statistics
178
-
179
- Get assignment statistics for an experiment.
180
-
181
- ```js
182
- async getExperimentAssignmentStatistics(
183
- experimentId: number
184
- ): Promise<AssignmentStatistics>
185
- ```
186
-
187
- <p align="right">(<a href="#top">back to top</a>)</p>
188
-
189
- ## Segmentation
190
-
191
- <div id="segmentation"></div>
192
-
193
- Experiments can be configured to target specific audiences using segmentation rules. When generating
194
- assignments it is possible to test these rules using user segmentation data which is an object
195
- containing key/value pairs unique to each user. (Allowed value types: `string`, `number`,
196
- `boolean`). A segmentation rule consist of the following properties:
197
-
198
- ```js
199
- key: string, // the key of the corresponding segmentationData property.
200
- operator: '==' | '!=' | 'semver' | 'regex' | 'boolean', // the operator that will be used to execute the rule
201
- value: string | number | boolean, // the value the operator will be executed against
202
- ```
203
-
204
- ## Segmentation rule operators
205
-
206
- ### Equals (==)
207
-
208
- Rule:
209
-
210
- ```js
211
- { key: 'country', operator: '==', value: 'SE }
212
- ```
213
-
214
- Example segmentation data:
215
-
216
- ```js
217
- {
218
- country: 'SE', // valid
219
- country: 'NO' // not valid
220
- }
221
- ```
222
-
223
- ### Not equals (!=)
224
-
225
- Rule:
226
-
227
- ```js
228
- { key: 'country', operator: '!=', value: 'SE' }
229
- ```
230
-
231
- Example segmentation data:
232
-
233
- ```js
234
- {
235
- country: 'NO', // valid
236
- country: 'SE' // not valid
237
- }
238
- ```
239
-
240
- ### Boolean (boolean)
241
-
242
- Rule:
243
-
244
- ```js
245
- { key: 'isEligible', operator: 'boolean', value: true }
246
- ```
247
-
248
- Example segmentation data:
249
-
250
- ```js
251
- {
252
- isEligible: true, // valid
253
- isEligible: false // not valid
254
- }
255
- ```
256
-
257
- ### Semver (semver)
258
-
259
- Rule:
260
-
261
- ```js
262
- { key: 'appVersion', operator: 'semver', value: '>1.1.0' }
263
- ```
264
-
265
- Example segmentation data:
266
-
267
- ```js
268
- {
269
- appVersion: '1.2.0', // valid
270
- appVersion: '1' // not valid
271
- }
272
- ```
273
-
274
- ### Regex (regex)
275
-
276
- Rule:
277
-
278
- ```js
279
- { key: 'country', operator: 'regex', value: 'SE|NO' }
280
- ```
281
-
282
- Example segmentation data:
283
-
284
- ```js
285
- {
286
- country: 'SE', // valid
287
- country: 'NO', // valid
288
- country: 'GB' // not valid
289
- }
290
- ```
291
-
292
- <p align="right">(<a href="#top">back to top</a>)</p>
293
-
294
- <div id="exclusion"></div>
295
-
296
- ## Mutual Exclusion
297
-
298
- Mutual exclusion is configured per-experiment. If an experiment is listed as mutually exclusive with
299
- another experiment(s) then new assignments will only be generated with one of the experiments and
300
- will never be created for the other(s)
301
-
302
- <p align="right">(<a href="#top">back to top</a>)</p>