flagsmith-nodejs 2.0.3 → 2.0.4
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/build/sdk/analytics.d.ts +1 -1
- package/build/sdk/analytics.js +2 -2
- package/build/sdk/models.js +1 -1
- package/example/package-lock.json +24 -43
- package/package.json +1 -1
- package/sdk/analytics.ts +2 -2
- package/sdk/models.ts +1 -1
- package/tests/sdk/analytics.test.ts +10 -10
- package/.idea/flagsmith-nodejs-client.iml +0 -12
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
package/build/sdk/analytics.d.ts
CHANGED
package/build/sdk/analytics.js
CHANGED
|
@@ -91,8 +91,8 @@ var AnalyticsProcessor = /** @class */ (function () {
|
|
|
91
91
|
});
|
|
92
92
|
});
|
|
93
93
|
};
|
|
94
|
-
AnalyticsProcessor.prototype.trackFeature = function (
|
|
95
|
-
this.analyticsData[
|
|
94
|
+
AnalyticsProcessor.prototype.trackFeature = function (featureName) {
|
|
95
|
+
this.analyticsData[featureName] = (this.analyticsData[featureName] || 0) + 1;
|
|
96
96
|
if (Date.now() - this.lastFlushed > ANALYTICS_TIMER * 1000) {
|
|
97
97
|
this.flush();
|
|
98
98
|
}
|
package/build/sdk/models.js
CHANGED
|
@@ -134,7 +134,7 @@ var Flags = /** @class */ (function () {
|
|
|
134
134
|
return { enabled: false, isDefault: true, value: undefined };
|
|
135
135
|
}
|
|
136
136
|
if (this.analyticsProcessor && flag.featureId) {
|
|
137
|
-
this.analyticsProcessor.trackFeature(flag.
|
|
137
|
+
this.analyticsProcessor.trackFeature(flag.featureName);
|
|
138
138
|
}
|
|
139
139
|
return flag;
|
|
140
140
|
};
|
|
@@ -457,13 +457,14 @@
|
|
|
457
457
|
"integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA=="
|
|
458
458
|
},
|
|
459
459
|
"node_modules/handlebars": {
|
|
460
|
-
"version": "4.7.
|
|
461
|
-
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.
|
|
462
|
-
"integrity": "sha512-
|
|
460
|
+
"version": "4.7.7",
|
|
461
|
+
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz",
|
|
462
|
+
"integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==",
|
|
463
463
|
"dependencies": {
|
|
464
|
+
"minimist": "^1.2.5",
|
|
464
465
|
"neo-async": "^2.6.0",
|
|
465
|
-
"
|
|
466
|
-
"
|
|
466
|
+
"source-map": "^0.6.1",
|
|
467
|
+
"wordwrap": "^1.0.0"
|
|
467
468
|
},
|
|
468
469
|
"bin": {
|
|
469
470
|
"handlebars": "bin/handlebars"
|
|
@@ -618,9 +619,9 @@
|
|
|
618
619
|
}
|
|
619
620
|
},
|
|
620
621
|
"node_modules/minimist": {
|
|
621
|
-
"version": "
|
|
622
|
-
"resolved": "https://registry.npmjs.org/minimist/-/minimist-
|
|
623
|
-
"integrity": "
|
|
622
|
+
"version": "1.2.6",
|
|
623
|
+
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
|
|
624
|
+
"integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q=="
|
|
624
625
|
},
|
|
625
626
|
"node_modules/moment": {
|
|
626
627
|
"version": "2.23.0",
|
|
@@ -727,15 +728,6 @@
|
|
|
727
728
|
"wrappy": "1"
|
|
728
729
|
}
|
|
729
730
|
},
|
|
730
|
-
"node_modules/optimist": {
|
|
731
|
-
"version": "0.6.1",
|
|
732
|
-
"resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz",
|
|
733
|
-
"integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=",
|
|
734
|
-
"dependencies": {
|
|
735
|
-
"minimist": "~0.0.1",
|
|
736
|
-
"wordwrap": "~0.0.2"
|
|
737
|
-
}
|
|
738
|
-
},
|
|
739
731
|
"node_modules/parseurl": {
|
|
740
732
|
"version": "1.3.2",
|
|
741
733
|
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz",
|
|
@@ -985,12 +977,9 @@
|
|
|
985
977
|
}
|
|
986
978
|
},
|
|
987
979
|
"node_modules/wordwrap": {
|
|
988
|
-
"version": "0.0
|
|
989
|
-
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.
|
|
990
|
-
"integrity": "
|
|
991
|
-
"engines": {
|
|
992
|
-
"node": ">=0.4.0"
|
|
993
|
-
}
|
|
980
|
+
"version": "1.0.0",
|
|
981
|
+
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
|
|
982
|
+
"integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q=="
|
|
994
983
|
},
|
|
995
984
|
"node_modules/wrappy": {
|
|
996
985
|
"version": "1.0.2",
|
|
@@ -1356,14 +1345,15 @@
|
|
|
1356
1345
|
"integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA=="
|
|
1357
1346
|
},
|
|
1358
1347
|
"handlebars": {
|
|
1359
|
-
"version": "4.7.
|
|
1360
|
-
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.
|
|
1361
|
-
"integrity": "sha512-
|
|
1348
|
+
"version": "4.7.7",
|
|
1349
|
+
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz",
|
|
1350
|
+
"integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==",
|
|
1362
1351
|
"requires": {
|
|
1352
|
+
"minimist": "^1.2.5",
|
|
1363
1353
|
"neo-async": "^2.6.0",
|
|
1364
|
-
"optimist": "^0.6.1",
|
|
1365
1354
|
"source-map": "^0.6.1",
|
|
1366
|
-
"uglify-js": "^3.1.4"
|
|
1355
|
+
"uglify-js": "^3.1.4",
|
|
1356
|
+
"wordwrap": "^1.0.0"
|
|
1367
1357
|
}
|
|
1368
1358
|
},
|
|
1369
1359
|
"has-symbols": {
|
|
@@ -1479,9 +1469,9 @@
|
|
|
1479
1469
|
}
|
|
1480
1470
|
},
|
|
1481
1471
|
"minimist": {
|
|
1482
|
-
"version": "
|
|
1483
|
-
"resolved": "https://registry.npmjs.org/minimist/-/minimist-
|
|
1484
|
-
"integrity": "
|
|
1472
|
+
"version": "1.2.6",
|
|
1473
|
+
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
|
|
1474
|
+
"integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q=="
|
|
1485
1475
|
},
|
|
1486
1476
|
"moment": {
|
|
1487
1477
|
"version": "2.23.0",
|
|
@@ -1556,15 +1546,6 @@
|
|
|
1556
1546
|
"wrappy": "1"
|
|
1557
1547
|
}
|
|
1558
1548
|
},
|
|
1559
|
-
"optimist": {
|
|
1560
|
-
"version": "0.6.1",
|
|
1561
|
-
"resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz",
|
|
1562
|
-
"integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=",
|
|
1563
|
-
"requires": {
|
|
1564
|
-
"minimist": "~0.0.1",
|
|
1565
|
-
"wordwrap": "~0.0.2"
|
|
1566
|
-
}
|
|
1567
|
-
},
|
|
1568
1549
|
"parseurl": {
|
|
1569
1550
|
"version": "1.3.2",
|
|
1570
1551
|
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz",
|
|
@@ -1762,9 +1743,9 @@
|
|
|
1762
1743
|
}
|
|
1763
1744
|
},
|
|
1764
1745
|
"wordwrap": {
|
|
1765
|
-
"version": "0.0
|
|
1766
|
-
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.
|
|
1767
|
-
"integrity": "
|
|
1746
|
+
"version": "1.0.0",
|
|
1747
|
+
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
|
|
1748
|
+
"integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q=="
|
|
1768
1749
|
},
|
|
1769
1750
|
"wrappy": {
|
|
1770
1751
|
"version": "1.0.2",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flagsmith-nodejs",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "Flagsmith lets you manage features flags and remote config across web, mobile and server side applications. Deliver true Continuous Integration. Get builds out faster. Control who has access to new features.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"repository": {
|
package/sdk/analytics.ts
CHANGED
|
@@ -49,8 +49,8 @@ export class AnalyticsProcessor {
|
|
|
49
49
|
this.lastFlushed = Date.now();
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
trackFeature(
|
|
53
|
-
this.analyticsData[
|
|
52
|
+
trackFeature(featureName: string) {
|
|
53
|
+
this.analyticsData[featureName] = (this.analyticsData[featureName] || 0) + 1;
|
|
54
54
|
if (Date.now() - this.lastFlushed > ANALYTICS_TIMER * 1000) {
|
|
55
55
|
this.flush();
|
|
56
56
|
}
|
package/sdk/models.ts
CHANGED
|
@@ -8,28 +8,28 @@ afterEach(() => {
|
|
|
8
8
|
|
|
9
9
|
test('test_analytics_processor_track_feature_updates_analytics_data', () => {
|
|
10
10
|
const aP = analyticsProcessor();
|
|
11
|
-
aP.trackFeature(
|
|
12
|
-
expect(aP.analyticsData[
|
|
11
|
+
aP.trackFeature("myFeature");
|
|
12
|
+
expect(aP.analyticsData["myFeature"]).toBe(1);
|
|
13
13
|
|
|
14
|
-
aP.trackFeature(
|
|
15
|
-
expect(aP.analyticsData[
|
|
14
|
+
aP.trackFeature("myFeature");
|
|
15
|
+
expect(aP.analyticsData["myFeature"]).toBe(2);
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
test('test_analytics_processor_flush_clears_analytics_data', async () => {
|
|
19
19
|
const aP = analyticsProcessor();
|
|
20
|
-
aP.trackFeature(
|
|
20
|
+
aP.trackFeature("myFeature");
|
|
21
21
|
await aP.flush();
|
|
22
22
|
expect(aP.analyticsData).toStrictEqual({});
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
test('test_analytics_processor_flush_post_request_data_match_ananlytics_data', async () => {
|
|
26
26
|
const aP = analyticsProcessor();
|
|
27
|
-
aP.trackFeature(
|
|
28
|
-
aP.trackFeature(
|
|
27
|
+
aP.trackFeature("myFeature1");
|
|
28
|
+
aP.trackFeature("myFeature2");
|
|
29
29
|
await aP.flush();
|
|
30
30
|
expect(fetch).toHaveBeenCalledTimes(1);
|
|
31
31
|
expect(fetch).toHaveBeenCalledWith('http://testUrlanalytics/flags/', {
|
|
32
|
-
body: '{"
|
|
32
|
+
body: '{"myFeature1":1,"myFeature2":1}',
|
|
33
33
|
headers: { 'Content-Type': 'application/json', 'X-Environment-Key': 'test-key' },
|
|
34
34
|
method: 'POST',
|
|
35
35
|
timeout: 3
|
|
@@ -39,9 +39,9 @@ test('test_analytics_processor_flush_post_request_data_match_ananlytics_data', a
|
|
|
39
39
|
jest.useFakeTimers()
|
|
40
40
|
test('test_analytics_processor_flush_post_request_data_match_ananlytics_data_test', async () => {
|
|
41
41
|
const aP = analyticsProcessor();
|
|
42
|
-
aP.trackFeature(
|
|
42
|
+
aP.trackFeature("myFeature1");
|
|
43
43
|
setTimeout(() => {
|
|
44
|
-
aP.trackFeature(
|
|
44
|
+
aP.trackFeature("myFeature2");
|
|
45
45
|
expect(fetch).toHaveBeenCalledTimes(1);
|
|
46
46
|
}, 15000);
|
|
47
47
|
jest.runOnlyPendingTimers();
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="WEB_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager">
|
|
4
|
-
<content url="file://$MODULE_DIR$">
|
|
5
|
-
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
6
|
-
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
7
|
-
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
-
</content>
|
|
9
|
-
<orderEntry type="inheritedJdk" />
|
|
10
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
-
</component>
|
|
12
|
-
</module>
|
package/.idea/modules.xml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="ProjectModuleManager">
|
|
4
|
-
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/flagsmith-nodejs-client.iml" filepath="$PROJECT_DIR$/.idea/flagsmith-nodejs-client.iml" />
|
|
6
|
-
</modules>
|
|
7
|
-
</component>
|
|
8
|
-
</project>
|