@featurevisor/sdk 0.36.0 → 0.37.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/CHANGELOG.md +11 -0
- package/README.md +14 -14
- package/coverage/clover.xml +224 -224
- package/coverage/coverage-final.json +4 -4
- package/coverage/lcov-report/bucket.ts.html +1 -1
- package/coverage/lcov-report/conditions.ts.html +38 -38
- package/coverage/lcov-report/datafileReader.ts.html +1 -1
- package/coverage/lcov-report/emitter.ts.html +1 -1
- package/coverage/lcov-report/feature.ts.html +7 -7
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/instance.ts.html +74 -113
- package/coverage/lcov-report/logger.ts.html +1 -1
- package/coverage/lcov-report/segments.ts.html +10 -10
- package/coverage/lcov.info +391 -391
- package/dist/index.js +1 -1
- package/dist/index.js.gz +0 -0
- package/dist/index.js.map +1 -1
- package/lib/conditions.d.ts +3 -3
- package/lib/conditions.js +35 -35
- package/lib/conditions.js.map +1 -1
- package/lib/feature.d.ts +3 -3
- package/lib/feature.js +5 -5
- package/lib/feature.js.map +1 -1
- package/lib/instance.d.ts +27 -26
- package/lib/instance.js +80 -86
- package/lib/instance.js.map +1 -1
- package/lib/segments.d.ts +3 -3
- package/lib/segments.js +8 -8
- package/lib/segments.js.map +1 -1
- package/package.json +3 -3
- package/src/conditions.ts +37 -37
- package/src/feature.ts +6 -6
- package/src/instance.spec.ts +6 -6
- package/src/instance.ts +70 -83
- package/src/segments.ts +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.37.0](https://github.com/fahad19/featurevisor/compare/v0.36.0...v0.37.0) (2023-07-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* renamed Attributes (object) to Context ([#101](https://github.com/fahad19/featurevisor/issues/101)) ([c392ad5](https://github.com/fahad19/featurevisor/commit/c392ad5f1b6100167aa5637b131f08036a7f5a55))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [0.36.0](https://github.com/fahad19/featurevisor/compare/v0.35.0...v0.36.0) (2023-07-13)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @featurevisor/sdk
|
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Visit [https://featurevisor.com/docs/sdks/](https://featurevisor.com/docs/sdks/)
|
|
|
14
14
|
- [`datafileUrl`](#datafileurl)
|
|
15
15
|
- [`handleDatafileFetch`](#handledatafilefetch)
|
|
16
16
|
- [`initialFeatures`](#initialfeatures)
|
|
17
|
-
- [`
|
|
17
|
+
- [`interceptContext`](#interceptcontext)
|
|
18
18
|
- [`logger`](#logger)
|
|
19
19
|
- [`onActivation`](#onactivation)
|
|
20
20
|
- [`onReady`](#onready)
|
|
@@ -70,7 +70,7 @@ Use it to take over bucketing key generation process.
|
|
|
70
70
|
|
|
71
71
|
```js
|
|
72
72
|
const sdk = createInstance({
|
|
73
|
-
configureBucketKey: (feature,
|
|
73
|
+
configureBucketKey: (feature, context, bucketKey) => {
|
|
74
74
|
return bucketKey;
|
|
75
75
|
}
|
|
76
76
|
});
|
|
@@ -85,7 +85,7 @@ Use it to take over bucketing process.
|
|
|
85
85
|
|
|
86
86
|
```js
|
|
87
87
|
const sdk = createInstance({
|
|
88
|
-
configureBucketValue: (feature,
|
|
88
|
+
configureBucketValue: (feature, context, bucketValue) => {
|
|
89
89
|
return bucketValue; // 0 to 100,000
|
|
90
90
|
}
|
|
91
91
|
});
|
|
@@ -143,15 +143,15 @@ const sdk = createInstance({
|
|
|
143
143
|
});
|
|
144
144
|
```
|
|
145
145
|
|
|
146
|
-
### `
|
|
146
|
+
### `interceptContext`
|
|
147
147
|
|
|
148
148
|
- Type: `function`
|
|
149
149
|
- Required: no
|
|
150
150
|
|
|
151
|
-
Intercept given
|
|
151
|
+
Intercept given context before they are used to bucket the user:
|
|
152
152
|
|
|
153
153
|
```js
|
|
154
|
-
const
|
|
154
|
+
const defaultContext = {
|
|
155
155
|
platform: "web",
|
|
156
156
|
locale: "en-US",
|
|
157
157
|
country: "US",
|
|
@@ -160,10 +160,10 @@ const defaultAttributes = {
|
|
|
160
160
|
};
|
|
161
161
|
|
|
162
162
|
const sdk = createInstance({
|
|
163
|
-
|
|
163
|
+
interceptContext: (context) => {
|
|
164
164
|
return {
|
|
165
|
-
...
|
|
166
|
-
...
|
|
165
|
+
...defaultContext,
|
|
166
|
+
...context,
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
169
|
});
|
|
@@ -198,13 +198,13 @@ Capture activated features along with their evaluated variation:
|
|
|
198
198
|
|
|
199
199
|
```js
|
|
200
200
|
const sdk = createInstance({
|
|
201
|
-
onActivation: (featureKey, variation,
|
|
201
|
+
onActivation: (featureKey, variation, context, captureContext) => {
|
|
202
202
|
// do something with the activated feature
|
|
203
203
|
}
|
|
204
204
|
});
|
|
205
205
|
```
|
|
206
206
|
|
|
207
|
-
`
|
|
207
|
+
`captureContext` will only contain attributes that are marked as `capture: true` in the Attributes' YAML files.
|
|
208
208
|
|
|
209
209
|
### `onReady`
|
|
210
210
|
|
|
@@ -296,7 +296,7 @@ These methods are available once the SDK instance is created:
|
|
|
296
296
|
|
|
297
297
|
### `getVariation`
|
|
298
298
|
|
|
299
|
-
> `getVariation(featureKey: string,
|
|
299
|
+
> `getVariation(featureKey: string, context: Context): VariationValue`
|
|
300
300
|
|
|
301
301
|
Also supports additional type specific methods:
|
|
302
302
|
|
|
@@ -307,7 +307,7 @@ Also supports additional type specific methods:
|
|
|
307
307
|
|
|
308
308
|
### `getVariable`
|
|
309
309
|
|
|
310
|
-
> `getVariable(featureKey: string, variableKey: string,
|
|
310
|
+
> `getVariable(featureKey: string, variableKey: string, context: Context): VariableValue`
|
|
311
311
|
|
|
312
312
|
Also supports additional type specific methods:
|
|
313
313
|
|
|
@@ -321,7 +321,7 @@ Also supports additional type specific methods:
|
|
|
321
321
|
|
|
322
322
|
### `activate`
|
|
323
323
|
|
|
324
|
-
> `activate(featureKey: string,
|
|
324
|
+
> `activate(featureKey: string, context: Context): VariationValue`
|
|
325
325
|
|
|
326
326
|
Same as `getVariation`, but also calls the `onActivation` callback.
|
|
327
327
|
|