@flagship.io/react-sdk 3.0.3 → 3.0.4-alpha.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 +14 -14
- package/dist/esm/Flag.js +7 -7
- package/dist/esm/FlagshipContext.js +29 -14
- package/dist/esm/FlagshipHooks.js +24 -24
- package/dist/esm/utils.js +0 -10
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/utils.d.ts +1 -2
- package/package.json +99 -99
package/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img src="https://mk0abtastybwtpirqi5t.kinstacdn.com/wp-content/uploads/picture-solutions-persona-product-flagship.jpg" width="211" height="182" alt="flagship-java" />
|
|
3
|
-
</p>
|
|
4
|
-
<h3 align="center">Bring your features to life</h3>
|
|
5
|
-
|
|
6
|
-
**Visit [https://developers.flagship.io/](https://developers.flagship.io/) to get started with Flagship.**
|
|
7
|
-
|
|
8
|
-
## Docs
|
|
9
|
-
|
|
10
|
-
- [docs](https://docs.developers.flagship.io/docs/react-v3-0-x)
|
|
11
|
-
|
|
12
|
-
## Licence
|
|
13
|
-
|
|
14
|
-
[Apache License.](https://github.com/flagship-io/flagship-react-sdk/blob/master/LICENSE)
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://mk0abtastybwtpirqi5t.kinstacdn.com/wp-content/uploads/picture-solutions-persona-product-flagship.jpg" width="211" height="182" alt="flagship-java" />
|
|
3
|
+
</p>
|
|
4
|
+
<h3 align="center">Bring your features to life</h3>
|
|
5
|
+
|
|
6
|
+
**Visit [https://developers.flagship.io/](https://developers.flagship.io/) to get started with Flagship.**
|
|
7
|
+
|
|
8
|
+
## Docs
|
|
9
|
+
|
|
10
|
+
- [docs](https://docs.developers.flagship.io/docs/react-v3-0-x)
|
|
11
|
+
|
|
12
|
+
## Licence
|
|
13
|
+
|
|
14
|
+
[Apache License.](https://github.com/flagship-io/flagship-react-sdk/blob/master/LICENSE)
|
package/dist/esm/Flag.js
CHANGED
|
@@ -6,41 +6,41 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
6
6
|
|
|
7
7
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
8
|
|
|
9
|
-
import { FlagMetadata
|
|
9
|
+
import Flagship, { FlagMetadata } from '@flagship.io/js-sdk';
|
|
10
10
|
import { noVisitorMessage } from './constants';
|
|
11
|
-
import {
|
|
11
|
+
import { logWarn } from './utils';
|
|
12
12
|
export var Flag = /*#__PURE__*/function () {
|
|
13
13
|
function Flag(defaultValue) {
|
|
14
14
|
_classCallCheck(this, Flag);
|
|
15
15
|
|
|
16
16
|
_defineProperty(this, "_defaultValue", void 0);
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
logWarn(Flagship.getConfig(), noVisitorMessage, 'GetFlag');
|
|
19
19
|
this._defaultValue = defaultValue;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
_createClass(Flag, [{
|
|
23
23
|
key: "getValue",
|
|
24
24
|
value: function getValue() {
|
|
25
|
-
|
|
25
|
+
logWarn(Flagship.getConfig(), noVisitorMessage, 'getValue');
|
|
26
26
|
return this._defaultValue;
|
|
27
27
|
}
|
|
28
28
|
}, {
|
|
29
29
|
key: "exists",
|
|
30
30
|
value: function exists() {
|
|
31
|
-
|
|
31
|
+
logWarn(Flagship.getConfig(), noVisitorMessage, 'exists');
|
|
32
32
|
return false;
|
|
33
33
|
}
|
|
34
34
|
}, {
|
|
35
35
|
key: "userExposed",
|
|
36
36
|
value: function userExposed() {
|
|
37
|
-
|
|
37
|
+
logWarn(Flagship.getConfig(), noVisitorMessage, 'userExposed');
|
|
38
38
|
return Promise.resolve();
|
|
39
39
|
}
|
|
40
40
|
}, {
|
|
41
41
|
key: "metadata",
|
|
42
42
|
get: function get() {
|
|
43
|
-
|
|
43
|
+
logWarn(Flagship.getConfig(), noVisitorMessage, 'metadata');
|
|
44
44
|
return new FlagMetadata({
|
|
45
45
|
campaignId: '',
|
|
46
46
|
campaignType: '',
|
|
@@ -59,7 +59,8 @@ export var FlagshipProvider = function FlagshipProvider(_ref) {
|
|
|
59
59
|
hitDeduplicationTime = _ref.hitDeduplicationTime,
|
|
60
60
|
visitorCacheImplementation = _ref.visitorCacheImplementation,
|
|
61
61
|
hitCacheImplementation = _ref.hitCacheImplementation,
|
|
62
|
-
disableCache = _ref.disableCache
|
|
62
|
+
disableCache = _ref.disableCache,
|
|
63
|
+
language = _ref.language;
|
|
63
64
|
var modifications = new Map();
|
|
64
65
|
|
|
65
66
|
if (initialFlagsData && initialFlagsData.forEach) {
|
|
@@ -184,17 +185,30 @@ export var FlagshipProvider = function FlagshipProvider(_ref) {
|
|
|
184
185
|
statusChangedCallback(status);
|
|
185
186
|
}
|
|
186
187
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
188
|
+
switch (status) {
|
|
189
|
+
case FlagshipStatus.STARTING:
|
|
190
|
+
if (status === FlagshipStatus.STARTING && onInitStart) {
|
|
191
|
+
onInitStart();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
break;
|
|
195
|
+
|
|
196
|
+
case FlagshipStatus.READY_PANIC_ON:
|
|
197
|
+
case FlagshipStatus.READY:
|
|
198
|
+
if (onInitDone) {
|
|
199
|
+
onInitDone();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
createVisitor();
|
|
203
|
+
break;
|
|
204
|
+
|
|
205
|
+
case FlagshipStatus.NOT_INITIALIZED:
|
|
206
|
+
setState(function (prev) {
|
|
207
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
208
|
+
config: Flagship.getConfig()
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
break;
|
|
198
212
|
}
|
|
199
213
|
};
|
|
200
214
|
|
|
@@ -226,7 +240,7 @@ export var FlagshipProvider = function FlagshipProvider(_ref) {
|
|
|
226
240
|
visitorCacheImplementation: visitorCacheImplementation,
|
|
227
241
|
hitCacheImplementation: hitCacheImplementation,
|
|
228
242
|
disableCache: disableCache,
|
|
229
|
-
language:
|
|
243
|
+
language: language
|
|
230
244
|
});
|
|
231
245
|
};
|
|
232
246
|
|
|
@@ -250,5 +264,6 @@ export var FlagshipProvider = function FlagshipProvider(_ref) {
|
|
|
250
264
|
FlagshipProvider.defaultProps = {
|
|
251
265
|
activateDeduplicationTime: 2,
|
|
252
266
|
hitDeduplicationTime: 2,
|
|
253
|
-
fetchNow: true
|
|
267
|
+
fetchNow: true,
|
|
268
|
+
language: 1
|
|
254
269
|
};
|
|
@@ -68,9 +68,9 @@ var fsModificationsSync = function fsModificationsSync(args) {
|
|
|
68
68
|
});
|
|
69
69
|
return flags;
|
|
70
70
|
};
|
|
71
|
-
/**
|
|
72
|
-
* Retrieve a modification value by its key. If no modification match the given key or if the stored value type and default value type do not match, default value will be returned.
|
|
73
|
-
* @deprecated use useFsGetFlag instead
|
|
71
|
+
/**
|
|
72
|
+
* Retrieve a modification value by its key. If no modification match the given key or if the stored value type and default value type do not match, default value will be returned.
|
|
73
|
+
* @deprecated use useFsGetFlag instead
|
|
74
74
|
*/
|
|
75
75
|
|
|
76
76
|
|
|
@@ -90,9 +90,9 @@ export var useFsModifications = function useFsModifications(params, activateAll)
|
|
|
90
90
|
activateAll: activateAll
|
|
91
91
|
});
|
|
92
92
|
};
|
|
93
|
-
/**
|
|
94
|
-
* Retrieve a modification value by its key. If no modification match the given key or if the stored value type and default value type do not match, default value will be returned.
|
|
95
|
-
* @deprecated use useFsGetFlag instead
|
|
93
|
+
/**
|
|
94
|
+
* Retrieve a modification value by its key. If no modification match the given key or if the stored value type and default value type do not match, default value will be returned.
|
|
95
|
+
* @deprecated use useFsGetFlag instead
|
|
96
96
|
*/
|
|
97
97
|
|
|
98
98
|
export var useFsModification = function useFsModification(params) {
|
|
@@ -138,10 +138,10 @@ var fsModificationInfoSync = function fsModificationInfoSync(args) {
|
|
|
138
138
|
|
|
139
139
|
return null;
|
|
140
140
|
};
|
|
141
|
-
/**
|
|
142
|
-
* Get the campaign modification information value matching the given key.
|
|
143
|
-
* @param {string} key key which identify the modification.
|
|
144
|
-
* @deprecated use useFsGetFlag instead
|
|
141
|
+
/**
|
|
142
|
+
* Get the campaign modification information value matching the given key.
|
|
143
|
+
* @param {string} key key which identify the modification.
|
|
144
|
+
* @deprecated use useFsGetFlag instead
|
|
145
145
|
*/
|
|
146
146
|
|
|
147
147
|
|
|
@@ -198,11 +198,11 @@ var fsActivate = /*#__PURE__*/function () {
|
|
|
198
198
|
return _ref.apply(this, arguments);
|
|
199
199
|
};
|
|
200
200
|
}();
|
|
201
|
-
/**
|
|
202
|
-
* This hook returns a flag object by its key. If no flag match the given key an empty flag will be returned.
|
|
203
|
-
* @param key
|
|
204
|
-
* @param defaultValue
|
|
205
|
-
* @returns
|
|
201
|
+
/**
|
|
202
|
+
* This hook returns a flag object by its key. If no flag match the given key an empty flag will be returned.
|
|
203
|
+
* @param key
|
|
204
|
+
* @param defaultValue
|
|
205
|
+
* @returns
|
|
206
206
|
*/
|
|
207
207
|
|
|
208
208
|
|
|
@@ -218,11 +218,11 @@ export var useFsFlag = function useFsFlag(key, defaultValue) {
|
|
|
218
218
|
|
|
219
219
|
return visitor.getFlag(key, defaultValue);
|
|
220
220
|
};
|
|
221
|
-
/**
|
|
222
|
-
* Report this user has seen this modification. Report this user has seen these modifications.
|
|
223
|
-
* @param params
|
|
224
|
-
* @deprecated use useFsGetFlag instead
|
|
225
|
-
* @returns
|
|
221
|
+
/**
|
|
222
|
+
* Report this user has seen this modification. Report this user has seen these modifications.
|
|
223
|
+
* @param params
|
|
224
|
+
* @deprecated use useFsGetFlag instead
|
|
225
|
+
* @returns
|
|
226
226
|
*/
|
|
227
227
|
|
|
228
228
|
export var useFsActivate = /*#__PURE__*/function () {
|
|
@@ -302,8 +302,8 @@ export var useFlagship = function useFlagship() {
|
|
|
302
302
|
|
|
303
303
|
visitor.unauthenticate();
|
|
304
304
|
};
|
|
305
|
-
/**
|
|
306
|
-
* Send a Hit to Flagship servers for reporting.
|
|
305
|
+
/**
|
|
306
|
+
* Send a Hit to Flagship servers for reporting.
|
|
307
307
|
*/
|
|
308
308
|
|
|
309
309
|
|
|
@@ -317,8 +317,8 @@ export var useFlagship = function useFlagship() {
|
|
|
317
317
|
|
|
318
318
|
return visitor.sendHit(hit);
|
|
319
319
|
};
|
|
320
|
-
/**
|
|
321
|
-
* Send a Hit to Flagship servers for reporting.
|
|
320
|
+
/**
|
|
321
|
+
* Send a Hit to Flagship servers for reporting.
|
|
322
322
|
*/
|
|
323
323
|
|
|
324
324
|
|
package/dist/esm/utils.js
CHANGED
|
@@ -21,16 +21,6 @@ export function logWarn(config, message, tag) {
|
|
|
21
21
|
|
|
22
22
|
config.logManager.warning(message, tag);
|
|
23
23
|
}
|
|
24
|
-
export function log(level, message, tag) {
|
|
25
|
-
var now = new Date(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
-
|
|
27
|
-
var getTwoDigit = function getTwoDigit(value) {
|
|
28
|
-
return value.toString().length === 1 ? "0".concat(value) : value;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
var out = "[".concat(getTwoDigit(now.getFullYear()), "-").concat(getTwoDigit(now.getMonth()), "-").concat(getTwoDigit(now.getDay()), " ").concat(getTwoDigit(now.getHours()), ":").concat(getTwoDigit(now.getMinutes()), "] [Flagship SDK] [").concat(LogLevel[level], "] [").concat(tag, "] : ").concat(message);
|
|
32
|
-
console.log(out);
|
|
33
|
-
}
|
|
34
24
|
export var getModificationsFromCampaigns = function getModificationsFromCampaigns(campaigns) {
|
|
35
25
|
var modifications = new Map();
|
|
36
26
|
|