Skip to content

Commit 2b8e781

Browse files
committed
fix: pr comments
1 parent fb8fb9e commit 2b8e781

5 files changed

Lines changed: 18 additions & 43 deletions

File tree

packages/browser-sdk/src/client.ts

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -295,19 +295,7 @@ export type InitOptions = ReflagDeprecatedContext & {
295295
* Defaults to `StorageOverridesProvider` using local storage.
296296
*/
297297
overridesProvider?: OverridesProvider;
298-
};
299298

300-
/**
301-
* Init options for bootstrapped flags.
302-
*/
303-
export type InitOptionsBootstrapped = Omit<
304-
InitOptions,
305-
| "fallbackFlags"
306-
| "timeoutMs"
307-
| "staleWhileRevalidate"
308-
| "staleTimeMs"
309-
| "expireTimeMs"
310-
> & {
311299
/**
312300
* Pre-fetched flags to be used instead of fetching them from the server.
313301
*/
@@ -316,13 +304,9 @@ export type InitOptionsBootstrapped = Omit<
316304
/**
317305
* Pre-fetched flag overrides to be used instead of reading them from the client.
318306
*/
319-
bootstrappedOverrides: FlagOverrides;
307+
bootstrappedOverrides?: FlagOverrides;
320308
};
321309

322-
function isBootstrapped(opts: InitOptions): opts is InitOptionsBootstrapped {
323-
return "bootstrappedFlags" in opts;
324-
}
325-
326310
const defaultConfig: Config = {
327311
apiBaseUrl: API_BASE_URL,
328312
appBaseUrl: APP_BASE_URL,
@@ -418,7 +402,7 @@ export class ReflagClient {
418402
/**
419403
* Create a new ReflagClient instance.
420404
*/
421-
constructor(opts: InitOptions | InitOptionsBootstrapped) {
405+
constructor(opts: InitOptions) {
422406
this.publishableKey = opts.publishableKey;
423407
this.logger =
424408
opts?.logger ?? loggerWithPrefix(quietConsoleLogger, "[Reflag]");
@@ -453,22 +437,17 @@ export class ReflagClient {
453437
this.httpClient,
454438
this.context,
455439
this.logger,
456-
isBootstrapped(opts)
457-
? {
458-
bootstrappedFlags: opts.bootstrappedFlags,
459-
bootstrappedOverrides: opts.bootstrappedOverrides,
460-
offline: this.config.offline,
461-
overridesProvider: opts.overridesProvider,
462-
}
463-
: {
464-
expireTimeMs: opts.expireTimeMs,
465-
staleTimeMs: opts.staleTimeMs,
466-
staleWhileRevalidate: opts.staleWhileRevalidate,
467-
timeoutMs: opts.timeoutMs,
468-
fallbackFlags: opts.fallbackFlags,
469-
offline: this.config.offline,
470-
overridesProvider: opts.overridesProvider,
471-
},
440+
{
441+
bootstrappedFlags: opts.bootstrappedFlags,
442+
bootstrappedOverrides: opts.bootstrappedOverrides,
443+
expireTimeMs: opts.expireTimeMs,
444+
staleTimeMs: opts.staleTimeMs,
445+
staleWhileRevalidate: opts.staleWhileRevalidate,
446+
timeoutMs: opts.timeoutMs,
447+
fallbackFlags: opts.fallbackFlags,
448+
offline: this.config.offline,
449+
overridesProvider: opts.overridesProvider,
450+
},
472451
);
473452

474453
if (
@@ -544,7 +523,6 @@ export class ReflagClient {
544523
this.logger.error("error sending company", e);
545524
});
546525
}
547-
this.config.bootstrapped = true;
548526
}
549527

550528
this.logger.info(

packages/browser-sdk/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ export type {
33
Flag,
44
FlagRemoteConfig,
55
InitOptions,
6-
InitOptionsBootstrapped,
76
ToolbarOptions,
87
} from "./client";
98
export { ReflagClient } from "./client";

packages/react-sdk/dev/nextjs-bootstrap-demo/app/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export async function getServerClient() {
3535

3636
/**
3737
* Get flag overrides from the NextJS cookies.
38+
* This requires the overrides provider to be set in the client.
3839
* @returns The parsed overrides object
3940
*/
4041
export async function getFlagOverrides(): Promise<

packages/react-sdk/dev/nextjs-bootstrap-demo/app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Image from "next/image";
22
import { Flags } from "@/components/Flags";
33

4-
export default function Home() {
4+
export default async function Home() {
55
return (
66
<main className="flex min-h-screen flex-col items-center justify-between p-24">
77
<div className="z-10 w-full max-w-5xl items-center justify-between font-mono text-sm lg:flex">

packages/react-sdk/src/index.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
CompanyContext,
1515
FlagOverrides,
1616
InitOptions,
17-
InitOptionsBootstrapped,
1817
RawFlags,
1918
ReflagClient,
2019
ReflagContext,
@@ -143,10 +142,7 @@ const reflagClients = new Map<string, ReflagClient>();
143142
* Only creates a new ReflagClient is not already created or if it hook is run on the server.
144143
* @internal
145144
*/
146-
function useReflagClient(
147-
initOptions: InitOptions | InitOptionsBootstrapped,
148-
debug = false,
149-
) {
145+
function useReflagClient(initOptions: InitOptions, debug = false) {
150146
const isServer = typeof window === "undefined";
151147
if (isServer || !reflagClients.has(initOptions.publishableKey)) {
152148
const client = new ReflagClient({
@@ -283,9 +279,10 @@ export function ReflagProvider({
283279
* Props for the ReflagBootstrappedProvider.
284280
*/
285281
export type ReflagBootstrappedProps = Omit<
286-
InitOptionsBootstrapped,
282+
InitOptions,
287283
| "user"
288284
| "company"
285+
| "other"
289286
| "otherContext"
290287
| "bootstrappedFlags"
291288
| "bootstrappedOverrides"

0 commit comments

Comments
 (0)