@eightyfourthousand/lib-instr 2026.3.0 → 2026.4.0
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.
- package/README.md +4 -2
- package/package.json +1 -1
- package/src/lib/feature-flags.tsx +14 -0
- package/src/lib/static-features.ts +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
# lib-instr
|
|
1
|
+
# @eightyfourthousand/lib-instr
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Feature flag and instrumentation helpers for 84000 applications.
|
|
4
|
+
|
|
5
|
+
This package contains shared feature-gating and instrumentation utilities used by frontend applications and companion libraries.
|
|
4
6
|
|
|
5
7
|
## Running unit tests
|
|
6
8
|
|
package/package.json
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
import {
|
|
2
4
|
useFeatureFlagEnabled as phUseFeatureFlagEnabled,
|
|
3
5
|
useFeatureFlagPayload as phUseFeatureFlagPayload,
|
|
@@ -5,11 +7,13 @@ import {
|
|
|
5
7
|
PostHogFeatureProps,
|
|
6
8
|
} from '@posthog/react';
|
|
7
9
|
import { JsonType } from 'posthog-js';
|
|
10
|
+
import { useEffect, useState } from 'react';
|
|
8
11
|
|
|
9
12
|
export type FeatureFlag =
|
|
10
13
|
| 'authority-pages'
|
|
11
14
|
| 'translation-hover-cards'
|
|
12
15
|
| 'studio-header-config'
|
|
16
|
+
| 'show-reader-header'
|
|
13
17
|
| 'show-restriction-warning';
|
|
14
18
|
|
|
15
19
|
export type FeatureFlagPayload = {
|
|
@@ -57,7 +61,17 @@ export type GatedFeatureProps = PostHogFeatureProps & {
|
|
|
57
61
|
};
|
|
58
62
|
|
|
59
63
|
export const GatedFeature = ({ children, flag }: GatedFeatureProps) => {
|
|
64
|
+
const [isClient, setIsClient] = useState(false);
|
|
60
65
|
const enabled = useFeatureFlagEnabled(flag);
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
setIsClient(true);
|
|
69
|
+
}, []);
|
|
70
|
+
|
|
71
|
+
if (!isClient) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
61
75
|
return enabled ? children : null;
|
|
62
76
|
};
|
|
63
77
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
export type StaticFeature = 'glossary-attestations';
|
|
6
6
|
|
|
7
7
|
const STATIC_FEATURE_FLAGS: Record<StaticFeature, string[]> = {
|
|
8
|
-
'glossary-attestations': ['scholars-room'],
|
|
8
|
+
'glossary-attestations': ['scholars-room', 'studio', 'reader-embed'],
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export const isStaticFeatureEnabled = (flagKey: StaticFeature) => {
|