@betterbugs/web-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,146 @@
1
+ # BetterBugs Web SDK
2
+
3
+ **Simplify bug reporting within your web apps with the BetterBugs Web SDK.**
4
+
5
+ The BetterBugs Web SDK allows you to include bug reporting capabilities in your application with minimal settings and effort.
6
+
7
+ Now, you can enhance your apps with user-friendly and easy-to-implement issue reporting capabilities, such as media capturing, log tracking, getting the two-minute Rewind session video, and real-time hooks to help you and your team report, diagnose, and fix issues effectively.
8
+
9
+ ---
10
+
11
+ ## πŸ” Breaking it down
12
+
13
+ Using the BetterBugs Web SDK, you can enhance your web apps with bug reporting features that allow you to capture useful data about the issues. Here’s more on it.
14
+
15
+ ---
16
+
17
+ ## πŸš€ Key Features of the SDK
18
+
19
+ - **Seamless integration** β€” Quick installation and easy to use with a few lines of code.
20
+ - **Configurable params** β€” Tweak settings for the parameters, such as `metaData`, `recordType`, `enableAnnotation`, and many others.
21
+ - **Use Methods** β€” Control the SDK with programmatic methods, such as `show()`, `hide()`, `startRecording()`, and many others.
22
+ - **Event hooks** β€” For deeper integration, listen for specific lifecycle events with hooks, such as:
23
+ - after a screenshot is captured (`onScreenshot`)
24
+ - a bug is submitted (`onBugSubmit`)
25
+ - a recording starts (`onRecordingStop`)
26
+ - and many others.
27
+ - **Session Rewind (coming soon)** – Automatically records the last 2 minutes of a session to capture all user interactions.
28
+ - **Floating widget customization** – Control the widget’s look and placement.
29
+
30
+ ---
31
+
32
+ ## πŸ“¦ Quick Installation
33
+
34
+ ### NPM install
35
+
36
+ ```bash
37
+ npm install @betterbugs/web-sdk
38
+ ```
39
+
40
+ ### Yarn install
41
+
42
+ ```bash
43
+ yarn add @betterbugs/web-sdk
44
+ ```
45
+
46
+ ---
47
+
48
+ ## 🧩 BetterBugs Web SDK Initialization: Usage Example
49
+
50
+ ```ts
51
+ import { Betterbugs } from '@betterbugs/web-sdk';
52
+
53
+ const bb = new Betterbugs({
54
+ apiKey: process.env.TEST_API_KEY || '',
55
+ metaData: { userID: 124 },
56
+ captureRewindOnScreenshot: true,
57
+ recordType: 'recordVideo',
58
+ position: {
59
+ top: '10px',
60
+ left: '20px',
61
+ },
62
+ mode: 'development',
63
+ enableRewind: true,
64
+ enableAnnotation: true,
65
+ showActionButton: true,
66
+ });
67
+ ```
68
+
69
+ ---
70
+
71
+ ## βœ… Quick Overview of the Example Code
72
+
73
+ 1. **Imports the Betterbugs SDK** β€” Pulls in Betterbugs from the `@betterbugs/web-sdk` package.
74
+ 2. **Creates a new instance (`bb`)** β€” The configuration object sets options for:
75
+ - `apiKey`: Get value from environment variable.
76
+ - `metaData`: Custom user information (`userID: 124`).
77
+ - `captureRewindOnScreenshot`: Enables rewind session event capture on screenshot.
78
+ - `recordType`: Uses `recordVideo` for media recording.
79
+ - `position`: Positions the widget.
80
+ - `mode`: Development mode for debugging.
81
+ - `enableRewind`: Enables rewind session video.
82
+ - `enableAnnotation`: Enables annotations.
83
+ - `showActionButton`: Displays floating action button.
84
+
85
+ ---
86
+
87
+ ## βš™οΈ Configurable Options
88
+
89
+ | Option | Type | Description |
90
+ | --------------------------- | ------------------------------------------------------------------ | ---------------------------------------------------------- |
91
+ | `apiKey` | `string` | Project-specific API\* (required) |
92
+ | `metaData` | `array<object>` | Custom metadata (e.g., `{ userId: 123 }`) |
93
+ | `captureRewindOnScreenshot` | `boolean` | Attach rewind session to screenshots |
94
+ | `recordType` | `"recordVideo" \| "domRecord"` | Recording type: media (`recordVideo`) or DOM (`domRecord`) |
95
+ | `enableRewind` | `boolean` | Enable rewind session capturing |
96
+ | `enableAnnotation` | `boolean` | Enable annotation tools |
97
+ | `showActionButton` | `boolean` | Toggle visibility of floating action button |
98
+ | `position` | `{ top?: string, left?: string, right?: string, bottom?: string }` | Widget position |
99
+ | `mode` | `"development" \| "production"` | Mode of operation (debugging or live use) |
100
+
101
+ ---
102
+
103
+ ## πŸ§ͺ Programmatic Methods
104
+
105
+ | Method | Description |
106
+ | --------------------- | ------------------------------- |
107
+ | `show()` | Show the floating widget |
108
+ | `hide()` | Hide the floating widget |
109
+ | `openWidget()` | Open the bug report widget |
110
+ | `closeWidget()` | Close the bug report widget |
111
+ | `updateMetadata()` | Update the attached metadata |
112
+ | `captureScreenshot()` | Trigger screenshot capture |
113
+ | `startRecording()` | Start session recording |
114
+ | `stopRecording()` | Stop the ongoing recording |
115
+ | `on()` | Register an event listener |
116
+ | `off()` | Unregister an event listener |
117
+ | `destroy()` | Destroy the BetterBugs instance |
118
+
119
+ ---
120
+
121
+ ## πŸ”„ Lifecycle Event Hooks
122
+
123
+ | Event | Trigger Description |
124
+ | -------------------- | ------------------------------------------ |
125
+ | `onScreenshot` | Triggered after the screenshot is captured |
126
+ | `onRecordingStart` | Triggered when the recording starts |
127
+ | `onRecordingStop` | Triggered when the recording stops |
128
+ | `onBugSubmit` | Triggered after a bug is submitted |
129
+ | `onMetaDataUpdate` | Triggered when metadata is updated |
130
+ | `onPositionUpdate` | Triggered when widget position changes |
131
+ | `onWidgetOpen` | Triggered when the widget is opened |
132
+ | `onWidgetClose` | Triggered when the widget is closed |
133
+ | `onShowActionButton` | Triggered when the action button is shown |
134
+ | `onHideActionButton` | Triggered when the action button is hidden |
135
+ | `onSessionCreated` | Triggered when a new session is created |
136
+
137
+ ---
138
+
139
+ ## 🧱 Floating Widget Customization Options
140
+
141
+ - **Positioning** β€” Define widget position using `{ top, left, right, bottom }`
142
+ - **UI Customization** β€” Modify button styles, background, and primary colors (coming soon)
143
+
144
+ ---
145
+
146
+ > **Note**: Session Rewind and additional UI customization features are coming soon.