Skip to content

Commit 2c12569

Browse files
committed
fix: type, exports, examples, and docs
1 parent 5cb8c91 commit 2c12569

7 files changed

Lines changed: 37 additions & 14 deletions

File tree

packages/browser-sdk/src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,8 @@ export class ReflagClient {
695695
* @param flags The flags to update.
696696
* @param triggerEvent Whether to trigger the `flagsUpdated` event.
697697
*/
698-
updateFlags(...args: Parameters<FlagsClient["setFetchedFlags"]>) {
699-
this.flagsClient.setFetchedFlags(...args);
698+
updateFlags(flags: RawFlags, triggerEvent = true) {
699+
this.flagsClient.setFetchedFlags(flags, triggerEvent);
700700
}
701701

702702
/**

packages/browser-sdk/src/context.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
* Context is a set of key-value pairs.
3+
* This is used to determine if feature targeting matches and to track events.
34
* Id should always be present so that it can be referenced to an existing company.
45
*/
56
export interface CompanyContext {
@@ -19,6 +20,11 @@ export interface CompanyContext {
1920
[key: string]: string | number | undefined;
2021
}
2122

23+
/**
24+
* Context is a set of key-value pairs.
25+
* This is used to determine if feature targeting matches and to track events.
26+
* Id should always be present so that it can be referenced to an existing user.
27+
*/
2228
export interface UserContext {
2329
/**
2430
* User id
@@ -41,6 +47,10 @@ export interface UserContext {
4147
[key: string]: string | number | undefined;
4248
}
4349

50+
/**
51+
* Context is a set of key-value pairs.
52+
* This is used to determine if feature targeting matches and to track events.
53+
*/
4454
export interface ReflagContext {
4555
/**
4656
* Company related context. If you provide `id` Reflag will enrich the evaluation context with
@@ -60,6 +70,10 @@ export interface ReflagContext {
6070
other?: Record<string, string | number | undefined>;
6171
}
6272

73+
/**
74+
* @deprecated Use `ReflagContext` instead, this interface will be removed in the next major version
75+
* @internal
76+
*/
6377
export interface ReflagDeprecatedContext extends ReflagContext {
6478
/**
6579
* Context which is not related to a user or a company.

packages/browser-sdk/src/hooksManager.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { CheckEvent, RawFlags } from "./flag/flags";
22
import { CompanyContext, UserContext } from "./context";
33

4+
/**
5+
* State of the client.
6+
*/
47
export type State = "idle" | "initializing" | "initialized" | "stopped";
58

69
export interface HookArgs {

packages/browser-sdk/src/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ export type {
66
ToolbarOptions,
77
} from "./client";
88
export { ReflagClient } from "./client";
9-
export type { CompanyContext, ReflagContext, UserContext } from "./context";
9+
export type {
10+
CompanyContext,
11+
ReflagContext,
12+
ReflagDeprecatedContext,
13+
UserContext,
14+
} from "./context";
1015
export type {
1116
Feedback,
1217
FeedbackOptions,
@@ -35,7 +40,7 @@ export type {
3540
RawFlag,
3641
RawFlags,
3742
} from "./flag/flags";
38-
export type { HookArgs, TrackEvent } from "./hooksManager";
43+
export type { HookArgs, State, TrackEvent } from "./hooksManager";
3944
export type { Logger } from "./logger";
4045
export { feedbackContainerId, propagatedEvents } from "./ui/constants";
4146
export type {

packages/react-sdk/src/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,10 @@ type ProviderContextType = {
172172

173173
const ProviderContext = createContext<ProviderContextType | null>(null);
174174

175-
type ReflagClientProviderProps = ReflagPropsBase & {
175+
/**
176+
* Props for the ReflagClientProvider.
177+
*/
178+
export type ReflagClientProviderProps = ReflagPropsBase & {
176179
client: ReflagClient;
177180
loadingComponent?: ReactNode;
178181
};

packages/vue-sdk/dev/plain/components/FlagsList.vue

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
style="margin-left: auto"
5151
@change="
5252
(e) => {
53-
const isChecked = e.target.checked;
53+
const isChecked = (e.target as HTMLInputElement).checked;
5454
const isEnabledOverride = flag.isEnabledOverride !== null;
5555
toggleFlag(flagKey, !isEnabledOverride ? isChecked : null);
5656
}
@@ -83,25 +83,20 @@
8383
</template>
8484

8585
<script setup lang="ts">
86-
import { computed, onMounted, ref } from "vue";
86+
import { computed, ref } from "vue";
8787
8888
import { useClient, useClientEvent } from "../../../src";
8989
9090
import Section from "./Section.vue";
9191
9292
const client = useClient();
93-
const flagsData = ref({});
93+
const flagsData = ref(client.getFlags());
9494
9595
// Update flags data when flags are updated
9696
function updateFlags() {
9797
flagsData.value = client.getFlags();
9898
}
9999
100-
// Initial load
101-
onMounted(() => {
102-
updateFlags();
103-
});
104-
105100
// Update flags data when flags are updated
106101
useClientEvent("flagsUpdated", updateFlags);
107102
@@ -114,7 +109,7 @@ function resetOverride(flagKey: string) {
114109
updateFlags();
115110
}
116111
117-
function toggleFlag(flagKey: string, checked: boolean) {
112+
function toggleFlag(flagKey: string, checked: boolean | null) {
118113
// Use simplified logic similar to React implementation
119114
client.getFlag(flagKey).setIsEnabledOverride(checked);
120115
updateFlags();

packages/vue-sdk/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ export type {
2020
BootstrappedFlags,
2121
EmptyFlagRemoteConfig,
2222
Flag,
23+
Flags,
2324
FlagType,
2425
ReflagBootstrappedProps,
26+
ReflagInitOptionsBase,
2527
ReflagProps,
2628
RequestFlagFeedbackOptions,
29+
TypedFlags,
2730
} from "./types";
2831
export type {
2932
CheckEvent,

0 commit comments

Comments
 (0)