@splitsoftware/splitio-commons 1.3.2-rc.1 → 1.3.2-rc.2
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/services/splitApi.js +2 -2
- package/cjs/sync/submitters/submitter.js +5 -4
- package/cjs/utils/settingsValidation/index.js +16 -6
- package/cjs/utils/settingsValidation/url.js +1 -1
- package/esm/services/splitApi.js +2 -2
- package/esm/sync/submitters/submitter.js +5 -4
- package/esm/utils/settingsValidation/index.js +17 -7
- package/esm/utils/settingsValidation/url.js +1 -1
- package/package.json +1 -1
- package/src/services/splitApi.ts +2 -2
- package/src/sync/submitters/submitter.ts +4 -4
- package/src/types.ts +1 -1
- package/src/utils/settingsValidation/index.ts +18 -8
- package/src/utils/settingsValidation/url.ts +1 -1
- package/types/types.d.ts +1 -1
package/cjs/services/splitApi.js
CHANGED
|
@@ -91,11 +91,11 @@ function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
91
91
|
return splitHttpClient(url, { method: 'POST', body: body, headers: headers }, telemetryTracker.trackHttp(constants_1.IMPRESSIONS_COUNT));
|
|
92
92
|
},
|
|
93
93
|
postMetricsConfig: function (body) {
|
|
94
|
-
var url = urls.telemetry + "/metrics/config";
|
|
94
|
+
var url = urls.telemetry + "/v1/metrics/config";
|
|
95
95
|
return splitHttpClient(url, { method: 'POST', body: body }, telemetryTracker.trackHttp(constants_1.TELEMETRY), true);
|
|
96
96
|
},
|
|
97
97
|
postMetricsUsage: function (body) {
|
|
98
|
-
var url = urls.telemetry + "/metrics/usage";
|
|
98
|
+
var url = urls.telemetry + "/v1/metrics/usage";
|
|
99
99
|
return splitHttpClient(url, { method: 'POST', body: body }, telemetryTracker.trackHttp(constants_1.TELEMETRY), true);
|
|
100
100
|
}
|
|
101
101
|
};
|
|
@@ -6,7 +6,8 @@ var constants_1 = require("../../logger/constants");
|
|
|
6
6
|
/**
|
|
7
7
|
* Base function to create submitters, such as ImpressionsSubmitter and EventsSubmitter
|
|
8
8
|
*/
|
|
9
|
-
function submitterFactory(log, postClient, sourceCache, postRate, dataName, fromCacheToPayload, maxRetries, debugLogs
|
|
9
|
+
function submitterFactory(log, postClient, sourceCache, postRate, dataName, fromCacheToPayload, maxRetries, debugLogs // true for telemetry submitters
|
|
10
|
+
) {
|
|
10
11
|
if (maxRetries === void 0) { maxRetries = 0; }
|
|
11
12
|
var retries = 0;
|
|
12
13
|
function postData() {
|
|
@@ -24,16 +25,16 @@ function submitterFactory(log, postClient, sourceCache, postRate, dataName, from
|
|
|
24
25
|
sourceCache.clear(); // we clear the queue if request successes.
|
|
25
26
|
}).catch(function (err) {
|
|
26
27
|
if (!maxRetries) {
|
|
27
|
-
log
|
|
28
|
+
log[debugLogs ? 'debug' : 'warn'](constants_1.SUBMITTERS_PUSH_FAILS, [dataCountMessage, err]);
|
|
28
29
|
}
|
|
29
30
|
else if (retries === maxRetries) {
|
|
30
31
|
retries = 0;
|
|
31
32
|
sourceCache.clear(); // we clear the queue if request fails after retries.
|
|
32
|
-
log
|
|
33
|
+
log[debugLogs ? 'debug' : 'warn'](constants_1.SUBMITTERS_PUSH_FAILS, [dataCountMessage, err]);
|
|
33
34
|
}
|
|
34
35
|
else {
|
|
35
36
|
retries++;
|
|
36
|
-
log
|
|
37
|
+
log[debugLogs ? 'debug' : 'warn'](constants_1.SUBMITTERS_PUSH_RETRY, [dataCountMessage, err]);
|
|
37
38
|
}
|
|
38
39
|
});
|
|
39
40
|
}
|
|
@@ -32,8 +32,8 @@ exports.base = {
|
|
|
32
32
|
segmentsRefreshRate: 60,
|
|
33
33
|
// publish telemetry stats each 3600 secs (1 hour)
|
|
34
34
|
telemetryRefreshRate: 3600,
|
|
35
|
-
// publish evaluations each
|
|
36
|
-
impressionsRefreshRate:
|
|
35
|
+
// publish evaluations each 300 sec (default value for OPTIMIZED impressions mode)
|
|
36
|
+
impressionsRefreshRate: 300,
|
|
37
37
|
// fetch offline changes each 15 sec
|
|
38
38
|
offlineRefreshRate: 15,
|
|
39
39
|
// publish events every 60 seconds after the first flush
|
|
@@ -55,7 +55,7 @@ exports.base = {
|
|
|
55
55
|
// Streaming Server
|
|
56
56
|
streaming: 'https://streaming.split.io',
|
|
57
57
|
// Telemetry Server
|
|
58
|
-
telemetry: 'https://telemetry.split.io',
|
|
58
|
+
telemetry: 'https://telemetry.split.io/api',
|
|
59
59
|
},
|
|
60
60
|
// Defines which kind of storage we should instanciate.
|
|
61
61
|
storage: undefined,
|
|
@@ -96,6 +96,8 @@ function settingsValidation(config, validationParams) {
|
|
|
96
96
|
// First thing to validate, since other validators might use the logger.
|
|
97
97
|
var log = logger(withDefaults); // @ts-ignore, modify readonly prop
|
|
98
98
|
withDefaults.log = log;
|
|
99
|
+
// ensure a valid impressionsMode
|
|
100
|
+
withDefaults.sync.impressionsMode = (0, impressionsMode_1.validImpressionsMode)(log, withDefaults.sync.impressionsMode);
|
|
99
101
|
function validateMinValue(paramName, actualValue, minValue) {
|
|
100
102
|
if (actualValue >= minValue)
|
|
101
103
|
return actualValue;
|
|
@@ -107,10 +109,20 @@ function settingsValidation(config, validationParams) {
|
|
|
107
109
|
var scheduler = withDefaults.scheduler, startup = withDefaults.startup;
|
|
108
110
|
scheduler.featuresRefreshRate = fromSecondsToMillis(scheduler.featuresRefreshRate);
|
|
109
111
|
scheduler.segmentsRefreshRate = fromSecondsToMillis(scheduler.segmentsRefreshRate);
|
|
110
|
-
scheduler.impressionsRefreshRate = fromSecondsToMillis(scheduler.impressionsRefreshRate);
|
|
111
112
|
scheduler.offlineRefreshRate = fromSecondsToMillis(scheduler.offlineRefreshRate);
|
|
112
113
|
scheduler.eventsPushRate = fromSecondsToMillis(scheduler.eventsPushRate);
|
|
113
114
|
scheduler.telemetryRefreshRate = fromSecondsToMillis(validateMinValue('telemetryRefreshRate', scheduler.telemetryRefreshRate, 60));
|
|
115
|
+
if (scheduler.impressionsRefreshRate !== exports.base.scheduler.impressionsRefreshRate) {
|
|
116
|
+
// Validate impressionsRefreshRate defined by user
|
|
117
|
+
scheduler.impressionsRefreshRate = validateMinValue('impressionsRefreshRate', scheduler.impressionsRefreshRate, withDefaults.sync.impressionsMode === constants_1.DEBUG ? 1 : 60 // Min is 1 sec for DEBUG and 60 secs for OPTIMIZED
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
// Default impressionsRefreshRate for DEBUG mode is 60 secs
|
|
122
|
+
if (withDefaults.sync.impressionsMode === constants_1.DEBUG)
|
|
123
|
+
scheduler.impressionsRefreshRate = 60;
|
|
124
|
+
}
|
|
125
|
+
scheduler.impressionsRefreshRate = fromSecondsToMillis(scheduler.impressionsRefreshRate);
|
|
114
126
|
// Log deprecation for old telemetry param
|
|
115
127
|
if (scheduler.metricsRefreshRate)
|
|
116
128
|
log.warn('`metricsRefreshRate` will be deprecated soon. For configuring telemetry rates, update `telemetryRefreshRate` value in configs');
|
|
@@ -166,8 +178,6 @@ function settingsValidation(config, validationParams) {
|
|
|
166
178
|
var splitFiltersValidation = (0, splitFilters_1.validateSplitFilters)(log, withDefaults.sync.splitFilters, withDefaults.mode);
|
|
167
179
|
withDefaults.sync.splitFilters = splitFiltersValidation.validFilters;
|
|
168
180
|
withDefaults.sync.__splitFiltersValidation = splitFiltersValidation;
|
|
169
|
-
// ensure a valid impressionsMode
|
|
170
|
-
withDefaults.sync.impressionsMode = (0, impressionsMode_1.validImpressionsMode)(log, withDefaults.sync.impressionsMode);
|
|
171
181
|
// ensure a valid user consent value
|
|
172
182
|
// @ts-ignore, modify readonly prop
|
|
173
183
|
withDefaults.userConsent = consent(withDefaults);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.url = void 0;
|
|
4
|
-
var telemetryEndpointMatcher = /^\/metrics\/(config|usage)/;
|
|
4
|
+
var telemetryEndpointMatcher = /^\/v1\/metrics\/(config|usage)/;
|
|
5
5
|
var eventsEndpointMatcher = /^\/(testImpressions|metrics|events)/;
|
|
6
6
|
var authEndpointMatcher = /^\/v2\/auth/;
|
|
7
7
|
var streamingEndpointMatcher = /^\/(sse|event-stream)/;
|
package/esm/services/splitApi.js
CHANGED
|
@@ -88,11 +88,11 @@ export function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
88
88
|
return splitHttpClient(url, { method: 'POST', body: body, headers: headers }, telemetryTracker.trackHttp(IMPRESSIONS_COUNT));
|
|
89
89
|
},
|
|
90
90
|
postMetricsConfig: function (body) {
|
|
91
|
-
var url = urls.telemetry + "/metrics/config";
|
|
91
|
+
var url = urls.telemetry + "/v1/metrics/config";
|
|
92
92
|
return splitHttpClient(url, { method: 'POST', body: body }, telemetryTracker.trackHttp(TELEMETRY), true);
|
|
93
93
|
},
|
|
94
94
|
postMetricsUsage: function (body) {
|
|
95
|
-
var url = urls.telemetry + "/metrics/usage";
|
|
95
|
+
var url = urls.telemetry + "/v1/metrics/usage";
|
|
96
96
|
return splitHttpClient(url, { method: 'POST', body: body }, telemetryTracker.trackHttp(TELEMETRY), true);
|
|
97
97
|
}
|
|
98
98
|
};
|
|
@@ -3,7 +3,8 @@ import { SUBMITTERS_PUSH, SUBMITTERS_PUSH_FAILS, SUBMITTERS_PUSH_RETRY } from '.
|
|
|
3
3
|
/**
|
|
4
4
|
* Base function to create submitters, such as ImpressionsSubmitter and EventsSubmitter
|
|
5
5
|
*/
|
|
6
|
-
export function submitterFactory(log, postClient, sourceCache, postRate, dataName, fromCacheToPayload, maxRetries, debugLogs
|
|
6
|
+
export function submitterFactory(log, postClient, sourceCache, postRate, dataName, fromCacheToPayload, maxRetries, debugLogs // true for telemetry submitters
|
|
7
|
+
) {
|
|
7
8
|
if (maxRetries === void 0) { maxRetries = 0; }
|
|
8
9
|
var retries = 0;
|
|
9
10
|
function postData() {
|
|
@@ -21,16 +22,16 @@ export function submitterFactory(log, postClient, sourceCache, postRate, dataNam
|
|
|
21
22
|
sourceCache.clear(); // we clear the queue if request successes.
|
|
22
23
|
}).catch(function (err) {
|
|
23
24
|
if (!maxRetries) {
|
|
24
|
-
log
|
|
25
|
+
log[debugLogs ? 'debug' : 'warn'](SUBMITTERS_PUSH_FAILS, [dataCountMessage, err]);
|
|
25
26
|
}
|
|
26
27
|
else if (retries === maxRetries) {
|
|
27
28
|
retries = 0;
|
|
28
29
|
sourceCache.clear(); // we clear the queue if request fails after retries.
|
|
29
|
-
log
|
|
30
|
+
log[debugLogs ? 'debug' : 'warn'](SUBMITTERS_PUSH_FAILS, [dataCountMessage, err]);
|
|
30
31
|
}
|
|
31
32
|
else {
|
|
32
33
|
retries++;
|
|
33
|
-
log
|
|
34
|
+
log[debugLogs ? 'debug' : 'warn'](SUBMITTERS_PUSH_RETRY, [dataCountMessage, err]);
|
|
34
35
|
}
|
|
35
36
|
});
|
|
36
37
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { merge } from '../lang';
|
|
2
2
|
import { mode } from './mode';
|
|
3
3
|
import { validateSplitFilters } from './splitFilters';
|
|
4
|
-
import { STANDALONE_MODE, OPTIMIZED, LOCALHOST_MODE } from '../constants';
|
|
4
|
+
import { STANDALONE_MODE, OPTIMIZED, LOCALHOST_MODE, DEBUG } from '../constants';
|
|
5
5
|
import { validImpressionsMode } from './impressionsMode';
|
|
6
6
|
import { validateKey } from '../inputValidation/key';
|
|
7
7
|
import { validateTrafficType } from '../inputValidation/trafficType';
|
|
@@ -29,8 +29,8 @@ export var base = {
|
|
|
29
29
|
segmentsRefreshRate: 60,
|
|
30
30
|
// publish telemetry stats each 3600 secs (1 hour)
|
|
31
31
|
telemetryRefreshRate: 3600,
|
|
32
|
-
// publish evaluations each
|
|
33
|
-
impressionsRefreshRate:
|
|
32
|
+
// publish evaluations each 300 sec (default value for OPTIMIZED impressions mode)
|
|
33
|
+
impressionsRefreshRate: 300,
|
|
34
34
|
// fetch offline changes each 15 sec
|
|
35
35
|
offlineRefreshRate: 15,
|
|
36
36
|
// publish events every 60 seconds after the first flush
|
|
@@ -52,7 +52,7 @@ export var base = {
|
|
|
52
52
|
// Streaming Server
|
|
53
53
|
streaming: 'https://streaming.split.io',
|
|
54
54
|
// Telemetry Server
|
|
55
|
-
telemetry: 'https://telemetry.split.io',
|
|
55
|
+
telemetry: 'https://telemetry.split.io/api',
|
|
56
56
|
},
|
|
57
57
|
// Defines which kind of storage we should instanciate.
|
|
58
58
|
storage: undefined,
|
|
@@ -93,6 +93,8 @@ export function settingsValidation(config, validationParams) {
|
|
|
93
93
|
// First thing to validate, since other validators might use the logger.
|
|
94
94
|
var log = logger(withDefaults); // @ts-ignore, modify readonly prop
|
|
95
95
|
withDefaults.log = log;
|
|
96
|
+
// ensure a valid impressionsMode
|
|
97
|
+
withDefaults.sync.impressionsMode = validImpressionsMode(log, withDefaults.sync.impressionsMode);
|
|
96
98
|
function validateMinValue(paramName, actualValue, minValue) {
|
|
97
99
|
if (actualValue >= minValue)
|
|
98
100
|
return actualValue;
|
|
@@ -104,10 +106,20 @@ export function settingsValidation(config, validationParams) {
|
|
|
104
106
|
var scheduler = withDefaults.scheduler, startup = withDefaults.startup;
|
|
105
107
|
scheduler.featuresRefreshRate = fromSecondsToMillis(scheduler.featuresRefreshRate);
|
|
106
108
|
scheduler.segmentsRefreshRate = fromSecondsToMillis(scheduler.segmentsRefreshRate);
|
|
107
|
-
scheduler.impressionsRefreshRate = fromSecondsToMillis(scheduler.impressionsRefreshRate);
|
|
108
109
|
scheduler.offlineRefreshRate = fromSecondsToMillis(scheduler.offlineRefreshRate);
|
|
109
110
|
scheduler.eventsPushRate = fromSecondsToMillis(scheduler.eventsPushRate);
|
|
110
111
|
scheduler.telemetryRefreshRate = fromSecondsToMillis(validateMinValue('telemetryRefreshRate', scheduler.telemetryRefreshRate, 60));
|
|
112
|
+
if (scheduler.impressionsRefreshRate !== base.scheduler.impressionsRefreshRate) {
|
|
113
|
+
// Validate impressionsRefreshRate defined by user
|
|
114
|
+
scheduler.impressionsRefreshRate = validateMinValue('impressionsRefreshRate', scheduler.impressionsRefreshRate, withDefaults.sync.impressionsMode === DEBUG ? 1 : 60 // Min is 1 sec for DEBUG and 60 secs for OPTIMIZED
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
// Default impressionsRefreshRate for DEBUG mode is 60 secs
|
|
119
|
+
if (withDefaults.sync.impressionsMode === DEBUG)
|
|
120
|
+
scheduler.impressionsRefreshRate = 60;
|
|
121
|
+
}
|
|
122
|
+
scheduler.impressionsRefreshRate = fromSecondsToMillis(scheduler.impressionsRefreshRate);
|
|
111
123
|
// Log deprecation for old telemetry param
|
|
112
124
|
if (scheduler.metricsRefreshRate)
|
|
113
125
|
log.warn('`metricsRefreshRate` will be deprecated soon. For configuring telemetry rates, update `telemetryRefreshRate` value in configs');
|
|
@@ -163,8 +175,6 @@ export function settingsValidation(config, validationParams) {
|
|
|
163
175
|
var splitFiltersValidation = validateSplitFilters(log, withDefaults.sync.splitFilters, withDefaults.mode);
|
|
164
176
|
withDefaults.sync.splitFilters = splitFiltersValidation.validFilters;
|
|
165
177
|
withDefaults.sync.__splitFiltersValidation = splitFiltersValidation;
|
|
166
|
-
// ensure a valid impressionsMode
|
|
167
|
-
withDefaults.sync.impressionsMode = validImpressionsMode(log, withDefaults.sync.impressionsMode);
|
|
168
178
|
// ensure a valid user consent value
|
|
169
179
|
// @ts-ignore, modify readonly prop
|
|
170
180
|
withDefaults.userConsent = consent(withDefaults);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var telemetryEndpointMatcher = /^\/metrics\/(config|usage)/;
|
|
1
|
+
var telemetryEndpointMatcher = /^\/v1\/metrics\/(config|usage)/;
|
|
2
2
|
var eventsEndpointMatcher = /^\/(testImpressions|metrics|events)/;
|
|
3
3
|
var authEndpointMatcher = /^\/v2\/auth/;
|
|
4
4
|
var streamingEndpointMatcher = /^\/(sse|event-stream)/;
|
package/package.json
CHANGED
package/src/services/splitApi.ts
CHANGED
|
@@ -108,12 +108,12 @@ export function splitApiFactory(
|
|
|
108
108
|
},
|
|
109
109
|
|
|
110
110
|
postMetricsConfig(body: string) {
|
|
111
|
-
const url = `${urls.telemetry}/metrics/config`;
|
|
111
|
+
const url = `${urls.telemetry}/v1/metrics/config`;
|
|
112
112
|
return splitHttpClient(url, { method: 'POST', body }, telemetryTracker.trackHttp(TELEMETRY), true);
|
|
113
113
|
},
|
|
114
114
|
|
|
115
115
|
postMetricsUsage(body: string) {
|
|
116
|
-
const url = `${urls.telemetry}/metrics/usage`;
|
|
116
|
+
const url = `${urls.telemetry}/v1/metrics/usage`;
|
|
117
117
|
return splitHttpClient(url, { method: 'POST', body }, telemetryTracker.trackHttp(TELEMETRY), true);
|
|
118
118
|
}
|
|
119
119
|
};
|
|
@@ -16,7 +16,7 @@ export function submitterFactory<TState>(
|
|
|
16
16
|
dataName: string,
|
|
17
17
|
fromCacheToPayload?: (cacheData: TState) => any,
|
|
18
18
|
maxRetries: number = 0,
|
|
19
|
-
debugLogs?: boolean
|
|
19
|
+
debugLogs?: boolean // true for telemetry submitters
|
|
20
20
|
): ISyncTask<[], void> {
|
|
21
21
|
|
|
22
22
|
let retries = 0;
|
|
@@ -37,14 +37,14 @@ export function submitterFactory<TState>(
|
|
|
37
37
|
sourceCache.clear(); // we clear the queue if request successes.
|
|
38
38
|
}).catch(err => {
|
|
39
39
|
if (!maxRetries) {
|
|
40
|
-
log
|
|
40
|
+
log[debugLogs ? 'debug' : 'warn'](SUBMITTERS_PUSH_FAILS, [dataCountMessage, err]);
|
|
41
41
|
} else if (retries === maxRetries) {
|
|
42
42
|
retries = 0;
|
|
43
43
|
sourceCache.clear(); // we clear the queue if request fails after retries.
|
|
44
|
-
log
|
|
44
|
+
log[debugLogs ? 'debug' : 'warn'](SUBMITTERS_PUSH_FAILS, [dataCountMessage, err]);
|
|
45
45
|
} else {
|
|
46
46
|
retries++;
|
|
47
|
-
log
|
|
47
|
+
log[debugLogs ? 'debug' : 'warn'](SUBMITTERS_PUSH_RETRY, [dataCountMessage, err]);
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
}
|
package/src/types.ts
CHANGED
|
@@ -684,7 +684,7 @@ export namespace SplitIO {
|
|
|
684
684
|
/**
|
|
685
685
|
* String property to override the base URL where the SDK will post telemetry data.
|
|
686
686
|
* @property {string} telemetry
|
|
687
|
-
* @default 'https://telemetry.split.io'
|
|
687
|
+
* @default 'https://telemetry.split.io/api'
|
|
688
688
|
*/
|
|
689
689
|
telemetry?: string
|
|
690
690
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { merge } from '../lang';
|
|
2
2
|
import { mode } from './mode';
|
|
3
3
|
import { validateSplitFilters } from './splitFilters';
|
|
4
|
-
import { STANDALONE_MODE, OPTIMIZED, LOCALHOST_MODE } from '../constants';
|
|
4
|
+
import { STANDALONE_MODE, OPTIMIZED, LOCALHOST_MODE, DEBUG } from '../constants';
|
|
5
5
|
import { validImpressionsMode } from './impressionsMode';
|
|
6
6
|
import { ISettingsValidationParams } from './types';
|
|
7
7
|
import { ISettings } from '../../types';
|
|
@@ -34,8 +34,8 @@ export const base = {
|
|
|
34
34
|
segmentsRefreshRate: 60,
|
|
35
35
|
// publish telemetry stats each 3600 secs (1 hour)
|
|
36
36
|
telemetryRefreshRate: 3600,
|
|
37
|
-
// publish evaluations each
|
|
38
|
-
impressionsRefreshRate:
|
|
37
|
+
// publish evaluations each 300 sec (default value for OPTIMIZED impressions mode)
|
|
38
|
+
impressionsRefreshRate: 300,
|
|
39
39
|
// fetch offline changes each 15 sec
|
|
40
40
|
offlineRefreshRate: 15,
|
|
41
41
|
// publish events every 60 seconds after the first flush
|
|
@@ -58,7 +58,7 @@ export const base = {
|
|
|
58
58
|
// Streaming Server
|
|
59
59
|
streaming: 'https://streaming.split.io',
|
|
60
60
|
// Telemetry Server
|
|
61
|
-
telemetry: 'https://telemetry.split.io',
|
|
61
|
+
telemetry: 'https://telemetry.split.io/api',
|
|
62
62
|
},
|
|
63
63
|
|
|
64
64
|
// Defines which kind of storage we should instanciate.
|
|
@@ -113,6 +113,9 @@ export function settingsValidation(config: unknown, validationParams: ISettingsV
|
|
|
113
113
|
const log = logger(withDefaults); // @ts-ignore, modify readonly prop
|
|
114
114
|
withDefaults.log = log;
|
|
115
115
|
|
|
116
|
+
// ensure a valid impressionsMode
|
|
117
|
+
withDefaults.sync.impressionsMode = validImpressionsMode(log, withDefaults.sync.impressionsMode);
|
|
118
|
+
|
|
116
119
|
function validateMinValue(paramName: string, actualValue: number, minValue: number) {
|
|
117
120
|
if (actualValue >= minValue) return actualValue;
|
|
118
121
|
// actualValue is not a number or is lower than minValue
|
|
@@ -124,11 +127,21 @@ export function settingsValidation(config: unknown, validationParams: ISettingsV
|
|
|
124
127
|
const { scheduler, startup } = withDefaults;
|
|
125
128
|
scheduler.featuresRefreshRate = fromSecondsToMillis(scheduler.featuresRefreshRate);
|
|
126
129
|
scheduler.segmentsRefreshRate = fromSecondsToMillis(scheduler.segmentsRefreshRate);
|
|
127
|
-
scheduler.impressionsRefreshRate = fromSecondsToMillis(scheduler.impressionsRefreshRate);
|
|
128
130
|
scheduler.offlineRefreshRate = fromSecondsToMillis(scheduler.offlineRefreshRate);
|
|
129
131
|
scheduler.eventsPushRate = fromSecondsToMillis(scheduler.eventsPushRate);
|
|
130
132
|
scheduler.telemetryRefreshRate = fromSecondsToMillis(validateMinValue('telemetryRefreshRate', scheduler.telemetryRefreshRate, 60));
|
|
131
133
|
|
|
134
|
+
if (scheduler.impressionsRefreshRate !== base.scheduler.impressionsRefreshRate) {
|
|
135
|
+
// Validate impressionsRefreshRate defined by user
|
|
136
|
+
scheduler.impressionsRefreshRate = validateMinValue('impressionsRefreshRate', scheduler.impressionsRefreshRate,
|
|
137
|
+
withDefaults.sync.impressionsMode === DEBUG ? 1 : 60 // Min is 1 sec for DEBUG and 60 secs for OPTIMIZED
|
|
138
|
+
);
|
|
139
|
+
} else {
|
|
140
|
+
// Default impressionsRefreshRate for DEBUG mode is 60 secs
|
|
141
|
+
if (withDefaults.sync.impressionsMode === DEBUG) scheduler.impressionsRefreshRate = 60;
|
|
142
|
+
}
|
|
143
|
+
scheduler.impressionsRefreshRate = fromSecondsToMillis(scheduler.impressionsRefreshRate);
|
|
144
|
+
|
|
132
145
|
// Log deprecation for old telemetry param
|
|
133
146
|
if (scheduler.metricsRefreshRate) log.warn('`metricsRefreshRate` will be deprecated soon. For configuring telemetry rates, update `telemetryRefreshRate` value in configs');
|
|
134
147
|
|
|
@@ -190,9 +203,6 @@ export function settingsValidation(config: unknown, validationParams: ISettingsV
|
|
|
190
203
|
withDefaults.sync.splitFilters = splitFiltersValidation.validFilters;
|
|
191
204
|
withDefaults.sync.__splitFiltersValidation = splitFiltersValidation;
|
|
192
205
|
|
|
193
|
-
// ensure a valid impressionsMode
|
|
194
|
-
withDefaults.sync.impressionsMode = validImpressionsMode(log, withDefaults.sync.impressionsMode);
|
|
195
|
-
|
|
196
206
|
// ensure a valid user consent value
|
|
197
207
|
// @ts-ignore, modify readonly prop
|
|
198
208
|
withDefaults.userConsent = consent(withDefaults);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ISettings } from '../../types';
|
|
2
2
|
|
|
3
|
-
const telemetryEndpointMatcher = /^\/metrics\/(config|usage)/;
|
|
3
|
+
const telemetryEndpointMatcher = /^\/v1\/metrics\/(config|usage)/;
|
|
4
4
|
const eventsEndpointMatcher = /^\/(testImpressions|metrics|events)/;
|
|
5
5
|
const authEndpointMatcher = /^\/v2\/auth/;
|
|
6
6
|
const streamingEndpointMatcher = /^\/(sse|event-stream)/;
|
package/types/types.d.ts
CHANGED
|
@@ -681,7 +681,7 @@ export declare namespace SplitIO {
|
|
|
681
681
|
/**
|
|
682
682
|
* String property to override the base URL where the SDK will post telemetry data.
|
|
683
683
|
* @property {string} telemetry
|
|
684
|
-
* @default 'https://telemetry.split.io'
|
|
684
|
+
* @default 'https://telemetry.split.io/api'
|
|
685
685
|
*/
|
|
686
686
|
telemetry?: string;
|
|
687
687
|
};
|