@lucida-analytics/react 0.1.0 → 0.1.1
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 +32 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @lucida-analytics/react
|
|
2
|
+
|
|
3
|
+
React 18+ provider and hooks over `@lucida-analytics/browser`. SSR-safe: the browser SDK is never touched on the server, and the
|
|
4
|
+
owned client is cached per `apiKey` so StrictMode double renders do not create two.
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
npm install @lucida-analytics/react @lucida-analytics/browser
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
import { LucidaProvider, useFeatureFlag, useCapture, FeatureGate } from "@lucida-analytics/react";
|
|
12
|
+
|
|
13
|
+
<LucidaProvider apiKey="lc_pk_..." options={{ apiHost: "https://<your capture host>" }}>
|
|
14
|
+
<App />
|
|
15
|
+
</LucidaProvider>;
|
|
16
|
+
|
|
17
|
+
function Buy() {
|
|
18
|
+
const capture = useCapture();
|
|
19
|
+
const variant = useFeatureFlag("new-checkout");
|
|
20
|
+
return <button onClick={() => capture("buy_clicked")}>{variant ? "New" : "Old"}</button>;
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
- `LucidaProvider` props: `apiKey`, `options` (browser SDK config), `client` (use an existing one), `bootstrapFlags` (server-resolved
|
|
25
|
+
flags: rendered on the server and the first client render, no flicker).
|
|
26
|
+
- Hooks: `useLucida()` (the client or `null`), `useCapture()`, `useFeatureFlag(key)` (the exposure is recorded after mount, never during
|
|
27
|
+
render), `useFeatureFlagVariant(key)`, `useFeatureFlagPayload(key)`, `useActiveFeatureFlags()`, `useReplay()` (start, stop, pause,
|
|
28
|
+
resume, tag, isRecording; inert on the server), `useEarlyAccess()` (`features`, `optIn`, `optOut`; needs the browser `earlyAccess` module).
|
|
29
|
+
- Components: `FeatureGate` (`flag`, `variant?`, `fallback?`), `Feature` (a flag-gated block that sends `$feature_view` once when it
|
|
30
|
+
scrolls into view and `$feature_interaction` on the first click; `trackView` and `trackInteraction` turn each off), `CaptureOnViewed`
|
|
31
|
+
(sends `$element_viewed`, or your `event`, when it becomes visible; `repeat` to send every time).
|
|
32
|
+
- Frameworks: `@lucida-analytics/next`, `@lucida-analytics/react-router` and `@lucida-analytics/tanstack-start` build on this package.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lucida-analytics/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
],
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": ">=18",
|
|
27
|
-
"@lucida-analytics/browser": "0.1.
|
|
27
|
+
"@lucida-analytics/browser": "^0.1.4"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/node": "^22.0.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"react": "^18.3.1",
|
|
35
35
|
"react-dom": "^18.3.1",
|
|
36
36
|
"tsup": "^8.5.0",
|
|
37
|
-
"@lucida-analytics/browser": "0.1.
|
|
37
|
+
"@lucida-analytics/browser": "0.1.4"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "tsup",
|