@forge/feature-flags-node 2.1.9-next.0-experimental-f57b265 → 2.1.9-next.0-experimental-2682d7a
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/CHANGELOG.md +2 -2
- package/out/index.d.ts.map +1 -1
- package/out/index.js +12 -8
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @forge/feature-flags-node
|
|
2
2
|
|
|
3
|
-
## 2.1.9-next.0-experimental-
|
|
3
|
+
## 2.1.9-next.0-experimental-2682d7a
|
|
4
4
|
|
|
5
5
|
### Major Changes
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
### Patch Changes
|
|
10
10
|
|
|
11
|
-
- @forge/api@7.0.1-next.0-experimental-
|
|
11
|
+
- @forge/api@7.0.1-next.0-experimental-2682d7a
|
|
12
12
|
|
|
13
13
|
## 2.1.9-next.0
|
|
14
14
|
|
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,sBAAsB,EAAW,MAAM,SAAS,CAAC;AAM7E,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,KAAK,CAAuC;IACpD,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAyB;IAC5D,OAAO,CAAC,YAAY,CAAC,CAAiB;IACtC,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2C;IACnE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAGnB;IAKI,UAAU,CAAC,MAAM,GAAE,sBAAuC,GAAG,OAAO,CAAC,IAAI,CAAC;YAyBlE,mBAAmB;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,sBAAsB,EAAW,MAAM,SAAS,CAAC;AAM7E,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,KAAK,CAAuC;IACpD,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAyB;IAC5D,OAAO,CAAC,YAAY,CAAC,CAAiB;IACtC,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2C;IACnE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAGnB;IAKI,UAAU,CAAC,MAAM,GAAE,sBAAuC,GAAG,OAAO,CAAC,IAAI,CAAC;YAyBlE,mBAAmB;IA6CjC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,UAAQ,GAAG,OAAO;IAgBpE,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAQhD,aAAa,IAAI,MAAM,EAAE;IAQnB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ9B,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,iBAAiB;IASzB,aAAa,IAAI,OAAO;IAOxB,gBAAgB,IAAI,MAAM;IAQ1B,QAAQ,IAAI,IAAI;CAMjB"}
|
package/out/index.js
CHANGED
|
@@ -23,7 +23,7 @@ class ForgeFeatureFlags {
|
|
|
23
23
|
await this.fetchConfigurations();
|
|
24
24
|
this.initialized = true;
|
|
25
25
|
this.metrics?.counter('forge.feature-flags.initialize.success', this.tags).incr();
|
|
26
|
-
if (this.pollingIntervalMs) {
|
|
26
|
+
if (this.pollingIntervalMs && (0, api_1.__getRuntime)()?.lambdaContext?.getRemainingTimeInMillis?.() > 60000) {
|
|
27
27
|
this.startPolling();
|
|
28
28
|
}
|
|
29
29
|
this.evaluator = new evaluator_1.Evaluator({ environment: config.environment });
|
|
@@ -41,23 +41,21 @@ class ForgeFeatureFlags {
|
|
|
41
41
|
try {
|
|
42
42
|
const runtime = (0, api_1.__getRuntime)();
|
|
43
43
|
if (runtime?.proxy?.tokenExpiry && runtime?.proxy?.tokenExpiry * 1000 < Date.now()) {
|
|
44
|
-
this.metrics
|
|
45
|
-
?.counter('forge.feature-flags.data-adapter.fetchFromAtlassianServers.tokenExpired', this.tags)
|
|
46
|
-
.incr();
|
|
44
|
+
this.metrics?.counter('forge.feature-flags.fetchFromAtlassianServers.tokenExpired', this.tags).incr();
|
|
47
45
|
throw new Error('Cannot fetch feature flags: authentication token has expired');
|
|
48
46
|
}
|
|
49
47
|
const remainingTime = runtime?.lambdaContext?.getRemainingTimeInMillis?.();
|
|
50
48
|
if (remainingTime !== undefined && remainingTime < 5000) {
|
|
51
|
-
this.metrics
|
|
52
|
-
?.counter('forge.feature-flags.data-adapter.fetchFromAtlassianServers.remainingTimeComplete', this.tags)
|
|
53
|
-
.incr();
|
|
49
|
+
this.metrics?.counter('forge.feature-flags.fetchFromAtlassianServers.remainingTimeComplete', this.tags).incr();
|
|
54
50
|
throw new Error('Cannot fetch feature flags: insufficient remaining execution time');
|
|
55
51
|
}
|
|
56
52
|
const response = await (0, api_1.__fetchProduct)({ provider: 'app', remote: 'feature-flags', type: 'feature-flags' })('/', {
|
|
57
53
|
method: 'GET',
|
|
58
54
|
redirect: 'follow',
|
|
59
55
|
headers: {
|
|
60
|
-
'Content-Type': 'application/json'
|
|
56
|
+
'Content-Type': 'application/json',
|
|
57
|
+
'x-b3-traceid': runtime?.tracing?.traceId,
|
|
58
|
+
'x-b3-spanid': runtime?.tracing?.spanId
|
|
61
59
|
}
|
|
62
60
|
});
|
|
63
61
|
if (!response.ok) {
|
|
@@ -74,6 +72,7 @@ class ForgeFeatureFlags {
|
|
|
74
72
|
}
|
|
75
73
|
checkFlag(user, flagId, defaultValue = false) {
|
|
76
74
|
this.ensureInitialized();
|
|
75
|
+
this.metrics?.counter('forge.feature-flags.checkFlag', this.tags).incr();
|
|
77
76
|
const flag = this.flags.get(flagId);
|
|
78
77
|
if (!flag) {
|
|
79
78
|
return defaultValue;
|
|
@@ -82,12 +81,15 @@ class ForgeFeatureFlags {
|
|
|
82
81
|
return result.value;
|
|
83
82
|
}
|
|
84
83
|
getFlag(flagId) {
|
|
84
|
+
this.metrics?.counter('forge.feature-flags.getFlag', this.tags).incr();
|
|
85
85
|
return this.flags.get(flagId);
|
|
86
86
|
}
|
|
87
87
|
getAllFlagIds() {
|
|
88
|
+
this.metrics?.counter('forge.feature-flags.getAllFlagIds', this.tags).incr();
|
|
88
89
|
return Array.from(this.flags.keys());
|
|
89
90
|
}
|
|
90
91
|
async refresh() {
|
|
92
|
+
this.metrics?.counter('forge.feature-flags.refresh', this.tags).incr();
|
|
91
93
|
await this.fetchConfigurations();
|
|
92
94
|
}
|
|
93
95
|
startPolling() {
|
|
@@ -116,12 +118,14 @@ class ForgeFeatureFlags {
|
|
|
116
118
|
return this.initialized;
|
|
117
119
|
}
|
|
118
120
|
getLastFetchTime() {
|
|
121
|
+
this.metrics?.counter('forge.feature-flags.getLastFetchTime', this.tags).incr();
|
|
119
122
|
return this.lastFetchTime;
|
|
120
123
|
}
|
|
121
124
|
shutdown() {
|
|
122
125
|
this.stopPolling();
|
|
123
126
|
this.flags.clear();
|
|
124
127
|
this.initialized = false;
|
|
128
|
+
this.metrics?.counter('forge.feature-flags.shutdown', this.tags).incr();
|
|
125
129
|
}
|
|
126
130
|
}
|
|
127
131
|
exports.ForgeFeatureFlags = ForgeFeatureFlags;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forge/feature-flags-node",
|
|
3
|
-
"version": "2.1.9-next.0-experimental-
|
|
3
|
+
"version": "2.1.9-next.0-experimental-2682d7a",
|
|
4
4
|
"description": "Feature Flags Node SDK for Atlassian Forge apps running on Node Runtime",
|
|
5
5
|
"author": "Atlassian",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@types/node": "20.19.1"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@forge/api": "^7.0.1-next.0-experimental-
|
|
18
|
+
"@forge/api": "^7.0.1-next.0-experimental-2682d7a"
|
|
19
19
|
},
|
|
20
20
|
"publishConfig": {
|
|
21
21
|
"registry": "https://packages.atlassian.com/api/npm/npm-public/"
|