Skip to content

Commit ca5e7bc

Browse files
committed
docs: clarify end-user opt-in behavior
1 parent 1d65313 commit ca5e7bc

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

‎packages/browser-sdk/README.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,13 @@ await reflagClient.setOptIn("huddle", {
223223
});
224224
```
225225

226-
`scope` defaults to `"user"`. User scope requires a current `user.id`; company scope requires a current `company.id`. Setting `optedIn` to `false` cancels only the selected scope's opt-in, so cancelling user opt-in does not cancel matching company opt-in, and vice versa. After a successful mutation response, `setOptIn()` waits for the returned flag-state version, applies the refreshed flags locally, and synchronously notifies `flagsUpdated` listeners before its promise resolves. It rejects if the updated scoped membership cannot be confirmed in the SDK; the remote mutation may already have succeeded, so retrying the idempotent setter is safe. The `description` comes from the dedicated SDK-facing opt-in description configured in Reflag.
226+
By default, `setOptIn()` changes the opt-in for the current user, so the current context must include a `user.id`. To manage the current company's opt-in instead, pass `scope: "company"`; the context must then include a `company.id`.
227+
228+
User and company opt-ins are managed independently. Setting `optedIn` to `false` removes the opt-in only for the selected scope. For example, cancelling a user's opt-in does not change the company's opt-in for the same flag.
229+
230+
`setOptIn` returns a promise so you can wait for the new membership state to be synchronized. It resolves after the latest flag state has been applied locally, the requested membership change has been confirmed, and `flagsUpdated` listeners have been notified.
231+
232+
The `description` comes from the dedicated SDK-facing opt-in description configured in Reflag.
227233

228234
## Remote config
229235

‎packages/react-sdk/README.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,11 @@ function OptInList() {
676676
}
677677
```
678678
679-
`scope` defaults to `"user"`. User scope requires a current `user.id`; company scope requires a current `company.id`. Setting `optedIn` to `false` cancels only the selected scope's opt-in. For successful mutation responses, the returned promise resolves only after the Browser SDK has applied and confirmed the refreshed membership state and notified `useOptInFlags()`. React commits the resulting render using its normal scheduling.
679+
By default, `useSetOptIn()` changes the opt-in for the current user, so the current context must include a `user.id`. To manage the current company's opt-in instead, pass `scope: "company"`; the context must then include a `company.id`.
680+
681+
User and company opt-ins are managed independently. Setting `optedIn` to `false` removes the opt-in only for the selected scope. For example, cancelling a user's opt-in does not change the company's opt-in for the same flag.
682+
683+
`setOptIn` returns a promise so you can wait for the new membership state to be synchronized. It resolves after the latest flag state has been applied, the requested membership change has been confirmed, and components using `useOptInFlags()` have been notified. React schedules the resulting render normally, so it may not yet be committed when the promise resolves.
680684
681685
### `useTrack()`
682686

‎packages/vue-sdk/README.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,11 @@ const setOptIn = useSetOptIn();
414414
</template>
415415
```
416416

417-
`scope` defaults to `"user"`. User scope requires a current `user.id`; company scope requires a current `company.id`. Setting `optedIn` to `false` cancels only the selected scope's opt-in. For successful mutation responses, the returned promise resolves only after the Browser SDK has applied and confirmed the refreshed membership state and notified `useOptInFlags()`. Vue commits the resulting render using its normal scheduling.
417+
By default, `useSetOptIn()` changes the opt-in for the current user, so the current context must include a `user.id`. To manage the current company's opt-in instead, pass `scope: "company"`; the context must then include a `company.id`.
418+
419+
User and company opt-ins are managed independently. Setting `optedIn` to `false` removes the opt-in only for the selected scope. For example, cancelling a user's opt-in does not change the company's opt-in for the same flag.
420+
421+
`setOptIn` returns a promise so you can wait for the new membership state to be synchronized. It resolves after the latest flag state has been applied, the requested membership change has been confirmed, and components using `useOptInFlags()` have been notified. Vue schedules the resulting render normally, so it may not yet be committed when the promise resolves.
418422

419423
### `useTrack()`
420424

0 commit comments

Comments
 (0)