@crikket-io/capture 0.1.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 +203 -0
- package/dist/browser.d.ts +6 -0
- package/dist/browser.js +1 -0
- package/dist/capture-screenshot-b3snwyge.js +1 -0
- package/dist/capture.css +907 -0
- package/dist/capture.global.js +10 -0
- package/dist/constants.d.ts +7 -0
- package/dist/debugger/debugger-collector.d.ts +15 -0
- package/dist/debugger/lazy-debugger-collector.d.ts +12 -0
- package/dist/debugger-collector-f0etqtvj.js +2 -0
- package/dist/eager.d.ts +18 -0
- package/dist/global.d.ts +6 -0
- package/dist/index-0avnsp70.js +2 -0
- package/dist/index-331vjad4.js +2 -0
- package/dist/index-97c5xshv.js +2 -0
- package/dist/index-ehy0ec5e.js +2 -0
- package/dist/index-nd41xgv7.js +2 -0
- package/dist/index-shtqtrh3.js +2 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +2 -0
- package/dist/launcher.css +42 -0
- package/dist/media/capture-screenshot.d.ts +1 -0
- package/dist/media/display-capture.d.ts +6 -0
- package/dist/media/lazy-capture-media.d.ts +3 -0
- package/dist/media/start-display-recording.d.ts +2 -0
- package/dist/plugin.d.ts +5 -0
- package/dist/plugin.js +1 -0
- package/dist/react.d.ts +2 -0
- package/dist/react.js +1 -0
- package/dist/review-form-section-frr1x0zk.js +1 -0
- package/dist/runtime/capture-runtime.d.ts +36 -0
- package/dist/runtime/lazy-capture-runtime.d.ts +33 -0
- package/dist/runtime/submit-captured-report.d.ts +8 -0
- package/dist/start-display-recording-cve3f1me.js +1 -0
- package/dist/submit-captured-report-behdzdha.js +1 -0
- package/dist/transport/default-submit-transport.d.ts +2 -0
- package/dist/transport/turnstile.d.ts +20 -0
- package/dist/types.d.ts +165 -0
- package/dist/ui/capture-widget/capture-widget-root.d.ts +6 -0
- package/dist/ui/capture-widget/capture-widget-shell.d.ts +8 -0
- package/dist/ui/capture-widget/capture-widget-view.d.ts +7 -0
- package/dist/ui/capture-widget/components/capture-launcher-button.d.ts +5 -0
- package/dist/ui/capture-widget/components/icons.d.ts +8 -0
- package/dist/ui/capture-widget/components/media-preview.d.ts +6 -0
- package/dist/ui/capture-widget/components/primitives/badge.d.ts +5 -0
- package/dist/ui/capture-widget/components/primitives/button.d.ts +7 -0
- package/dist/ui/capture-widget/components/primitives/card.d.ts +11 -0
- package/dist/ui/capture-widget/components/primitives/cn.d.ts +1 -0
- package/dist/ui/capture-widget/components/primitives/field.d.ts +4 -0
- package/dist/ui/capture-widget/components/primitives/input.d.ts +1 -0
- package/dist/ui/capture-widget/components/primitives/label.d.ts +1 -0
- package/dist/ui/capture-widget/components/primitives/textarea.d.ts +1 -0
- package/dist/ui/capture-widget/components/screenshot-annotation-editor.d.ts +7 -0
- package/dist/ui/capture-widget/components/summary-stat.d.ts +4 -0
- package/dist/ui/capture-widget/hooks/use-capture-ui-handlers.d.ts +12 -0
- package/dist/ui/capture-widget/hooks/use-recording-clock.d.ts +4 -0
- package/dist/ui/capture-widget/hooks/use-review-form.d.ts +14 -0
- package/dist/ui/capture-widget/sections/chooser-section.d.ts +5 -0
- package/dist/ui/capture-widget/sections/recording-dock.d.ts +6 -0
- package/dist/ui/capture-widget/sections/review-form-section.d.ts +11 -0
- package/dist/ui/capture-widget/sections/success-section.d.ts +5 -0
- package/dist/ui/capture-widget/utils/get-view-description.d.ts +2 -0
- package/dist/ui/capture-widget/utils/review-form-schema.d.ts +22 -0
- package/dist/ui/capture-widget/utils/screenshot-annotations.d.ts +45 -0
- package/dist/ui/mount-capture-launcher.d.ts +11 -0
- package/dist/ui/mount-capture-ui.d.ts +2 -0
- package/dist/ui/store/capture-ui-store.d.ts +2 -0
- package/dist/ui/types.d.ts +63 -0
- package/dist/utils.d.ts +16 -0
- package/package.json +85 -0
- package/react.d.ts +2 -0
- package/react.js +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# @crikket-io/capture
|
|
2
|
+
|
|
3
|
+
Embeddable capture SDK for collecting bug reports from websites.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @crikket-io/capture
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bun add @crikket-io/capture
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
### 1. Create a public key
|
|
18
|
+
|
|
19
|
+
In Crikket, go to `Settings` -> `Public Keys`.
|
|
20
|
+
|
|
21
|
+
Create one public key per owned website or app surface, then add the exact
|
|
22
|
+
origins where the widget is allowed to run, for example:
|
|
23
|
+
|
|
24
|
+
- `https://example.com`
|
|
25
|
+
- `https://www.example.com`
|
|
26
|
+
- `http://localhost:3000`
|
|
27
|
+
|
|
28
|
+
Copy the generated public key after saving. Public keys are safe to embed in
|
|
29
|
+
client-side code.
|
|
30
|
+
|
|
31
|
+
### 2. Initialize the widget on your site
|
|
32
|
+
|
|
33
|
+
Call `init()` from a browser entrypoint in your app:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { init } from "@crikket-io/capture"
|
|
37
|
+
|
|
38
|
+
init({
|
|
39
|
+
key: "crk_your_public_key",
|
|
40
|
+
host: "https://api.crikket.io",
|
|
41
|
+
})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
If you are using Crikket Cloud, `host` defaults to `https://api.crikket.io`.
|
|
45
|
+
If you are self-hosting Crikket, pass your own app origin:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { init } from "@crikket-io/capture"
|
|
49
|
+
|
|
50
|
+
init({
|
|
51
|
+
key: "crk_your_public_key",
|
|
52
|
+
host: "https://crikket.your-company.com",
|
|
53
|
+
})
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
That mounts the floating launcher and lets users capture a screenshot or screen
|
|
57
|
+
recording, fill out the report form, and submit directly from your site.
|
|
58
|
+
|
|
59
|
+
## Usage
|
|
60
|
+
|
|
61
|
+
### `init()` in any browser app
|
|
62
|
+
|
|
63
|
+
Use `init()` when you want the smallest integration surface. Run it once in a
|
|
64
|
+
browser-only entrypoint.
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { init } from "@crikket-io/capture"
|
|
68
|
+
|
|
69
|
+
init({
|
|
70
|
+
key: "crk_your_public_key",
|
|
71
|
+
host: "https://api.crikket.io",
|
|
72
|
+
})
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Available options:
|
|
76
|
+
|
|
77
|
+
- `key`: required public key from Crikket `Settings` -> `Public Keys`
|
|
78
|
+
- `host`: optional Crikket API origin; defaults to `https://api.crikket.io`
|
|
79
|
+
- `autoMount`: mount automatically on init; defaults to `true`
|
|
80
|
+
- `mountTarget`: custom element to mount into; defaults to `document.body`
|
|
81
|
+
- `submitPath`: custom bug report base path; defaults to `/api/embed/bug-reports`
|
|
82
|
+
- `zIndex`: custom widget stacking order
|
|
83
|
+
|
|
84
|
+
`submitPath` is used as the base path for the capture control-plane flow. By
|
|
85
|
+
default the SDK derives these routes from `/api/embed/bug-reports`:
|
|
86
|
+
|
|
87
|
+
- `/api/embed/capture-token`
|
|
88
|
+
- `/api/embed/bug-report-upload-session`
|
|
89
|
+
- `/api/embed/bug-report-finalize`
|
|
90
|
+
|
|
91
|
+
The package also exports runtime controls if you need them:
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
import { close, init, open } from "@crikket-io/capture"
|
|
95
|
+
|
|
96
|
+
init({
|
|
97
|
+
key: "crk_your_public_key",
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
open()
|
|
101
|
+
close()
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Next.js 15.3+ with `instrumentation-client.ts`
|
|
105
|
+
|
|
106
|
+
For Next.js 15.3 and newer, initialize the SDK once in
|
|
107
|
+
`instrumentation-client.ts` so it runs globally in the browser.
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
import { init } from "@crikket-io/capture"
|
|
111
|
+
|
|
112
|
+
const capturePublicKey = process.env.NEXT_PUBLIC_CRIKKET_KEY
|
|
113
|
+
|
|
114
|
+
if (capturePublicKey) {
|
|
115
|
+
init({
|
|
116
|
+
key: capturePublicKey,
|
|
117
|
+
host: process.env.NEXT_PUBLIC_CRIKKET_HOST ?? "https://api.crikket.io",
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Example file:
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
// instrumentation-client.ts
|
|
126
|
+
import { init } from "@crikket-io/capture"
|
|
127
|
+
|
|
128
|
+
const capturePublicKey = process.env.NEXT_PUBLIC_CRIKKET_KEY
|
|
129
|
+
|
|
130
|
+
if (capturePublicKey) {
|
|
131
|
+
init({
|
|
132
|
+
key: capturePublicKey,
|
|
133
|
+
host: process.env.NEXT_PUBLIC_CRIKKET_HOST ?? "https://api.crikket.io",
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Recommended environment variables:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
NEXT_PUBLIC_CRIKKET_KEY=crk_your_public_key
|
|
142
|
+
NEXT_PUBLIC_CRIKKET_HOST=https://api.crikket.io
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
If you are using Crikket Cloud, you can omit
|
|
146
|
+
`NEXT_PUBLIC_CRIKKET_HOST` and just pass the public key.
|
|
147
|
+
|
|
148
|
+
### React integration
|
|
149
|
+
|
|
150
|
+
If you prefer a React-native integration point, use the plugin from
|
|
151
|
+
`@crikket-io/capture/react` and mount it once near your app root.
|
|
152
|
+
|
|
153
|
+
```tsx
|
|
154
|
+
"use client"
|
|
155
|
+
|
|
156
|
+
import { CapturePlugin } from "@crikket-io/capture/react"
|
|
157
|
+
|
|
158
|
+
export function AppProviders(): React.JSX.Element {
|
|
159
|
+
return (
|
|
160
|
+
<>
|
|
161
|
+
<CapturePlugin
|
|
162
|
+
host="https://api.crikket.io"
|
|
163
|
+
publicKey="crk_your_public_key"
|
|
164
|
+
/>
|
|
165
|
+
{/* rest of your app */}
|
|
166
|
+
</>
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
With environment variables:
|
|
172
|
+
|
|
173
|
+
```tsx
|
|
174
|
+
"use client"
|
|
175
|
+
|
|
176
|
+
import { CapturePlugin } from "@crikket-io/capture/react"
|
|
177
|
+
|
|
178
|
+
export function CaptureProvider(): React.JSX.Element | null {
|
|
179
|
+
const publicKey = process.env.NEXT_PUBLIC_CRIKKET_KEY
|
|
180
|
+
|
|
181
|
+
if (!publicKey) {
|
|
182
|
+
return null
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<CapturePlugin
|
|
187
|
+
host={process.env.NEXT_PUBLIC_CRIKKET_HOST ?? "https://api.crikket.io"}
|
|
188
|
+
publicKey={publicKey}
|
|
189
|
+
/>
|
|
190
|
+
)
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
`CapturePlugin` accepts the same options as `init()`, except it uses
|
|
195
|
+
`publicKey` instead of `key`.
|
|
196
|
+
|
|
197
|
+
## Notes
|
|
198
|
+
|
|
199
|
+
- Public keys should be scoped per website or app surface.
|
|
200
|
+
- Allowed origins should be exact HTTP(S) origins, including local development
|
|
201
|
+
origins you want to permit.
|
|
202
|
+
- The SDK must run in a browser environment.
|
|
203
|
+
- Browser permission prompts for screen capture are expected platform behavior.
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,b as i,c as o,d as r,e as a,f as n,g as p,h as s,i as u,j as l,k as d,l as f,m as c}from"./index.js";import"./index-shtqtrh3.js";import{G as t}from"./index-0avnsp70.js";import"./index-ehy0ec5e.js";import"./index-97c5xshv.js";import"./index-331vjad4.js";var m={close:a,defaultSubmitTransport:t,destroy:n,getConfig:c,init:e,isInitialized:f,mount:i,open:r,reset:d,startRecording:p,stopRecording:s,submit:l,takeScreenshot:u,unmount:o};if(typeof window<"u")window.CrikketCapture=m;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as c,o as s,p as d,q as h,s as l}from"./index-nd41xgv7.js";import"./index-331vjad4.js";async function m(){let t=await c(!1);s(t);let e=document.createElement("video");try{if(!t.getVideoTracks()[0])throw Error("No video track available for screenshot capture.");await d(e,t);let{videoWidth:a,videoHeight:o}=e;if(!(a>0&&o>0))throw Error("Captured screen dimensions were invalid.");let r=document.createElement("canvas");r.width=a,r.height=o;let i=r.getContext("2d");if(!i)throw Error("Failed to initialize screenshot canvas.");return i.drawImage(e,0,0,a,o),l(r,"image/png")}finally{h(e);for(let n of t.getTracks())n.stop()}}export{m as captureScreenshot};
|