@splitsoftware/splitio-commons 2.4.1 → 2.4.2-rc.1
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/cjs/sdkClient/sdkClient.js +1 -0
- package/cjs/sdkFactory/index.js +10 -3
- package/cjs/trackers/impressionsTracker.js +4 -4
- package/esm/sdkClient/sdkClient.js +1 -0
- package/esm/sdkFactory/index.js +10 -3
- package/esm/trackers/impressionsTracker.js +4 -4
- package/package.json +1 -1
- package/src/sdkClient/sdkClient.ts +1 -0
- package/src/sdkFactory/index.ts +13 -3
- package/src/trackers/impressionsTracker.ts +3 -3
|
@@ -38,6 +38,7 @@ function sdkClientFactory(params, isSharedClient) {
|
|
|
38
38
|
(0, clientInputValidation_1.clientInputValidationDecorator)(settings, (0, client_1.clientFactory)(params), sdkReadinessManager.readinessManager),
|
|
39
39
|
// Sdk destroy
|
|
40
40
|
{
|
|
41
|
+
__ctx: params,
|
|
41
42
|
flush: function () {
|
|
42
43
|
// @TODO define cooldown time
|
|
43
44
|
return __cooldown(__flush, COOLDOWN_TIME_IN_MILLIS);
|
package/cjs/sdkFactory/index.js
CHANGED
|
@@ -87,8 +87,7 @@ function sdkFactory(params) {
|
|
|
87
87
|
initCallbacks.length = 0;
|
|
88
88
|
}
|
|
89
89
|
log.info(constants_1.NEW_FACTORY);
|
|
90
|
-
|
|
91
|
-
return (0, objectAssign_1.objectAssign)({
|
|
90
|
+
var factory = (0, objectAssign_1.objectAssign)({
|
|
92
91
|
// Split evaluation and event tracking engine
|
|
93
92
|
client: clientMethod,
|
|
94
93
|
// Manager API to explore available information
|
|
@@ -102,7 +101,15 @@ function sdkFactory(params) {
|
|
|
102
101
|
destroy: function () {
|
|
103
102
|
hasInit = false;
|
|
104
103
|
return Promise.all(Object.keys(clients).map(function (key) { return clients[key].destroy(); })).then(function () { });
|
|
105
|
-
}
|
|
104
|
+
},
|
|
105
|
+
__ctx: ctx
|
|
106
106
|
}, extraProps && extraProps(ctx), lazyInit ? { init: init } : init());
|
|
107
|
+
// append factory to global
|
|
108
|
+
if (typeof window === 'object') { // @ts-ignore
|
|
109
|
+
// eslint-disable-next-line no-undef
|
|
110
|
+
(window.__HARNESS_FME__ = window.__HARNESS_FME__ || []).push(factory);
|
|
111
|
+
}
|
|
112
|
+
// @ts-ignore
|
|
113
|
+
return factory;
|
|
107
114
|
}
|
|
108
115
|
exports.sdkFactory = sdkFactory;
|
|
@@ -9,7 +9,7 @@ var constants_2 = require("../utils/constants");
|
|
|
9
9
|
* Impressions tracker stores impressions in cache and pass them to the listener and integrations manager if provided.
|
|
10
10
|
*/
|
|
11
11
|
function impressionsTrackerFactory(settings, impressionsCache, noneStrategy, strategy, whenInit, integrationsManager, telemetryCache) {
|
|
12
|
-
var log = settings.log,
|
|
12
|
+
var log = settings.log, _a = settings.runtime, ip = _a.ip, hostname = _a.hostname, version = settings.version;
|
|
13
13
|
return {
|
|
14
14
|
track: function (impressions, attributes) {
|
|
15
15
|
if (settings.userConsent === constants_2.CONSENT_DECLINED)
|
|
@@ -42,7 +42,7 @@ function impressionsTrackerFactory(settings, impressionsCache, noneStrategy, str
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
// @TODO next block might be handled by the integration manager. In that case, the metadata object doesn't need to be passed in the constructor
|
|
45
|
-
if (impressionListener || integrationsManager) {
|
|
45
|
+
if (settings.impressionListener || integrationsManager) {
|
|
46
46
|
var _loop_1 = function (i) {
|
|
47
47
|
var impressionData = {
|
|
48
48
|
// copy of impression, to avoid unexpected behavior if modified by integrations or impressionListener
|
|
@@ -59,8 +59,8 @@ function impressionsTrackerFactory(settings, impressionsCache, noneStrategy, str
|
|
|
59
59
|
if (integrationsManager)
|
|
60
60
|
integrationsManager.handleImpression(impressionData);
|
|
61
61
|
try { // @ts-ignore. An exception on the listeners should not break the SDK.
|
|
62
|
-
if (impressionListener)
|
|
63
|
-
impressionListener.logImpression(impressionData);
|
|
62
|
+
if (settings.impressionListener)
|
|
63
|
+
settings.impressionListener.logImpression(impressionData);
|
|
64
64
|
}
|
|
65
65
|
catch (err) {
|
|
66
66
|
log.error(constants_1.ERROR_IMPRESSIONS_LISTENER, [err]);
|
|
@@ -35,6 +35,7 @@ export function sdkClientFactory(params, isSharedClient) {
|
|
|
35
35
|
clientInputValidationDecorator(settings, clientFactory(params), sdkReadinessManager.readinessManager),
|
|
36
36
|
// Sdk destroy
|
|
37
37
|
{
|
|
38
|
+
__ctx: params,
|
|
38
39
|
flush: function () {
|
|
39
40
|
// @TODO define cooldown time
|
|
40
41
|
return __cooldown(__flush, COOLDOWN_TIME_IN_MILLIS);
|
package/esm/sdkFactory/index.js
CHANGED
|
@@ -84,8 +84,7 @@ export function sdkFactory(params) {
|
|
|
84
84
|
initCallbacks.length = 0;
|
|
85
85
|
}
|
|
86
86
|
log.info(NEW_FACTORY);
|
|
87
|
-
|
|
88
|
-
return objectAssign({
|
|
87
|
+
var factory = objectAssign({
|
|
89
88
|
// Split evaluation and event tracking engine
|
|
90
89
|
client: clientMethod,
|
|
91
90
|
// Manager API to explore available information
|
|
@@ -99,6 +98,14 @@ export function sdkFactory(params) {
|
|
|
99
98
|
destroy: function () {
|
|
100
99
|
hasInit = false;
|
|
101
100
|
return Promise.all(Object.keys(clients).map(function (key) { return clients[key].destroy(); })).then(function () { });
|
|
102
|
-
}
|
|
101
|
+
},
|
|
102
|
+
__ctx: ctx
|
|
103
103
|
}, extraProps && extraProps(ctx), lazyInit ? { init: init } : init());
|
|
104
|
+
// append factory to global
|
|
105
|
+
if (typeof window === 'object') { // @ts-ignore
|
|
106
|
+
// eslint-disable-next-line no-undef
|
|
107
|
+
(window.__HARNESS_FME__ = window.__HARNESS_FME__ || []).push(factory);
|
|
108
|
+
}
|
|
109
|
+
// @ts-ignore
|
|
110
|
+
return factory;
|
|
104
111
|
}
|
|
@@ -6,7 +6,7 @@ import { CONSENT_DECLINED, DEDUPED, QUEUED } from '../utils/constants';
|
|
|
6
6
|
* Impressions tracker stores impressions in cache and pass them to the listener and integrations manager if provided.
|
|
7
7
|
*/
|
|
8
8
|
export function impressionsTrackerFactory(settings, impressionsCache, noneStrategy, strategy, whenInit, integrationsManager, telemetryCache) {
|
|
9
|
-
var log = settings.log,
|
|
9
|
+
var log = settings.log, _a = settings.runtime, ip = _a.ip, hostname = _a.hostname, version = settings.version;
|
|
10
10
|
return {
|
|
11
11
|
track: function (impressions, attributes) {
|
|
12
12
|
if (settings.userConsent === CONSENT_DECLINED)
|
|
@@ -39,7 +39,7 @@ export function impressionsTrackerFactory(settings, impressionsCache, noneStrate
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
// @TODO next block might be handled by the integration manager. In that case, the metadata object doesn't need to be passed in the constructor
|
|
42
|
-
if (impressionListener || integrationsManager) {
|
|
42
|
+
if (settings.impressionListener || integrationsManager) {
|
|
43
43
|
var _loop_1 = function (i) {
|
|
44
44
|
var impressionData = {
|
|
45
45
|
// copy of impression, to avoid unexpected behavior if modified by integrations or impressionListener
|
|
@@ -56,8 +56,8 @@ export function impressionsTrackerFactory(settings, impressionsCache, noneStrate
|
|
|
56
56
|
if (integrationsManager)
|
|
57
57
|
integrationsManager.handleImpression(impressionData);
|
|
58
58
|
try { // @ts-ignore. An exception on the listeners should not break the SDK.
|
|
59
|
-
if (impressionListener)
|
|
60
|
-
impressionListener.logImpression(impressionData);
|
|
59
|
+
if (settings.impressionListener)
|
|
60
|
+
settings.impressionListener.logImpression(impressionData);
|
|
61
61
|
}
|
|
62
62
|
catch (err) {
|
|
63
63
|
log.error(ERROR_IMPRESSIONS_LISTENER, [err]);
|
package/package.json
CHANGED
package/src/sdkFactory/index.ts
CHANGED
|
@@ -107,8 +107,7 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ISDK | SplitIO.IA
|
|
|
107
107
|
|
|
108
108
|
log.info(NEW_FACTORY);
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
return objectAssign({
|
|
110
|
+
const factory = objectAssign({
|
|
112
111
|
// Split evaluation and event tracking engine
|
|
113
112
|
client: clientMethod,
|
|
114
113
|
|
|
@@ -126,6 +125,17 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ISDK | SplitIO.IA
|
|
|
126
125
|
destroy() {
|
|
127
126
|
hasInit = false;
|
|
128
127
|
return Promise.all(Object.keys(clients).map(key => clients[key].destroy())).then(() => { });
|
|
129
|
-
}
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
__ctx: ctx
|
|
130
131
|
}, extraProps && extraProps(ctx), lazyInit ? { init } : init());
|
|
132
|
+
|
|
133
|
+
// append factory to global
|
|
134
|
+
if (typeof window === 'object') { // @ts-ignore
|
|
135
|
+
// eslint-disable-next-line no-undef
|
|
136
|
+
(window.__HARNESS_FME__ = window.__HARNESS_FME__ || []).push(factory);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// @ts-ignore
|
|
140
|
+
return factory;
|
|
131
141
|
}
|
|
@@ -20,7 +20,7 @@ export function impressionsTrackerFactory(
|
|
|
20
20
|
telemetryCache?: ITelemetryCacheSync | ITelemetryCacheAsync,
|
|
21
21
|
): IImpressionsTracker {
|
|
22
22
|
|
|
23
|
-
const { log,
|
|
23
|
+
const { log, runtime: { ip, hostname }, version } = settings;
|
|
24
24
|
|
|
25
25
|
return {
|
|
26
26
|
track(impressions: ImpressionDecorated[], attributes?: SplitIO.Attributes) {
|
|
@@ -56,7 +56,7 @@ export function impressionsTrackerFactory(
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
// @TODO next block might be handled by the integration manager. In that case, the metadata object doesn't need to be passed in the constructor
|
|
59
|
-
if (impressionListener || integrationsManager) {
|
|
59
|
+
if (settings.impressionListener || integrationsManager) {
|
|
60
60
|
for (let i = 0; i < impressionsLength; i++) {
|
|
61
61
|
const impressionData: SplitIO.ImpressionData = {
|
|
62
62
|
// copy of impression, to avoid unexpected behavior if modified by integrations or impressionListener
|
|
@@ -74,7 +74,7 @@ export function impressionsTrackerFactory(
|
|
|
74
74
|
if (integrationsManager) integrationsManager.handleImpression(impressionData);
|
|
75
75
|
|
|
76
76
|
try { // @ts-ignore. An exception on the listeners should not break the SDK.
|
|
77
|
-
if (impressionListener) impressionListener.logImpression(impressionData);
|
|
77
|
+
if (settings.impressionListener) settings.impressionListener.logImpression(impressionData);
|
|
78
78
|
} catch (err) {
|
|
79
79
|
log.error(ERROR_IMPRESSIONS_LISTENER, [err]);
|
|
80
80
|
}
|