@reproapp/react-sdk 0.0.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 ADDED
@@ -0,0 +1,119 @@
1
+ # Repro React SDK
2
+
3
+ Capture user sessions with rrweb, tie network requests to user actions, and share a viewer link for fast debugging.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm i repro-react rrweb
9
+ # or
10
+ yarn add repro-react rrweb
11
+ # or
12
+ pnpm add repro-react rrweb
13
+ ```
14
+
15
+ Peer requirements:
16
+ - react >= 17
17
+ - react-dom >= 17
18
+ - rrweb >= 1 < 2
19
+
20
+ ## Configure
21
+
22
+ 1) Get your `appId` and `tenantId` from Repro.
23
+ 2) Wrap your app with the provider.
24
+
25
+ ```tsx
26
+ import ReproProvider from "repro-react";
27
+
28
+ export default function App() {
29
+ return (
30
+ <ReproProvider appId="app_123" tenantId="tenant_abc">
31
+ <YourApp />
32
+ </ReproProvider>
33
+ );
34
+ }
35
+ ```
36
+
37
+ Optional configuration and full interface coverage:
38
+
39
+ ```tsx
40
+ import ReproProvider, { attachAxios, type MaskingOptions } from "repro-react";
41
+ import axios from "axios";
42
+
43
+ const masking: MaskingOptions = {
44
+ maskAllInputs: true,
45
+ maskTextSelector: ".pii",
46
+ maskInputOptions: { password: true },
47
+ };
48
+
49
+ const api = axios.create({ baseURL: "https://api.example.com" });
50
+ attachAxios(api);
51
+
52
+ export default function App() {
53
+ return (
54
+ <ReproProvider
55
+ appId="app_123"
56
+ tenantId="tenant_abc"
57
+ apiBase="https://repro.example.com"
58
+ button={{ text: "Report issue" }}
59
+ masking={masking}
60
+ >
61
+ <YourApp />
62
+ </ReproProvider>
63
+ );
64
+ }
65
+ ```
66
+
67
+ Notes:
68
+ - `apiBase` defaults to `http://localhost:4000`.
69
+ - `button.text` overrides the floating button label (same label for Record and Stop).
70
+ - `attachAxios` works with any Axios instance; `window.axios` is auto-attached if present.
71
+ - This SDK runs in the browser; for Next.js use a client component.
72
+
73
+ ## Run
74
+
75
+ 1) Start your app (for example, `npm run dev`).
76
+ 2) Open the page and click "Authenticate to Record".
77
+ 3) Sign in with your Repro user credentials.
78
+ 4) Click "Record", reproduce the issue, then click "Stop & Report".
79
+
80
+ ## Verify it works
81
+
82
+ - The floating controls appear at the bottom right. "Stop & Report" is visible while recording.
83
+ - After stopping, a share card appears with a viewer link you can copy.
84
+ - In DevTools -> Network, app requests include `X-Bug-Session-Id` and `X-Bug-Action-Id` while recording.
85
+ - Requests to your `apiBase` succeed (for example, `POST /v1/sessions` and `POST /v1/sessions/:id/finish`).
86
+
87
+ ## API
88
+
89
+ ### ReproProvider
90
+
91
+ ```ts
92
+ type Props = {
93
+ appId: string;
94
+ tenantId: string;
95
+ apiBase?: string; // default: http://localhost:4000
96
+ children: React.ReactNode;
97
+ button?: { text?: string };
98
+ masking?: MaskingOptions;
99
+ };
100
+ ```
101
+
102
+ ### attachAxios
103
+
104
+ ```ts
105
+ attachAxios(axiosInstance: any): void
106
+ ```
107
+
108
+ Attach request/response interceptors to an Axios instance so it can inject
109
+ `X-Bug-Session-Id` and `X-Bug-Action-Id` during active recordings.
110
+
111
+ ### MaskingOptions
112
+
113
+ Supported rrweb masking options:
114
+ - `maskAllInputs`
115
+ - `maskTextClass`
116
+ - `maskTextSelector`
117
+ - `maskInputOptions`
118
+ - `maskInputFn`
119
+ - `maskTextFn`
@@ -0,0 +1,24 @@
1
+ import React from "react";
2
+ import { record } from "rrweb";
3
+ /**
4
+ * Repro React SDK (MVP)
5
+ * - Floating "Record / Stop & Report" button
6
+ * - Bootstrap -> start session -> rrweb capture
7
+ * - Intercepts window.fetch to inject X-Bug-Session-Id / X-Bug-Action-Id
8
+ * - Generates Action IDs on clicks; posts minimal action events
9
+ * - Uses ORIGINAL fetch for SDK-internal calls to avoid recursion
10
+ */
11
+ type RrwebRecordOptions = NonNullable<Parameters<typeof record>[0]>;
12
+ export type MaskingOptions = Pick<RrwebRecordOptions, "maskAllInputs" | "maskTextClass" | "maskTextSelector" | "maskInputOptions" | "maskInputFn" | "maskTextFn">;
13
+ type Props = {
14
+ appId: string;
15
+ children: React.ReactNode;
16
+ button?: {
17
+ text?: string;
18
+ };
19
+ masking?: MaskingOptions;
20
+ };
21
+ /** Manually attach Repro to any Axios instance (no recursion). */
22
+ export declare function attachAxios(axiosInstance: any): void;
23
+ export declare function ReproProvider({ appId, children, button, masking }: Props): import("react/jsx-runtime").JSX.Element;
24
+ export default ReproProvider;