@splitsoftware/splitio 10.18.2-rc.0 → 10.18.3-rc.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/CHANGES.txt CHANGED
@@ -1,3 +1,8 @@
1
+ 10.19.0 (May XX, 2022)
2
+ - Added `scheduler.telemetryRefreshRate` property to SDK configuration, and deprecated `scheduler.metricsRefreshRate` property.
3
+ - Updated SDK telemetry storage, metrics and updater to be more effective and send less often.
4
+ - Bugfixing - Updated default values for `scheduler.impressionsRefreshRate` config parameter: 300s for OPTIMIZED impression mode and 60s for DEBUG impression mode.
5
+
1
6
  10.18.2 (May 6, 2022)
2
7
  - Bugfixing - Removed "ip" dependency to use an inline copy of it that fixes an error when using it in Node v18 (https://github.com/indutny/node-ip/issues/113).
3
8
 
@@ -2,9 +2,11 @@ import { EventEmitter } from './EventEmitter';
2
2
  import { getFetch } from '../platform/getFetch/browser';
3
3
  import { getEventSource } from '../platform/getEventSource/browser';
4
4
  import { BrowserSignalListener } from '@splitsoftware/splitio-commons/esm/listeners/browser';
5
+ import { now } from '@splitsoftware/splitio-commons/esm/utils/timeTracker/now/browser';
5
6
  export var platform = {
6
7
  getFetch: getFetch,
7
8
  getEventSource: getEventSource,
8
- EventEmitter: EventEmitter
9
+ EventEmitter: EventEmitter,
10
+ now: now
9
11
  };
10
12
  export var SignalListener = BrowserSignalListener;
@@ -3,10 +3,12 @@ import { getFetch } from '../platform/getFetch/node';
3
3
  import { getEventSource } from '../platform/getEventSource/node';
4
4
  import { getOptions } from '../platform/request/options/node';
5
5
  import { NodeSignalListener } from '@splitsoftware/splitio-commons/esm/listeners/node';
6
+ import { now } from '@splitsoftware/splitio-commons/esm/utils/timeTracker/now/node';
6
7
  export var platform = {
7
8
  getOptions: getOptions,
8
9
  getFetch: getFetch,
9
10
  getEventSource: getEventSource,
10
- EventEmitter: EventEmitter
11
+ EventEmitter: EventEmitter,
12
+ now: now
11
13
  };
12
14
  export var SignalListener = NodeSignalListener;
@@ -15,8 +15,7 @@ export var defaults = {
15
15
  eventsFirstPushWindow: 0
16
16
  },
17
17
  scheduler: {
18
- featuresRefreshRate: 5,
19
- impressionsRefreshRate: 300
18
+ featuresRefreshRate: 5
20
19
  },
21
20
  features: '.split',
22
21
  // Instance version.
@@ -1 +1 @@
1
- export var packageVersion = '10.18.2-rc.0';
1
+ export var packageVersion = '10.18.3-rc.0';
@@ -1,5 +1,5 @@
1
1
  import osFunction from 'os';
2
- import ipFunction from './ip';
2
+ import ipFunction from '../../utils/ip';
3
3
  import { UNKNOWN, NA, CONSUMER_MODE } from '@splitsoftware/splitio-commons/esm/utils/constants';
4
4
  export function validateRuntime(settings) {
5
5
  var isIPAddressesEnabled = settings.core.IPAddressesEnabled === true;
package/es/utils/ip.js ADDED
@@ -0,0 +1,111 @@
1
+ /* eslint-disable no-redeclare */
2
+ /*
3
+ Trimmed version of "ip" package (https://www.npmjs.com/package/ip) that fixes an error when running in Node v18.
4
+
5
+ This software is licensed under the MIT License.
6
+
7
+ Copyright Fedor Indutny, 2012.
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
+ */
15
+ 'use strict';
16
+ var ip = exports;
17
+ var os = require('os');
18
+ function _resolveFamily(family) {
19
+ return typeof family === 'number' ? 'ipv' + family : family.toLowerCase();
20
+ }
21
+ function _normalizeFamily(family) {
22
+ return family ? _resolveFamily(family) : 'ipv4';
23
+ }
24
+ function isPrivate(addr) {
25
+ return /^(::f{4}:)?10\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i
26
+ .test(addr) ||
27
+ /^(::f{4}:)?192\.168\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
28
+ /^(::f{4}:)?172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})$/i
29
+ .test(addr) ||
30
+ /^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
31
+ /^(::f{4}:)?169\.254\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
32
+ /^f[cd][0-9a-f]{2}:/i.test(addr) ||
33
+ /^fe80:/i.test(addr) ||
34
+ /^::1$/.test(addr) ||
35
+ /^::$/.test(addr);
36
+ }
37
+ function isPublic(addr) {
38
+ return !isPrivate(addr);
39
+ }
40
+ function isLoopback(addr) {
41
+ return /^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/
42
+ .test(addr) ||
43
+ /^fe80::1$/.test(addr) ||
44
+ /^::1$/.test(addr) ||
45
+ /^::$/.test(addr);
46
+ }
47
+ function loopback(family) {
48
+ //
49
+ // Default to `ipv4`
50
+ //
51
+ family = _normalizeFamily(family);
52
+ if (family !== 'ipv4' && family !== 'ipv6') {
53
+ throw new Error('family must be ipv4 or ipv6');
54
+ }
55
+ return family === 'ipv4' ? '127.0.0.1' : 'fe80::1';
56
+ }
57
+ //
58
+ // ### function address (name, family)
59
+ // #### @name {string|'public'|'private'} **Optional** Name or security
60
+ // of the network interface.
61
+ // #### @family {ipv4|ipv6} **Optional** IP family of the address (defaults
62
+ // to ipv4).
63
+ //
64
+ // Returns the address for the network interface on the current system with
65
+ // the specified `name`:
66
+ // * String: First `family` address of the interface.
67
+ // If not found see `undefined`.
68
+ // * 'public': the first public ip address of family.
69
+ // * 'private': the first private ip address of family.
70
+ // * undefined: First address with `ipv4` or loopback address `127.0.0.1`.
71
+ //
72
+ ip.address = function (name, family) {
73
+ var interfaces = os.networkInterfaces();
74
+ var all;
75
+ //
76
+ // Default to `ipv4`
77
+ //
78
+ family = _normalizeFamily(family);
79
+ //
80
+ // If a specific network interface has been named,
81
+ // return the address.
82
+ //
83
+ if (name && name !== 'private' && name !== 'public') {
84
+ var res = interfaces[name].filter(function (details) {
85
+ var itemFamily = _resolveFamily(details.family);
86
+ return itemFamily === family;
87
+ });
88
+ if (res.length === 0)
89
+ return undefined;
90
+ return res[0].address;
91
+ }
92
+ var all = Object.keys(interfaces).map(function (nic) {
93
+ //
94
+ // Note: name will only be `public` or `private`
95
+ // when this is called.
96
+ //
97
+ var addresses = interfaces[nic].filter(function (details) {
98
+ details.family = _resolveFamily(details.family);
99
+ if (details.family !== family || isLoopback(details.address)) {
100
+ return false;
101
+ }
102
+ else if (!name) {
103
+ return true;
104
+ }
105
+ return name === 'public' ? isPrivate(details.address) :
106
+ isPublic(details.address);
107
+ });
108
+ return addresses.length ? addresses[0].address : undefined;
109
+ }).filter(Boolean);
110
+ return !all.length ? loopback(family) : all[0];
111
+ };
@@ -5,9 +5,11 @@ var EventEmitter_1 = require("./EventEmitter");
5
5
  var browser_1 = require("../platform/getFetch/browser");
6
6
  var browser_2 = require("../platform/getEventSource/browser");
7
7
  var browser_3 = require("@splitsoftware/splitio-commons/cjs/listeners/browser");
8
+ var browser_4 = require("@splitsoftware/splitio-commons/cjs/utils/timeTracker/now/browser");
8
9
  exports.platform = {
9
10
  getFetch: browser_1.getFetch,
10
11
  getEventSource: browser_2.getEventSource,
11
- EventEmitter: EventEmitter_1.EventEmitter
12
+ EventEmitter: EventEmitter_1.EventEmitter,
13
+ now: browser_4.now
12
14
  };
13
15
  exports.SignalListener = browser_3.BrowserSignalListener;
@@ -7,10 +7,12 @@ var node_1 = require("../platform/getFetch/node");
7
7
  var node_2 = require("../platform/getEventSource/node");
8
8
  var node_3 = require("../platform/request/options/node");
9
9
  var node_4 = require("@splitsoftware/splitio-commons/cjs/listeners/node");
10
+ var node_5 = require("@splitsoftware/splitio-commons/cjs/utils/timeTracker/now/node");
10
11
  exports.platform = {
11
12
  getOptions: node_3.getOptions,
12
13
  getFetch: node_1.getFetch,
13
14
  getEventSource: node_2.getEventSource,
14
- EventEmitter: events_1.default
15
+ EventEmitter: events_1.default,
16
+ now: node_5.now
15
17
  };
16
18
  exports.SignalListener = node_4.NodeSignalListener;
@@ -18,8 +18,7 @@ exports.defaults = {
18
18
  eventsFirstPushWindow: 0
19
19
  },
20
20
  scheduler: {
21
- featuresRefreshRate: 5,
22
- impressionsRefreshRate: 300
21
+ featuresRefreshRate: 5
23
22
  },
24
23
  features: '.split',
25
24
  // Instance version.
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.packageVersion = void 0;
4
- exports.packageVersion = '10.18.2-rc.0';
4
+ exports.packageVersion = '10.18.3-rc.0';
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateRuntime = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var os_1 = (0, tslib_1.__importDefault)(require("os"));
6
- var ip_1 = (0, tslib_1.__importDefault)(require("./ip"));
6
+ var ip_1 = (0, tslib_1.__importDefault)(require("../../utils/ip"));
7
7
  var constants_1 = require("@splitsoftware/splitio-commons/cjs/utils/constants");
8
8
  function validateRuntime(settings) {
9
9
  var isIPAddressesEnabled = settings.core.IPAddressesEnabled === true;
@@ -0,0 +1,111 @@
1
+ /* eslint-disable no-redeclare */
2
+ /*
3
+ Trimmed version of "ip" package (https://www.npmjs.com/package/ip) that fixes an error when running in Node v18.
4
+
5
+ This software is licensed under the MIT License.
6
+
7
+ Copyright Fedor Indutny, 2012.
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
+ */
15
+ 'use strict';
16
+ var ip = exports;
17
+ var os = require('os');
18
+ function _resolveFamily(family) {
19
+ return typeof family === 'number' ? 'ipv' + family : family.toLowerCase();
20
+ }
21
+ function _normalizeFamily(family) {
22
+ return family ? _resolveFamily(family) : 'ipv4';
23
+ }
24
+ function isPrivate(addr) {
25
+ return /^(::f{4}:)?10\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i
26
+ .test(addr) ||
27
+ /^(::f{4}:)?192\.168\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
28
+ /^(::f{4}:)?172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})$/i
29
+ .test(addr) ||
30
+ /^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
31
+ /^(::f{4}:)?169\.254\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
32
+ /^f[cd][0-9a-f]{2}:/i.test(addr) ||
33
+ /^fe80:/i.test(addr) ||
34
+ /^::1$/.test(addr) ||
35
+ /^::$/.test(addr);
36
+ }
37
+ function isPublic(addr) {
38
+ return !isPrivate(addr);
39
+ }
40
+ function isLoopback(addr) {
41
+ return /^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/
42
+ .test(addr) ||
43
+ /^fe80::1$/.test(addr) ||
44
+ /^::1$/.test(addr) ||
45
+ /^::$/.test(addr);
46
+ }
47
+ function loopback(family) {
48
+ //
49
+ // Default to `ipv4`
50
+ //
51
+ family = _normalizeFamily(family);
52
+ if (family !== 'ipv4' && family !== 'ipv6') {
53
+ throw new Error('family must be ipv4 or ipv6');
54
+ }
55
+ return family === 'ipv4' ? '127.0.0.1' : 'fe80::1';
56
+ }
57
+ //
58
+ // ### function address (name, family)
59
+ // #### @name {string|'public'|'private'} **Optional** Name or security
60
+ // of the network interface.
61
+ // #### @family {ipv4|ipv6} **Optional** IP family of the address (defaults
62
+ // to ipv4).
63
+ //
64
+ // Returns the address for the network interface on the current system with
65
+ // the specified `name`:
66
+ // * String: First `family` address of the interface.
67
+ // If not found see `undefined`.
68
+ // * 'public': the first public ip address of family.
69
+ // * 'private': the first private ip address of family.
70
+ // * undefined: First address with `ipv4` or loopback address `127.0.0.1`.
71
+ //
72
+ ip.address = function (name, family) {
73
+ var interfaces = os.networkInterfaces();
74
+ var all;
75
+ //
76
+ // Default to `ipv4`
77
+ //
78
+ family = _normalizeFamily(family);
79
+ //
80
+ // If a specific network interface has been named,
81
+ // return the address.
82
+ //
83
+ if (name && name !== 'private' && name !== 'public') {
84
+ var res = interfaces[name].filter(function (details) {
85
+ var itemFamily = _resolveFamily(details.family);
86
+ return itemFamily === family;
87
+ });
88
+ if (res.length === 0)
89
+ return undefined;
90
+ return res[0].address;
91
+ }
92
+ var all = Object.keys(interfaces).map(function (nic) {
93
+ //
94
+ // Note: name will only be `public` or `private`
95
+ // when this is called.
96
+ //
97
+ var addresses = interfaces[nic].filter(function (details) {
98
+ details.family = _resolveFamily(details.family);
99
+ if (details.family !== family || isLoopback(details.address)) {
100
+ return false;
101
+ }
102
+ else if (!name) {
103
+ return true;
104
+ }
105
+ return name === 'public' ? isPrivate(details.address) :
106
+ isPublic(details.address);
107
+ });
108
+ return addresses.length ? addresses[0].address : undefined;
109
+ }).filter(Boolean);
110
+ return !all.length ? loopback(family) : all[0];
111
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio",
3
- "version": "10.18.2-rc.0",
3
+ "version": "10.18.3-rc.0",
4
4
  "description": "Split SDK",
5
5
  "files": [
6
6
  "README.md",
@@ -32,7 +32,7 @@
32
32
  "node": ">=6"
33
33
  },
34
34
  "dependencies": {
35
- "@splitsoftware/splitio-commons": "1.3.1",
35
+ "@splitsoftware/splitio-commons": "1.3.2-rc.5",
36
36
  "@types/google.analytics": "0.0.40",
37
37
  "@types/ioredis": "^4.28.0",
38
38
  "ioredis": "^4.28.0",
@@ -2,11 +2,13 @@ import { EventEmitter } from './EventEmitter';
2
2
  import { getFetch } from '../platform/getFetch/browser';
3
3
  import { getEventSource } from '../platform/getEventSource/browser';
4
4
  import { BrowserSignalListener } from '@splitsoftware/splitio-commons/src/listeners/browser';
5
+ import { now } from '@splitsoftware/splitio-commons/src/utils/timeTracker/now/browser';
5
6
 
6
7
  export const platform = {
7
8
  getFetch,
8
9
  getEventSource,
9
- EventEmitter
10
+ EventEmitter,
11
+ now
10
12
  };
11
13
 
12
14
  export const SignalListener = BrowserSignalListener;
@@ -3,12 +3,14 @@ import { getFetch } from '../platform/getFetch/node';
3
3
  import { getEventSource } from '../platform/getEventSource/node';
4
4
  import { getOptions } from '../platform/request/options/node';
5
5
  import { NodeSignalListener } from '@splitsoftware/splitio-commons/src/listeners/node';
6
+ import { now } from '@splitsoftware/splitio-commons/src/utils/timeTracker/now/node';
6
7
 
7
8
  export const platform = {
8
9
  getOptions,
9
10
  getFetch,
10
11
  getEventSource,
11
- EventEmitter
12
+ EventEmitter,
13
+ now
12
14
  };
13
15
 
14
16
  export const SignalListener = NodeSignalListener;
@@ -16,8 +16,7 @@ export const defaults = {
16
16
  eventsFirstPushWindow: 0
17
17
  },
18
18
  scheduler: {
19
- featuresRefreshRate: 5,
20
- impressionsRefreshRate: 300
19
+ featuresRefreshRate: 5
21
20
  },
22
21
  features: '.split',
23
22
 
@@ -1 +1 @@
1
- export const packageVersion = '10.18.2-rc.0';
1
+ export const packageVersion = '10.18.3-rc.0';
@@ -1,5 +1,5 @@
1
1
  import osFunction from 'os';
2
- import ipFunction from './ip';
2
+ import ipFunction from '../../utils/ip';
3
3
 
4
4
  import { UNKNOWN, NA, CONSUMER_MODE } from '@splitsoftware/splitio-commons/src/utils/constants';
5
5
 
@@ -0,0 +1,126 @@
1
+ /* eslint-disable no-redeclare */
2
+ /*
3
+ Trimmed version of "ip" package (https://www.npmjs.com/package/ip) that fixes an error when running in Node v18.
4
+
5
+ This software is licensed under the MIT License.
6
+
7
+ Copyright Fedor Indutny, 2012.
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
+ */
15
+ 'use strict';
16
+
17
+ var ip = exports;
18
+ var os = require('os');
19
+
20
+ function _resolveFamily(family) {
21
+ return typeof family === 'number' ? 'ipv' + family : family.toLowerCase();
22
+ }
23
+
24
+ function _normalizeFamily(family) {
25
+ return family ? _resolveFamily(family) : 'ipv4';
26
+ }
27
+
28
+ function isPrivate(addr) {
29
+ return /^(::f{4}:)?10\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i
30
+ .test(addr) ||
31
+ /^(::f{4}:)?192\.168\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
32
+ /^(::f{4}:)?172\.(1[6-9]|2\d|30|31)\.([0-9]{1,3})\.([0-9]{1,3})$/i
33
+ .test(addr) ||
34
+ /^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
35
+ /^(::f{4}:)?169\.254\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(addr) ||
36
+ /^f[cd][0-9a-f]{2}:/i.test(addr) ||
37
+ /^fe80:/i.test(addr) ||
38
+ /^::1$/.test(addr) ||
39
+ /^::$/.test(addr);
40
+ }
41
+
42
+ function isPublic(addr) {
43
+ return !isPrivate(addr);
44
+ }
45
+
46
+ function isLoopback(addr) {
47
+ return /^(::f{4}:)?127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/
48
+ .test(addr) ||
49
+ /^fe80::1$/.test(addr) ||
50
+ /^::1$/.test(addr) ||
51
+ /^::$/.test(addr);
52
+ }
53
+
54
+ function loopback(family) {
55
+ //
56
+ // Default to `ipv4`
57
+ //
58
+ family = _normalizeFamily(family);
59
+
60
+ if (family !== 'ipv4' && family !== 'ipv6') {
61
+ throw new Error('family must be ipv4 or ipv6');
62
+ }
63
+
64
+ return family === 'ipv4' ? '127.0.0.1' : 'fe80::1';
65
+ }
66
+
67
+ //
68
+ // ### function address (name, family)
69
+ // #### @name {string|'public'|'private'} **Optional** Name or security
70
+ // of the network interface.
71
+ // #### @family {ipv4|ipv6} **Optional** IP family of the address (defaults
72
+ // to ipv4).
73
+ //
74
+ // Returns the address for the network interface on the current system with
75
+ // the specified `name`:
76
+ // * String: First `family` address of the interface.
77
+ // If not found see `undefined`.
78
+ // * 'public': the first public ip address of family.
79
+ // * 'private': the first private ip address of family.
80
+ // * undefined: First address with `ipv4` or loopback address `127.0.0.1`.
81
+ //
82
+ ip.address = function (name, family) {
83
+ var interfaces = os.networkInterfaces();
84
+ var all;
85
+
86
+ //
87
+ // Default to `ipv4`
88
+ //
89
+ family = _normalizeFamily(family);
90
+
91
+ //
92
+ // If a specific network interface has been named,
93
+ // return the address.
94
+ //
95
+ if (name && name !== 'private' && name !== 'public') {
96
+ var res = interfaces[name].filter(function (details) {
97
+ var itemFamily = _resolveFamily(details.family);
98
+ return itemFamily === family;
99
+ });
100
+ if (res.length === 0)
101
+ return undefined;
102
+ return res[0].address;
103
+ }
104
+
105
+ var all = Object.keys(interfaces).map(function (nic) {
106
+ //
107
+ // Note: name will only be `public` or `private`
108
+ // when this is called.
109
+ //
110
+ var addresses = interfaces[nic].filter(function (details) {
111
+ details.family = _resolveFamily(details.family);
112
+ if (details.family !== family || isLoopback(details.address)) {
113
+ return false;
114
+ } else if (!name) {
115
+ return true;
116
+ }
117
+
118
+ return name === 'public' ? isPrivate(details.address) :
119
+ isPublic(details.address);
120
+ });
121
+
122
+ return addresses.length ? addresses[0].address : undefined;
123
+ }).filter(Boolean);
124
+
125
+ return !all.length ? loopback(family) : all[0];
126
+ };
@@ -71,7 +71,11 @@ interface ISettings {
71
71
  featuresRefreshRate: number,
72
72
  impressionsRefreshRate: number,
73
73
  impressionsQueueSize: number,
74
- metricsRefreshRate: number,
74
+ /**
75
+ * @deprecated
76
+ */
77
+ metricsRefreshRate?: number,
78
+ telemetryRefreshRate: number,
75
79
  segmentsRefreshRate: number,
76
80
  offlineRefreshRate: number,
77
81
  eventsPushRate: number,
@@ -93,7 +97,8 @@ interface ISettings {
93
97
  events: string,
94
98
  sdk: string,
95
99
  auth: string,
96
- streaming: string
100
+ streaming: string,
101
+ telemetry: string
97
102
  },
98
103
  readonly debug: boolean | LogLevel,
99
104
  readonly version: string,
@@ -297,8 +302,15 @@ interface INodeBasicSettings extends ISharedSettings {
297
302
  * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
298
303
  * @property {number} metricsRefreshRate
299
304
  * @default 120
305
+ * @deprecated This parameter is ignored now. Use `telemetryRefreshRate` instead.
300
306
  */
301
307
  metricsRefreshRate?: number,
308
+ /**
309
+ * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
310
+ * @property {number} telemetryRefreshRate
311
+ * @default 3600
312
+ */
313
+ telemetryRefreshRate?: number,
302
314
  /**
303
315
  * The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds.
304
316
  * @property {number} segmentsRefreshRate
@@ -843,7 +855,13 @@ declare namespace SplitIO {
843
855
  * @property {string} streaming
844
856
  * @default 'https://streaming.split.io'
845
857
  */
846
- streaming?: string
858
+ streaming?: string,
859
+ /**
860
+ * String property to override the base URL where the SDK will post telemetry data.
861
+ * @property {string} telemetry
862
+ * @default 'https://telemetry.split.io/api'
863
+ */
864
+ telemetry?: string
847
865
  };
848
866
 
849
867
  /**
@@ -947,8 +965,15 @@ declare namespace SplitIO {
947
965
  * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
948
966
  * @property {number} metricsRefreshRate
949
967
  * @default 120
968
+ * @deprecated This parameter is ignored now. Use `telemetryRefreshRate` instead.
950
969
  */
951
970
  metricsRefreshRate?: number,
971
+ /**
972
+ * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
973
+ * @property {number} telemetryRefreshRate
974
+ * @default 3600
975
+ */
976
+ telemetryRefreshRate?: number,
952
977
  /**
953
978
  * The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds.
954
979
  * @property {number} segmentsRefreshRate