@geejay/use-feature-flags 1.0.12 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,6 +13,9 @@ export function useFeatureFlags(passedKey, environment = window.location.hostnam
13
13
  const debounceTimeout = useRef(null);
14
14
  const cleanupRef = useRef();
15
15
  const apiKey = passedKey;
16
+ useEffect(() => {
17
+ console.log('[use-feature-flags] initializing', `environment: ${sanitizedEnvironment}`, `apiKey provided: ${Boolean(apiKey)}`);
18
+ }, [sanitizedEnvironment, apiKey]);
16
19
  const supabase = createClient(DEFAULT_SUPABASE_URL, DEFAULT_SUPABASE_KEY, {
17
20
  global: {
18
21
  headers: {
@@ -22,6 +25,7 @@ export function useFeatureFlags(passedKey, environment = window.location.hostnam
22
25
  });
23
26
  const fetchFlags = async () => {
24
27
  setState((prev) => ({ ...prev, loading: true }));
28
+ console.log('[use-feature-flags] fetching flags for', sanitizedEnvironment);
25
29
  try {
26
30
  const res = await fetch(EDGE_FN_URL, {
27
31
  method: 'POST',
@@ -39,7 +43,7 @@ export function useFeatureFlags(passedKey, environment = window.location.hostnam
39
43
  }
40
44
  const flags = json.flags || [];
41
45
  setState({ flags, loading: false });
42
- console.log(`Flags are cool man ${JSON.stringify(flags)}`);
46
+ console.log('[use-feature-flags] fetched flags', flags);
43
47
  // Store environment_id from first flag (assumes all have same env)
44
48
  if (flags.length > 0 && flags[0].environment_id) {
45
49
  setEnvId(flags[0].environment_id);
@@ -89,7 +93,11 @@ export function useFeatureFlags(passedKey, environment = window.location.hostnam
89
93
  };
90
94
  }, [envId]);
91
95
  return {
92
- isActive: (key) => state.flags.some((f) => f.key === key && f.enabled === true),
96
+ isActive: (key) => {
97
+ const active = state.flags.some((f) => f.key === key && f.enabled === true);
98
+ console.log('[use-feature-flags] isActive', key, active);
99
+ return active;
100
+ },
93
101
  flags: state.flags,
94
102
  loading: state.loading,
95
103
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geejay/use-feature-flags",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "React hook for feature flag management using Supabase",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",