This is page 7 of 7. Use http://codebase.md/bucketco/docs/integrations/.gitbook/assets/CleanShot%202025-10-09%20at%2010%E2%80%[email protected]?lines=true&page={x} to view the full context. # Directory Structure ``` ├── .gitbook │ ├── assets │ │ ├── 03642c5-dwFrame_201 (1).png │ │ ├── 03642c5-dwFrame_201.png │ │ ├── 1753259671871 (1).jpeg │ │ ├── 1a0b50d-image.png │ │ ├── 1a439d9-image.png │ │ ├── 2506596-Customized_Widgets.png │ │ ├── 342658e-image.png │ │ ├── 4017197-image.png │ │ ├── 43e55f0-image.png │ │ ├── 4783e3f-image.png │ │ ├── 5b0ce63-image (1).png │ │ ├── 5b0ce63-image.png │ │ ├── 630b5e9-image.png │ │ ├── 8bf8a6e-Frame_201.png │ │ ├── 9efd67c-image.png │ │ ├── aa37226-image.png │ │ ├── Access (1) (1).png │ │ ├── Access (1).png │ │ ├── Access (2).png │ │ ├── Access.png │ │ ├── Adding features to a feature view-min.png │ │ ├── Adopted-min.png │ │ ├── Adoption strategy V2-min.png │ │ ├── Adoption strategy-min.png │ │ ├── Advanced targeting rules V2-min.png │ │ ├── Advanced targeting rules v3-min.png │ │ ├── Advanced targeting rules-min.png │ │ ├── aecc6f2-image.png │ │ ├── amplitude.svg │ │ ├── An example targeting configuration with two rules.-min.png │ │ ├── api.svg │ │ ├── App Settings-min.png │ │ ├── Automated feedback surveys settings v3-min.png │ │ ├── Automated feedback surveys settings-min.png │ │ ├── Automated feedback surveys-min.png │ │ ├── aws-s3.svg │ │ ├── be124cd-dwdwFrame_201 (1).png │ │ ├── be124cd-dwdwFrame_201.png │ │ ├── ccc4f9e-image.png │ │ ├── CleanShot 2024-06-11 at 8 [email protected] │ │ ├── CleanShot 2024-11-22 at 8 [email protected] │ │ ├── CleanShot 2024-11-22 at 8 [email protected] │ │ ├── CleanShot 2024-11-25 at 9 [email protected] │ │ ├── CleanShot 2024-11-25 at 9 [email protected] │ │ ├── CleanShot 2024-11-25 at 9 [email protected] │ │ ├── CleanShot 2024-11-27 at 10 [email protected] │ │ ├── CleanShot 2024-11-27 at 10 [email protected] │ │ ├── CleanShot 2024-11-27 at 10 [email protected] │ │ ├── CleanShot 2024-11-27 at 10 [email protected] │ │ ├── CleanShot 2025-01-07 at 1 [email protected] │ │ ├── CleanShot 2025-01-07 at 1 [email protected] │ │ ├── CleanShot 2025-01-07 at 1 [email protected] │ │ ├── CleanShot 2025-01-07 at 12 [email protected] │ │ ├── CleanShot 2025-01-07 at 12 .39.12@2x (1).png │ │ ├── CleanShot 2025-01-07 at 12 [email protected] │ │ ├── CleanShot 2025-01-09 at 10 [email protected] │ │ ├── CleanShot 2025-01-09 at 11 .11.54@2x (1).png │ │ ├── CleanShot 2025-01-09 at 11 [email protected] │ │ ├── CleanShot 2025-01-09 at 9 [email protected] │ │ ├── CleanShot 2025-01-23 at 1 [email protected] │ │ ├── CleanShot 2025-01-23 at 1 [email protected] │ │ ├── CleanShot 2025-01-23 at 1 [email protected] │ │ ├── CleanShot 2025-01-23 at 2 [email protected] │ │ ├── CleanShot 2025-05-09 at 1 [email protected] │ │ ├── CleanShot 2025-10-09 at 10 [email protected] │ │ ├── Companies Tab-min.png │ │ ├── Companies-min.png │ │ ├── company example v2-min (1).png │ │ ├── company example v2-min.png │ │ ├── company example v3-min.png │ │ ├── Company segment filters-min.png │ │ ├── Create a new environment-min.png │ │ ├── Creating and managing apps-min.png │ │ ├── cursor-mcp-demo_h264.mp4 │ │ ├── datadog.svg │ │ ├── Debugger-min (1).png │ │ ├── Debugger-min (2).png │ │ ├── Debugger-min.png │ │ ├── Enabling Feedback Surveys-min.png │ │ ├── Environments Page V2-min.png │ │ ├── Environments Switcher-min.png │ │ ├── Environments-min.png │ │ ├── Evaluate Feature.png │ │ ├── example 1 (1).png │ │ ├── example 1.png │ │ ├── example 2 (1).png │ │ ├── example 2.png │ │ ├── ezgif-242d06617aea38.gif │ │ ├── Feature Tab-min.png │ │ ├── Feature targeting rules example v2-min.png │ │ ├── Feature targeting rules example V2-min.png │ │ ├── Feature targeting rules example v3-min.png │ │ ├── Feature targeting rules example-min.png │ │ ├── Feature targeting rules UI V2-min.png │ │ ├── Feature targeting rules UI v3-min.png │ │ ├── Feature targeting rules UI-min.png │ │ ├── Feature usage configuration-v2-min.png │ │ ├── Feature view.png │ │ ├── feature-flag-list-rum-event.d9c1c876a34458edc70d1317efaec05b.png.avif │ │ ├── Feature-targeting-rules-v2-min.png │ │ ├── Features Page V2-min (1).png │ │ ├── Features Page V2-min.png │ │ ├── Features Page-min.png │ │ ├── Features-min.png │ │ ├── Feedback Tab V2-min.png │ │ ├── Feedback-min.png │ │ ├── Getting started-min.png │ │ ├── gitbook-logo.svg │ │ ├── github-logo.svg │ │ ├── Global settings - Feature views-min.png │ │ ├── Global settings - Manual Targeting-min.png │ │ ├── Global settings - Release Stages Editing V4-min.png │ │ ├── Global settings - Release Stages-min.png │ │ ├── Goal Form.png │ │ ├── How to use release stages v2-min.png │ │ ├── How to use release stages-min (1).png │ │ ├── How to use release stages-min.png │ │ ├── https___content.gitbook.com_content_pgXAy2Cgsm5pON9oJ06m_blobs_6wGbrQlJPE4JllBuIhla_image (1).png │ │ ├── image (1) (1).png │ │ ├── image (1) (2).png │ │ ├── image (1).png │ │ ├── image (10).png │ │ ├── image (11).png │ │ ├── image (12).png │ │ ├── image (13).png │ │ ├── image (14).png │ │ ├── image (15).png │ │ ├── image (16).png │ │ ├── image (17).png │ │ ├── image (18).png │ │ ├── image (19).png │ │ ├── image (2) (1).png │ │ ├── image (2).png │ │ ├── image (20).png │ │ ├── image (21).png │ │ ├── image (22).png │ │ ├── image (23).png │ │ ├── image (24).png │ │ ├── image (25).png │ │ ├── image (26).png │ │ ├── image (27).png │ │ ├── image (28).png │ │ ├── image (29).png │ │ ├── image (3).png │ │ ├── image (30).png │ │ ├── image (31).png │ │ ├── image (32).png │ │ ├── image (33).png │ │ ├── image (4).png │ │ ├── image (5).png │ │ ├── image (6).png │ │ ├── image (7).png │ │ ├── image (8).png │ │ ├── image (9).png │ │ ├── image.png │ │ ├── Iterate Feature V2.png │ │ ├── LInear mention.mp4 │ │ ├── linear.svg │ │ ├── mcp-remote-min.mp4 │ │ ├── mcp-remote.mp4 │ │ ├── mixpanel.svg │ │ ├── Modifying or deleting an app-min.png │ │ ├── Monitor (1) (1).png │ │ ├── Monitor (1).png │ │ ├── Monitor (2).png │ │ ├── Monitor (3).png │ │ ├── Monitor (4).png │ │ ├── Monitor (5).png │ │ ├── Monitor (6).png │ │ ├── Monitor (7).png │ │ ├── Monitor.png │ │ ├── New feature.png │ │ ├── next-js.svg │ │ ├── node-js.svg │ │ ├── openfeature.svg │ │ ├── posthog.svg │ │ ├── Pre-Release.png │ │ ├── react.svg │ │ ├── Release Goals.png │ │ ├── Release Stage Beta Targeting Rules v3-min.png │ │ ├── Release Stage Beta Targeting Rules V3-min.png │ │ ├── Release Stage Beta Targeting Rules V5-min.png │ │ ├── Release Stage Beta Targeting Rules-min.png │ │ ├── remote config - 3.png │ │ ├── Remote config.png │ │ ├── Rolling back flags-V2.png │ │ ├── Rules in other environments.png │ │ ├── rum-explorer-error-feature-flag-search.7b9f6c046db1de1c71d279c139f1508a.png.avif │ │ ├── rum-explorer-session-feature-flag-search.435802460fd607608ad5155f029da57b.png.avif │ │ ├── Satisfaction feedback-min.png │ │ ├── Satisified-min.png │ │ ├── Save the segment-min.png │ │ ├── Saving New Segment-min.png │ │ ├── Screenshot 2024-08-14 at 19.25.06 (1).png │ │ ├── Screenshot 2024-08-14 at 19.25.06.png │ │ ├── Screenshot 2024-08-15 at 13.57.46.png │ │ ├── Screenshot 2024-10-10 at 14.04.09.png │ │ ├── Screenshot 2024-10-10 at 14.04.34.png │ │ ├── Screenshot 2025-07-10 at 14.04.07.png │ │ ├── Screenshot 2025-07-10 at 14.11.01.png │ │ ├── Screenshot 2025-07-10 at 14.29.20.png │ │ ├── Screenshot 2025-07-15 at 21.31.16.png │ │ ├── Screenshot 2025-07-21 at 20.07.27.png │ │ ├── Screenshot 2025-09-02 at 17.08.25.png │ │ ├── Screenshot 2025-09-02 at 17.10.36 (1).png │ │ ├── Screenshot 2025-09-02 at 17.10.36 (2).png │ │ ├── Screenshot 2025-09-02 at 17.10.36.png │ │ ├── Screenshot 2025-09-02 at 17.11.21 (1).png │ │ ├── Screenshot 2025-09-02 at 17.11.21.png │ │ ├── Screenshot 2025-09-02 at 17.13.15 (1).png │ │ ├── Screenshot 2025-09-02 at 17.13.15.png │ │ ├── Screenshot 2025-09-02 at 17.19.44 (1).png │ │ ├── Screenshot 2025-09-02 at 17.19.44.png │ │ ├── Screenshot 2025-09-09 at 09.32.31.png │ │ ├── Screenshot 2025-09-12 at 11.50.41.png │ │ ├── Screenshot 2025-09-12 at 12.30.38.png │ │ ├── Screenshot 2025-09-12 at 13.14.44.png │ │ ├── Screenshot 2025-09-12 at 13.18.07.png │ │ ├── Screenshot 2025-09-12 at 13.21.25.png │ │ ├── Screenshot 2025-09-12 at 13.25.21.png │ │ ├── Screenshot 2025-09-12 at 14.29.56.png │ │ ├── Screenshot 2025-09-12 at 14.37.52.png │ │ ├── Screenshot 2025-09-12 at 14.58.27.png │ │ ├── Screenshot 2025-09-12 at 15.00.32.png │ │ ├── Screenshot 2025-09-12 at 15.01.32.png │ │ ├── Screenshot 2025-09-12 at 15.03.33.png │ │ ├── Screenshot 2025-09-12 at 15.04.39.png │ │ ├── Screenshot 2025-09-12 at 15.06.50.png │ │ ├── Screenshot 2025-09-12 at 15.13.45.png │ │ ├── Screenshot 2025-09-12 at 15.14.43.png │ │ ├── Screenshot 2025-09-12 at 15.16.42.png │ │ ├── Screenshot 2025-09-12 at 15.18.42.png │ │ ├── Screenshot 2025-09-12 at 15.32.39.png │ │ ├── Screenshot 2025-09-12 at 15.33.57.png │ │ ├── Screenshot 2025-09-12 at 15.35.09.png │ │ ├── Screenshot 2025-09-12 at 15.36.14.png │ │ ├── segment (1).svg │ │ ├── segment.svg │ │ ├── Segments.png │ │ ├── Set segment conditions-min.png │ │ ├── Setting multiple targeting rules.png │ │ ├── Setting Tab-min.png │ │ ├── Setting targeting rules v3-min.png │ │ ├── Setting targeting rules-min.png │ │ ├── Settings-min (1).png │ │ ├── Settings-min.png │ │ ├── slack (1).svg │ │ ├── Slack (with auto-layout)-min.png │ │ ├── Slack and Environments-min.png │ │ ├── Slack and Feature views-min.png │ │ ├── Slack Integration.png │ │ ├── Slack Settings under Features-min.png │ │ ├── Slack with User Feedback.png │ │ ├── slack.svg │ │ ├── slackConnected (1).png │ │ ├── slackConnected.png │ │ ├── slackDisconnected (1).png │ │ ├── slackDisconnected.png │ │ ├── STARS Configuration-min.png │ │ ├── STARS Feature Funnel-min.png │ │ ├── STARS Feature Report-min.png │ │ ├── STARS states.png │ │ ├── surveys-min.png │ │ ├── Switching Between Environments-min.png │ │ ├── Targeting rules interface-min.png │ │ ├── Targeting rules.png │ │ ├── There are 5 different types of conditions to chose from-min.png │ │ ├── Track adoption in the UI V2-min.png │ │ ├── Track adoption in the UI v3-min.png │ │ ├── Track adoption in the UI-min.png │ │ ├── Track new feature V2-min.png │ │ ├── Tracking Tab-min.png │ │ ├── ts-js.svg │ │ ├── type-check-failed.png │ │ ├── type-check-payload-failed.png │ │ ├── usage attribute example v3.png │ │ ├── usage attribute example-min.png │ │ ├── Usage configuration-min.png │ │ ├── vercel-logo.svg │ │ ├── vue-logo.svg │ │ ├── What is the STARS Framework v3-min.png │ │ └── What is the STARS Framework_-min.png │ └── includes │ ├── integrations.md │ ├── languages.md │ ├── need-some-help-chat-with-us.md │ ├── sdks.md │ └── untitled.md ├── .github │ └── README.md ├── .vscode │ └── settings.json ├── api │ ├── api-access.md │ ├── cli.md │ ├── mcp.md │ ├── public-api │ │ ├── public-api-reference.md │ │ └── README.md │ └── reflag-rest-api │ ├── README.md │ └── reflag-api-reference.md ├── guides │ ├── self-opt-in.md │ └── use-reflag-in-your-cli.md ├── integrations │ ├── amplitude.md │ ├── aws-s3.md │ ├── cursor.md │ ├── datadog.md │ ├── github.md │ ├── linear.md │ ├── mixpanel.md │ ├── overview.md │ ├── posthog.md │ ├── segment.md │ └── slack.md ├── introduction │ └── concepts │ ├── app.md │ ├── company.md │ ├── environment.md │ ├── event.md │ ├── feature-events.md │ ├── feature-view.md │ ├── feature.md │ ├── feedback.md │ ├── filter.md │ ├── README.md │ ├── release-stage.md │ ├── segment.md │ ├── targeting-rules.md │ └── user.md ├── product-handbook │ ├── anonymous-users.md │ ├── concepts │ │ ├── app.md │ │ ├── company.md │ │ ├── environment.md │ │ ├── event.md │ │ ├── feature-events.md │ │ ├── feature-view.md │ │ ├── feature.md │ │ ├── feedback.md │ │ ├── filter.md │ │ ├── README.md │ │ ├── release-stage.md │ │ ├── segment.md │ │ ├── targeting-rules.md │ │ └── user.md │ ├── creating-and-managing-apps │ │ ├── environments.md │ │ └── README.md │ ├── creating-and-managing-apps.md │ ├── creating-segments.md │ ├── data-export.md │ ├── data-residency.md │ ├── feature-clean-up-and-archival-beta │ │ ├── ai-code-clean-up-beta.md │ │ └── README.md │ ├── feature-entitlements │ │ ├── README.md │ │ └── simple-role-based-entitlements.md │ ├── feature-rollouts │ │ ├── feature-targeting-rules.md │ │ └── README.md │ ├── feature-targeting-rules │ │ ├── creating-segments.md │ │ └── environments.md │ ├── feature-views.md │ ├── launch-monitor │ │ ├── automated-feedback-surveys.md │ │ ├── give-feedback-button.md │ │ └── README.md │ ├── product-overview.md │ ├── remote-config.md │ ├── self-opt-in.md │ ├── service-resiliency.md │ ├── team-permissions.md │ └── type-safety.md ├── README.md ├── sdk │ ├── _media │ │ ├── type-check-failed.png │ │ └── type-check-payload-failed.png │ ├── @reflag │ │ ├── browser-sdk │ │ │ ├── globals.md │ │ │ └── README.md │ │ ├── node-sdk │ │ │ ├── globals.md │ │ │ └── README.md │ │ ├── react-sdk │ │ │ ├── globals.md │ │ │ └── README.md │ │ └── vue-sdk │ │ ├── globals.md │ │ └── README.md │ ├── documents │ │ ├── browser-sdk │ │ │ └── FEEDBACK.md │ │ └── cli │ │ └── README.md │ └── README.md ├── SUMMARY.md ├── support │ └── get-support.md └── supported-languages ├── next.js.md ├── openfeature.md ├── overview.md └── ruby-rails-stimulus.md ``` # Files -------------------------------------------------------------------------------- /sdk/@reflag/node-sdk/globals.md: -------------------------------------------------------------------------------- ```markdown 1 | --- 2 | layout: 3 | visible: true 4 | title: 5 | visible: true 6 | description: 7 | visible: false 8 | tableOfContents: 9 | visible: true 10 | outline: 11 | visible: true 12 | pagination: 13 | visible: true 14 | --- 15 | 16 | # @reflag/node-sdk 17 | 18 | ## Classes 19 | 20 | ### BoundReflagClient 21 | 22 | A client bound with a specific user, company, and other context. 23 | 24 | #### Constructors 25 | 26 | ##### new BoundReflagClient() 27 | 28 | ```ts 29 | new BoundReflagClient(client: ReflagClient, options: ContextWithTracking): BoundReflagClient 30 | ``` 31 | 32 | **`Internal`** 33 | 34 | (Internal) Creates a new BoundReflagClient. Use `bindClient` to create a new client bound with a specific context. 35 | 36 | ###### Parameters 37 | 38 | <table> 39 | <thead> 40 | <tr> 41 | <th>Parameter</th> 42 | <th>Type</th> 43 | <th>Description</th> 44 | </tr> 45 | </thead> 46 | <tbody> 47 | <tr> 48 | <td> 49 | 50 | `client` 51 | 52 | </td> 53 | <td> 54 | 55 | [`ReflagClient`](globals.md#reflagclient) 56 | 57 | </td> 58 | <td> 59 | 60 | The `ReflagClient` to use. 61 | 62 | </td> 63 | </tr> 64 | <tr> 65 | <td> 66 | 67 | `options` 68 | 69 | </td> 70 | <td> 71 | 72 | [`ContextWithTracking`](globals.md#contextwithtracking) 73 | 74 | </td> 75 | <td> 76 | 77 | The options for the client. 78 | 79 | </td> 80 | </tr> 81 | </tbody> 82 | </table> 83 | 84 | ###### Returns 85 | 86 | [`BoundReflagClient`](globals.md#boundreflagclient) 87 | 88 | #### Accessors 89 | 90 | ##### company 91 | 92 | ###### Get Signature 93 | 94 | ```ts 95 | get company(): 96 | | undefined 97 | | { 98 | [k: string]: any; avatar: string; 99 | id: undefined | string | number; 100 | name: string; 101 | } 102 | ``` 103 | 104 | Gets the company associated with the client. 105 | 106 | ###### Returns 107 | 108 | \| `undefined` 109 | \| \{ 110 | `[k: string]`: `any`; `avatar`: `string`; 111 | `id`: `undefined` \| `string` \| `number`; 112 | `name`: `string`; 113 | \} 114 | 115 | The company or `undefined` if it is not set. 116 | 117 | ##### otherContext 118 | 119 | ###### Get Signature 120 | 121 | ```ts 122 | get otherContext(): 123 | | undefined 124 | | Record<string, any> 125 | ``` 126 | 127 | Gets the "other" context associated with the client. 128 | 129 | ###### Returns 130 | 131 | \| `undefined` 132 | \| [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `any`\> 133 | 134 | The "other" context or `undefined` if it is not set. 135 | 136 | ##### user 137 | 138 | ###### Get Signature 139 | 140 | ```ts 141 | get user(): 142 | | undefined 143 | | { 144 | [k: string]: any; avatar: string; 145 | email: string; 146 | id: undefined | string | number; 147 | name: string; 148 | } 149 | ``` 150 | 151 | Gets the user associated with the client. 152 | 153 | ###### Returns 154 | 155 | \| `undefined` 156 | \| \{ 157 | `[k: string]`: `any`; `avatar`: `string`; 158 | `email`: `string`; 159 | `id`: `undefined` \| `string` \| `number`; 160 | `name`: `string`; 161 | \} 162 | 163 | The user or `undefined` if it is not set. 164 | 165 | #### Methods 166 | 167 | ##### bindClient() 168 | 169 | ```ts 170 | bindClient(context: ContextWithTracking): BoundReflagClient 171 | ``` 172 | 173 | Create a new client bound with the additional context. 174 | Note: This performs a shallow merge for user/company/other individually. 175 | 176 | ###### Parameters 177 | 178 | <table> 179 | <thead> 180 | <tr> 181 | <th>Parameter</th> 182 | <th>Type</th> 183 | <th>Description</th> 184 | </tr> 185 | </thead> 186 | <tbody> 187 | <tr> 188 | <td> 189 | 190 | `context` 191 | 192 | </td> 193 | <td> 194 | 195 | [`ContextWithTracking`](globals.md#contextwithtracking) 196 | 197 | </td> 198 | <td> 199 | 200 | The context to bind the client to. 201 | 202 | </td> 203 | </tr> 204 | </tbody> 205 | </table> 206 | 207 | ###### Returns 208 | 209 | [`BoundReflagClient`](globals.md#boundreflagclient) 210 | 211 | new client bound with the additional context 212 | 213 | ##### flush() 214 | 215 | ```ts 216 | flush(): Promise<void> 217 | ``` 218 | 219 | Flushes the batch buffer. 220 | 221 | ###### Returns 222 | 223 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\> 224 | 225 | ##### getFlag() 226 | 227 | ```ts 228 | getFlag<TKey>(key: TKey): Flag 229 | ``` 230 | 231 | Get a specific flag for the user/company/other context bound to this client. 232 | Using the `isEnabled` property sends a `check` event to Reflag. 233 | 234 | ###### Type Parameters 235 | 236 | <table> 237 | <thead> 238 | <tr> 239 | <th>Type Parameter</th> 240 | </tr> 241 | </thead> 242 | <tbody> 243 | <tr> 244 | <td> 245 | 246 | `TKey` *extends* `string` 247 | 248 | </td> 249 | </tr> 250 | </tbody> 251 | </table> 252 | 253 | ###### Parameters 254 | 255 | <table> 256 | <thead> 257 | <tr> 258 | <th>Parameter</th> 259 | <th>Type</th> 260 | <th>Description</th> 261 | </tr> 262 | </thead> 263 | <tbody> 264 | <tr> 265 | <td> 266 | 267 | `key` 268 | 269 | </td> 270 | <td> 271 | 272 | `TKey` 273 | 274 | </td> 275 | <td> 276 | 277 | The key of the flag to get. 278 | 279 | </td> 280 | </tr> 281 | </tbody> 282 | </table> 283 | 284 | ###### Returns 285 | 286 | [`Flag`](globals.md#flagtconfig) 287 | 288 | Flags for the given user/company and whether each one is enabled or not 289 | 290 | ##### getFlagRemote() 291 | 292 | ```ts 293 | getFlagRemote(key: string): Promise<Flag> 294 | ``` 295 | 296 | Get remotely evaluated flag for the user/company/other context bound to this client. 297 | 298 | ###### Parameters 299 | 300 | <table> 301 | <thead> 302 | <tr> 303 | <th>Parameter</th> 304 | <th>Type</th> 305 | <th>Description</th> 306 | </tr> 307 | </thead> 308 | <tbody> 309 | <tr> 310 | <td> 311 | 312 | `key` 313 | 314 | </td> 315 | <td> 316 | 317 | `string` 318 | 319 | </td> 320 | <td> 321 | 322 | The key of the flag to get. 323 | 324 | </td> 325 | </tr> 326 | </tbody> 327 | </table> 328 | 329 | ###### Returns 330 | 331 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`Flag`](globals.md#flagtconfig)\> 332 | 333 | Flag for the given user/company and key and whether it's enabled or not 334 | 335 | ##### getFlags() 336 | 337 | ```ts 338 | getFlags(): Record<string, Flag> 339 | ``` 340 | 341 | Get flags for the user/company/other context bound to this client. 342 | Meant for use in serialization of flags for transferring to the client-side/browser. 343 | 344 | ###### Returns 345 | 346 | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, [`Flag`](globals.md#flagtconfig)\> 347 | 348 | Flags for the given user/company and whether each one is enabled or not 349 | 350 | ##### getFlagsForBootstrap() 351 | 352 | ```ts 353 | getFlagsForBootstrap(): BootstrappedFlags 354 | ``` 355 | 356 | Get raw flags for the user/company/other context bound to this client without wrapping them in getters. 357 | This method returns raw flag data suitable for bootstrapping client-side applications. 358 | 359 | ###### Returns 360 | 361 | [`BootstrappedFlags`](globals.md#bootstrappedflags) 362 | 363 | Raw flags for the given user/company and whether each one is enabled or not 364 | 365 | ##### getFlagsRemote() 366 | 367 | ```ts 368 | getFlagsRemote(): Promise<Record<string, Flag>> 369 | ``` 370 | 371 | Get remotely evaluated flag for the user/company/other context bound to this client. 372 | 373 | ###### Returns 374 | 375 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, [`Flag`](globals.md#flagtconfig)\>\> 376 | 377 | Flags for the given user/company and whether each one is enabled or not 378 | 379 | ##### track() 380 | 381 | ```ts 382 | track(event: string, options?: TrackOptions & { 383 | companyId: string; 384 | }): Promise<void> 385 | ``` 386 | 387 | Track an event in Reflag. 388 | 389 | ###### Parameters 390 | 391 | <table> 392 | <thead> 393 | <tr> 394 | <th>Parameter</th> 395 | <th>Type</th> 396 | <th>Description</th> 397 | </tr> 398 | </thead> 399 | <tbody> 400 | <tr> 401 | <td> 402 | 403 | `event` 404 | 405 | </td> 406 | <td> 407 | 408 | `string` 409 | 410 | </td> 411 | <td> 412 | 413 | The event to track. 414 | 415 | </td> 416 | </tr> 417 | <tr> 418 | <td> 419 | 420 | `options`? 421 | 422 | </td> 423 | <td> 424 | 425 | [`TrackOptions`](globals.md#trackoptions) & \{ `companyId`: `string`; \} 426 | 427 | </td> 428 | <td> 429 | 430 | The options for the event. 431 | 432 | </td> 433 | </tr> 434 | </tbody> 435 | </table> 436 | 437 | ###### Returns 438 | 439 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\> 440 | 441 | ###### Throws 442 | 443 | An error if the event is invalid or the options are invalid. 444 | 445 | *** 446 | 447 | ### EdgeClient 448 | 449 | The EdgeClient is ReflagClient pre-configured to be used in edge runtimes, like 450 | Cloudflare Workers. 451 | 452 | #### Example 453 | 454 | ```ts 455 | // set the REFLAG_SECRET_KEY environment variable or pass the secret key in the constructor 456 | const client = new EdgeClient(); 457 | 458 | // evaluate a flag 459 | const context = { 460 | user: { id: "user-id" }, 461 | company: { id: "company-id" }, 462 | } 463 | const { isEnabled } = client.getFlag(context, "flag-key"); 464 | 465 | ``` 466 | 467 | #### Extends 468 | 469 | - [`ReflagClient`](globals.md#reflagclient) 470 | 471 | #### Constructors 472 | 473 | ##### new EdgeClient() 474 | 475 | ```ts 476 | new EdgeClient(options: EdgeClientOptions): EdgeClient 477 | ``` 478 | 479 | ###### Parameters 480 | 481 | <table> 482 | <thead> 483 | <tr> 484 | <th>Parameter</th> 485 | <th>Type</th> 486 | </tr> 487 | </thead> 488 | <tbody> 489 | <tr> 490 | <td> 491 | 492 | `options` 493 | 494 | </td> 495 | <td> 496 | 497 | [`EdgeClientOptions`](globals.md#edgeclientoptions) 498 | 499 | </td> 500 | </tr> 501 | </tbody> 502 | </table> 503 | 504 | ###### Returns 505 | 506 | [`EdgeClient`](globals.md#edgeclient) 507 | 508 | ###### Overrides 509 | 510 | [`ReflagClient`](globals.md#reflagclient).[`constructor`](globals.md#constructors-2) 511 | 512 | #### Properties 513 | 514 | <table> 515 | <thead> 516 | <tr> 517 | <th>Property</th> 518 | <th>Modifier</th> 519 | <th>Type</th> 520 | <th>Description</th> 521 | </tr> 522 | </thead> 523 | <tbody> 524 | <tr> 525 | <td> 526 | 527 | <a id="httpclient"></a> `httpClient` 528 | 529 | </td> 530 | <td> 531 | 532 | `public` 533 | 534 | </td> 535 | <td> 536 | 537 | [`HttpClient`](globals.md#httpclient-2) 538 | 539 | </td> 540 | <td> 541 | 542 | ‐ 543 | 544 | </td> 545 | </tr> 546 | <tr> 547 | <td> 548 | 549 | <a id="logger"></a> `logger` 550 | 551 | </td> 552 | <td> 553 | 554 | `readonly` 555 | 556 | </td> 557 | <td> 558 | 559 | [`Logger`](globals.md#logger-2) 560 | 561 | </td> 562 | <td> 563 | 564 | Gets the logger associated with the client. 565 | 566 | </td> 567 | </tr> 568 | </tbody> 569 | </table> 570 | 571 | #### Accessors 572 | 573 | ##### flagOverrides 574 | 575 | ###### Set Signature 576 | 577 | ```ts 578 | set flagOverrides(overrides: 579 | | Partial<Record<string, FlagOverride>> 580 | | FlagOverridesFn): void 581 | ``` 582 | 583 | Sets the flag overrides. 584 | 585 | ###### Remarks 586 | 587 | The flag overrides are used to override the flag definitions. 588 | This is useful for testing or development. 589 | 590 | ###### Example 591 | 592 | ```ts 593 | client.flagOverrides = { 594 | "flag-1": true, 595 | "flag-2": false, 596 | }; 597 | ``` 598 | 599 | ###### Parameters 600 | 601 | <table> 602 | <thead> 603 | <tr> 604 | <th>Parameter</th> 605 | <th>Type</th> 606 | <th>Description</th> 607 | </tr> 608 | </thead> 609 | <tbody> 610 | <tr> 611 | <td> 612 | 613 | `overrides` 614 | 615 | </td> 616 | <td> 617 | 618 | \| [`Partial`](https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype)\<[`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, [`FlagOverride`](globals.md#flagoverride)\>\> \| [`FlagOverridesFn`](globals.md#flagoverridesfn) 619 | 620 | </td> 621 | <td> 622 | 623 | The flag overrides. 624 | 625 | </td> 626 | </tr> 627 | </tbody> 628 | </table> 629 | 630 | ###### Returns 631 | 632 | `void` 633 | 634 | ###### Inherited from 635 | 636 | [`ReflagClient`](globals.md#reflagclient).[`flagOverrides`](globals.md#flagoverrides-1) 637 | 638 | #### Methods 639 | 640 | ##### bindClient() 641 | 642 | ```ts 643 | bindClient(context: ContextWithTracking): BoundReflagClient 644 | ``` 645 | 646 | Returns a new BoundReflagClient with the user/company/otherContext 647 | set to be used in subsequent calls. 648 | For example, for evaluating flag targeting or tracking events. 649 | 650 | ###### Parameters 651 | 652 | <table> 653 | <thead> 654 | <tr> 655 | <th>Parameter</th> 656 | <th>Type</th> 657 | <th>Description</th> 658 | </tr> 659 | </thead> 660 | <tbody> 661 | <tr> 662 | <td> 663 | 664 | `context` 665 | 666 | </td> 667 | <td> 668 | 669 | [`ContextWithTracking`](globals.md#contextwithtracking) 670 | 671 | </td> 672 | <td> 673 | 674 | The context to bind the client to. 675 | 676 | </td> 677 | </tr> 678 | </tbody> 679 | </table> 680 | 681 | ###### Returns 682 | 683 | [`BoundReflagClient`](globals.md#boundreflagclient) 684 | 685 | A new client bound with the arguments given. 686 | 687 | ###### Throws 688 | 689 | An error if the user/company is given but their ID is not a string. 690 | 691 | ###### Remarks 692 | 693 | The `updateUser` / `updateCompany` methods will automatically be called when 694 | the user/company is set respectively. 695 | 696 | ###### Inherited from 697 | 698 | [`ReflagClient`](globals.md#reflagclient).[`bindClient`](globals.md#bindclient-2) 699 | 700 | ##### clearFlagOverrides() 701 | 702 | ```ts 703 | clearFlagOverrides(): void 704 | ``` 705 | 706 | Clears the flag overrides. 707 | 708 | ###### Returns 709 | 710 | `void` 711 | 712 | ###### Remarks 713 | 714 | This is useful for testing or development. 715 | 716 | ###### Example 717 | 718 | ```ts 719 | afterAll(() => { 720 | client.clearFlagOverrides(); 721 | }); 722 | ``` 723 | 724 | ###### Inherited from 725 | 726 | [`ReflagClient`](globals.md#reflagclient).[`clearFlagOverrides`](globals.md#clearflagoverrides-1) 727 | 728 | ##### destroy() 729 | 730 | ```ts 731 | destroy(): void 732 | ``` 733 | 734 | Destroys the client and cleans up all resources including timers and background processes. 735 | 736 | ###### Returns 737 | 738 | `void` 739 | 740 | ###### Remarks 741 | 742 | After calling this method, the client should not be used anymore. 743 | This is particularly useful in development environments with hot reloading to prevent 744 | multiple background processes from running simultaneously. 745 | 746 | ###### Inherited from 747 | 748 | [`ReflagClient`](globals.md#reflagclient).[`destroy`](globals.md#destroy-1) 749 | 750 | ##### flush() 751 | 752 | ```ts 753 | flush(): Promise<void> 754 | ``` 755 | 756 | Flushes and completes any in-flight fetches in the flag cache. 757 | 758 | ###### Returns 759 | 760 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\> 761 | 762 | ###### Remarks 763 | 764 | It is recommended to call this method when the application is shutting down to ensure all events are sent 765 | before the process exits. 766 | 767 | This method is automatically called when the process exits if `batchOptions.flushOnExit` is `true` in the options (default). 768 | 769 | ###### Inherited from 770 | 771 | [`ReflagClient`](globals.md#reflagclient).[`flush`](globals.md#flush-2) 772 | 773 | ##### getFlag() 774 | 775 | ```ts 776 | getFlag<TKey>(__namedParameters: ContextWithTracking, key: TKey): Flag 777 | ``` 778 | 779 | Gets the evaluated flag for the current context which includes the user, company, and custom context. 780 | Using the `isEnabled` property sends a `check` event to Reflag. 781 | 782 | ###### Type Parameters 783 | 784 | <table> 785 | <thead> 786 | <tr> 787 | <th>Type Parameter</th> 788 | </tr> 789 | </thead> 790 | <tbody> 791 | <tr> 792 | <td> 793 | 794 | `TKey` *extends* `string` 795 | 796 | </td> 797 | </tr> 798 | </tbody> 799 | </table> 800 | 801 | ###### Parameters 802 | 803 | <table> 804 | <thead> 805 | <tr> 806 | <th>Parameter</th> 807 | <th>Type</th> 808 | <th>Description</th> 809 | </tr> 810 | </thead> 811 | <tbody> 812 | <tr> 813 | <td> 814 | 815 | `__namedParameters` 816 | 817 | </td> 818 | <td> 819 | 820 | [`ContextWithTracking`](globals.md#contextwithtracking) 821 | 822 | </td> 823 | <td> 824 | 825 | ‐ 826 | 827 | </td> 828 | </tr> 829 | <tr> 830 | <td> 831 | 832 | `key` 833 | 834 | </td> 835 | <td> 836 | 837 | `TKey` 838 | 839 | </td> 840 | <td> 841 | 842 | The key of the flag to get. 843 | 844 | </td> 845 | </tr> 846 | </tbody> 847 | </table> 848 | 849 | ###### Returns 850 | 851 | [`Flag`](globals.md#flagtconfig) 852 | 853 | The evaluated flag. 854 | 855 | ###### Remarks 856 | 857 | Call `initialize` before calling this method to ensure the flag definitions are cached, no flags will be returned otherwise. 858 | 859 | ###### Inherited from 860 | 861 | [`ReflagClient`](globals.md#reflagclient).[`getFlag`](globals.md#getflag-2) 862 | 863 | ##### getFlagDefinitions() 864 | 865 | ```ts 866 | getFlagDefinitions(): FlagDefinition[] 867 | ``` 868 | 869 | Gets the flag definitions, including all config values. 870 | To evaluate which flags are enabled for a given user/company, use `getFlags`. 871 | 872 | ###### Returns 873 | 874 | [`FlagDefinition`](globals.md#flagdefinition)[] 875 | 876 | The flags definitions. 877 | 878 | ###### Inherited from 879 | 880 | [`ReflagClient`](globals.md#reflagclient).[`getFlagDefinitions`](globals.md#getflagdefinitions-1) 881 | 882 | ##### getFlagRemote() 883 | 884 | ```ts 885 | getFlagRemote<TKey>( 886 | key: TKey, 887 | userId?: IdType, 888 | companyId?: IdType, 889 | additionalContext?: Context): Promise<Flag> 890 | ``` 891 | 892 | Gets evaluated flag with the usage of remote context. 893 | This method triggers a network request every time it's called. 894 | 895 | ###### Type Parameters 896 | 897 | <table> 898 | <thead> 899 | <tr> 900 | <th>Type Parameter</th> 901 | </tr> 902 | </thead> 903 | <tbody> 904 | <tr> 905 | <td> 906 | 907 | `TKey` *extends* `string` 908 | 909 | </td> 910 | </tr> 911 | </tbody> 912 | </table> 913 | 914 | ###### Parameters 915 | 916 | <table> 917 | <thead> 918 | <tr> 919 | <th>Parameter</th> 920 | <th>Type</th> 921 | <th>Description</th> 922 | </tr> 923 | </thead> 924 | <tbody> 925 | <tr> 926 | <td> 927 | 928 | `key` 929 | 930 | </td> 931 | <td> 932 | 933 | `TKey` 934 | 935 | </td> 936 | <td> 937 | 938 | The key of the flag to get. 939 | 940 | </td> 941 | </tr> 942 | <tr> 943 | <td> 944 | 945 | `userId`? 946 | 947 | </td> 948 | <td> 949 | 950 | [`IdType`](globals.md#idtype) 951 | 952 | </td> 953 | <td> 954 | 955 | The userId of the user to get the flag for. 956 | 957 | </td> 958 | </tr> 959 | <tr> 960 | <td> 961 | 962 | `companyId`? 963 | 964 | </td> 965 | <td> 966 | 967 | [`IdType`](globals.md#idtype) 968 | 969 | </td> 970 | <td> 971 | 972 | The companyId of the company to get the flag for. 973 | 974 | </td> 975 | </tr> 976 | <tr> 977 | <td> 978 | 979 | `additionalContext`? 980 | 981 | </td> 982 | <td> 983 | 984 | [`Context`](globals.md#context-1) 985 | 986 | </td> 987 | <td> 988 | 989 | The additional context to get the flag for. 990 | 991 | </td> 992 | </tr> 993 | </tbody> 994 | </table> 995 | 996 | ###### Returns 997 | 998 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`Flag`](globals.md#flagtconfig)\> 999 | 1000 | evaluated flag 1001 | 1002 | ###### Inherited from 1003 | 1004 | [`ReflagClient`](globals.md#reflagclient).[`getFlagRemote`](globals.md#getflagremote-2) 1005 | 1006 | ##### getFlags() 1007 | 1008 | ```ts 1009 | getFlags(options: ContextWithTracking): Record<string, Flag> 1010 | ``` 1011 | 1012 | Gets the evaluated flags for the current context which includes the user, company, and custom context. 1013 | 1014 | ###### Parameters 1015 | 1016 | <table> 1017 | <thead> 1018 | <tr> 1019 | <th>Parameter</th> 1020 | <th>Type</th> 1021 | <th>Description</th> 1022 | </tr> 1023 | </thead> 1024 | <tbody> 1025 | <tr> 1026 | <td> 1027 | 1028 | `options` 1029 | 1030 | </td> 1031 | <td> 1032 | 1033 | [`ContextWithTracking`](globals.md#contextwithtracking) 1034 | 1035 | </td> 1036 | <td> 1037 | 1038 | The options for the context. 1039 | 1040 | </td> 1041 | </tr> 1042 | </tbody> 1043 | </table> 1044 | 1045 | ###### Returns 1046 | 1047 | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, [`Flag`](globals.md#flagtconfig)\> 1048 | 1049 | The evaluated flags. 1050 | 1051 | ###### Remarks 1052 | 1053 | Call `initialize` before calling this method to ensure the flag definitions are cached, no flags will be returned otherwise. 1054 | 1055 | ###### Inherited from 1056 | 1057 | [`ReflagClient`](globals.md#reflagclient).[`getFlags`](globals.md#getflags-2) 1058 | 1059 | ##### getFlagsForBootstrap() 1060 | 1061 | ```ts 1062 | getFlagsForBootstrap(options: ContextWithTracking): BootstrappedFlags 1063 | ``` 1064 | 1065 | Gets the evaluated flags for the current context without wrapping them in getters. 1066 | This method returns raw flag data suitable for bootstrapping client-side applications. 1067 | 1068 | ###### Parameters 1069 | 1070 | <table> 1071 | <thead> 1072 | <tr> 1073 | <th>Parameter</th> 1074 | <th>Type</th> 1075 | <th>Description</th> 1076 | </tr> 1077 | </thead> 1078 | <tbody> 1079 | <tr> 1080 | <td> 1081 | 1082 | `options` 1083 | 1084 | </td> 1085 | <td> 1086 | 1087 | [`ContextWithTracking`](globals.md#contextwithtracking) 1088 | 1089 | </td> 1090 | <td> 1091 | 1092 | The options for the context. 1093 | 1094 | </td> 1095 | </tr> 1096 | </tbody> 1097 | </table> 1098 | 1099 | ###### Returns 1100 | 1101 | [`BootstrappedFlags`](globals.md#bootstrappedflags) 1102 | 1103 | The evaluated raw flags and the context. 1104 | 1105 | ###### Remarks 1106 | 1107 | Call `initialize` before calling this method to ensure the flag definitions are cached, no flags will be returned otherwise. 1108 | This method returns RawFlag objects without wrapping them in getters, making them suitable for serialization. 1109 | 1110 | ###### Inherited from 1111 | 1112 | [`ReflagClient`](globals.md#reflagclient).[`getFlagsForBootstrap`](globals.md#getflagsforbootstrap-2) 1113 | 1114 | ##### getFlagsRemote() 1115 | 1116 | ```ts 1117 | getFlagsRemote( 1118 | userId?: IdType, 1119 | companyId?: IdType, 1120 | additionalContext?: Context): Promise<Record<string, Flag>> 1121 | ``` 1122 | 1123 | Gets evaluated flags with the usage of remote context. 1124 | This method triggers a network request every time it's called. 1125 | 1126 | ###### Parameters 1127 | 1128 | <table> 1129 | <thead> 1130 | <tr> 1131 | <th>Parameter</th> 1132 | <th>Type</th> 1133 | <th>Description</th> 1134 | </tr> 1135 | </thead> 1136 | <tbody> 1137 | <tr> 1138 | <td> 1139 | 1140 | `userId`? 1141 | 1142 | </td> 1143 | <td> 1144 | 1145 | [`IdType`](globals.md#idtype) 1146 | 1147 | </td> 1148 | <td> 1149 | 1150 | The userId of the user to get the flags for. 1151 | 1152 | </td> 1153 | </tr> 1154 | <tr> 1155 | <td> 1156 | 1157 | `companyId`? 1158 | 1159 | </td> 1160 | <td> 1161 | 1162 | [`IdType`](globals.md#idtype) 1163 | 1164 | </td> 1165 | <td> 1166 | 1167 | The companyId of the company to get the flags for. 1168 | 1169 | </td> 1170 | </tr> 1171 | <tr> 1172 | <td> 1173 | 1174 | `additionalContext`? 1175 | 1176 | </td> 1177 | <td> 1178 | 1179 | [`Context`](globals.md#context-1) 1180 | 1181 | </td> 1182 | <td> 1183 | 1184 | The additional context to get the flags for. 1185 | 1186 | </td> 1187 | </tr> 1188 | </tbody> 1189 | </table> 1190 | 1191 | ###### Returns 1192 | 1193 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, [`Flag`](globals.md#flagtconfig)\>\> 1194 | 1195 | evaluated flags 1196 | 1197 | ###### Inherited from 1198 | 1199 | [`ReflagClient`](globals.md#reflagclient).[`getFlagsRemote`](globals.md#getflagsremote-2) 1200 | 1201 | ##### initialize() 1202 | 1203 | ```ts 1204 | initialize(): Promise<void> 1205 | ``` 1206 | 1207 | Initializes the client by caching the flags definitions. 1208 | 1209 | ###### Returns 1210 | 1211 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\> 1212 | 1213 | ###### Remarks 1214 | 1215 | Call this method before calling `getFlags` to ensure the flag definitions are cached. 1216 | The client will ignore subsequent calls to this method. 1217 | 1218 | ###### Inherited from 1219 | 1220 | [`ReflagClient`](globals.md#reflagclient).[`initialize`](globals.md#initialize-1) 1221 | 1222 | ##### track() 1223 | 1224 | ```ts 1225 | track( 1226 | userId: IdType, 1227 | event: string, 1228 | options?: TrackOptions & { 1229 | companyId: IdType; 1230 | }): Promise<void> 1231 | ``` 1232 | 1233 | Tracks an event in Reflag. 1234 | 1235 | ###### Parameters 1236 | 1237 | <table> 1238 | <thead> 1239 | <tr> 1240 | <th>Parameter</th> 1241 | <th>Type</th> 1242 | </tr> 1243 | </thead> 1244 | <tbody> 1245 | <tr> 1246 | <td> 1247 | 1248 | `userId` 1249 | 1250 | </td> 1251 | <td> 1252 | 1253 | [`IdType`](globals.md#idtype) 1254 | 1255 | </td> 1256 | </tr> 1257 | <tr> 1258 | <td> 1259 | 1260 | `event` 1261 | 1262 | </td> 1263 | <td> 1264 | 1265 | `string` 1266 | 1267 | </td> 1268 | </tr> 1269 | <tr> 1270 | <td> 1271 | 1272 | `options`? 1273 | 1274 | </td> 1275 | <td> 1276 | 1277 | [`TrackOptions`](globals.md#trackoptions) & \{ `companyId`: [`IdType`](globals.md#idtype); \} 1278 | 1279 | </td> 1280 | </tr> 1281 | </tbody> 1282 | </table> 1283 | 1284 | ###### Returns 1285 | 1286 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\> 1287 | 1288 | ###### Throws 1289 | 1290 | An error if the user is not set or the event is invalid or the options are invalid. 1291 | 1292 | ###### Remarks 1293 | 1294 | If the company is set, the event will be associated with the company. 1295 | 1296 | ###### Inherited from 1297 | 1298 | [`ReflagClient`](globals.md#reflagclient).[`track`](globals.md#track-2) 1299 | 1300 | ##### updateCompany() 1301 | 1302 | ```ts 1303 | updateCompany(companyId: IdType, options?: TrackOptions & { 1304 | userId: IdType; 1305 | }): Promise<void> 1306 | ``` 1307 | 1308 | Updates the associated company in Reflag. 1309 | 1310 | ###### Parameters 1311 | 1312 | <table> 1313 | <thead> 1314 | <tr> 1315 | <th>Parameter</th> 1316 | <th>Type</th> 1317 | <th>Description</th> 1318 | </tr> 1319 | </thead> 1320 | <tbody> 1321 | <tr> 1322 | <td> 1323 | 1324 | `companyId` 1325 | 1326 | </td> 1327 | <td> 1328 | 1329 | [`IdType`](globals.md#idtype) 1330 | 1331 | </td> 1332 | <td> 1333 | 1334 | The companyId of the company to update. 1335 | 1336 | </td> 1337 | </tr> 1338 | <tr> 1339 | <td> 1340 | 1341 | `options`? 1342 | 1343 | </td> 1344 | <td> 1345 | 1346 | [`TrackOptions`](globals.md#trackoptions) & \{ `userId`: [`IdType`](globals.md#idtype); \} 1347 | 1348 | </td> 1349 | <td> 1350 | 1351 | The options for the company. 1352 | 1353 | </td> 1354 | </tr> 1355 | </tbody> 1356 | </table> 1357 | 1358 | ###### Returns 1359 | 1360 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\> 1361 | 1362 | ###### Throws 1363 | 1364 | An error if the company is not set or the options are invalid. 1365 | 1366 | ###### Remarks 1367 | 1368 | The company must be set using `withCompany` before calling this method. 1369 | If the user is set, the company will be associated with the user. 1370 | 1371 | ###### Inherited from 1372 | 1373 | [`ReflagClient`](globals.md#reflagclient).[`updateCompany`](globals.md#updatecompany-1) 1374 | 1375 | ##### updateUser() 1376 | 1377 | ```ts 1378 | updateUser(userId: IdType, options?: TrackOptions): Promise<void> 1379 | ``` 1380 | 1381 | Updates the associated user in Reflag. 1382 | 1383 | ###### Parameters 1384 | 1385 | <table> 1386 | <thead> 1387 | <tr> 1388 | <th>Parameter</th> 1389 | <th>Type</th> 1390 | <th>Description</th> 1391 | </tr> 1392 | </thead> 1393 | <tbody> 1394 | <tr> 1395 | <td> 1396 | 1397 | `userId` 1398 | 1399 | </td> 1400 | <td> 1401 | 1402 | [`IdType`](globals.md#idtype) 1403 | 1404 | </td> 1405 | <td> 1406 | 1407 | The userId of the user to update. 1408 | 1409 | </td> 1410 | </tr> 1411 | <tr> 1412 | <td> 1413 | 1414 | `options`? 1415 | 1416 | </td> 1417 | <td> 1418 | 1419 | [`TrackOptions`](globals.md#trackoptions) 1420 | 1421 | </td> 1422 | <td> 1423 | 1424 | The options for the user. 1425 | 1426 | </td> 1427 | </tr> 1428 | </tbody> 1429 | </table> 1430 | 1431 | ###### Returns 1432 | 1433 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\> 1434 | 1435 | ###### Throws 1436 | 1437 | An error if the company is not set or the options are invalid. 1438 | 1439 | ###### Remarks 1440 | 1441 | The company must be set using `withCompany` before calling this method. 1442 | If the user is set, the company will be associated with the user. 1443 | 1444 | ###### Inherited from 1445 | 1446 | [`ReflagClient`](globals.md#reflagclient).[`updateUser`](globals.md#updateuser-1) 1447 | 1448 | *** 1449 | 1450 | ### ReflagClient 1451 | 1452 | The SDK client. 1453 | 1454 | #### Remarks 1455 | 1456 | This is the main class for interacting with Reflag. 1457 | It is used to evaluate flags, update user and company contexts, and track events. 1458 | 1459 | #### Example 1460 | 1461 | ```ts 1462 | // set the REFLAG_SECRET_KEY environment variable or pass the secret key to the constructor 1463 | const client = new ReflagClient(); 1464 | 1465 | // evaluate a flag 1466 | const isFlagEnabled = client.getFlag("flag-key", { 1467 | user: { id: "user-id" }, 1468 | company: { id: "company-id" }, 1469 | }); 1470 | ``` 1471 | 1472 | #### Extended by 1473 | 1474 | - [`EdgeClient`](globals.md#edgeclient) 1475 | 1476 | #### Constructors 1477 | 1478 | ##### new ReflagClient() 1479 | 1480 | ```ts 1481 | new ReflagClient(options: ClientOptions): ReflagClient 1482 | ``` 1483 | 1484 | Creates a new SDK client. 1485 | See README for configuration options. 1486 | 1487 | ###### Parameters 1488 | 1489 | <table> 1490 | <thead> 1491 | <tr> 1492 | <th>Parameter</th> 1493 | <th>Type</th> 1494 | <th>Description</th> 1495 | </tr> 1496 | </thead> 1497 | <tbody> 1498 | <tr> 1499 | <td> 1500 | 1501 | `options` 1502 | 1503 | </td> 1504 | <td> 1505 | 1506 | [`ClientOptions`](globals.md#clientoptions) 1507 | 1508 | </td> 1509 | <td> 1510 | 1511 | The options for the client or an existing client to clone. 1512 | 1513 | </td> 1514 | </tr> 1515 | </tbody> 1516 | </table> 1517 | 1518 | ###### Returns 1519 | 1520 | [`ReflagClient`](globals.md#reflagclient) 1521 | 1522 | ###### Throws 1523 | 1524 | An error if the options are invalid. 1525 | 1526 | #### Properties 1527 | 1528 | <table> 1529 | <thead> 1530 | <tr> 1531 | <th>Property</th> 1532 | <th>Modifier</th> 1533 | <th>Type</th> 1534 | <th>Description</th> 1535 | </tr> 1536 | </thead> 1537 | <tbody> 1538 | <tr> 1539 | <td> 1540 | 1541 | <a id="httpclient-1"></a> `httpClient` 1542 | 1543 | </td> 1544 | <td> 1545 | 1546 | `public` 1547 | 1548 | </td> 1549 | <td> 1550 | 1551 | [`HttpClient`](globals.md#httpclient-2) 1552 | 1553 | </td> 1554 | <td> 1555 | 1556 | ‐ 1557 | 1558 | </td> 1559 | </tr> 1560 | <tr> 1561 | <td> 1562 | 1563 | <a id="logger-1"></a> `logger` 1564 | 1565 | </td> 1566 | <td> 1567 | 1568 | `readonly` 1569 | 1570 | </td> 1571 | <td> 1572 | 1573 | [`Logger`](globals.md#logger-2) 1574 | 1575 | </td> 1576 | <td> 1577 | 1578 | Gets the logger associated with the client. 1579 | 1580 | </td> 1581 | </tr> 1582 | </tbody> 1583 | </table> 1584 | 1585 | #### Accessors 1586 | 1587 | ##### flagOverrides 1588 | 1589 | ###### Set Signature 1590 | 1591 | ```ts 1592 | set flagOverrides(overrides: 1593 | | Partial<Record<string, FlagOverride>> 1594 | | FlagOverridesFn): void 1595 | ``` 1596 | 1597 | Sets the flag overrides. 1598 | 1599 | ###### Remarks 1600 | 1601 | The flag overrides are used to override the flag definitions. 1602 | This is useful for testing or development. 1603 | 1604 | ###### Example 1605 | 1606 | ```ts 1607 | client.flagOverrides = { 1608 | "flag-1": true, 1609 | "flag-2": false, 1610 | }; 1611 | ``` 1612 | 1613 | ###### Parameters 1614 | 1615 | <table> 1616 | <thead> 1617 | <tr> 1618 | <th>Parameter</th> 1619 | <th>Type</th> 1620 | <th>Description</th> 1621 | </tr> 1622 | </thead> 1623 | <tbody> 1624 | <tr> 1625 | <td> 1626 | 1627 | `overrides` 1628 | 1629 | </td> 1630 | <td> 1631 | 1632 | \| [`Partial`](https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype)\<[`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, [`FlagOverride`](globals.md#flagoverride)\>\> \| [`FlagOverridesFn`](globals.md#flagoverridesfn) 1633 | 1634 | </td> 1635 | <td> 1636 | 1637 | The flag overrides. 1638 | 1639 | </td> 1640 | </tr> 1641 | </tbody> 1642 | </table> 1643 | 1644 | ###### Returns 1645 | 1646 | `void` 1647 | 1648 | #### Methods 1649 | 1650 | ##### bindClient() 1651 | 1652 | ```ts 1653 | bindClient(context: ContextWithTracking): BoundReflagClient 1654 | ``` 1655 | 1656 | Returns a new BoundReflagClient with the user/company/otherContext 1657 | set to be used in subsequent calls. 1658 | For example, for evaluating flag targeting or tracking events. 1659 | 1660 | ###### Parameters 1661 | 1662 | <table> 1663 | <thead> 1664 | <tr> 1665 | <th>Parameter</th> 1666 | <th>Type</th> 1667 | <th>Description</th> 1668 | </tr> 1669 | </thead> 1670 | <tbody> 1671 | <tr> 1672 | <td> 1673 | 1674 | `context` 1675 | 1676 | </td> 1677 | <td> 1678 | 1679 | [`ContextWithTracking`](globals.md#contextwithtracking) 1680 | 1681 | </td> 1682 | <td> 1683 | 1684 | The context to bind the client to. 1685 | 1686 | </td> 1687 | </tr> 1688 | </tbody> 1689 | </table> 1690 | 1691 | ###### Returns 1692 | 1693 | [`BoundReflagClient`](globals.md#boundreflagclient) 1694 | 1695 | A new client bound with the arguments given. 1696 | 1697 | ###### Throws 1698 | 1699 | An error if the user/company is given but their ID is not a string. 1700 | 1701 | ###### Remarks 1702 | 1703 | The `updateUser` / `updateCompany` methods will automatically be called when 1704 | the user/company is set respectively. 1705 | 1706 | ##### clearFlagOverrides() 1707 | 1708 | ```ts 1709 | clearFlagOverrides(): void 1710 | ``` 1711 | 1712 | Clears the flag overrides. 1713 | 1714 | ###### Returns 1715 | 1716 | `void` 1717 | 1718 | ###### Remarks 1719 | 1720 | This is useful for testing or development. 1721 | 1722 | ###### Example 1723 | 1724 | ```ts 1725 | afterAll(() => { 1726 | client.clearFlagOverrides(); 1727 | }); 1728 | ``` 1729 | 1730 | ##### destroy() 1731 | 1732 | ```ts 1733 | destroy(): void 1734 | ``` 1735 | 1736 | Destroys the client and cleans up all resources including timers and background processes. 1737 | 1738 | ###### Returns 1739 | 1740 | `void` 1741 | 1742 | ###### Remarks 1743 | 1744 | After calling this method, the client should not be used anymore. 1745 | This is particularly useful in development environments with hot reloading to prevent 1746 | multiple background processes from running simultaneously. 1747 | 1748 | ##### flush() 1749 | 1750 | ```ts 1751 | flush(): Promise<void> 1752 | ``` 1753 | 1754 | Flushes and completes any in-flight fetches in the flag cache. 1755 | 1756 | ###### Returns 1757 | 1758 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\> 1759 | 1760 | ###### Remarks 1761 | 1762 | It is recommended to call this method when the application is shutting down to ensure all events are sent 1763 | before the process exits. 1764 | 1765 | This method is automatically called when the process exits if `batchOptions.flushOnExit` is `true` in the options (default). 1766 | 1767 | ##### getFlag() 1768 | 1769 | ```ts 1770 | getFlag<TKey>(__namedParameters: ContextWithTracking, key: TKey): Flag 1771 | ``` 1772 | 1773 | Gets the evaluated flag for the current context which includes the user, company, and custom context. 1774 | Using the `isEnabled` property sends a `check` event to Reflag. 1775 | 1776 | ###### Type Parameters 1777 | 1778 | <table> 1779 | <thead> 1780 | <tr> 1781 | <th>Type Parameter</th> 1782 | </tr> 1783 | </thead> 1784 | <tbody> 1785 | <tr> 1786 | <td> 1787 | 1788 | `TKey` *extends* `string` 1789 | 1790 | </td> 1791 | </tr> 1792 | </tbody> 1793 | </table> 1794 | 1795 | ###### Parameters 1796 | 1797 | <table> 1798 | <thead> 1799 | <tr> 1800 | <th>Parameter</th> 1801 | <th>Type</th> 1802 | <th>Description</th> 1803 | </tr> 1804 | </thead> 1805 | <tbody> 1806 | <tr> 1807 | <td> 1808 | 1809 | `__namedParameters` 1810 | 1811 | </td> 1812 | <td> 1813 | 1814 | [`ContextWithTracking`](globals.md#contextwithtracking) 1815 | 1816 | </td> 1817 | <td> 1818 | 1819 | ‐ 1820 | 1821 | </td> 1822 | </tr> 1823 | <tr> 1824 | <td> 1825 | 1826 | `key` 1827 | 1828 | </td> 1829 | <td> 1830 | 1831 | `TKey` 1832 | 1833 | </td> 1834 | <td> 1835 | 1836 | The key of the flag to get. 1837 | 1838 | </td> 1839 | </tr> 1840 | </tbody> 1841 | </table> 1842 | 1843 | ###### Returns 1844 | 1845 | [`Flag`](globals.md#flagtconfig) 1846 | 1847 | The evaluated flag. 1848 | 1849 | ###### Remarks 1850 | 1851 | Call `initialize` before calling this method to ensure the flag definitions are cached, no flags will be returned otherwise. 1852 | 1853 | ##### getFlagDefinitions() 1854 | 1855 | ```ts 1856 | getFlagDefinitions(): FlagDefinition[] 1857 | ``` 1858 | 1859 | Gets the flag definitions, including all config values. 1860 | To evaluate which flags are enabled for a given user/company, use `getFlags`. 1861 | 1862 | ###### Returns 1863 | 1864 | [`FlagDefinition`](globals.md#flagdefinition)[] 1865 | 1866 | The flags definitions. 1867 | 1868 | ##### getFlagRemote() 1869 | 1870 | ```ts 1871 | getFlagRemote<TKey>( 1872 | key: TKey, 1873 | userId?: IdType, 1874 | companyId?: IdType, 1875 | additionalContext?: Context): Promise<Flag> 1876 | ``` 1877 | 1878 | Gets evaluated flag with the usage of remote context. 1879 | This method triggers a network request every time it's called. 1880 | 1881 | ###### Type Parameters 1882 | 1883 | <table> 1884 | <thead> 1885 | <tr> 1886 | <th>Type Parameter</th> 1887 | </tr> 1888 | </thead> 1889 | <tbody> 1890 | <tr> 1891 | <td> 1892 | 1893 | `TKey` *extends* `string` 1894 | 1895 | </td> 1896 | </tr> 1897 | </tbody> 1898 | </table> 1899 | 1900 | ###### Parameters 1901 | 1902 | <table> 1903 | <thead> 1904 | <tr> 1905 | <th>Parameter</th> 1906 | <th>Type</th> 1907 | <th>Description</th> 1908 | </tr> 1909 | </thead> 1910 | <tbody> 1911 | <tr> 1912 | <td> 1913 | 1914 | `key` 1915 | 1916 | </td> 1917 | <td> 1918 | 1919 | `TKey` 1920 | 1921 | </td> 1922 | <td> 1923 | 1924 | The key of the flag to get. 1925 | 1926 | </td> 1927 | </tr> 1928 | <tr> 1929 | <td> 1930 | 1931 | `userId`? 1932 | 1933 | </td> 1934 | <td> 1935 | 1936 | [`IdType`](globals.md#idtype) 1937 | 1938 | </td> 1939 | <td> 1940 | 1941 | The userId of the user to get the flag for. 1942 | 1943 | </td> 1944 | </tr> 1945 | <tr> 1946 | <td> 1947 | 1948 | `companyId`? 1949 | 1950 | </td> 1951 | <td> 1952 | 1953 | [`IdType`](globals.md#idtype) 1954 | 1955 | </td> 1956 | <td> 1957 | 1958 | The companyId of the company to get the flag for. 1959 | 1960 | </td> 1961 | </tr> 1962 | <tr> 1963 | <td> 1964 | 1965 | `additionalContext`? 1966 | 1967 | </td> 1968 | <td> 1969 | 1970 | [`Context`](globals.md#context-1) 1971 | 1972 | </td> 1973 | <td> 1974 | 1975 | The additional context to get the flag for. 1976 | 1977 | </td> 1978 | </tr> 1979 | </tbody> 1980 | </table> 1981 | 1982 | ###### Returns 1983 | 1984 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`Flag`](globals.md#flagtconfig)\> 1985 | 1986 | evaluated flag 1987 | 1988 | ##### getFlags() 1989 | 1990 | ```ts 1991 | getFlags(options: ContextWithTracking): Record<string, Flag> 1992 | ``` 1993 | 1994 | Gets the evaluated flags for the current context which includes the user, company, and custom context. 1995 | 1996 | ###### Parameters 1997 | 1998 | <table> 1999 | <thead> 2000 | <tr> 2001 | <th>Parameter</th> 2002 | <th>Type</th> 2003 | <th>Description</th> 2004 | </tr> 2005 | </thead> 2006 | <tbody> 2007 | <tr> 2008 | <td> 2009 | 2010 | `options` 2011 | 2012 | </td> 2013 | <td> 2014 | 2015 | [`ContextWithTracking`](globals.md#contextwithtracking) 2016 | 2017 | </td> 2018 | <td> 2019 | 2020 | The options for the context. 2021 | 2022 | </td> 2023 | </tr> 2024 | </tbody> 2025 | </table> 2026 | 2027 | ###### Returns 2028 | 2029 | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, [`Flag`](globals.md#flagtconfig)\> 2030 | 2031 | The evaluated flags. 2032 | 2033 | ###### Remarks 2034 | 2035 | Call `initialize` before calling this method to ensure the flag definitions are cached, no flags will be returned otherwise. 2036 | 2037 | ##### getFlagsForBootstrap() 2038 | 2039 | ```ts 2040 | getFlagsForBootstrap(options: ContextWithTracking): BootstrappedFlags 2041 | ``` 2042 | 2043 | Gets the evaluated flags for the current context without wrapping them in getters. 2044 | This method returns raw flag data suitable for bootstrapping client-side applications. 2045 | 2046 | ###### Parameters 2047 | 2048 | <table> 2049 | <thead> 2050 | <tr> 2051 | <th>Parameter</th> 2052 | <th>Type</th> 2053 | <th>Description</th> 2054 | </tr> 2055 | </thead> 2056 | <tbody> 2057 | <tr> 2058 | <td> 2059 | 2060 | `options` 2061 | 2062 | </td> 2063 | <td> 2064 | 2065 | [`ContextWithTracking`](globals.md#contextwithtracking) 2066 | 2067 | </td> 2068 | <td> 2069 | 2070 | The options for the context. 2071 | 2072 | </td> 2073 | </tr> 2074 | </tbody> 2075 | </table> 2076 | 2077 | ###### Returns 2078 | 2079 | [`BootstrappedFlags`](globals.md#bootstrappedflags) 2080 | 2081 | The evaluated raw flags and the context. 2082 | 2083 | ###### Remarks 2084 | 2085 | Call `initialize` before calling this method to ensure the flag definitions are cached, no flags will be returned otherwise. 2086 | This method returns RawFlag objects without wrapping them in getters, making them suitable for serialization. 2087 | 2088 | ##### getFlagsRemote() 2089 | 2090 | ```ts 2091 | getFlagsRemote( 2092 | userId?: IdType, 2093 | companyId?: IdType, 2094 | additionalContext?: Context): Promise<Record<string, Flag>> 2095 | ``` 2096 | 2097 | Gets evaluated flags with the usage of remote context. 2098 | This method triggers a network request every time it's called. 2099 | 2100 | ###### Parameters 2101 | 2102 | <table> 2103 | <thead> 2104 | <tr> 2105 | <th>Parameter</th> 2106 | <th>Type</th> 2107 | <th>Description</th> 2108 | </tr> 2109 | </thead> 2110 | <tbody> 2111 | <tr> 2112 | <td> 2113 | 2114 | `userId`? 2115 | 2116 | </td> 2117 | <td> 2118 | 2119 | [`IdType`](globals.md#idtype) 2120 | 2121 | </td> 2122 | <td> 2123 | 2124 | The userId of the user to get the flags for. 2125 | 2126 | </td> 2127 | </tr> 2128 | <tr> 2129 | <td> 2130 | 2131 | `companyId`? 2132 | 2133 | </td> 2134 | <td> 2135 | 2136 | [`IdType`](globals.md#idtype) 2137 | 2138 | </td> 2139 | <td> 2140 | 2141 | The companyId of the company to get the flags for. 2142 | 2143 | </td> 2144 | </tr> 2145 | <tr> 2146 | <td> 2147 | 2148 | `additionalContext`? 2149 | 2150 | </td> 2151 | <td> 2152 | 2153 | [`Context`](globals.md#context-1) 2154 | 2155 | </td> 2156 | <td> 2157 | 2158 | The additional context to get the flags for. 2159 | 2160 | </td> 2161 | </tr> 2162 | </tbody> 2163 | </table> 2164 | 2165 | ###### Returns 2166 | 2167 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, [`Flag`](globals.md#flagtconfig)\>\> 2168 | 2169 | evaluated flags 2170 | 2171 | ##### initialize() 2172 | 2173 | ```ts 2174 | initialize(): Promise<void> 2175 | ``` 2176 | 2177 | Initializes the client by caching the flags definitions. 2178 | 2179 | ###### Returns 2180 | 2181 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\> 2182 | 2183 | ###### Remarks 2184 | 2185 | Call this method before calling `getFlags` to ensure the flag definitions are cached. 2186 | The client will ignore subsequent calls to this method. 2187 | 2188 | ##### track() 2189 | 2190 | ```ts 2191 | track( 2192 | userId: IdType, 2193 | event: string, 2194 | options?: TrackOptions & { 2195 | companyId: IdType; 2196 | }): Promise<void> 2197 | ``` 2198 | 2199 | Tracks an event in Reflag. 2200 | 2201 | ###### Parameters 2202 | 2203 | <table> 2204 | <thead> 2205 | <tr> 2206 | <th>Parameter</th> 2207 | <th>Type</th> 2208 | </tr> 2209 | </thead> 2210 | <tbody> 2211 | <tr> 2212 | <td> 2213 | 2214 | `userId` 2215 | 2216 | </td> 2217 | <td> 2218 | 2219 | [`IdType`](globals.md#idtype) 2220 | 2221 | </td> 2222 | </tr> 2223 | <tr> 2224 | <td> 2225 | 2226 | `event` 2227 | 2228 | </td> 2229 | <td> 2230 | 2231 | `string` 2232 | 2233 | </td> 2234 | </tr> 2235 | <tr> 2236 | <td> 2237 | 2238 | `options`? 2239 | 2240 | </td> 2241 | <td> 2242 | 2243 | [`TrackOptions`](globals.md#trackoptions) & \{ `companyId`: [`IdType`](globals.md#idtype); \} 2244 | 2245 | </td> 2246 | </tr> 2247 | </tbody> 2248 | </table> 2249 | 2250 | ###### Returns 2251 | 2252 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\> 2253 | 2254 | ###### Throws 2255 | 2256 | An error if the user is not set or the event is invalid or the options are invalid. 2257 | 2258 | ###### Remarks 2259 | 2260 | If the company is set, the event will be associated with the company. 2261 | 2262 | ##### updateCompany() 2263 | 2264 | ```ts 2265 | updateCompany(companyId: IdType, options?: TrackOptions & { 2266 | userId: IdType; 2267 | }): Promise<void> 2268 | ``` 2269 | 2270 | Updates the associated company in Reflag. 2271 | 2272 | ###### Parameters 2273 | 2274 | <table> 2275 | <thead> 2276 | <tr> 2277 | <th>Parameter</th> 2278 | <th>Type</th> 2279 | <th>Description</th> 2280 | </tr> 2281 | </thead> 2282 | <tbody> 2283 | <tr> 2284 | <td> 2285 | 2286 | `companyId` 2287 | 2288 | </td> 2289 | <td> 2290 | 2291 | [`IdType`](globals.md#idtype) 2292 | 2293 | </td> 2294 | <td> 2295 | 2296 | The companyId of the company to update. 2297 | 2298 | </td> 2299 | </tr> 2300 | <tr> 2301 | <td> 2302 | 2303 | `options`? 2304 | 2305 | </td> 2306 | <td> 2307 | 2308 | [`TrackOptions`](globals.md#trackoptions) & \{ `userId`: [`IdType`](globals.md#idtype); \} 2309 | 2310 | </td> 2311 | <td> 2312 | 2313 | The options for the company. 2314 | 2315 | </td> 2316 | </tr> 2317 | </tbody> 2318 | </table> 2319 | 2320 | ###### Returns 2321 | 2322 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\> 2323 | 2324 | ###### Throws 2325 | 2326 | An error if the company is not set or the options are invalid. 2327 | 2328 | ###### Remarks 2329 | 2330 | The company must be set using `withCompany` before calling this method. 2331 | If the user is set, the company will be associated with the user. 2332 | 2333 | ##### updateUser() 2334 | 2335 | ```ts 2336 | updateUser(userId: IdType, options?: TrackOptions): Promise<void> 2337 | ``` 2338 | 2339 | Updates the associated user in Reflag. 2340 | 2341 | ###### Parameters 2342 | 2343 | <table> 2344 | <thead> 2345 | <tr> 2346 | <th>Parameter</th> 2347 | <th>Type</th> 2348 | <th>Description</th> 2349 | </tr> 2350 | </thead> 2351 | <tbody> 2352 | <tr> 2353 | <td> 2354 | 2355 | `userId` 2356 | 2357 | </td> 2358 | <td> 2359 | 2360 | [`IdType`](globals.md#idtype) 2361 | 2362 | </td> 2363 | <td> 2364 | 2365 | The userId of the user to update. 2366 | 2367 | </td> 2368 | </tr> 2369 | <tr> 2370 | <td> 2371 | 2372 | `options`? 2373 | 2374 | </td> 2375 | <td> 2376 | 2377 | [`TrackOptions`](globals.md#trackoptions) 2378 | 2379 | </td> 2380 | <td> 2381 | 2382 | The options for the user. 2383 | 2384 | </td> 2385 | </tr> 2386 | </tbody> 2387 | </table> 2388 | 2389 | ###### Returns 2390 | 2391 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\> 2392 | 2393 | ###### Throws 2394 | 2395 | An error if the company is not set or the options are invalid. 2396 | 2397 | ###### Remarks 2398 | 2399 | The company must be set using `withCompany` before calling this method. 2400 | If the user is set, the company will be associated with the user. 2401 | 2402 | ## Interfaces 2403 | 2404 | ### ContextWithTracking 2405 | 2406 | A context with tracking option. 2407 | 2408 | #### Extends 2409 | 2410 | - [`Context`](globals.md#context-1) 2411 | 2412 | #### Properties 2413 | 2414 | <table> 2415 | <thead> 2416 | <tr> 2417 | <th>Property</th> 2418 | <th>Type</th> 2419 | <th>Description</th> 2420 | </tr> 2421 | </thead> 2422 | <tbody> 2423 | <tr> 2424 | <td> 2425 | 2426 | <a id="company-1"></a> `company?` 2427 | 2428 | </td> 2429 | <td> 2430 | 2431 | \{ `[k: string]`: `any`; `avatar`: `string`; `id`: `undefined` \| `string` \| `number`; `name`: `string`; \} 2432 | 2433 | </td> 2434 | <td> 2435 | 2436 | The company context. If no `id` key is set, the whole object is ignored. 2437 | 2438 | </td> 2439 | </tr> 2440 | <tr> 2441 | <td> 2442 | 2443 | `company.avatar?` 2444 | 2445 | </td> 2446 | <td> 2447 | 2448 | `string` 2449 | 2450 | </td> 2451 | <td> 2452 | 2453 | The avatar URL of the company. 2454 | 2455 | </td> 2456 | </tr> 2457 | <tr> 2458 | <td> 2459 | 2460 | `company.id` 2461 | 2462 | </td> 2463 | <td> 2464 | 2465 | `undefined` \| `string` \| `number` 2466 | 2467 | </td> 2468 | <td> 2469 | 2470 | The identifier of the company. 2471 | 2472 | </td> 2473 | </tr> 2474 | <tr> 2475 | <td> 2476 | 2477 | `company.name?` 2478 | 2479 | </td> 2480 | <td> 2481 | 2482 | `string` 2483 | 2484 | </td> 2485 | <td> 2486 | 2487 | The name of the company. 2488 | 2489 | </td> 2490 | </tr> 2491 | <tr> 2492 | <td> 2493 | 2494 | <a id="enabletracking"></a> `enableTracking?` 2495 | 2496 | </td> 2497 | <td> 2498 | 2499 | `boolean` 2500 | 2501 | </td> 2502 | <td> 2503 | 2504 | Enable tracking for the context. 2505 | If set to `false`, tracking will be disabled for the context. Default is `true`. 2506 | 2507 | </td> 2508 | </tr> 2509 | <tr> 2510 | <td> 2511 | 2512 | <a id="meta"></a> `meta?` 2513 | 2514 | </td> 2515 | <td> 2516 | 2517 | [`TrackingMeta`](globals.md#trackingmeta) 2518 | 2519 | </td> 2520 | <td> 2521 | 2522 | The meta context used to update the user or company when syncing is required during 2523 | feature retrieval. 2524 | 2525 | </td> 2526 | </tr> 2527 | <tr> 2528 | <td> 2529 | 2530 | <a id="other"></a> `other?` 2531 | 2532 | </td> 2533 | <td> 2534 | 2535 | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `any`\> 2536 | 2537 | </td> 2538 | <td> 2539 | 2540 | The other context. This is used for any additional context that is not related to user or company. 2541 | 2542 | </td> 2543 | </tr> 2544 | <tr> 2545 | <td> 2546 | 2547 | <a id="user-1"></a> `user?` 2548 | 2549 | </td> 2550 | <td> 2551 | 2552 | \{ `[k: string]`: `any`; `avatar`: `string`; `email`: `string`; `id`: `undefined` \| `string` \| `number`; `name`: `string`; \} 2553 | 2554 | </td> 2555 | <td> 2556 | 2557 | The user context. If no `id` key is set, the whole object is ignored. 2558 | 2559 | </td> 2560 | </tr> 2561 | <tr> 2562 | <td> 2563 | 2564 | `user.avatar?` 2565 | 2566 | </td> 2567 | <td> 2568 | 2569 | `string` 2570 | 2571 | </td> 2572 | <td> 2573 | 2574 | The avatar URL of the user. 2575 | 2576 | </td> 2577 | </tr> 2578 | <tr> 2579 | <td> 2580 | 2581 | `user.email?` 2582 | 2583 | </td> 2584 | <td> 2585 | 2586 | `string` 2587 | 2588 | </td> 2589 | <td> 2590 | 2591 | The email of the user. 2592 | 2593 | </td> 2594 | </tr> 2595 | <tr> 2596 | <td> 2597 | 2598 | `user.id` 2599 | 2600 | </td> 2601 | <td> 2602 | 2603 | `undefined` \| `string` \| `number` 2604 | 2605 | </td> 2606 | <td> 2607 | 2608 | The identifier of the user. 2609 | 2610 | </td> 2611 | </tr> 2612 | <tr> 2613 | <td> 2614 | 2615 | `user.name?` 2616 | 2617 | </td> 2618 | <td> 2619 | 2620 | `string` 2621 | 2622 | </td> 2623 | <td> 2624 | 2625 | The name of the user. 2626 | 2627 | </td> 2628 | </tr> 2629 | </tbody> 2630 | </table> 2631 | 2632 | *** 2633 | 2634 | ### Flag\<TConfig\> 2635 | 2636 | Describes a feature 2637 | 2638 | #### Type Parameters 2639 | 2640 | <table> 2641 | <thead> 2642 | <tr> 2643 | <th>Type Parameter</th> 2644 | <th>Default type</th> 2645 | </tr> 2646 | </thead> 2647 | <tbody> 2648 | <tr> 2649 | <td> 2650 | 2651 | `TConfig` *extends* [`FlagType`](globals.md#flagtype)\[`"config"`\] 2652 | 2653 | </td> 2654 | <td> 2655 | 2656 | [`EmptyFlagRemoteConfig`](globals.md#emptyflagremoteconfig) 2657 | 2658 | </td> 2659 | </tr> 2660 | </tbody> 2661 | </table> 2662 | 2663 | #### Properties 2664 | 2665 | <table> 2666 | <thead> 2667 | <tr> 2668 | <th>Property</th> 2669 | <th>Type</th> 2670 | <th>Description</th> 2671 | </tr> 2672 | </thead> 2673 | <tbody> 2674 | <tr> 2675 | <td> 2676 | 2677 | <a id="config"></a> `config` 2678 | 2679 | </td> 2680 | <td> 2681 | 2682 | \| [`EmptyFlagRemoteConfig`](globals.md#emptyflagremoteconfig) \| \{ `key`: `string`; \} & `TConfig` 2683 | 2684 | </td> 2685 | <td> 2686 | 2687 | ‐ 2688 | 2689 | </td> 2690 | </tr> 2691 | <tr> 2692 | <td> 2693 | 2694 | <a id="isenabled"></a> `isEnabled` 2695 | 2696 | </td> 2697 | <td> 2698 | 2699 | `boolean` 2700 | 2701 | </td> 2702 | <td> 2703 | 2704 | If the feature is enabled. 2705 | 2706 | </td> 2707 | </tr> 2708 | <tr> 2709 | <td> 2710 | 2711 | <a id="key"></a> `key` 2712 | 2713 | </td> 2714 | <td> 2715 | 2716 | `string` 2717 | 2718 | </td> 2719 | <td> 2720 | 2721 | The key of the feature. 2722 | 2723 | </td> 2724 | </tr> 2725 | </tbody> 2726 | </table> 2727 | 2728 | #### Methods 2729 | 2730 | ##### track() 2731 | 2732 | ```ts 2733 | track(): Promise<void> 2734 | ``` 2735 | 2736 | Track feature usage in Reflag. 2737 | 2738 | ###### Returns 2739 | 2740 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\> 2741 | 2742 | *** 2743 | 2744 | ### Flags 2745 | 2746 | Describes a collection of evaluated features. 2747 | 2748 | #### Remarks 2749 | 2750 | You should extend the Flags interface to define the available features. 2751 | 2752 | *** 2753 | 2754 | ### HttpClient 2755 | 2756 | Defines the interface for an HTTP client. 2757 | 2758 | #### Remarks 2759 | 2760 | This interface is used to abstract the HTTP client implementation from the SDK. 2761 | Define your own implementation of this interface to use a different HTTP client. 2762 | 2763 | #### Methods 2764 | 2765 | ##### get() 2766 | 2767 | ```ts 2768 | get<TResponse>( 2769 | url: string, 2770 | headers: Record<string, string>, 2771 | timeoutMs: number): Promise<HttpClientResponse<TResponse>> 2772 | ``` 2773 | 2774 | Sends a GET request to the specified URL. 2775 | 2776 | ###### Type Parameters 2777 | 2778 | <table> 2779 | <thead> 2780 | <tr> 2781 | <th>Type Parameter</th> 2782 | </tr> 2783 | </thead> 2784 | <tbody> 2785 | <tr> 2786 | <td> 2787 | 2788 | `TResponse` 2789 | 2790 | </td> 2791 | </tr> 2792 | </tbody> 2793 | </table> 2794 | 2795 | ###### Parameters 2796 | 2797 | <table> 2798 | <thead> 2799 | <tr> 2800 | <th>Parameter</th> 2801 | <th>Type</th> 2802 | <th>Description</th> 2803 | </tr> 2804 | </thead> 2805 | <tbody> 2806 | <tr> 2807 | <td> 2808 | 2809 | `url` 2810 | 2811 | </td> 2812 | <td> 2813 | 2814 | `string` 2815 | 2816 | </td> 2817 | <td> 2818 | 2819 | The URL to send the request to. 2820 | 2821 | </td> 2822 | </tr> 2823 | <tr> 2824 | <td> 2825 | 2826 | `headers` 2827 | 2828 | </td> 2829 | <td> 2830 | 2831 | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\> 2832 | 2833 | </td> 2834 | <td> 2835 | 2836 | The headers to include in the request. 2837 | 2838 | </td> 2839 | </tr> 2840 | <tr> 2841 | <td> 2842 | 2843 | `timeoutMs` 2844 | 2845 | </td> 2846 | <td> 2847 | 2848 | `number` 2849 | 2850 | </td> 2851 | <td> 2852 | 2853 | ‐ 2854 | 2855 | </td> 2856 | </tr> 2857 | </tbody> 2858 | </table> 2859 | 2860 | ###### Returns 2861 | 2862 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`HttpClientResponse`](globals.md#httpclientresponsetresponse)\<`TResponse`\>\> 2863 | 2864 | The response from the server. 2865 | 2866 | ##### post() 2867 | 2868 | ```ts 2869 | post<TBody, TResponse>( 2870 | url: string, 2871 | headers: Record<string, string>, 2872 | body: TBody): Promise<HttpClientResponse<TResponse>> 2873 | ``` 2874 | 2875 | Sends a POST request to the specified URL. 2876 | 2877 | ###### Type Parameters 2878 | 2879 | <table> 2880 | <thead> 2881 | <tr> 2882 | <th>Type Parameter</th> 2883 | </tr> 2884 | </thead> 2885 | <tbody> 2886 | <tr> 2887 | <td> 2888 | 2889 | `TBody` 2890 | 2891 | </td> 2892 | </tr> 2893 | <tr> 2894 | <td> 2895 | 2896 | `TResponse` 2897 | 2898 | </td> 2899 | </tr> 2900 | </tbody> 2901 | </table> 2902 | 2903 | ###### Parameters 2904 | 2905 | <table> 2906 | <thead> 2907 | <tr> 2908 | <th>Parameter</th> 2909 | <th>Type</th> 2910 | <th>Description</th> 2911 | </tr> 2912 | </thead> 2913 | <tbody> 2914 | <tr> 2915 | <td> 2916 | 2917 | `url` 2918 | 2919 | </td> 2920 | <td> 2921 | 2922 | `string` 2923 | 2924 | </td> 2925 | <td> 2926 | 2927 | The URL to send the request to. 2928 | 2929 | </td> 2930 | </tr> 2931 | <tr> 2932 | <td> 2933 | 2934 | `headers` 2935 | 2936 | </td> 2937 | <td> 2938 | 2939 | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\> 2940 | 2941 | </td> 2942 | <td> 2943 | 2944 | The headers to include in the request. 2945 | 2946 | </td> 2947 | </tr> 2948 | <tr> 2949 | <td> 2950 | 2951 | `body` 2952 | 2953 | </td> 2954 | <td> 2955 | 2956 | `TBody` 2957 | 2958 | </td> 2959 | <td> 2960 | 2961 | The body of the request. 2962 | 2963 | </td> 2964 | </tr> 2965 | </tbody> 2966 | </table> 2967 | 2968 | ###### Returns 2969 | 2970 | [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`HttpClientResponse`](globals.md#httpclientresponsetresponse)\<`TResponse`\>\> 2971 | 2972 | The response from the server. 2973 | 2974 | *** 2975 | 2976 | ### Logger 2977 | 2978 | Logger interface for logging messages 2979 | 2980 | #### Properties 2981 | 2982 | <table> 2983 | <thead> 2984 | <tr> 2985 | <th>Property</th> 2986 | <th>Type</th> 2987 | <th>Description</th> 2988 | </tr> 2989 | </thead> 2990 | <tbody> 2991 | <tr> 2992 | <td> 2993 | 2994 | <a id="debug"></a> `debug` 2995 | 2996 | </td> 2997 | <td> 2998 | 2999 | (`message`: `string`, `data`?: `any`) => `void` 3000 | 3001 | </td> 3002 | <td> 3003 | 3004 | Log a debug messages 3005 | 3006 | </td> 3007 | </tr> 3008 | <tr> 3009 | <td> 3010 | 3011 | <a id="error"></a> `error` 3012 | 3013 | </td> 3014 | <td> 3015 | 3016 | (`message`: `string`, `data`?: `any`) => `void` 3017 | 3018 | </td> 3019 | <td> 3020 | 3021 | Log an error messages 3022 | 3023 | </td> 3024 | </tr> 3025 | <tr> 3026 | <td> 3027 | 3028 | <a id="info"></a> `info` 3029 | 3030 | </td> 3031 | <td> 3032 | 3033 | (`message`: `string`, `data`?: `any`) => `void` 3034 | 3035 | </td> 3036 | <td> 3037 | 3038 | Log an info messages 3039 | 3040 | </td> 3041 | </tr> 3042 | <tr> 3043 | <td> 3044 | 3045 | <a id="warn"></a> `warn` 3046 | 3047 | </td> 3048 | <td> 3049 | 3050 | (`message`: `string`, `data`?: `any`) => `void` 3051 | 3052 | </td> 3053 | <td> 3054 | 3055 | Log a warning messages 3056 | 3057 | </td> 3058 | </tr> 3059 | </tbody> 3060 | </table> 3061 | 3062 | *** 3063 | 3064 | ### RawFlag 3065 | 3066 | Describes a feature. 3067 | 3068 | #### Properties 3069 | 3070 | <table> 3071 | <thead> 3072 | <tr> 3073 | <th>Property</th> 3074 | <th>Type</th> 3075 | <th>Description</th> 3076 | </tr> 3077 | </thead> 3078 | <tbody> 3079 | <tr> 3080 | <td> 3081 | 3082 | <a id="config-1"></a> `config?` 3083 | 3084 | </td> 3085 | <td> 3086 | 3087 | [`RawFlagRemoteConfig`](globals.md#rawflagremoteconfig) 3088 | 3089 | </td> 3090 | <td> 3091 | 3092 | The remote configuration value for the feature. 3093 | 3094 | </td> 3095 | </tr> 3096 | <tr> 3097 | <td> 3098 | 3099 | <a id="isenabled-1"></a> `isEnabled` 3100 | 3101 | </td> 3102 | <td> 3103 | 3104 | `boolean` 3105 | 3106 | </td> 3107 | <td> 3108 | 3109 | If the feature is enabled. 3110 | 3111 | </td> 3112 | </tr> 3113 | <tr> 3114 | <td> 3115 | 3116 | <a id="key-1"></a> `key` 3117 | 3118 | </td> 3119 | <td> 3120 | 3121 | `string` 3122 | 3123 | </td> 3124 | <td> 3125 | 3126 | The key of the feature. 3127 | 3128 | </td> 3129 | </tr> 3130 | <tr> 3131 | <td> 3132 | 3133 | <a id="missingcontextfields"></a> `missingContextFields?` 3134 | 3135 | </td> 3136 | <td> 3137 | 3138 | `string`[] 3139 | 3140 | </td> 3141 | <td> 3142 | 3143 | The missing fields in the evaluation context (optional). 3144 | 3145 | </td> 3146 | </tr> 3147 | <tr> 3148 | <td> 3149 | 3150 | <a id="ruleevaluationresults"></a> `ruleEvaluationResults?` 3151 | 3152 | </td> 3153 | <td> 3154 | 3155 | `boolean`[] 3156 | 3157 | </td> 3158 | <td> 3159 | 3160 | The rule results of the evaluation (optional). 3161 | 3162 | </td> 3163 | </tr> 3164 | <tr> 3165 | <td> 3166 | 3167 | <a id="targetingversion"></a> `targetingVersion?` 3168 | 3169 | </td> 3170 | <td> 3171 | 3172 | `number` 3173 | 3174 | </td> 3175 | <td> 3176 | 3177 | The version of the targeting used to evaluate if the feature is enabled (optional). 3178 | 3179 | </td> 3180 | </tr> 3181 | </tbody> 3182 | </table> 3183 | 3184 | ## Type Aliases 3185 | 3186 | ### Attributes 3187 | 3188 | ```ts 3189 | type Attributes = Record<string, any>; 3190 | ``` 3191 | 3192 | Describes the attributes of a user, company or event. 3193 | 3194 | *** 3195 | 3196 | ### BatchBufferOptions\<T\> 3197 | 3198 | ```ts 3199 | type BatchBufferOptions<T> = { 3200 | flushHandler: (items: T[]) => Promise<void>; 3201 | flushOnExit: boolean; 3202 | intervalMs: number; 3203 | logger: Logger; 3204 | maxSize: number; 3205 | }; 3206 | ``` 3207 | 3208 | Options for configuring the BatchBuffer. 3209 | 3210 | #### Type Parameters 3211 | 3212 | <table> 3213 | <thead> 3214 | <tr> 3215 | <th>Type Parameter</th> 3216 | <th>Description</th> 3217 | </tr> 3218 | </thead> 3219 | <tbody> 3220 | <tr> 3221 | <td> 3222 | 3223 | `T` 3224 | 3225 | </td> 3226 | <td> 3227 | 3228 | The type of items in the buffer. 3229 | 3230 | </td> 3231 | </tr> 3232 | </tbody> 3233 | </table> 3234 | 3235 | #### Type declaration 3236 | 3237 | <table> 3238 | <thead> 3239 | <tr> 3240 | <th>Name</th> 3241 | <th>Type</th> 3242 | <th>Description</th> 3243 | </tr> 3244 | </thead> 3245 | <tbody> 3246 | <tr> 3247 | <td> 3248 | 3249 | <a id="flushhandler"></a> `flushHandler` 3250 | 3251 | </td> 3252 | <td> 3253 | 3254 | (`items`: `T`[]) => [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\> 3255 | 3256 | </td> 3257 | <td> 3258 | 3259 | A function that handles flushing the items in the buffer. 3260 | 3261 | </td> 3262 | </tr> 3263 | <tr> 3264 | <td> 3265 | 3266 | <a id="flushonexit"></a> `flushOnExit`? 3267 | 3268 | </td> 3269 | <td> 3270 | 3271 | `boolean` 3272 | 3273 | </td> 3274 | <td> 3275 | 3276 | Whether to flush the buffer on exit. 3277 | 3278 | </td> 3279 | </tr> 3280 | <tr> 3281 | <td> 3282 | 3283 | <a id="intervalms"></a> `intervalMs`? 3284 | 3285 | </td> 3286 | <td> 3287 | 3288 | `number` 3289 | 3290 | </td> 3291 | <td> 3292 | 3293 | The interval in milliseconds at which the buffer is flushed. 3294 | 3295 | **Remarks** 3296 | 3297 | If `0`, the buffer is flushed only when `maxSize` is reached. 3298 | 3299 | </td> 3300 | </tr> 3301 | <tr> 3302 | <td> 3303 | 3304 | <a id="logger-3"></a> `logger`? 3305 | 3306 | </td> 3307 | <td> 3308 | 3309 | [`Logger`](globals.md#logger-2) 3310 | 3311 | </td> 3312 | <td> 3313 | 3314 | The logger to use for logging (optional). 3315 | 3316 | </td> 3317 | </tr> 3318 | <tr> 3319 | <td> 3320 | 3321 | <a id="maxsize"></a> `maxSize`? 3322 | 3323 | </td> 3324 | <td> 3325 | 3326 | `number` 3327 | 3328 | </td> 3329 | <td> 3330 | 3331 | The maximum size of the buffer before it is flushed. 3332 | 3333 | </td> 3334 | </tr> 3335 | </tbody> 3336 | </table> 3337 | 3338 | *** 3339 | 3340 | ### BootstrappedFlags 3341 | 3342 | ```ts 3343 | type BootstrappedFlags = { 3344 | context: Context; 3345 | flags: RawFlags; 3346 | }; 3347 | ``` 3348 | 3349 | Describes a collection of evaluated raw flags and the context for bootstrapping. 3350 | 3351 | #### Type declaration 3352 | 3353 | <table> 3354 | <thead> 3355 | <tr> 3356 | <th>Name</th> 3357 | <th>Type</th> 3358 | </tr> 3359 | </thead> 3360 | <tbody> 3361 | <tr> 3362 | <td> 3363 | 3364 | <a id="context"></a> `context` 3365 | 3366 | </td> 3367 | <td> 3368 | 3369 | [`Context`](globals.md#context-1) 3370 | 3371 | </td> 3372 | </tr> 3373 | <tr> 3374 | <td> 3375 | 3376 | <a id="flags-1"></a> `flags` 3377 | 3378 | </td> 3379 | <td> 3380 | 3381 | [`RawFlags`](globals.md#rawflags) 3382 | 3383 | </td> 3384 | </tr> 3385 | </tbody> 3386 | </table> 3387 | 3388 | *** 3389 | 3390 | ### CacheStrategy 3391 | 3392 | ```ts 3393 | type CacheStrategy = "periodically-update" | "in-request"; 3394 | ``` 3395 | 3396 | *** 3397 | 3398 | ### ClientOptions 3399 | 3400 | ```ts 3401 | type ClientOptions = { 3402 | apiBaseUrl: string; 3403 | batchOptions: Omit<BatchBufferOptions<any>, "flushHandler" | "logger">; 3404 | cacheStrategy: CacheStrategy; 3405 | configFile: string; 3406 | emitEvaluationEvents: boolean; 3407 | fallbackFlags: | TypedFlagKey[] 3408 | | Record<TypedFlagKey, Exclude<FlagOverride, false>>; 3409 | fetchTimeoutMs: number; 3410 | flagOverrides: | string 3411 | | (context: Context) => FlagOverrides; 3412 | flagsFetchRetries: number; 3413 | host: string; 3414 | httpClient: HttpClient; 3415 | logger: Logger; 3416 | logLevel: LogLevel; 3417 | offline: boolean; 3418 | secretKey: string; 3419 | }; 3420 | ``` 3421 | 3422 | Defines the options for the SDK client. 3423 | 3424 | #### Type declaration 3425 | 3426 | <table> 3427 | <thead> 3428 | <tr> 3429 | <th>Name</th> 3430 | <th>Type</th> 3431 | <th>Description</th> 3432 | </tr> 3433 | </thead> 3434 | <tbody> 3435 | <tr> 3436 | <td> 3437 | 3438 | <a id="apibaseurl"></a> `apiBaseUrl`? 3439 | 3440 | </td> 3441 | <td> 3442 | 3443 | `string` 3444 | 3445 | </td> 3446 | <td> 3447 | 3448 | The host to send requests to (optional). 3449 | 3450 | </td> 3451 | </tr> 3452 | <tr> 3453 | <td> 3454 | 3455 | <a id="batchoptions"></a> `batchOptions`? 3456 | 3457 | </td> 3458 | <td> 3459 | 3460 | [`Omit`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys)\<[`BatchBufferOptions`](globals.md#batchbufferoptionst)\<`any`\>, `"flushHandler"` \| `"logger"`\> 3461 | 3462 | </td> 3463 | <td> 3464 | 3465 | The options for the batch buffer (optional). 3466 | If not provided, the default options are used. 3467 | 3468 | </td> 3469 | </tr> 3470 | <tr> 3471 | <td> 3472 | 3473 | <a id="cachestrategy-1"></a> `cacheStrategy`? 3474 | 3475 | </td> 3476 | <td> 3477 | 3478 | [`CacheStrategy`](globals.md#cachestrategy) 3479 | 3480 | </td> 3481 | <td> 3482 | 3483 | The cache strategy to use for the client (optional, defaults to "periodically-update"). 3484 | 3485 | </td> 3486 | </tr> 3487 | <tr> 3488 | <td> 3489 | 3490 | <a id="configfile"></a> `configFile`? 3491 | 3492 | </td> 3493 | <td> 3494 | 3495 | `string` 3496 | 3497 | </td> 3498 | <td> 3499 | 3500 | The path to the config file. If supplied, the config file will be loaded. 3501 | Defaults to `reflag.config.json` when NODE_ENV is not production. Can also be 3502 | set through the environment variable REFLAG_CONFIG_FILE. 3503 | 3504 | </td> 3505 | </tr> 3506 | <tr> 3507 | <td> 3508 | 3509 | <a id="emitevaluationevents"></a> `emitEvaluationEvents`? 3510 | 3511 | </td> 3512 | <td> 3513 | 3514 | `boolean` 3515 | 3516 | </td> 3517 | <td> 3518 | 3519 | If set to `false`, no evaluation events will be emitted. 3520 | 3521 | </td> 3522 | </tr> 3523 | <tr> 3524 | <td> 3525 | 3526 | <a id="fallbackflags"></a> `fallbackFlags`? 3527 | 3528 | </td> 3529 | <td> 3530 | 3531 | \| [`TypedFlagKey`](globals.md#typedflagkey)[] 3532 | \| [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<[`TypedFlagKey`](globals.md#typedflagkey), [`Exclude`](https://www.typescriptlang.org/docs/handbook/utility-types.html#excludeuniontype-excludedmembers)\<[`FlagOverride`](globals.md#flagoverride), `false`\>\> 3533 | 3534 | </td> 3535 | <td> 3536 | 3537 | The features to "enable" as fallbacks when the API is unavailable (optional). 3538 | Can be an array of feature keys, or a record of feature keys and boolean or object values. 3539 | 3540 | If a record is supplied instead of array, the values of each key are either the 3541 | configuration values or the boolean value `true`. 3542 | 3543 | </td> 3544 | </tr> 3545 | <tr> 3546 | <td> 3547 | 3548 | <a id="fetchtimeoutms"></a> `fetchTimeoutMs`? 3549 | 3550 | </td> 3551 | <td> 3552 | 3553 | `number` 3554 | 3555 | </td> 3556 | <td> 3557 | 3558 | The timeout in milliseconds for fetching feature targeting data (optional). 3559 | Default is 10000 ms. 3560 | 3561 | </td> 3562 | </tr> 3563 | <tr> 3564 | <td> 3565 | 3566 | <a id="flagoverrides-2"></a> `flagOverrides`? 3567 | 3568 | </td> 3569 | <td> 3570 | 3571 | \| `string` 3572 | \| (`context`: [`Context`](globals.md#context-1)) => [`FlagOverrides`](globals.md#flagoverrides-3) 3573 | 3574 | </td> 3575 | <td> 3576 | 3577 | If a filename is specified, feature targeting results be overridden with 3578 | the values from this file. The file should be a JSON object with flag 3579 | keys as keys, and boolean or object as values. 3580 | 3581 | If a function is specified, the function will be called with the context 3582 | and should return a record of flag keys and boolean or object values. 3583 | 3584 | Defaults to "reflagFlags.json". 3585 | 3586 | </td> 3587 | </tr> 3588 | <tr> 3589 | <td> 3590 | 3591 | <a id="flagsfetchretries"></a> `flagsFetchRetries`? 3592 | 3593 | </td> 3594 | <td> 3595 | 3596 | `number` 3597 | 3598 | </td> 3599 | <td> 3600 | 3601 | Number of times to retry fetching feature definitions (optional). 3602 | Default is 3 times. 3603 | 3604 | </td> 3605 | </tr> 3606 | <tr> 3607 | <td> 3608 | 3609 | <a id="host"></a> `host`? 3610 | 3611 | </td> 3612 | <td> 3613 | 3614 | `string` 3615 | 3616 | </td> 3617 | <td> 3618 | 3619 | **Deprecated** 3620 | 3621 | Use `apiBaseUrl` instead. 3622 | 3623 | </td> 3624 | </tr> 3625 | <tr> 3626 | <td> 3627 | 3628 | <a id="httpclient-3"></a> `httpClient`? 3629 | 3630 | </td> 3631 | <td> 3632 | 3633 | [`HttpClient`](globals.md#httpclient-2) 3634 | 3635 | </td> 3636 | <td> 3637 | 3638 | The HTTP client to use for sending requests (optional). Default is the built-in fetch client. 3639 | 3640 | </td> 3641 | </tr> 3642 | <tr> 3643 | <td> 3644 | 3645 | <a id="logger-4"></a> `logger`? 3646 | 3647 | </td> 3648 | <td> 3649 | 3650 | [`Logger`](globals.md#logger-2) 3651 | 3652 | </td> 3653 | <td> 3654 | 3655 | The logger to use for logging (optional). Default is info level logging to console. 3656 | 3657 | </td> 3658 | </tr> 3659 | <tr> 3660 | <td> 3661 | 3662 | <a id="loglevel"></a> `logLevel`? 3663 | 3664 | </td> 3665 | <td> 3666 | 3667 | [`LogLevel`](globals.md#loglevel-1) 3668 | 3669 | </td> 3670 | <td> 3671 | 3672 | Use the console logger, but set a log level. Ineffective if a custom logger is provided. 3673 | 3674 | </td> 3675 | </tr> 3676 | <tr> 3677 | <td> 3678 | 3679 | <a id="offline"></a> `offline`? 3680 | 3681 | </td> 3682 | <td> 3683 | 3684 | `boolean` 3685 | 3686 | </td> 3687 | <td> 3688 | 3689 | In offline mode, no data is sent or fetched from the the Reflag API. 3690 | This is useful for testing or development. 3691 | 3692 | </td> 3693 | </tr> 3694 | <tr> 3695 | <td> 3696 | 3697 | <a id="secretkey"></a> `secretKey`? 3698 | 3699 | </td> 3700 | <td> 3701 | 3702 | `string` 3703 | 3704 | </td> 3705 | <td> 3706 | 3707 | The secret key used to authenticate with the Reflag API. 3708 | 3709 | </td> 3710 | </tr> 3711 | </tbody> 3712 | </table> 3713 | 3714 | *** 3715 | 3716 | ### Context 3717 | 3718 | ```ts 3719 | type Context = { 3720 | company: { 3721 | [k: string]: any; avatar: string; 3722 | id: string | number | undefined; 3723 | name: string; 3724 | }; 3725 | other: Record<string, any>; 3726 | user: { 3727 | [k: string]: any; avatar: string; 3728 | email: string; 3729 | id: string | number | undefined; 3730 | name: string; 3731 | }; 3732 | }; 3733 | ``` 3734 | 3735 | Describes the current user context, company context, and other context. 3736 | This is used to determine if feature targeting matches and to track events. 3737 | 3738 | #### Type declaration 3739 | 3740 | <table> 3741 | <thead> 3742 | <tr> 3743 | <th>Name</th> 3744 | <th>Type</th> 3745 | <th>Description</th> 3746 | </tr> 3747 | </thead> 3748 | <tbody> 3749 | <tr> 3750 | <td> 3751 | 3752 | <a id="company-2"></a> `company`? 3753 | 3754 | </td> 3755 | <td> 3756 | 3757 | \{ 3758 | `[k: string]`: `any`; `avatar`: `string`; 3759 | `id`: `string` \| `number` \| `undefined`; 3760 | `name`: `string`; 3761 | \} 3762 | 3763 | </td> 3764 | <td> 3765 | 3766 | The company context. If no `id` key is set, the whole object is ignored. 3767 | 3768 | </td> 3769 | </tr> 3770 | <tr> 3771 | <td> 3772 | 3773 | `company.avatar`? 3774 | 3775 | </td> 3776 | <td> 3777 | 3778 | `string` 3779 | 3780 | </td> 3781 | <td> 3782 | 3783 | The avatar URL of the company. 3784 | 3785 | </td> 3786 | </tr> 3787 | <tr> 3788 | <td> 3789 | 3790 | `company.id` 3791 | 3792 | </td> 3793 | <td> 3794 | 3795 | `string` \| `number` \| `undefined` 3796 | 3797 | </td> 3798 | <td> 3799 | 3800 | The identifier of the company. 3801 | 3802 | </td> 3803 | </tr> 3804 | <tr> 3805 | <td> 3806 | 3807 | `company.name`? 3808 | 3809 | </td> 3810 | <td> 3811 | 3812 | `string` 3813 | 3814 | </td> 3815 | <td> 3816 | 3817 | The name of the company. 3818 | 3819 | </td> 3820 | </tr> 3821 | <tr> 3822 | <td> 3823 | 3824 | <a id="other-1"></a> `other`? 3825 | 3826 | </td> 3827 | <td> 3828 | 3829 | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `any`\> 3830 | 3831 | </td> 3832 | <td> 3833 | 3834 | The other context. This is used for any additional context that is not related to user or company. 3835 | 3836 | </td> 3837 | </tr> 3838 | <tr> 3839 | <td> 3840 | 3841 | <a id="user-2"></a> `user`? 3842 | 3843 | </td> 3844 | <td> 3845 | 3846 | \{ 3847 | `[k: string]`: `any`; `avatar`: `string`; 3848 | `email`: `string`; 3849 | `id`: `string` \| `number` \| `undefined`; 3850 | `name`: `string`; 3851 | \} 3852 | 3853 | </td> 3854 | <td> 3855 | 3856 | The user context. If no `id` key is set, the whole object is ignored. 3857 | 3858 | </td> 3859 | </tr> 3860 | <tr> 3861 | <td> 3862 | 3863 | `user.avatar`? 3864 | 3865 | </td> 3866 | <td> 3867 | 3868 | `string` 3869 | 3870 | </td> 3871 | <td> 3872 | 3873 | The avatar URL of the user. 3874 | 3875 | </td> 3876 | </tr> 3877 | <tr> 3878 | <td> 3879 | 3880 | `user.email`? 3881 | 3882 | </td> 3883 | <td> 3884 | 3885 | `string` 3886 | 3887 | </td> 3888 | <td> 3889 | 3890 | The email of the user. 3891 | 3892 | </td> 3893 | </tr> 3894 | <tr> 3895 | <td> 3896 | 3897 | `user.id` 3898 | 3899 | </td> 3900 | <td> 3901 | 3902 | `string` \| `number` \| `undefined` 3903 | 3904 | </td> 3905 | <td> 3906 | 3907 | The identifier of the user. 3908 | 3909 | </td> 3910 | </tr> 3911 | <tr> 3912 | <td> 3913 | 3914 | `user.name`? 3915 | 3916 | </td> 3917 | <td> 3918 | 3919 | `string` 3920 | 3921 | </td> 3922 | <td> 3923 | 3924 | The name of the user. 3925 | 3926 | </td> 3927 | </tr> 3928 | </tbody> 3929 | </table> 3930 | 3931 | *** 3932 | 3933 | ### EdgeClientOptions 3934 | 3935 | ```ts 3936 | type EdgeClientOptions = Omit<ClientOptions, "cacheStrategy" | "flushIntervalMs" | "batchOptions">; 3937 | ``` 3938 | 3939 | *** 3940 | 3941 | ### EmptyFlagRemoteConfig 3942 | 3943 | ```ts 3944 | type EmptyFlagRemoteConfig = { 3945 | key: undefined; 3946 | payload: undefined; 3947 | }; 3948 | ``` 3949 | 3950 | #### Type declaration 3951 | 3952 | <table> 3953 | <thead> 3954 | <tr> 3955 | <th>Name</th> 3956 | <th>Type</th> 3957 | </tr> 3958 | </thead> 3959 | <tbody> 3960 | <tr> 3961 | <td> 3962 | 3963 | <a id="key-2"></a> `key` 3964 | 3965 | </td> 3966 | <td> 3967 | 3968 | `undefined` 3969 | 3970 | </td> 3971 | </tr> 3972 | <tr> 3973 | <td> 3974 | 3975 | <a id="payload"></a> `payload` 3976 | 3977 | </td> 3978 | <td> 3979 | 3980 | `undefined` 3981 | 3982 | </td> 3983 | </tr> 3984 | </tbody> 3985 | </table> 3986 | 3987 | *** 3988 | 3989 | ### FlagConfigVariant 3990 | 3991 | ```ts 3992 | type FlagConfigVariant = { 3993 | filter: RuleFilter; 3994 | key: string; 3995 | payload: any; 3996 | }; 3997 | ``` 3998 | 3999 | Describes a remote feature config variant. 4000 | 4001 | #### Type declaration 4002 | 4003 | <table> 4004 | <thead> 4005 | <tr> 4006 | <th>Name</th> 4007 | <th>Type</th> 4008 | <th>Description</th> 4009 | </tr> 4010 | </thead> 4011 | <tbody> 4012 | <tr> 4013 | <td> 4014 | 4015 | <a id="filter"></a> `filter` 4016 | 4017 | </td> 4018 | <td> 4019 | 4020 | `RuleFilter` 4021 | 4022 | </td> 4023 | <td> 4024 | 4025 | The filter for the variant. 4026 | 4027 | </td> 4028 | </tr> 4029 | <tr> 4030 | <td> 4031 | 4032 | <a id="key-3"></a> `key` 4033 | 4034 | </td> 4035 | <td> 4036 | 4037 | `string` 4038 | 4039 | </td> 4040 | <td> 4041 | 4042 | The key of the variant. 4043 | 4044 | </td> 4045 | </tr> 4046 | <tr> 4047 | <td> 4048 | 4049 | <a id="payload-1"></a> `payload` 4050 | 4051 | </td> 4052 | <td> 4053 | 4054 | `any` 4055 | 4056 | </td> 4057 | <td> 4058 | 4059 | The optional user-supplied payload data. 4060 | 4061 | </td> 4062 | </tr> 4063 | </tbody> 4064 | </table> 4065 | 4066 | *** 4067 | 4068 | ### FlagDefinition 4069 | 4070 | ```ts 4071 | type FlagDefinition = { 4072 | config: { 4073 | variants: FlagConfigVariant[]; 4074 | version: number; 4075 | }; 4076 | description: string | null; 4077 | flag: { 4078 | rules: { 4079 | filter: RuleFilter; 4080 | }[]; 4081 | version: number; 4082 | }; 4083 | key: string; 4084 | }; 4085 | ``` 4086 | 4087 | Describes a feature definition. 4088 | 4089 | #### Type declaration 4090 | 4091 | <table> 4092 | <thead> 4093 | <tr> 4094 | <th>Name</th> 4095 | <th>Type</th> 4096 | <th>Description</th> 4097 | </tr> 4098 | </thead> 4099 | <tbody> 4100 | <tr> 4101 | <td> 4102 | 4103 | <a id="config-2"></a> `config`? 4104 | 4105 | </td> 4106 | <td> 4107 | 4108 | \{ 4109 | `variants`: [`FlagConfigVariant`](globals.md#flagconfigvariant)[]; 4110 | `version`: `number`; 4111 | \} 4112 | 4113 | </td> 4114 | <td> 4115 | 4116 | The remote configuration for the feature. 4117 | 4118 | </td> 4119 | </tr> 4120 | <tr> 4121 | <td> 4122 | 4123 | `config.variants` 4124 | 4125 | </td> 4126 | <td> 4127 | 4128 | [`FlagConfigVariant`](globals.md#flagconfigvariant)[] 4129 | 4130 | </td> 4131 | <td> 4132 | 4133 | The variants of the remote configuration. 4134 | 4135 | </td> 4136 | </tr> 4137 | <tr> 4138 | <td> 4139 | 4140 | `config.version` 4141 | 4142 | </td> 4143 | <td> 4144 | 4145 | `number` 4146 | 4147 | </td> 4148 | <td> 4149 | 4150 | The version of the remote configuration. 4151 | 4152 | </td> 4153 | </tr> 4154 | <tr> 4155 | <td> 4156 | 4157 | <a id="description"></a> `description` 4158 | 4159 | </td> 4160 | <td> 4161 | 4162 | `string` \| `null` 4163 | 4164 | </td> 4165 | <td> 4166 | 4167 | Description of the feature. 4168 | 4169 | </td> 4170 | </tr> 4171 | <tr> 4172 | <td> 4173 | 4174 | <a id="flag"></a> `flag` 4175 | 4176 | </td> 4177 | <td> 4178 | 4179 | \{ 4180 | `rules`: \{ 4181 | `filter`: `RuleFilter`; 4182 | \}[]; 4183 | `version`: `number`; 4184 | \} 4185 | 4186 | </td> 4187 | <td> 4188 | 4189 | The targeting rules for the feature. 4190 | 4191 | </td> 4192 | </tr> 4193 | <tr> 4194 | <td> 4195 | 4196 | `flag.rules` 4197 | 4198 | </td> 4199 | <td> 4200 | 4201 | \{ 4202 | `filter`: `RuleFilter`; 4203 | \}[] 4204 | 4205 | </td> 4206 | <td> 4207 | 4208 | The targeting rules. 4209 | 4210 | </td> 4211 | </tr> 4212 | <tr> 4213 | <td> 4214 | 4215 | `flag.version` 4216 | 4217 | </td> 4218 | <td> 4219 | 4220 | `number` 4221 | 4222 | </td> 4223 | <td> 4224 | 4225 | The version of the targeting rules. 4226 | 4227 | </td> 4228 | </tr> 4229 | <tr> 4230 | <td> 4231 | 4232 | <a id="key-4"></a> `key` 4233 | 4234 | </td> 4235 | <td> 4236 | 4237 | `string` 4238 | 4239 | </td> 4240 | <td> 4241 | 4242 | The key of the feature. 4243 | 4244 | </td> 4245 | </tr> 4246 | </tbody> 4247 | </table> 4248 | 4249 | *** 4250 | 4251 | ### FlagOverride 4252 | 4253 | ```ts 4254 | type FlagOverride = 4255 | | FlagType & { 4256 | config: { 4257 | key: string; 4258 | }; 4259 | isEnabled: boolean; 4260 | } 4261 | | boolean; 4262 | ``` 4263 | 4264 | *** 4265 | 4266 | ### FlagOverrides 4267 | 4268 | ```ts 4269 | type FlagOverrides = Partial<keyof Flags extends never ? Record<string, FlagOverride> : { [FlagKey in keyof Flags]: Flags[FlagKey] extends FlagOverride ? Flags[FlagKey] : Exclude<FlagOverride, "config"> }>; 4270 | ``` 4271 | 4272 | Describes the feature overrides. 4273 | 4274 | *** 4275 | 4276 | ### FlagOverridesFn() 4277 | 4278 | ```ts 4279 | type FlagOverridesFn = (context: Context) => FlagOverrides; 4280 | ``` 4281 | 4282 | #### Parameters 4283 | 4284 | <table> 4285 | <thead> 4286 | <tr> 4287 | <th>Parameter</th> 4288 | <th>Type</th> 4289 | </tr> 4290 | </thead> 4291 | <tbody> 4292 | <tr> 4293 | <td> 4294 | 4295 | `context` 4296 | 4297 | </td> 4298 | <td> 4299 | 4300 | [`Context`](globals.md#context-1) 4301 | 4302 | </td> 4303 | </tr> 4304 | </tbody> 4305 | </table> 4306 | 4307 | #### Returns 4308 | 4309 | [`FlagOverrides`](globals.md#flagoverrides-3) 4310 | 4311 | *** 4312 | 4313 | ### FlagRemoteConfig 4314 | 4315 | ```ts 4316 | type FlagRemoteConfig = 4317 | | { 4318 | key: string; 4319 | payload: any; 4320 | } 4321 | | EmptyFlagRemoteConfig; 4322 | ``` 4323 | 4324 | A remotely managed configuration value for a feature. 4325 | 4326 | #### Type declaration 4327 | 4328 | \{ 4329 | `key`: `string`; 4330 | `payload`: `any`; 4331 | \} 4332 | 4333 | <table> 4334 | <thead> 4335 | <tr> 4336 | <th>Name</th> 4337 | <th>Type</th> 4338 | <th>Description</th> 4339 | </tr> 4340 | </thead> 4341 | <tbody> 4342 | <tr> 4343 | <td> 4344 | 4345 | `key` 4346 | 4347 | </td> 4348 | <td> 4349 | 4350 | `string` 4351 | 4352 | </td> 4353 | <td> 4354 | 4355 | The key of the matched configuration value. 4356 | 4357 | </td> 4358 | </tr> 4359 | <tr> 4360 | <td> 4361 | 4362 | `payload` 4363 | 4364 | </td> 4365 | <td> 4366 | 4367 | `any` 4368 | 4369 | </td> 4370 | <td> 4371 | 4372 | The optional user-supplied payload data. 4373 | 4374 | </td> 4375 | </tr> 4376 | </tbody> 4377 | </table> 4378 | 4379 | [`EmptyFlagRemoteConfig`](globals.md#emptyflagremoteconfig) 4380 | 4381 | *** 4382 | 4383 | ### FlagType 4384 | 4385 | ```ts 4386 | type FlagType = { 4387 | config: { 4388 | payload: any; 4389 | }; 4390 | }; 4391 | ``` 4392 | 4393 | #### Type declaration 4394 | 4395 | <table> 4396 | <thead> 4397 | <tr> 4398 | <th>Name</th> 4399 | <th>Type</th> 4400 | </tr> 4401 | </thead> 4402 | <tbody> 4403 | <tr> 4404 | <td> 4405 | 4406 | <a id="config-3"></a> `config`? 4407 | 4408 | </td> 4409 | <td> 4410 | 4411 | \{ 4412 | `payload`: `any`; 4413 | \} 4414 | 4415 | </td> 4416 | </tr> 4417 | <tr> 4418 | <td> 4419 | 4420 | `config.payload` 4421 | 4422 | </td> 4423 | <td> 4424 | 4425 | `any` 4426 | 4427 | </td> 4428 | </tr> 4429 | </tbody> 4430 | </table> 4431 | 4432 | *** 4433 | 4434 | ### HttpClientResponse\<TResponse\> 4435 | 4436 | ```ts 4437 | type HttpClientResponse<TResponse> = { 4438 | body: TResponse | undefined; 4439 | ok: boolean; 4440 | status: number; 4441 | }; 4442 | ``` 4443 | 4444 | Describes the response of a HTTP client. 4445 | 4446 | #### Type Parameters 4447 | 4448 | <table> 4449 | <thead> 4450 | <tr> 4451 | <th>Type Parameter</th> 4452 | <th>Description</th> 4453 | </tr> 4454 | </thead> 4455 | <tbody> 4456 | <tr> 4457 | <td> 4458 | 4459 | `TResponse` 4460 | 4461 | </td> 4462 | <td> 4463 | 4464 | The type of the response body. 4465 | 4466 | </td> 4467 | </tr> 4468 | </tbody> 4469 | </table> 4470 | 4471 | #### Type declaration 4472 | 4473 | <table> 4474 | <thead> 4475 | <tr> 4476 | <th>Name</th> 4477 | <th>Type</th> 4478 | <th>Description</th> 4479 | </tr> 4480 | </thead> 4481 | <tbody> 4482 | <tr> 4483 | <td> 4484 | 4485 | <a id="body"></a> `body` 4486 | 4487 | </td> 4488 | <td> 4489 | 4490 | `TResponse` \| `undefined` 4491 | 4492 | </td> 4493 | <td> 4494 | 4495 | The body of the response if available. 4496 | 4497 | </td> 4498 | </tr> 4499 | <tr> 4500 | <td> 4501 | 4502 | <a id="ok"></a> `ok` 4503 | 4504 | </td> 4505 | <td> 4506 | 4507 | `boolean` 4508 | 4509 | </td> 4510 | <td> 4511 | 4512 | Indicates that the request succeeded. 4513 | 4514 | </td> 4515 | </tr> 4516 | <tr> 4517 | <td> 4518 | 4519 | <a id="status"></a> `status` 4520 | 4521 | </td> 4522 | <td> 4523 | 4524 | `number` 4525 | 4526 | </td> 4527 | <td> 4528 | 4529 | The status code of the response. 4530 | 4531 | </td> 4532 | </tr> 4533 | </tbody> 4534 | </table> 4535 | 4536 | *** 4537 | 4538 | ### IdType 4539 | 4540 | ```ts 4541 | type IdType = string | number; 4542 | ``` 4543 | 4544 | *** 4545 | 4546 | ### LogLevel 4547 | 4548 | ```ts 4549 | type LogLevel = typeof LOG_LEVELS[number]; 4550 | ``` 4551 | 4552 | *** 4553 | 4554 | ### RawFlagRemoteConfig 4555 | 4556 | ```ts 4557 | type RawFlagRemoteConfig = { 4558 | key: string; 4559 | missingContextFields: string[]; 4560 | payload: any; 4561 | ruleEvaluationResults: boolean[]; 4562 | targetingVersion: number; 4563 | }; 4564 | ``` 4565 | 4566 | A remotely managed configuration value for a feature. 4567 | 4568 | #### Type declaration 4569 | 4570 | <table> 4571 | <thead> 4572 | <tr> 4573 | <th>Name</th> 4574 | <th>Type</th> 4575 | <th>Description</th> 4576 | </tr> 4577 | </thead> 4578 | <tbody> 4579 | <tr> 4580 | <td> 4581 | 4582 | <a id="key-5"></a> `key` 4583 | 4584 | </td> 4585 | <td> 4586 | 4587 | `string` 4588 | 4589 | </td> 4590 | <td> 4591 | 4592 | The key of the matched configuration value. 4593 | 4594 | </td> 4595 | </tr> 4596 | <tr> 4597 | <td> 4598 | 4599 | <a id="missingcontextfields-1"></a> `missingContextFields`? 4600 | 4601 | </td> 4602 | <td> 4603 | 4604 | `string`[] 4605 | 4606 | </td> 4607 | <td> 4608 | 4609 | The missing fields in the evaluation context (optional). 4610 | 4611 | </td> 4612 | </tr> 4613 | <tr> 4614 | <td> 4615 | 4616 | <a id="payload-2"></a> `payload` 4617 | 4618 | </td> 4619 | <td> 4620 | 4621 | `any` 4622 | 4623 | </td> 4624 | <td> 4625 | 4626 | The optional user-supplied payload data. 4627 | 4628 | </td> 4629 | </tr> 4630 | <tr> 4631 | <td> 4632 | 4633 | <a id="ruleevaluationresults-1"></a> `ruleEvaluationResults`? 4634 | 4635 | </td> 4636 | <td> 4637 | 4638 | `boolean`[] 4639 | 4640 | </td> 4641 | <td> 4642 | 4643 | The rule results of the evaluation (optional). 4644 | 4645 | </td> 4646 | </tr> 4647 | <tr> 4648 | <td> 4649 | 4650 | <a id="targetingversion-1"></a> `targetingVersion`? 4651 | 4652 | </td> 4653 | <td> 4654 | 4655 | `number` 4656 | 4657 | </td> 4658 | <td> 4659 | 4660 | The version of the targeting rules used to select the config value. 4661 | 4662 | </td> 4663 | </tr> 4664 | </tbody> 4665 | </table> 4666 | 4667 | *** 4668 | 4669 | ### RawFlags 4670 | 4671 | ```ts 4672 | type RawFlags = Record<TypedFlagKey, RawFlag>; 4673 | ``` 4674 | 4675 | Describes a collection of evaluated raw flags. 4676 | 4677 | *** 4678 | 4679 | ### TrackingMeta 4680 | 4681 | ```ts 4682 | type TrackingMeta = { 4683 | active: boolean; 4684 | }; 4685 | ``` 4686 | 4687 | Describes the meta context associated with tracking. 4688 | 4689 | #### Type declaration 4690 | 4691 | <table> 4692 | <thead> 4693 | <tr> 4694 | <th>Name</th> 4695 | <th>Type</th> 4696 | <th>Description</th> 4697 | </tr> 4698 | </thead> 4699 | <tbody> 4700 | <tr> 4701 | <td> 4702 | 4703 | <a id="active"></a> `active`? 4704 | 4705 | </td> 4706 | <td> 4707 | 4708 | `boolean` 4709 | 4710 | </td> 4711 | <td> 4712 | 4713 | Whether the user or company is active. 4714 | 4715 | </td> 4716 | </tr> 4717 | </tbody> 4718 | </table> 4719 | 4720 | *** 4721 | 4722 | ### TrackOptions 4723 | 4724 | ```ts 4725 | type TrackOptions = { 4726 | attributes: Attributes; 4727 | meta: TrackingMeta; 4728 | }; 4729 | ``` 4730 | 4731 | Defines the options for tracking of entities. 4732 | 4733 | #### Type declaration 4734 | 4735 | <table> 4736 | <thead> 4737 | <tr> 4738 | <th>Name</th> 4739 | <th>Type</th> 4740 | <th>Description</th> 4741 | </tr> 4742 | </thead> 4743 | <tbody> 4744 | <tr> 4745 | <td> 4746 | 4747 | <a id="attributes-1"></a> `attributes`? 4748 | 4749 | </td> 4750 | <td> 4751 | 4752 | [`Attributes`](globals.md#attributes) 4753 | 4754 | </td> 4755 | <td> 4756 | 4757 | The attributes associated with the event. 4758 | 4759 | </td> 4760 | </tr> 4761 | <tr> 4762 | <td> 4763 | 4764 | <a id="meta-1"></a> `meta`? 4765 | 4766 | </td> 4767 | <td> 4768 | 4769 | [`TrackingMeta`](globals.md#trackingmeta) 4770 | 4771 | </td> 4772 | <td> 4773 | 4774 | The meta context associated with the event. 4775 | 4776 | </td> 4777 | </tr> 4778 | </tbody> 4779 | </table> 4780 | 4781 | *** 4782 | 4783 | ### TypedFlagKey 4784 | 4785 | ```ts 4786 | type TypedFlagKey = keyof TypedFlags; 4787 | ``` 4788 | 4789 | *** 4790 | 4791 | ### TypedFlags 4792 | 4793 | ```ts 4794 | type TypedFlags = keyof Flags extends never ? Record<string, Flag> : { [FlagKey in keyof Flags]: Flags[FlagKey] extends FlagType ? Flag<Flags[FlagKey]["config"]> : Flag }; 4795 | ``` 4796 | 4797 | Describes a collection of evaluated feature. 4798 | 4799 | #### Remarks 4800 | 4801 | This types falls back to a generic Record<string, Flag> if the Flags interface 4802 | has not been extended. 4803 | 4804 | ## Variables 4805 | 4806 | ### LOG\_LEVELS 4807 | 4808 | ```ts 4809 | const LOG_LEVELS: readonly ["DEBUG", "INFO", "WARN", "ERROR"]; 4810 | ``` 4811 | ```