@forge/feature-flags-node 2.1.1-next.0-experimental-04e7c02 → 2.1.1-next.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/CHANGELOG.md CHANGED
@@ -1,11 +1,10 @@
1
1
  # @forge/feature-flags-node
2
2
 
3
- ## 2.1.1-next.0-experimental-04e7c02
3
+ ## 2.1.1-next.1
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - Updated dependencies [94243f1]
8
- - @forge/api@6.1.5-next.1-experimental-04e7c02
7
+ - 65c16a6: Update the feature flag SDK example in the README.md
9
8
 
10
9
  ## 2.1.1-next.0
11
10
 
package/README.md CHANGED
@@ -17,7 +17,36 @@ import { getAppContext } from "@forge/api";
17
17
  import { ForgeFeatureFlags } from "@forge/feature-flags-node";
18
18
 
19
19
  export const handler = async (payload, context) => {
20
- const { environmentType } = getAppContext();
20
+ // Get app context values
21
+ const {
22
+ appVersion,
23
+ license: appLicense,
24
+ environmentType,
25
+ } = getAppContext();
26
+
27
+ // Determine license value based on trialEndDate and isActive
28
+ let licenseValue = "INACTIVE";
29
+ const trialEndDate = appLicense?.trialEndDate;
30
+ const isActive = appLicense?.isActive;
31
+
32
+ if (trialEndDate) {
33
+ const now = new Date();
34
+ const trialEnd = new Date(trialEndDate);
35
+ if (trialEnd > now) {
36
+ licenseValue = "TRIAL";
37
+ } else if (isActive) {
38
+ licenseValue = "ACTIVE";
39
+ }
40
+ } else if (isActive) {
41
+ licenseValue = "ACTIVE";
42
+ }
43
+
44
+ // Determine capabilitySet value (enum)
45
+ let capabilitySetValue = "capabilityStandard";
46
+ if (appLicense?.capabilitySet === "capabilityAdvanced") {
47
+ capabilitySetValue = "capabilityAdvanced";
48
+ }
49
+
21
50
 
22
51
  // Initialize the feature flags SDK
23
52
  const featureFlags = new ForgeFeatureFlags();
@@ -25,13 +54,17 @@ export const handler = async (payload, context) => {
25
54
  environment: environmentType?.toLowerCase() || "development"
26
55
  });
27
56
 
28
- // Define a user
57
+ // Define a user with all possible attributes that will be used in the feature flag rules
29
58
  const user = {
30
59
  identifiers:{
31
60
  accountId: context?.principal?.accountId,
32
61
  },
33
62
  attributes: {
34
- license: context?.license?.isActive ? "active" : "inactive"
63
+ installContext: context?.installContext,
64
+ accountId: context?.principal?.accountId,
65
+ appVersion: appVersion,
66
+ license: licenseValue, // "ACTIVE", "INACTIVE", "TRIAL"
67
+ capabilitySet: capabilitySetValue // "capabilityAdvanced", "capabilityStandard"
35
68
  }
36
69
  };
37
70
 
@@ -143,7 +176,7 @@ Checks if the service is initialized.
143
176
  ### User Interface
144
177
 
145
178
  ```typescript
146
- interface ForgeUser {
179
+ interface FeatureFlagUser {
147
180
  custom?: Record<string, string | number>;
148
181
  attributes?: {
149
182
  installContext?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/feature-flags-node",
3
- "version": "2.1.1-next.0-experimental-04e7c02",
3
+ "version": "2.1.1-next.1",
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": "^6.1.5-next.1-experimental-04e7c02",
18
+ "@forge/api": "^6.1.5-next.0",
19
19
  "statsig-node": "^6.4.3"
20
20
  },
21
21
  "publishConfig": {