@blipit/browser 0.3.3 → 0.3.7
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/CHANGELOG.md +15 -0
- package/README.md +110 -7
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.global.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +5 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
## 0.3.7
|
|
2
|
+
|
|
3
|
+
- `reportButton(options?)` returns the official Report a bug button: the Blipit icon and "Report a bug" in the visitor's language, `type="button"`, opens the reporter and shows a spinner (`aria-busy`) while it loads. Options: `label`, `variant` (`solid`, `outline`, `ghost`), `size` (`md`, `sm`), `theme` (`auto`, `light`, `dark`). Styles are scoped to `.blipit-rb` and injected once, so page CSS does not change the button and the button does not change the page.
|
|
4
|
+
- The script tag build loads the button's styles and icon from `blipit-button.js` next to `blipit.js` on first use, so `blipit.js` grows by about 0.2 KB gzipped; npm builds bundle them.
|
|
5
|
+
|
|
6
|
+
## 0.3.6
|
|
7
|
+
|
|
8
|
+
- The automatic screenshot no longer hangs on "Capturing screenshot…" when the page has a `<video>` that has nothing loaded or shows a live camera stream (`srcObject`). Those videos are left out of the screenshot. Any screenshot that takes longer than 20 seconds is abandoned, and the report can still be sent.
|
|
9
|
+
|
|
10
|
+
## 0.3.5
|
|
11
|
+
|
|
12
|
+
- `init` with an empty key logs one `[blipit]` warning instead of doing nothing; a secret key (`blipit_sk_`) is refused with a console error and nothing starts.
|
|
13
|
+
- With `debug: true`, the console says whether the Report a bug button was shown (and where), turned off by `feedbackWidget: false`, hidden by the project setting, or why the widget settings could not be loaded.
|
|
14
|
+
- `updateWidget(options)` changes the button while the page runs; `updateWidget(false)` removes it.
|
|
15
|
+
- `https://blipit.io/sdk/blipit.js` serves the latest version again, with `blipit-report.js` and `blipit-replay.js` next to it.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @blipit/browser
|
|
2
2
|
|
|
3
|
-
Blipit error monitoring SDK for browsers.
|
|
3
|
+
Blipit error monitoring SDK for browsers. 11 KB gzipped, with the Report a bug button. Know your app broke before your users tell you.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -8,20 +8,62 @@ Blipit error monitoring SDK for browsers. 9.6 KB gzipped, with the bug-report bu
|
|
|
8
8
|
npm install @blipit/browser
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
## Keys
|
|
12
|
+
|
|
13
|
+
Sign in at [app.blipit.io](https://app.blipit.io) and open **API keys**. Each project has two keys:
|
|
14
|
+
|
|
15
|
+
- **Public key** (`blipit_pk_...`): goes in browser code. It can only send events, so it is safe to show.
|
|
16
|
+
- **Secret key** (`blipit_sk_...`): servers and Odoo only. It is shown once when created; **Create a new secret key**
|
|
17
|
+
replaces it and stops the old one at once. `init` refuses a secret key with a console error.
|
|
18
|
+
|
|
19
|
+
With Vite, keep the public key in `.env` as `VITE_BLIPIT_KEY` (only `VITE_` variables reach the browser) and restart
|
|
20
|
+
the dev server after changing it. On Vercel or any other host, add the variable there and deploy again: `VITE_` and
|
|
21
|
+
`NEXT_PUBLIC_` values are written into the build. Keep `.env` files out of git.
|
|
22
|
+
|
|
11
23
|
## Quick start
|
|
12
24
|
|
|
13
25
|
```js
|
|
14
26
|
import * as Blipit from "@blipit/browser";
|
|
15
27
|
|
|
16
28
|
Blipit.init({
|
|
17
|
-
key:
|
|
18
|
-
endpoint: "https://your-ingest-host/api/v1/events",
|
|
29
|
+
key: import.meta.env.VITE_BLIPIT_KEY,
|
|
19
30
|
release: "myapp@1.4.2",
|
|
20
31
|
environment: "production",
|
|
21
32
|
});
|
|
22
33
|
```
|
|
23
34
|
|
|
24
|
-
|
|
35
|
+
Or without a bundler:
|
|
36
|
+
|
|
37
|
+
```html
|
|
38
|
+
<script src="https://blipit.io/sdk/blipit.js"></script>
|
|
39
|
+
<script>
|
|
40
|
+
Blipit.init({ key: "blipit_pk_your_public_key" });
|
|
41
|
+
</script>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`https://blipit.io/sdk/blipit.js` is always the latest version; `https://blipit.io/sdk/0.3.6/blipit.js` is pinned.
|
|
45
|
+
|
|
46
|
+
That's it. Uncaught errors and unhandled promise rejections are captured automatically, with breadcrumbs for clicks,
|
|
47
|
+
fetch calls, console errors/warnings, and SPA navigations. With no key, `init` logs a `[blipit]` warning and does
|
|
48
|
+
nothing else.
|
|
49
|
+
|
|
50
|
+
## Errors your framework catches
|
|
51
|
+
|
|
52
|
+
Frameworks catch errors inside components before the browser sees them. Pass them on:
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
createRoot(document.getElementById("root")!, {
|
|
56
|
+
onCaughtError: (error) => Blipit.captureException(error),
|
|
57
|
+
onUncaughtError: (error) => Blipit.captureException(error),
|
|
58
|
+
}).render(<App />);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
app.config.errorHandler = (err) => Blipit.captureException(err);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
React 18 and older: call `Blipit.captureException(error)` in an error boundary's `componentDidCatch`. Angular: a
|
|
66
|
+
custom `ErrorHandler` whose `handleError` calls `captureException`. SvelteKit: `handleError` in `src/hooks.client.ts`.
|
|
25
67
|
|
|
26
68
|
## Manual capture
|
|
27
69
|
|
|
@@ -85,14 +127,15 @@ key.
|
|
|
85
127
|
| `maxBreadcrumbs` | `50` | Ring buffer size, max 100 |
|
|
86
128
|
| `autoMuteExtensions` | `true` | Drop errors whose frames are all from browser extensions |
|
|
87
129
|
| `webVitals` | `true` | Report LCP, INP, CLS, FCP and TTFB once per page view to `/api/v1/vitals` |
|
|
88
|
-
| `feedbackWidget` | on |
|
|
130
|
+
| `feedbackWidget` | on | Report a bug button: `false` hides it, or `{ position, style, color, text, shortcut, src }`. See below |
|
|
131
|
+
| `theme` | `"auto"` | Reporter theme: `"light"`, `"dark"` or `"auto"` |
|
|
89
132
|
| `replay` | off | Session replay add-on: `{ sessionSampleRate: 0, onErrorSampleRate: 1, src }`. Loaded from `src` (default `blipit-replay.js` next to the core script, see below) only when a session is sampled |
|
|
90
133
|
| `user` | — | `{ id, name, email }` of the signed-in person, same as calling `setUser`; prefills the bug report form |
|
|
91
134
|
| `company` | — | Company name or `{ id, name }`, added to bug reports as `context.company` |
|
|
92
135
|
| `platform` | — | `"odoo"` adds Odoo context to bug reports (model, record id, view, action, menu; field and widget of the picked element) |
|
|
93
136
|
| `ignoreErrors` | built-in noise list | Extra strings/regexes to drop (matched on error message) |
|
|
94
137
|
| `beforeSend` | — | Inspect/modify the event; return `null` to drop it |
|
|
95
|
-
| `debug` | `false` | Log SDK activity to the console |
|
|
138
|
+
| `debug` | `false` | Log SDK activity to the console, including why the Report a bug button is shown or hidden |
|
|
96
139
|
|
|
97
140
|
## Bug reports
|
|
98
141
|
|
|
@@ -115,15 +158,59 @@ Blipit.init({
|
|
|
115
158
|
Blipit.openReport();
|
|
116
159
|
Blipit.attachReport(document.querySelector("#help-menu-report"));
|
|
117
160
|
Blipit.setReportMetadata(() => ({ plan: "pro", cartItems: cart.length }));
|
|
161
|
+
Blipit.updateWidget({ position: "middle-left" });
|
|
162
|
+
Blipit.updateWidget(false);
|
|
118
163
|
```
|
|
119
164
|
|
|
165
|
+
The official button: `reportButton(options?)` returns a `<button>` with the Blipit icon and "Report a bug" in the
|
|
166
|
+
visitor's language. It opens the reporter, shows a spinner while the reporter loads and carries its own scoped styles,
|
|
167
|
+
so the page's CSS does not change it and it does not change the page.
|
|
168
|
+
|
|
169
|
+
```js
|
|
170
|
+
document.querySelector("#help-menu").append(Blipit.reportButton());
|
|
171
|
+
document.querySelector("#toolbar").append(Blipit.reportButton({ variant: "outline", size: "sm" }));
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
- `variant`: `solid` (default), `outline` or `ghost`. `size`: `md` (default, 40 px) or `sm` (32 px).
|
|
175
|
+
- `theme`: `auto` (default, follows the page background), `light` or `dark`. `label` replaces the text in every language.
|
|
176
|
+
- With the script tag, the button's styles and icon come from `blipit-button.js` (about 3 KB gzipped) next to
|
|
177
|
+
`blipit.js`, so the core script stays small; the button is hidden until they load. With npm they are bundled.
|
|
178
|
+
- React: `<BlipitReportButton />` from `@blipit/nextjs` (Next.js) or `@blipit/nextjs/react` (any React app).
|
|
179
|
+
- The Blipit icon may only be used next to "Report a bug": https://blipit.io/docs/report-button#using-the-blipit-logo.
|
|
180
|
+
|
|
181
|
+
Your own button, in React or Vue:
|
|
182
|
+
|
|
183
|
+
```tsx
|
|
184
|
+
import { openReport } from "@blipit/browser";
|
|
185
|
+
|
|
186
|
+
export function ReportIssue() {
|
|
187
|
+
return <button onClick={() => openReport()}>Report Issue</button>;
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
```vue
|
|
192
|
+
<script setup lang="ts">
|
|
193
|
+
import { openReport } from "@blipit/browser";
|
|
194
|
+
</script>
|
|
195
|
+
|
|
196
|
+
<template>
|
|
197
|
+
<button @click="openReport()">Report Issue</button>
|
|
198
|
+
</template>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Call `setUser({ id, username, email })` after sign-in so the reporter's name and email are filled in and they get
|
|
202
|
+
status emails. Screenshots of every option and a live demo: https://blipit.io/docs/report-button. The mobile SDKs
|
|
203
|
+
have no report widget yet.
|
|
204
|
+
|
|
120
205
|
- `position` is `bottom-right` (default), `bottom-left`, `middle-right` or `middle-left`. `color` and
|
|
121
206
|
`text` override the defaults; the label is translated into the visitor's language otherwise. Options
|
|
122
207
|
passed in code win over the project settings.
|
|
123
208
|
- `style` is `label` (default: icon and text) or `icon` (a round icon-only button; the text stays as its
|
|
124
209
|
tooltip and accessible name). The dashboard has the same choice under Button style.
|
|
125
210
|
- `feedbackWidget: false` hides the button; `openReport()` and `attachReport()` keep working, so you
|
|
126
|
-
can open the reporter from your own menu.
|
|
211
|
+
can open the reporter from your own menu. Turning off "Show the bug report button" in the project's Bug report
|
|
212
|
+
widget settings also hides it. The SDK keeps the project settings for up to an hour.
|
|
213
|
+
- `updateWidget(options)` changes the button while the page runs; `updateWidget(false)` removes it.
|
|
127
214
|
- The button is in a shadow root, so the page's CSS cannot restyle it, and it shrinks to an icon on
|
|
128
215
|
screens narrower than 480 px.
|
|
129
216
|
- The editor is a separate file, `blipit-report.js` (about 75 KB gzipped), loaded on the first click.
|
|
@@ -156,6 +243,22 @@ the browser's screen-share prompt. The UI is translated into English, Arabic (ri
|
|
|
156
243
|
Spanish, French, Italian, Japanese, Dutch, Portuguese, Turkish and Chinese, picked from the browser
|
|
157
244
|
language, and follows the system light or dark theme.
|
|
158
245
|
|
|
246
|
+
## Content Security Policy
|
|
247
|
+
|
|
248
|
+
`script-src https://blipit.io` (the script tag, and the reporter and replay add-ons loaded on first use) and
|
|
249
|
+
`connect-src https://in.blipit.io https://*.r2.cloudflarestorage.com` (events, and screen recordings uploaded to
|
|
250
|
+
storage).
|
|
251
|
+
|
|
252
|
+
## Troubleshooting
|
|
253
|
+
|
|
254
|
+
No Report a bug button and no events? Open the console and look for `[blipit]` lines, with `debug: true` for more.
|
|
255
|
+
|
|
256
|
+
- The key is empty in the browser: the variable must start with `VITE_` (Vite) or `NEXT_PUBLIC_` (Next.js), the
|
|
257
|
+
dev server must be restarted after editing `.env`, and a deployed build must be rebuilt after the variable is added.
|
|
258
|
+
- A secret key (`blipit_sk_`) is refused; use the public key.
|
|
259
|
+
- "Show the bug report button" is off in the project settings, or the code passes `feedbackWidget: false`.
|
|
260
|
+
- An ad blocker blocks `in.blipit.io`, or the Content Security Policy above is missing.
|
|
261
|
+
|
|
159
262
|
## Built-in noise filtering
|
|
160
263
|
|
|
161
264
|
Dropped by default, before leaving the page: browser-extension stack traces, `ResizeObserver loop` warnings, cross-origin `Script error.`, and rapid duplicates of the same unhandled error (5-second window).
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)){if(!n||/^\s*(Error|TypeError|RangeError|SyntaxError|ReferenceError)\b/.test(n))continue;let i=Re.exec(n)??_e.exec(n);if(!i)continue;let[,r,a,d,c]=i;if(!a)continue;let s={filename:p(a,1024),in_app:Be(a)};r&&(s.function=p(r,512)),d&&(s.lineno=Number(d)),c&&(s.colno=Number(c)),t.push(s)}return t.reverse(),t.slice(-128)}function ne(e){return e.length===0?!1:e.every(t=>ee.test(t.filename))}var j="@blipit/browser",B="0.3.3",A=Q(typeof document<"u"?document.currentScript?.src:void 0,B),N="https://in.blipit.io/api/v1/events",Ce=[/ResizeObserver loop/i,/^Script error\.?$/,/__gCrWeb|__firefox__/],Le={login_failed:"Failed login",login_succeeded:"Successful login",login_blocked:"Blocked login",password_reset_requested:"Password reset requested",privilege_granted:"Privilege granted"},Ie={login_failed:"warning",login_succeeded:"info",login_blocked:"warning",password_reset_requested:"info",privilege_granted:"warning"};function Me(e){if(!J.includes(e?.kind))return;let t=p(String(e.actor??"").trim(),256);if(!t)return;let n={kind:e.kind,actor:t};return e.actorId&&(n.actor_id=p(String(e.actorId),128)),e.ip&&(n.ip=p(String(e.ip).trim(),45)),e.userAgent&&(n.user_agent=p(String(e.userAgent),512)),e.database&&(n.database=p(String(e.database),64)),e.outcome&&(n.outcome=p(String(e.outcome),64)),e.target&&(n.target=p(String(e.target),256)),n}var $=class{constructor(t){this.options=t;this.endpoint=t.endpoint??N,this.transport=new M(this.endpoint,t.key,t.debug??!1,t.instance),t.autoSessionTracking&&(t.release?this.session=new O(x(this.endpoint,"/api/v1/sessions"),t.key,t.release,t.environment??"production"):t.debug&&console.warn("[blipit] session tracking needs the release option")),this.maxBreadcrumbs=Math.min(t.maxBreadcrumbs??50,100),this.ignoreErrors=[...Ce,...t.ignoreErrors??[]]}options;transport;breadcrumbs=[];user;tags={};maxBreadcrumbs;ignoreErrors;seen=new Set;session;lastEventId;errorIds=[];logs={console:[],network:[],actions:[]};endpoint;replay;setUser(t){this.user=t,this.session?.setUser(t?.id??t?.email)}setTag(t,n){this.tags[p(t,64)]=p(n,256)}addBreadcrumb(t){let n={timestamp:y(),...t};n.message&&(n.message=Y(n.message)),n.data&&typeof n.data.url=="string"&&(n.data={...n.data,url:_(n.data.url)}),this.breadcrumbs.push(n),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift()}captureException(t,n=!0){let i=t instanceof Error?t:new Error(String(t)),r={type:i.name||"Error",value:p(i.message||String(i),4096),handled:n},a=te(i.stack);return a.length>0&&(r.stacktrace={frames:a}),this.processAndSend({exception:r,level:"error"})}captureMessage(t,n="info"){return this.processAndSend({message:p(t,8192),level:n})}captureSecurity(t){let n=Me(t);if(!n){this.options.debug&&console.warn("[blipit] security event dropped, needs a known kind and an actor");return}return this.processAndSend({message:`${Le[n.kind]} for ${n.actor}`,level:Ie[n.kind],security:n},!1)}processAndSend(t,n=!0){if(n&&this.options.sampleRate!==void 0&&Math.random()>this.options.sampleRate)return;let i=t.exception?.value??t.message??"";if(n){for(let c of this.ignoreErrors)if(typeof c=="string"?i.includes(c):c.test(i))return;if((this.options.autoMuteExtensions??!0)&&t.exception?.stacktrace&&ne(t.exception.stacktrace.frames))return;let d=`${t.exception?.type??""}|${i}`;if(t.exception?.handled===!1){if(this.seen.has(d)&&this.seen.size<100)return;this.seen.add(d),setTimeout(()=>this.seen.delete(d),5e3)}}let r={event_id:T(),timestamp:y(),platform:"javascript",release:this.options.release,environment:this.options.environment??"production",user:this.user,tags:Object.keys(this.tags).length>0?{...this.tags}:void 0,breadcrumbs:this.breadcrumbs.length>0?[...this.breadcrumbs]:void 0,request:typeof location<"u"?{url:_(location.href)}:void 0,contexts:this.collectContexts(),sdk:{name:j,version:B},...t};for(let d of Object.keys(r))r[d]===void 0&&delete r[d];let a=this.replay?.active()&&(r.level==="error"||r.level==="fatal")?this.replay:void 0;if(a&&(r.tags={...r.tags,replay_id:a.id}),this.options.beforeSend){let d=this.options.beforeSend(r);if(!d)return;r=d}return this.transport.enqueue(r),this.lastEventId=r.event_id,(r.level==="error"||r.level==="fatal")&&w(this.errorIds,r.event_id,20),r.exception&&this.session?.markError(r.exception.handled===!1),a?.error(r.event_id),r.event_id}collectContexts(){if(typeof navigator>"u")return;let t={},n=navigator.userAgent??"",i=/(Edg|OPR|Chrome|Firefox|Safari)\/(\d+[\d.]*)/.exec(n)??void 0;i&&(t.browser={name:i[1],version:i[2]});let r=/\(([^)]+)\)/.exec(n);return r&&r[1]&&(t.os={name:p(r[1],64)}),typeof screen<"u"&&(t.device={screen:`${screen.width}x${screen.height}`}),Object.keys(t).length>0?t:void 0}flush(){return this.transport.flush()}};function q(e){return typeof e=="string"?e.length:e?.size}function ie(e){return e&&Number(e)||void 0}function Oe(e,t){return async(n,i)=>{let r=typeof n=="string"?n:n instanceof URL?n.href:n.url,a=(i?.method??n.method??"GET").toUpperCase(),d=Date.now();try{let c=await e(n,i);return t(a,r,c.status,d,q(i?.body),ie(c.headers.get("content-length"))),c}catch(c){throw t(a,r,0,d,q(i?.body)),c}}}function $e(e,t){let n=e.open,i=e.send;e.open=function(r,a){return this._blipit=[String(r).toUpperCase(),String(a)],n.apply(this,arguments)},e.send=function(r){let a=this._blipit;if(a){let d=Date.now();this.addEventListener("loadend",()=>t(a[0],a[1],this.status,d,q(r),ie(this.getResponseHeader("content-length"))))}return i.apply(this,arguments)}}function re(e){if(typeof window>"u")return;let t=x(e.endpoint,""),{console:n,network:i,actions:r}=e.logs;window.addEventListener("error",s=>{e.captureException(s.error??s.message,!1)}),window.addEventListener("unhandledrejection",s=>{e.captureException(s.reason,!1)}),typeof document<"u"&&(document.addEventListener("click",s=>{let o=s.target;if(!(o instanceof Element)||o.closest("[data-blipit-ui]"))return;let u=K(o);e.addBreadcrumb({category:"ui.click",message:`Clicked ${u}`});let g=o.closest(G)?"***":p((o.textContent??"").trim().replace(/\s+/g," "),80);w(r,{timestamp:y(),type:"click",selector:u,text:g},50)},{capture:!0,passive:!0}),document.addEventListener("focusin",s=>{let o=s.target;o instanceof Element&&/^(INPUT|TEXTAREA|SELECT)$/.test(o.tagName)&&w(r,{timestamp:y(),type:"focus",selector:K(o)},50)},{capture:!0,passive:!0}));let a=(s,o,u,g,l,f)=>{t&&o.startsWith(t)||(e.addBreadcrumb({category:"http",message:`${s} ${_(o)} \u2192 ${u||"network error"}`,level:u>=400||!u?"error":"info",data:{url:_(o),method:s,status_code:u||void 0}}),w(i,{timestamp:y(),method:s,url:F(o),status:u,duration:Date.now()-g,request_size:l,response_size:f},50))};typeof window.fetch=="function"&&(window.fetch=Oe(window.fetch.bind(window),a)),typeof XMLHttpRequest<"u"&&$e(XMLHttpRequest.prototype,a);for(let s of["log","info","debug","warn","error"]){let o=console[s].bind(console);console[s]=(...u)=>{let g=p(u.map(l=>typeof l=="string"?l:Ae(l)).join(" "),1024);if(s==="warn"||s==="error"){e.addBreadcrumb({category:"console",level:s==="warn"?"warning":"error",message:g});let l=u.find(f=>f instanceof Error);w(n,{timestamp:y(),level:s,message:g,stack:p((l??new Error).stack??"",2e3)},100)}else w(n,{timestamp:y(),level:s,message:g},100);o(...u)}}let d=()=>w(r,{timestamp:y(),type:"navigation",url:F(location.href)},50),c=()=>{e.addBreadcrumb({category:"navigation",message:`Navigated to ${_(location.href)}`}),d()};if(d(),window.history){let s=window.history.pushState.bind(window.history);window.history.pushState=(...o)=>{s(...o),c()},window.addEventListener("popstate",c)}}function Ae(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function oe(){let e=0,t=0,n=0,i=0;return r=>(r.hadRecentInput||(t>0&&r.startTime-i<1e3&&r.startTime-n<5e3?t+=r.value:(t=r.value,n=r.startTime),i=r.startTime,t>e&&(e=t)),e)}function Ne(e){if(e.size===0)return;let t=[...e.values()].sort((n,i)=>i-n);return t[Math.min(t.length-1,Math.floor(e.size/50))]}function Ue(e){return/iPad|Tablet|Android(?!.*Mobile)/i.test(e)?"tablet":/Mobi|iPhone|Android/i.test(e)?"mobile":"desktop"}function I(e,t,n){try{new PerformanceObserver(i=>i.getEntries().forEach(r=>t(r))).observe({type:e,buffered:!0,...n})}catch{}}function se(e,t,n){if(typeof PerformanceObserver>"u"||typeof document>"u")return;let i=performance.getEntriesByType("navigation")[0],r=i?.activationStart??0,a=h=>Math.max(0,Math.round(h-r)),d=document.visibilityState==="hidden",c=location.pathname,s=i?.type,o={},u=oe(),g=new Map,l=!1,f=!1;i&&i.responseStart>0&&(o.ttfb=a(i.responseStart)),d||(I("paint",h=>{h.name==="first-contentful-paint"&&(o.fcp=a(h.startTime))}),I("largest-contentful-paint",h=>{l||(o.lcp=a(h.startTime))}));let E=()=>{l=!0};addEventListener("keydown",E,{once:!0,capture:!0}),addEventListener("pointerdown",E,{once:!0,capture:!0}),I("layout-shift",h=>{o.cls=Math.round(u(h)*1e4)/1e4});let b=h=>{if(!h.interactionId)return;g.set(h.interactionId,Math.max(g.get(h.interactionId)??0,h.duration));let V=Ne(g);V!==void 0&&(o.inp=Math.round(V))};I("event",b,{durationThreshold:40}),I("first-input",b);let R=navigator.connection?.effectiveType,k=`${new URL("/api/v1/vitals",e).href}?key=${encodeURIComponent(t)}${n?`&instance=${encodeURIComponent(n)}`:""}`,S=()=>{if(f||Object.keys(o).length===0)return;f=!0;let h=JSON.stringify({path:c.slice(0,512),metrics:o,nav:s,connection:R&&/^(slow-2g|2g|3g|4g)$/.test(R)?R:void 0,device:Ue(navigator.userAgent)});try{if(navigator.sendBeacon?.(k,h))return}catch{}fetch(k,{method:"POST",body:h,keepalive:!0}).catch(()=>{})},L=()=>{location.pathname!==c&&(S(),c=location.pathname,s="route",o={},u=oe(),g=new Map,l=!0,f=!1)};document.addEventListener("visibilitychange",()=>document.visibilityState==="hidden"&&S()),addEventListener("pagehide",S),addEventListener("popstate",L);let he=history.pushState;history.pushState=function(...h){he.apply(this,h),L()}}function Pe(e,t=Math.random){return t()<(e.sessionSampleRate??0)?"session":t()<(e.onErrorSampleRate??1)?"buffer":null}function ae(e,t,n,i,r){let a=Pe(e);if(!a||typeof document>"u")return;let d=T(),c,s=document.createElement("script");return s.src=e.src??`${r}blipit-replay.js`,s.async=!0,s.onload=()=>{let o=window.BlipitReplay?.start;c=o?.({id:d,mode:a,endpoint:t,key:n,instance:i})},document.head.appendChild(s),{id:d,active:()=>c?.active()??!1,error:o=>c?.error(o),report:o=>c?.report?.(o)}}function v(e,t,n){let i=document.createElement(e);return i.style.cssText=t,n!==void 0&&(i.textContent=n),i}var z="display:block;width:100%;box-sizing:border-box;margin:4px 0 12px;padding:8px 10px;font:inherit;border:1px solid #c5ccd6;border-radius:6px;background:#fff;color:#111",de="font:inherit;padding:8px 14px;border-radius:6px;cursor:pointer;border:1px solid #c5ccd6;background:#fff;color:#111",H=!1;function U(e,t,n){if(H||typeof document>"u"||!document.body)return;H=!0;let i=v("dialog","max-width:420px;width:calc(100% - 32px);padding:20px;border:1px solid #c5ccd6;border-radius:10px;font:14px/1.45 system-ui,sans-serif;color:#111;background:#fff");i.setAttribute("aria-labelledby","blipit-fb-title");let r=v("form","margin:0"),a=v("h2","margin:0 0 12px;font-size:17px",n.title??"Tell us what happened");a.id="blipit-fb-title";let d=(R,k,S)=>{let L=v("label","display:block;font-weight:600",R);L.htmlFor=S,k.id=S,r.append(L,k)},c=v("input",z);c.type="text",c.maxLength=128,c.autocomplete="name",c.value=n.name??"";let s=v("input",z);s.type="email",s.maxLength=254,s.autocomplete="email",s.value=n.email??"";let o=v("textarea",`${z};min-height:110px;resize:vertical`);o.required=!0,o.maxLength=5e3;let u=v("p","margin:0 0 12px;min-height:1.2em;font-size:13px");u.setAttribute("role","status"),u.setAttribute("aria-live","polite");let g=v("div","display:flex;gap:8px;justify-content:flex-end"),l=v("button",de,"Cancel");l.type="button";let f=v("button",`${de};background:#111;color:#fff;border-color:#111`,"Send");f.type="submit",r.append(a),d("Name (optional)",c,"blipit-fb-name"),d("Email (optional)",s,"blipit-fb-email"),d("What went wrong?",o,"blipit-fb-message"),g.append(l,f),r.append(u,g),i.append(r),document.body.append(i);let E=()=>{H=!1,i.remove()},b=()=>typeof i.close=="function"&&i.open?i.close():E();l.addEventListener("click",b),i.addEventListener("close",E),r.addEventListener("submit",async R=>{R.preventDefault();let k=o.value.trim();if(!k){u.textContent="Please describe what happened.",o.focus();return}f.disabled=!0,l.disabled=!0,f.setAttribute("aria-busy","true"),f.textContent="Sending\u2026",u.textContent="";try{let S=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":t},body:JSON.stringify({name:c.value.trim()||void 0,email:s.value.trim()||void 0,message:k,event_id:n.eventId,url:typeof location<"u"?location.href.split(/[?#]/)[0]:void 0})});if(!S.ok)throw new Error(String(S.status));u.textContent="Thanks, your message was sent.",f.textContent="Sent",setTimeout(b,1200)}catch{u.textContent="That did not send. Please try again.",f.disabled=!1,l.disabled=!1,f.removeAttribute("aria-busy"),f.textContent="Send"}}),typeof i.showModal=="function"?i.showModal():i.setAttribute("open",""),o.focus()}var ce={en:["Report a bug","Loading\u2026"],ar:["\u0623\u0628\u0644\u063A \u0639\u0646 \u062E\u0637\u0623","\u062C\u0627\u0631\u064D \u0627\u0644\u062A\u062D\u0645\u064A\u0644\u2026"],de:["Fehler melden","Wird geladen\u2026"],es:["Reportar un error","Cargando\u2026"],fr:["Signaler un bug","Chargement\u2026"],it:["Segnala un bug","Caricamento\u2026"],ja:["\u4E0D\u5177\u5408\u3092\u5831\u544A","\u8AAD\u307F\u8FBC\u307F\u4E2D\u2026"],nl:["Bug melden","Laden\u2026"],pt:["Reportar erro","Carregando\u2026"],tr:["Hata bildir","Y\xFCkleniyor\u2026"],zh:["\u62A5\u544A\u95EE\u9898","\u52A0\u8F7D\u4E2D\u2026"]},De="button{all:initial;position:fixed;z-index:2147483646;display:flex;align-items:center;gap:8px;padding:11px 18px;border-radius:99px;background:var(--c,linear-gradient(135deg,#3882F6,#2F5BEA));color:#fff;font:600 14px system-ui,-apple-system,sans-serif;letter-spacing:-.01em;cursor:pointer;box-shadow:0 14px 32px -12px rgba(56,130,246,.75),0 2px 6px rgba(11,26,58,.18),inset 0 1px 0 rgba(255,255,255,.22);transition:transform .2s,box-shadow .2s;animation:in .35s cubic-bezier(.2,.8,.2,1)}button:hover{transform:translateY(-2px);box-shadow:0 20px 40px -12px rgba(56,130,246,.85),0 3px 8px rgba(11,26,58,.2),inset 0 1px 0 rgba(255,255,255,.22)}button:active{transform:scale(.97)}button:focus-visible{outline:3px solid #00C2FF;outline-offset:3px}button:disabled{cursor:progress}svg,i{width:18px;height:18px}i{box-sizing:border-box;border:2px solid;border-right-color:transparent;border-radius:50%;animation:r .8s linear infinite}@keyframes r{to{transform:rotate(1turn)}}@keyframes in{from{opacity:0;transform:translateY(12px) scale(.94)}}.o span{display:none}.o{padding:13px}@media(max-width:480px){span{display:none}button{padding:13px}}@media(pointer:coarse){button{min-height:44px;box-sizing:border-box}}@media(prefers-reduced-motion:reduce){button{animation:none;transition:none}i{animation-duration:3s}}",Fe='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h16v12H9l-5 4zM12 7v4M12 13.5v.5"/></svg>',ue,X,pe,C,W=()=>{};function le(e){ue=e}function Ke(e){return X??=new Promise((t,n)=>{let i=document.createElement("script");i.src=e,i.async=!0,i.onload=()=>{let r=window.BlipitReport;r?t(r):n(new Error("report"))},i.onerror=n,document.head.appendChild(i)}).catch(t=>{throw X=void 0,t}),X}function P(e){if(typeof document>"u")return;let t=typeof e.options.feedbackWidget=="object"?e.options.feedbackWidget:{};W(!0),Promise.all([Ke(t.src??`${A}blipit-report.js`),pe??=fe(e)]).then(([n,i])=>i.enabled!==!1&&n.open(e,{metadata:ue,recording:i.recording===!0,recordingMaxMs:i.recording_max_ms,storageFull:i.storage_full===!0,reportsFull:i.reports_full===!0,theme:i.theme,hide:r=>C&&(C.style.display=r?"none":"")}),()=>U(x(e.endpoint,"/api/v1/feedback"),e.options.key,{eventId:e.lastEventId,name:e.user?.username,email:e.user?.email})).finally(()=>W(!1))}async function fe(e){let t=`blipit_fb_${B}_${e.options.key}`;try{let n=JSON.parse(localStorage.getItem(t)??"null");if(n&&Date.now()-n.t<36e5)return n.s}catch{}try{let n=await fetch(x(e.endpoint,"/api/v1/feedback/settings"),{headers:{"X-Blipit-Key":e.options.key,...e.options.instance?{"X-Blipit-Instance":e.options.instance}:{}}});if(!n.ok)return{};let i=await n.json();try{localStorage.setItem(t,JSON.stringify({t:Date.now(),s:i}))}catch{}return i}catch{return{}}}async function me(e){let t=e.options.feedbackWidget;if(t===!1||typeof document>"u")return;let n=await(pe??=fe(e));if(n.enabled===!1)return;let i={...n,...typeof t=="object"?t:{}},[r,a]=ce[(navigator.language??"en").slice(0,2)]??ce.en,d=i.text||r;C=document.createElement("div"),C.setAttribute("data-blipit-ui","");let c=C.attachShadow({mode:"open"}),s=document.createElement("style");s.textContent=De;let o=document.createElement("button");o.type="button";let[u,g]=(/^(bottom|middle)-(left|right)$/.test(i.position??"")?i.position:"bottom-right").split("-");o.style.cssText=`${i.color?`--c:${i.color};`:""}${g}:calc(20px + env(safe-area-inset-${g},0px));${u==="bottom"?"bottom:calc(20px + env(safe-area-inset-bottom,0px))":"top:50%;margin-top:-22px"}`,o.setAttribute("aria-haspopup","dialog"),i.style==="icon"&&(o.className="o",o.title=d);let l=b=>{o.disabled=b,o.setAttribute("aria-label",b?a:d),o.innerHTML=b?"<i></i><span></span>":`${Fe}<span></span>`,o.lastChild.textContent=b?a:d};W=l,l(!1),o.addEventListener("click",()=>P(e)),c.append(s,o);let f=i.shortcut?.toLowerCase().replace(/\s/g,"");f&&document.addEventListener("keydown",b=>{[b.ctrlKey&&"ctrl",b.shiftKey&&"shift",b.altKey&&"alt",b.metaKey&&"meta",b.key.toLowerCase()].filter(Boolean).join("+")===f&&(b.preventDefault(),P(e))});let E=()=>document.body.append(C);document.body?E():document.addEventListener("DOMContentLoaded",E)}var m;function je(e){if(!m){if(m=new $(e),e.user){let{id:t,name:n,email:i,username:r}=e.user;m.setUser({id:t===void 0?void 0:String(t),email:i,username:r??n})}re(m),e.webVitals!==!1&&typeof window<"u"&&se(e.endpoint??N,e.key,e.instance),e.replay&&(m.replay=ae(e.replay,e.endpoint??N,e.key,e.instance,A)),typeof window<"u"&&me(m),e.debug&&console.log(`[blipit] ${j}@${B} initialized`)}}function qe(e){return m?.captureException(e,!0)}function ze(e,t){return m?.captureMessage(e,t)}function He(e){return m?.captureSecurity(e)}function Xe(e){m?.setUser(e)}function We(e,t){m?.setTag(e,t)}function Ve(e){m?.addBreadcrumb(e)}function Je(e={}){m&&U(x(m.endpoint,"/api/v1/feedback"),m.options.key,{...e,eventId:e.eventId??m.lastEventId})}function ge(){m&&P(m)}function Ye(e){e.addEventListener("click",t=>{t.preventDefault(),ge()})}function Ge(){return m?.flush()??Promise.resolve()}0&&(module.exports={addBreadcrumb,attachReport,captureException,captureMessage,captureSecurity,flush,init,openReport,setReportMetadata,setTag,setUser,showFeedback});
|
|
1
|
+
"use strict";var j=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var Le=Object.getOwnPropertyNames;var Me=Object.prototype.hasOwnProperty;var Oe=(e,t)=>{for(var n in t)j(e,n,{get:t[n],enumerable:!0})},Ie=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Le(t))!Me.call(e,r)&&r!==n&&j(e,r,{get:()=>t[r],enumerable:!(i=Ce(t,r))||i.enumerable});return e};var Ae=e=>Ie(j({},"__esModule",{value:!0}),e);var vt={};Oe(vt,{addBreadcrumb:()=>ft,attachReport:()=>gt,captureException:()=>dt,captureMessage:()=>ct,captureSecurity:()=>ut,flush:()=>yt,init:()=>at,openReport:()=>ee,reportButton:()=>ht,setReportMetadata:()=>we,setTag:()=>lt,setUser:()=>pt,showFeedback:()=>mt,updateWidget:()=>bt});module.exports=Ae(vt);var ne=["login_failed","login_succeeded","login_blocked","password_reset_requested","privilege_granted"];var N=class{constructor(t,n,i,r){this.endpoint=t;this.key=n;this.debug=i;this.instance=r;typeof document<"u"&&document.addEventListener&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.flushWithBeacon()})}endpoint;key;debug;instance;queue=[];timer;sending=!1;enqueue(t){this.queue.push(t),this.queue.length>30&&this.queue.shift(),this.timer||(this.timer=setTimeout(()=>{this.timer=void 0,this.flush()},1e3))}async flush(){if(!this.sending){this.sending=!0;try{for(;this.queue.length>0;){let t=this.queue[0];if(!await this.send(t))break;this.queue.shift()}}finally{this.sending=!1}}}async send(t,n=0){try{let i=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":this.key,...this.instance?{"X-Blipit-Instance":this.instance}:{}},body:JSON.stringify(t),keepalive:!0});return i.status===429||i.status>=500?this.retry(t,n):(this.debug&&i.status>=400&&console.warn("[blipit] event rejected",i.status,await i.text()),!0)}catch{return this.retry(t,n)}}async retry(t,n){return n>=2?(this.debug&&console.warn("[blipit] dropping event after retries",t.event_id),!0):(await new Promise(i=>setTimeout(i,1e3*2**n)),this.send(t,n+1))}flushWithBeacon(){if(!(typeof navigator>"u"||!navigator.sendBeacon))for(;this.queue.length>0;){let t=this.queue.shift(),n=`key=${encodeURIComponent(this.key)}${this.instance?`&instance=${encodeURIComponent(this.instance)}`:""}`,i=`${this.endpoint}${this.endpoint.includes("?")?"&":"?"}${n}`;navigator.sendBeacon(i,JSON.stringify(t))}}};function L(){let e=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(e);else for(let n=0;n<16;n++)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0");return t}function v(){return new Date().toISOString()}var Ne=/token|key|password|secret|auth|session|passwd|api/i;function C(e){let t=e.indexOf("?");if(t===-1)return e.slice(0,2048);let n=e.slice(0,t),r=e.slice(t+1).split("&").map(o=>{let c=o.indexOf("=");if(c===-1)return o;let d=o.slice(0,c);return Ne.test(d)?`${d}=[redacted]`:o}).join("&");return`${n}?${r}`.slice(0,2048)}var Fe=/\b((?:[a-zA-Z0-9_-]*(?:token|key|password|secret|auth|session|passwd|api)[a-zA-Z0-9_-]*)=)[^&\s"']+/gi;function ie(e){return e.replace(Fe,"$1[redacted]")}function f(e,t){return e.length>t?e.slice(0,t):e}var re=".blipit-mask,[data-blipit-mask]";function q(e){return e.replace(/#.*/,"").replace(/([?&][^=&]*)=[^&]*/g,"$1=").slice(0,2048)}function E(e,t,n){e.push(t),e.length>n&&e.shift()}function W(e){let t=e.id?`#${e.id}`:"",n=typeof e.className=="string"&&e.className.trim()?`.${e.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";return f(`${e.tagName.toLowerCase()}${t}${n}`,128)}function S(e,t){return`${e.replace(/\/api\/v1\/events.*$/,"").replace(/\/$/,"")}${t}`}function oe(e,t){let n=e?/^(https?:\/\/[^?#]*\/)blipit(?:\.min)?\.js(?:[?#].*)?$/.exec(e):null;return n?n[1]:`https://blipit.io/sdk/${t}/`}function Ue(e){let t=e.match(/rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,\s/]+([\d.]+%?))?/);if(!t||(t[4]===void 0?1:t[4].endsWith("%")?parseFloat(t[4])/100:parseFloat(t[4]))<.5)return null;let[i,r,o]=[t[1],t[2],t[3]].map(c=>{let d=parseFloat(c)/255;return d<=.03928?d/12.92:((d+.055)/1.055)**2.4});return .2126*i+.7152*r+.0722*o}function se(e){if(e==="light"||e==="dark")return e;if(typeof document<"u"){for(let n of[document.body,document.documentElement]){if(!n)continue;let i=Ue(getComputedStyle(n).backgroundColor);if(i!==null)return i<.4?"dark":"light"}let t=getComputedStyle(document.documentElement).colorScheme;if(t==="dark")return"dark";if(t&&t!=="normal"&&!t.includes("dark"))return"light"}return typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var ae={ok:0,errored:1,crashed:2},F=class{constructor(t,n,i,r){this.url=t;this.key=n;this.release=i;this.environment=r;this.start(),typeof document<"u"&&document.addEventListener&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.end():this.sid||this.start()})}url;key;release;environment;sid="";started="";status="ok";errors=0;did;setUser(t){this.did=t}markError(t){if(!this.sid)return;this.errors+=1;let n=t?"crashed":"errored";ae[n]<=ae[this.status]||(this.status=n,this.send(!1))}start(){this.sid=L(),this.started=v(),this.status="ok",this.errors=0,this.send(!1)}end(){this.sid&&(this.send(!0),this.sid="")}send(t){let n=JSON.stringify({sid:this.sid,did:this.did,status:this.status==="ok"&&t?"exited":this.status,errors:this.errors,started:this.started,release:this.release,environment:this.environment}),i=`${this.url}?key=${encodeURIComponent(this.key)}`;try{if(t&&typeof navigator<"u"&&navigator.sendBeacon){navigator.sendBeacon(i,n);return}if(typeof fetch>"u")return;fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":this.key},body:n,keepalive:!0}).catch(()=>{})}catch{return}}};var Pe=/^\s*at (?:async )?(?:new )?(?:(.+?) )?\(?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack):.*?|[^()]+?)(?::(\d+))?(?::(\d+))?\)?\s*$/,De=/^\s*(?:(.*?)@)?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack).*?|[^@]*?)(?::(\d+))?(?::(\d+))?\s*$/,de=/^(chrome|moz|safari-web)-extension:/;function ze(){if(typeof location<"u"&&location.origin)return location.origin}function Ke(e){if(de.test(e)||e==="<anonymous>"||e==="[native code]")return!1;let t=ze();return!!(!t||e.startsWith(t)||!/^[a-z]+:/i.test(e))}function ce(e){if(!e)return[];let t=[];for(let n of e.split(`
|
|
2
|
+
`)){if(!n||/^\s*(Error|TypeError|RangeError|SyntaxError|ReferenceError)\b/.test(n))continue;let i=Pe.exec(n)??De.exec(n);if(!i)continue;let[,r,o,c,d]=i;if(!o)continue;let s={filename:f(o,1024),in_app:Ke(o)};r&&(s.function=f(r,512)),c&&(s.lineno=Number(c)),d&&(s.colno=Number(d)),t.push(s)}return t.reverse(),t.slice(-128)}function ue(e){return e.length===0?!1:e.every(t=>de.test(t.filename))}var H="@blipit/browser",M="0.3.7",P=oe(typeof document<"u"?document.currentScript?.src:void 0,M),D="https://in.blipit.io/api/v1/events",je=[/ResizeObserver loop/i,/^Script error\.?$/,/__gCrWeb|__firefox__/],qe={login_failed:"Failed login",login_succeeded:"Successful login",login_blocked:"Blocked login",password_reset_requested:"Password reset requested",privilege_granted:"Privilege granted"},We={login_failed:"warning",login_succeeded:"info",login_blocked:"warning",password_reset_requested:"info",privilege_granted:"warning"};function He(e){if(!ne.includes(e?.kind))return;let t=f(String(e.actor??"").trim(),256);if(!t)return;let n={kind:e.kind,actor:t};return e.actorId&&(n.actor_id=f(String(e.actorId),128)),e.ip&&(n.ip=f(String(e.ip).trim(),45)),e.userAgent&&(n.user_agent=f(String(e.userAgent),512)),e.database&&(n.database=f(String(e.database),64)),e.outcome&&(n.outcome=f(String(e.outcome),64)),e.target&&(n.target=f(String(e.target),256)),n}var U=class{constructor(t){this.options=t;this.endpoint=t.endpoint??D,this.transport=new N(this.endpoint,t.key,t.debug??!1,t.instance),t.autoSessionTracking&&(t.release?this.session=new F(S(this.endpoint,"/api/v1/sessions"),t.key,t.release,t.environment??"production"):t.debug&&console.warn("[blipit] session tracking needs the release option")),this.maxBreadcrumbs=Math.min(t.maxBreadcrumbs??50,100),this.ignoreErrors=[...je,...t.ignoreErrors??[]]}options;transport;breadcrumbs=[];user;tags={};maxBreadcrumbs;ignoreErrors;seen=new Set;session;lastEventId;errorIds=[];logs={console:[],network:[],actions:[]};endpoint;replay;setUser(t){this.user=t,this.session?.setUser(t?.id??t?.email)}setTag(t,n){this.tags[f(t,64)]=f(n,256)}addBreadcrumb(t){let n={timestamp:v(),...t};n.message&&(n.message=ie(n.message)),n.data&&typeof n.data.url=="string"&&(n.data={...n.data,url:C(n.data.url)}),this.breadcrumbs.push(n),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift()}captureException(t,n=!0){let i=t instanceof Error?t:new Error(String(t)),r={type:i.name||"Error",value:f(i.message||String(i),4096),handled:n},o=ce(i.stack);return o.length>0&&(r.stacktrace={frames:o}),this.processAndSend({exception:r,level:"error"})}captureMessage(t,n="info"){return this.processAndSend({message:f(t,8192),level:n})}captureSecurity(t){let n=He(t);if(!n){this.options.debug&&console.warn("[blipit] security event dropped, needs a known kind and an actor");return}return this.processAndSend({message:`${qe[n.kind]} for ${n.actor}`,level:We[n.kind],security:n},!1)}processAndSend(t,n=!0){if(n&&this.options.sampleRate!==void 0&&Math.random()>this.options.sampleRate)return;let i=t.exception?.value??t.message??"";if(n){for(let d of this.ignoreErrors)if(typeof d=="string"?i.includes(d):d.test(i))return;if((this.options.autoMuteExtensions??!0)&&t.exception?.stacktrace&&ue(t.exception.stacktrace.frames))return;let c=`${t.exception?.type??""}|${i}`;if(t.exception?.handled===!1){if(this.seen.has(c)&&this.seen.size<100)return;this.seen.add(c),setTimeout(()=>this.seen.delete(c),5e3)}}let r={event_id:L(),timestamp:v(),platform:"javascript",release:this.options.release,environment:this.options.environment??"production",user:this.user,tags:Object.keys(this.tags).length>0?{...this.tags}:void 0,breadcrumbs:this.breadcrumbs.length>0?[...this.breadcrumbs]:void 0,request:typeof location<"u"?{url:C(location.href)}:void 0,contexts:this.collectContexts(),sdk:{name:H,version:M},...t};for(let c of Object.keys(r))r[c]===void 0&&delete r[c];let o=this.replay?.active()&&(r.level==="error"||r.level==="fatal")?this.replay:void 0;if(o&&(r.tags={...r.tags,replay_id:o.id}),this.options.beforeSend){let c=this.options.beforeSend(r);if(!c)return;r=c}return this.transport.enqueue(r),this.lastEventId=r.event_id,(r.level==="error"||r.level==="fatal")&&E(this.errorIds,r.event_id,20),r.exception&&this.session?.markError(r.exception.handled===!1),o?.error(r.event_id),r.event_id}collectContexts(){if(typeof navigator>"u")return;let t={},n=navigator.userAgent??"",i=/(Edg|OPR|Chrome|Firefox|Safari)\/(\d+[\d.]*)/.exec(n)??void 0;i&&(t.browser={name:i[1],version:i[2]});let r=/\(([^)]+)\)/.exec(n);return r&&r[1]&&(t.os={name:f(r[1],64)}),typeof screen<"u"&&(t.device={screen:`${screen.width}x${screen.height}`}),Object.keys(t).length>0?t:void 0}flush(){return this.transport.flush()}};function X(e){return typeof e=="string"?e.length:e?.size}function pe(e){return e&&Number(e)||void 0}function Xe(e,t){return async(n,i)=>{let r=typeof n=="string"?n:n instanceof URL?n.href:n.url,o=(i?.method??n.method??"GET").toUpperCase(),c=Date.now();try{let d=await e(n,i);return t(o,r,d.status,c,X(i?.body),pe(d.headers.get("content-length"))),d}catch(d){throw t(o,r,0,c,X(i?.body)),d}}}function Ve(e,t){let n=e.open,i=e.send;e.open=function(r,o){return this._blipit=[String(r).toUpperCase(),String(o)],n.apply(this,arguments)},e.send=function(r){let o=this._blipit;if(o){let c=Date.now();this.addEventListener("loadend",()=>t(o[0],o[1],this.status,c,X(r),pe(this.getResponseHeader("content-length"))))}return i.apply(this,arguments)}}function le(e){if(typeof window>"u")return;let t=S(e.endpoint,""),{console:n,network:i,actions:r}=e.logs;window.addEventListener("error",s=>{e.captureException(s.error??s.message,!1)}),window.addEventListener("unhandledrejection",s=>{e.captureException(s.reason,!1)}),typeof document<"u"&&(document.addEventListener("click",s=>{let a=s.target;if(!(a instanceof Element)||a.closest("[data-blipit-ui]"))return;let u=W(a);e.addBreadcrumb({category:"ui.click",message:`Clicked ${u}`});let b=a.closest(re)?"***":f((a.textContent??"").trim().replace(/\s+/g," "),80);E(r,{timestamp:v(),type:"click",selector:u,text:b},50)},{capture:!0,passive:!0}),document.addEventListener("focusin",s=>{let a=s.target;a instanceof Element&&/^(INPUT|TEXTAREA|SELECT)$/.test(a.tagName)&&E(r,{timestamp:v(),type:"focus",selector:W(a)},50)},{capture:!0,passive:!0}));let o=(s,a,u,b,l,g)=>{t&&a.startsWith(t)||(e.addBreadcrumb({category:"http",message:`${s} ${C(a)} \u2192 ${u||"network error"}`,level:u>=400||!u?"error":"info",data:{url:C(a),method:s,status_code:u||void 0}}),E(i,{timestamp:v(),method:s,url:q(a),status:u,duration:Date.now()-b,request_size:l,response_size:g},50))};typeof window.fetch=="function"&&(window.fetch=Xe(window.fetch.bind(window),o)),typeof XMLHttpRequest<"u"&&Ve(XMLHttpRequest.prototype,o);for(let s of["log","info","debug","warn","error"]){let a=console[s].bind(console);console[s]=(...u)=>{let b=f(u.map(l=>typeof l=="string"?l:Ge(l)).join(" "),1024);if(s==="warn"||s==="error"){e.addBreadcrumb({category:"console",level:s==="warn"?"warning":"error",message:b});let l=u.find(g=>g instanceof Error);E(n,{timestamp:v(),level:s,message:b,stack:f((l??new Error).stack??"",2e3)},100)}else E(n,{timestamp:v(),level:s,message:b},100);a(...u)}}let c=()=>E(r,{timestamp:v(),type:"navigation",url:q(location.href)},50),d=()=>{e.addBreadcrumb({category:"navigation",message:`Navigated to ${C(location.href)}`}),c()};if(c(),window.history){let s=window.history.pushState.bind(window.history);window.history.pushState=(...a)=>{s(...a),d()},window.addEventListener("popstate",d)}}function Ge(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function fe(){let e=0,t=0,n=0,i=0;return r=>(r.hadRecentInput||(t>0&&r.startTime-i<1e3&&r.startTime-n<5e3?t+=r.value:(t=r.value,n=r.startTime),i=r.startTime,t>e&&(e=t)),e)}function Ye(e){if(e.size===0)return;let t=[...e.values()].sort((n,i)=>i-n);return t[Math.min(t.length-1,Math.floor(e.size/50))]}function Je(e){return/iPad|Tablet|Android(?!.*Mobile)/i.test(e)?"tablet":/Mobi|iPhone|Android/i.test(e)?"mobile":"desktop"}function O(e,t,n){try{new PerformanceObserver(i=>i.getEntries().forEach(r=>t(r))).observe({type:e,buffered:!0,...n})}catch{}}function me(e,t,n){if(typeof PerformanceObserver>"u"||typeof document>"u")return;let i=performance.getEntriesByType("navigation")[0],r=i?.activationStart??0,o=y=>Math.max(0,Math.round(y-r)),c=document.visibilityState==="hidden",d=location.pathname,s=i?.type,a={},u=fe(),b=new Map,l=!1,g=!1;i&&i.responseStart>0&&(a.ttfb=o(i.responseStart)),c||(O("paint",y=>{y.name==="first-contentful-paint"&&(a.fcp=o(y.startTime))}),O("largest-contentful-paint",y=>{l||(a.lcp=o(y.startTime))}));let $=()=>{l=!0};addEventListener("keydown",$,{once:!0,capture:!0}),addEventListener("pointerdown",$,{once:!0,capture:!0}),O("layout-shift",y=>{a.cls=Math.round(u(y)*1e4)/1e4});let B=y=>{if(!y.interactionId)return;b.set(y.interactionId,Math.max(b.get(y.interactionId)??0,y.duration));let te=Ye(b);te!==void 0&&(a.inp=Math.round(te))};O("event",B,{durationThreshold:40}),O("first-input",B);let w=navigator.connection?.effectiveType,h=`${new URL("/api/v1/vitals",e).href}?key=${encodeURIComponent(t)}${n?`&instance=${encodeURIComponent(n)}`:""}`,k=()=>{if(g||Object.keys(a).length===0)return;g=!0;let y=JSON.stringify({path:d.slice(0,512),metrics:a,nav:s,connection:w&&/^(slow-2g|2g|3g|4g)$/.test(w)?w:void 0,device:Je(navigator.userAgent)});try{if(navigator.sendBeacon?.(h,y))return}catch{}fetch(h,{method:"POST",body:y,keepalive:!0}).catch(()=>{})},T=()=>{location.pathname!==d&&(k(),d=location.pathname,s="route",a={},u=fe(),b=new Map,l=!0,g=!1)};document.addEventListener("visibilitychange",()=>document.visibilityState==="hidden"&&k()),addEventListener("pagehide",k),addEventListener("popstate",T);let A=history.pushState;history.pushState=function(...y){A.apply(this,y),T()}}function Ze(e,t=Math.random){return t()<(e.sessionSampleRate??0)?"session":t()<(e.onErrorSampleRate??1)?"buffer":null}function ge(e,t,n,i,r){let o=Ze(e);if(!o||typeof document>"u")return;let c=L(),d,s=document.createElement("script");return s.src=e.src??`${r}blipit-replay.js`,s.async=!0,s.onload=()=>{let a=window.BlipitReplay?.start;d=a?.({id:c,mode:o,endpoint:t,key:n,instance:i})},document.head.appendChild(s),{id:c,active:()=>d?.active()??!1,error:a=>d?.error(a),report:a=>d?.report?.(a)}}var he={en:["Report {ref} sent.","We will email you updates."],ar:["\u062A\u0645 \u0625\u0631\u0633\u0627\u0644 \u0627\u0644\u0628\u0644\u0627\u063A {ref}.","\u0633\u0646\u0631\u0627\u0633\u0644\u0643 \u0628\u0627\u0644\u062A\u062D\u062F\u064A\u062B\u0627\u062A."],de:["Meldung {ref} gesendet.","Wir informieren Sie per E-Mail."],es:["Reporte {ref} enviado.","Te enviaremos novedades por correo."],fr:["Signalement {ref} envoy\xE9.","Nous vous tiendrons au courant par e-mail."],it:["Segnalazione {ref} inviata.","Ti invieremo aggiornamenti via email."],ja:["\u5831\u544A {ref} \u3092\u9001\u4FE1\u3057\u307E\u3057\u305F\u3002","\u9032\u6357\u306F\u30E1\u30FC\u30EB\u3067\u304A\u77E5\u3089\u305B\u3057\u307E\u3059\u3002"],nl:["Melding {ref} verstuurd.","We mailen je updates."],pt:["Relato {ref} enviado.","Vamos enviar novidades por e-mail."],tr:["{ref} numaral\u0131 bildirim g\xF6nderildi.","Geli\u015Fmeleri e-postayla bildirece\u011Fiz."],zh:["\u62A5\u544A {ref} \u5DF2\u53D1\u9001\u3002","\u6211\u4EEC\u4F1A\u901A\u8FC7\u90AE\u4EF6\u544A\u77E5\u8FDB\u5C55\u3002"]};function Qe(e,t,n){if(typeof e!="string"||!/^BR-\d{1,12}$/.test(e))return null;let[i,r]=he[n.toLowerCase().split(/[-_]/)[0]]??he.en;return`${i.replace("{ref}",e)}${t===!0?` ${r}`:""}`}function x(e,t,n){let i=document.createElement(e);return i.style.cssText=t,n!==void 0&&(i.textContent=n),i}var V="display:block;width:100%;box-sizing:border-box;margin:4px 0 12px;padding:8px 10px;font:inherit;border:1px solid #c5ccd6;border-radius:6px;background:#fff;color:#111",be="font:inherit;padding:8px 14px;border-radius:6px;cursor:pointer;border:1px solid #c5ccd6;background:#fff;color:#111",G=!1;function z(e,t,n){if(G||typeof document>"u"||!document.body)return;G=!0;let i=x("dialog","max-width:420px;width:calc(100% - 32px);padding:20px;border:1px solid #c5ccd6;border-radius:10px;font:14px/1.45 system-ui,sans-serif;color:#111;background:#fff");i.setAttribute("aria-labelledby","blipit-fb-title");let r=x("form","margin:0"),o=x("h2","margin:0 0 12px;font-size:17px",n.title??"Tell us what happened");o.id="blipit-fb-title";let c=(w,h,k)=>{let T=x("label","display:block;font-weight:600",w);T.htmlFor=k,h.id=k,r.append(T,h)},d=x("input",V);d.type="text",d.maxLength=128,d.autocomplete="name",d.value=n.name??"";let s=x("input",V);s.type="email",s.maxLength=254,s.autocomplete="email",s.value=n.email??"";let a=x("textarea",`${V};min-height:110px;resize:vertical`);a.required=!0,a.maxLength=5e3;let u=x("p","margin:0 0 12px;min-height:1.2em;font-size:13px");u.setAttribute("role","status"),u.setAttribute("aria-live","polite");let b=x("div","display:flex;gap:8px;justify-content:flex-end"),l=x("button",be,"Cancel");l.type="button";let g=x("button",`${be};background:#111;color:#fff;border-color:#111`,"Send");g.type="submit",r.append(o),c("Name (optional)",d,"blipit-fb-name"),c("Email (optional)",s,"blipit-fb-email"),c("What went wrong?",a,"blipit-fb-message"),b.append(l,g),r.append(u,b),i.append(r),document.body.append(i);let $=()=>{G=!1,i.remove()},B=()=>typeof i.close=="function"&&i.open?i.close():$();l.addEventListener("click",B),i.addEventListener("close",$),r.addEventListener("submit",async w=>{w.preventDefault();let h=a.value.trim();if(!h){u.textContent="Please describe what happened.",a.focus();return}g.disabled=!0,l.disabled=!0,g.setAttribute("aria-busy","true"),g.textContent="Sending\u2026",u.textContent="";try{let k=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":t},body:JSON.stringify({name:d.value.trim()||void 0,email:s.value.trim()||void 0,message:h,event_id:n.eventId,url:typeof location<"u"?location.href.split(/[?#]/)[0]:void 0})});if(!k.ok)throw new Error(String(k.status));let T=await k.json().catch(()=>({})),A=Qe(T.ref,T.emails,typeof navigator>"u"?"en":navigator.language??"en");u.textContent=A??"Thanks, your message was sent.",g.textContent="Sent",setTimeout(B,A?4e3:1200)}catch{u.textContent="That did not send. Please try again.",g.disabled=!1,l.disabled=!1,g.removeAttribute("aria-busy"),g.textContent="Send"}}),typeof i.showModal=="function"?i.showModal():i.setAttribute("open",""),a.focus()}var J={en:["Report a bug","Loading\u2026"],ar:["\u0623\u0628\u0644\u063A \u0639\u0646 \u062E\u0637\u0623","\u062C\u0627\u0631\u064D \u0627\u0644\u062A\u062D\u0645\u064A\u0644\u2026"],de:["Fehler melden","Wird geladen\u2026"],es:["Reportar un error","Cargando\u2026"],fr:["Signaler un bug","Chargement\u2026"],it:["Segnala un bug","Caricamento\u2026"],ja:["\u4E0D\u5177\u5408\u3092\u5831\u544A","\u8AAD\u307F\u8FBC\u307F\u4E2D\u2026"],nl:["Bug melden","Laden\u2026"],pt:["Reportar erro","Carregando\u2026"],tr:["Hata bildir","Y\xFCkleniyor\u2026"],zh:["\u62A5\u544A\u95EE\u9898","\u52A0\u8F7D\u4E2D\u2026"]},et="button{all:initial;position:fixed;z-index:2147483646;display:flex;align-items:center;gap:8px;padding:11px 18px;border-radius:99px;background:var(--c,linear-gradient(135deg,#3882F6,#2F5BEA));color:#fff;font:600 14px system-ui,-apple-system,sans-serif;letter-spacing:-.01em;cursor:pointer;box-shadow:0 14px 32px -12px rgba(56,130,246,.75),0 2px 6px rgba(11,26,58,.18),inset 0 1px 0 rgba(255,255,255,.22);transition:transform .2s,box-shadow .2s;animation:in .35s cubic-bezier(.2,.8,.2,1)}button:hover{transform:translateY(-2px);box-shadow:0 20px 40px -12px rgba(56,130,246,.85),0 3px 8px rgba(11,26,58,.2),inset 0 1px 0 rgba(255,255,255,.22)}button:active{transform:scale(.97)}button:focus-visible{outline:3px solid #00C2FF;outline-offset:3px}button:disabled{cursor:progress}svg,i{width:18px;height:18px}i{box-sizing:border-box;border:2px solid;border-right-color:transparent;border-radius:50%;animation:r .8s linear infinite}@keyframes r{to{transform:rotate(1turn)}}@keyframes in{from{opacity:0;transform:translateY(12px) scale(.94)}}.o span{display:none}.o{padding:13px}@media(max-width:480px){span{display:none}button{padding:13px}}@media(pointer:coarse){button{min-height:44px;box-sizing:border-box}}@media(prefers-reduced-motion:reduce){button{animation:none;transition:none}i{animation-duration:3s}}",tt='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h16v12H9l-5 4zM12 7v4M12 13.5v.5"/></svg>',ve,Y={},xe,R,Z=()=>{},_,ye=0;function I(e,t){e.options.debug&&console.log(`[blipit] ${t}`)}function we(e){ve=e}function nt(e,t){return Y[t]??=new Promise((n,i)=>{let r=document.createElement("script");r.src=e,r.async=!0,r.onload=()=>{let o=window[t];o?n(o):i(new Error(t))},r.onerror=i,document.head.appendChild(r)}).catch(n=>{throw delete Y[t],n}),Y[t]}function ke(){let e=(navigator.language??"en").slice(0,2);return J[e]?e:"en"}function Se(e,t){let n=document.createElement("button");return n.type="button",n.className="blipit-rb",n.setAttribute("aria-haspopup","dialog"),e?n.textContent=e:(n.lang=ke(),n.textContent=J[n.lang][0]),n.addEventListener("click",()=>n.hasAttribute("aria-busy")||t()),n}function K(e){if(typeof document>"u")return;let t=typeof e.options.feedbackWidget=="object"?e.options.feedbackWidget:{},n=document.querySelectorAll("button.blipit-rb"),i=r=>{Z(r),n.forEach(o=>r?o.setAttribute("aria-busy","true"):o.removeAttribute("aria-busy"))};i(!0),Promise.all([nt(t.src??`${P}blipit-report.js`,"BlipitReport"),xe??=Ee(e)]).then(([r,o])=>o.enabled!==!1&&r.open(e,{metadata:ve,recording:o.recording===!0,recordingMaxMs:o.recording_max_ms,storageFull:o.storage_full===!0,reportsFull:o.reports_full===!0,theme:o.theme,hide:c=>R&&(R.style.display=c?"none":"")}),()=>z(S(e.endpoint,"/api/v1/feedback"),e.options.key,{eventId:e.lastEventId,name:e.user?.username,email:e.user?.email})).finally(()=>i(!1))}async function Ee(e){let t=`blipit_fb_${M}_${e.options.key}`;try{let n=JSON.parse(localStorage.getItem(t)??"null");if(n&&Date.now()-n.t<36e5)return n.s}catch{}try{let n=await fetch(S(e.endpoint,"/api/v1/feedback/settings"),{headers:{"X-Blipit-Key":e.options.key,...e.options.instance?{"X-Blipit-Instance":e.options.instance}:{}}});if(!n.ok)return I(e,`widget settings failed (HTTP ${n.status}), using defaults`),{};let i=await n.json();try{localStorage.setItem(t,JSON.stringify({t:Date.now(),s:i}))}catch{}return i}catch{return I(e,"widget settings unreachable (offline, ad blocker or CSP connect-src), using defaults"),{}}}async function Q(e){let t=e.options.feedbackWidget,n=++ye;if(typeof document>"u")return;if(t===!1)return I(e,"Report a bug button off: feedbackWidget is false");let i=await(xe??=Ee(e));if(n!==ye)return;if(i.enabled===!1)return I(e,"Report a bug button hidden by the project's Bug report widget setting");let r={...i,...typeof t=="object"?t:{}},[o,c]=J[ke()],d=r.text||o;R=document.createElement("div"),R.setAttribute("data-blipit-ui","");let s=R.attachShadow({mode:"open"}),a=document.createElement("style");a.textContent=et;let u=document.createElement("button");u.type="button";let[b,l]=(/^(bottom|middle)-(left|right)$/.test(r.position??"")?r.position:"bottom-right").split("-");u.style.cssText=`${r.color?`--c:${r.color};`:""}${l}:calc(20px + env(safe-area-inset-${l},0px));${b==="bottom"?"bottom:calc(20px + env(safe-area-inset-bottom,0px))":"top:50%;margin-top:-22px"}`,u.setAttribute("aria-haspopup","dialog"),r.style==="icon"&&(u.className="o",u.title=d);let g=h=>{u.disabled=h,u.setAttribute("aria-label",h?c:d),u.innerHTML=h?"<i></i><span></span>":`${tt}<span></span>`,u.lastChild.textContent=h?c:d};Z=g,g(!1),u.addEventListener("click",()=>K(e)),s.append(a,u);let $=r.shortcut?.toLowerCase().replace(/\s/g,"");_&&document.removeEventListener("keydown",_),_=void 0,$&&(_=h=>{[h.ctrlKey&&"ctrl",h.shiftKey&&"shift",h.altKey&&"alt",h.metaKey&&"meta",h.key.toLowerCase()].filter(Boolean).join("+")===$&&(h.preventDefault(),K(e))},document.addEventListener("keydown",_));let B=R,w=()=>{R===B&&(document.body.append(B),I(e,`Report a bug button shown at ${b}-${l}`))};document.body?w():document.addEventListener("DOMContentLoaded",w)}function Re(e,t){let n=e.options.feedbackWidget;e.options.feedbackWidget=t===!1?!1:{...typeof n=="object"?n:{},...t},R?.remove(),R=void 0,_&&document.removeEventListener("keydown",_),_=void 0,Z=()=>{},Q(e)}var $e='<svg viewBox="0 0 242.4 208.7" aria-hidden="true"><defs><linearGradient id="bm1" x1="0" y1="1" x2=".5" y2="0"><stop offset="0" stop-color="#00C2FF"/><stop offset=".35" stop-color="#3882F6"/><stop offset="1" stop-color="#0F172A"/></linearGradient><linearGradient id="bm2" x1="0" y1="1" x2="1" y2="0"><stop offset="0" stop-color="#3882F6"/><stop offset=".5" stop-color="#00C2FF"/><stop offset="1" stop-color="#3882F6"/></linearGradient></defs><path fill="url(#bm1)" d="M115.5,164.5c-3.9,0-7.8-.4-11.5-1.2-3.7-.8-7.3-1.9-10.8-3.4-3.4-1.4-6.7-3.2-9.7-5.3-3.0-2.0-5.9-4.4-8.5-7.0s-4.9-5.4-7.0-8.5c-2.1-3.1-3.9-6.3-5.3-9.8-1.5-3.5-2.6-7.1-3.4-10.8-.8-3.8-1.2-7.7-1.2-11.5V19.1c0-6.6,5.4-12.0,12.0-12.0s12.0,5.4,12.0,12.0v88.2c0,2.2.2,4.5.7,6.7.4,2.1,1.1,4.2,1.9,6.2.8,2.0,1.9,3.9,3.1,5.7,1.2,1.8,2.6,3.4,4.1,4.9s3.2,2.9,4.9,4.1c1.8,1.2,3.7,2.2,5.6,3.1,2.0.8,4.1,1.5,6.2,1.9,4.4.9,9.1.9,13.4,0,2.1-.4,4.2-1.1,6.2-1.9,2.0-.8,3.9-1.9,5.7-3.1,1.8-1.2,3.4-2.6,4.9-4.1s2.9-3.2,4.1-4.9c1.2-1.8,2.2-3.7,3.1-5.7.8-2.0,1.5-4.1,1.9-6.2.5-2.2.7-4.5.7-6.7s-.2-4.5-.7-6.7c-.4-2.1-1.1-4.2-1.9-6.2-.8-2.0-1.9-3.9-3.1-5.7-1.2-1.8-2.6-3.4-4.1-4.9s-3.2-2.9-4.9-4.1c-1.8-1.2-3.7-2.2-5.7-3.1-2.0-.8-4.1-1.5-6.2-1.9-4.4-.9-9.1-.9-13.4,0-6.5,1.3-12.9-2.9-14.2-9.4-1.3-6.5,2.9-12.9,9.4-14.2,7.6-1.6,15.5-1.6,23.1,0,3.7.8,7.3,1.9,10.8,3.4,3.4,1.4,6.7,3.2,9.7,5.3,3.0,2.0,5.9,4.4,8.5,7.0s4.9,5.4,7.0,8.5c2.1,3.1,3.9,6.3,5.3,9.8,1.5,3.5,2.6,7.1,3.4,10.8.8,3.8,1.2,7.7,1.2,11.5s-.4,7.8-1.2,11.5c-.8,3.7-1.9,7.3-3.4,10.8-1.4,3.4-3.2,6.7-5.3,9.7-2.0,3.0-4.4,5.9-7.0,8.5s-5.4,4.9-8.5,7.0c-3.1,2.1-6.3,3.9-9.8,5.3-3.5,1.5-7.1,2.6-10.8,3.4-3.8.8-7.7,1.2-11.5,1.2Z"/><path fill="url(#bm2)" d="M208.1,103.0c-.0-.6-.8-.9-1.2-.5-3.2,3.1-7.6,5.0-12.4,5.0-3.9,0-9.1-1.6-10.2-2.5-.3-.1-.1,1.4-.1,2.5,0,40.5-34.4,73.0-75.5,70.0-33.4-2.5-60.8-28.8-64.4-62.1-1.0-9.4-.2-18.6,2.2-27.0,1.6-5.6,2.6-11.4,2.6-17.3v-22.4c0-3.4-4.3-5.0-6.5-2.4-13.2,15.4-21.6,35.1-22.7,56.6-2.6,54.1,40.6,98.9,94.1,98.9s94.2-42.3,94.2-94.2c0-1.5-.1-3.0-.1-4.5Z"/><path fill="url(#bm2)" d="M201.2,70.1c-14.8-35.8-50.9-60.5-92.3-58.3h-.1c-8.2.5-14.6,7.4-14.6,15.7v.1c0,5.4,4.7,9.6,10.0,8.8,3.2-.5,6.5-.7,9.9-.7,28.7,0,53.5,17.4,64.3,42.1.2.5.9.6,1.2.1,3.2-4.8,8.7-7.9,14.9-7.9,2.0,0,4.0.3,5.8,1.0.6.2,1.1-.4.9-1.0Z"/><circle fill="#00C2FF" cx="194.5" cy="88" r="15.8"/></svg>';var p=".blipit-rb.blipit-rb",it=`${p}{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:9px;height:40px;padding-inline:5px 17px;border-radius:99px;font:600 14px/1 system-ui,-apple-system,"Segoe UI",sans-serif;letter-spacing:-.01em;white-space:nowrap;cursor:pointer;user-select:none;-webkit-tap-highlight-color:transparent;color:#fff;background:linear-gradient(135deg,#3882F6,#2F5BEA);box-shadow:0 10px 24px -12px rgba(56,130,246,.8),0 1px 3px rgba(11,26,58,.16),inset 0 1px 0 rgba(255,255,255,.22);transition:transform .2s,box-shadow .2s}${p}:hover{transform:translateY(-1px);box-shadow:0 16px 32px -12px rgba(56,130,246,.85),0 2px 6px rgba(11,26,58,.18),inset 0 1px 0 rgba(255,255,255,.22)}${p}:active{transform:scale(.97)}${p}:focus-visible{outline:3px solid #00C2FF;outline-offset:3px}${p}[aria-busy=true]{cursor:progress}${p}>span{all:unset}${p}>.blipit-rb-m{position:relative;display:grid;place-items:center;flex:none;width:30px;height:30px;border-radius:99px;background:#fff;box-shadow:0 0 0 1px rgba(11,26,58,.08),0 1px 2px rgba(11,26,58,.12)}${p} svg{display:block;width:19px;height:17px}${p}[data-size=sm]{height:32px;gap:7px;padding-inline:4px 13px;font-size:13px}${p}[data-size=sm]>.blipit-rb-m{width:24px;height:24px}${p}[data-size=sm] svg{width:15px;height:13px}${p}[data-variant=outline],${p}[data-variant=ghost]{color:#0B1A3A;background:transparent;box-shadow:inset 0 0 0 1px #CBD7EA}${p}[data-variant=ghost]{box-shadow:none}${p}[data-variant=outline]:hover,${p}[data-variant=ghost]:hover{transform:none;background:rgba(56,130,246,.08);box-shadow:inset 0 0 0 1px rgba(56,130,246,.45)}${p}[data-variant=ghost]:hover{box-shadow:none}${p}[data-theme=dark]{background:linear-gradient(135deg,#5B9BFF,#3D6BF0);box-shadow:0 10px 24px -12px rgba(91,155,255,.7),inset 0 1px 0 rgba(255,255,255,.2)}${p}[data-theme=dark][data-variant=outline],${p}[data-theme=dark][data-variant=ghost]{color:#E8EEF8;background:transparent;box-shadow:inset 0 0 0 1px rgba(255,255,255,.16)}${p}[data-theme=dark][data-variant=ghost]{box-shadow:none}${p}[data-theme=dark][data-variant=outline]:hover,${p}[data-theme=dark][data-variant=ghost]:hover{background:rgba(91,155,255,.16);box-shadow:inset 0 0 0 1px rgba(91,155,255,.45)}${p}[data-theme=dark][data-variant=ghost]:hover{box-shadow:none}${p}[data-theme=dark]>.blipit-rb-m{box-shadow:0 0 0 1px rgba(255,255,255,.1)}${p}[aria-busy=true] svg{visibility:hidden}${p}[aria-busy=true]>.blipit-rb-m::after{content:"";position:absolute;inset:4px;border:2px solid #3882F6;border-right-color:transparent;border-radius:50%;animation:blipit-rb-r .8s linear infinite}@keyframes blipit-rb-r{to{transform:rotate(1turn)}}@media(pointer:coarse){${p}{min-height:44px}}@media(prefers-reduced-motion:reduce){${p}{transition:none}${p}:hover,${p}:active{transform:none}${p}[aria-busy=true]>.blipit-rb-m::after{animation-duration:3s}}@media(forced-colors:active){${p}{border:1px solid ButtonText}}`,rt=0;function Be(e,t={}){if(!document.getElementById("blipit-rb-css")){let o=document.createElement("style");o.id="blipit-rb-css",o.textContent=it,document.head.append(o)}let n=++rt,i=document.createElement("span");i.className="blipit-rb-m",i.innerHTML=$e.replace(/bm(\d)/g,`bm$1-${n}`);let r=document.createElement("span");r.textContent=e.textContent,e.replaceChildren(i,r),e.classList.add("blipit-rb"),e.setAttribute("data-variant",t.variant==="outline"||t.variant==="ghost"?t.variant:"solid"),e.setAttribute("data-size",t.size==="sm"?"sm":"md"),e.setAttribute("data-theme",se(t.theme==="light"||t.theme==="dark"?t.theme:void 0))}var m,Te=new Set;function _e(e,t){Te.has(t)||(Te.add(t),console[e](t))}var ot="[blipit] init() has no key, so error tracking and the Report a bug button are off. Pass your public key (blipit_pk_...) from app.blipit.io, API keys.",st="[blipit] init() got a secret key (blipit_sk_...), so Blipit did not start: secret keys must never be in browser code. Use the public key (blipit_pk_...) and create a new secret key in app.blipit.io, API keys.";function at(e){if(m)return;let t=typeof e?.key=="string"?e.key.trim():"";if(!t)return _e("warn",ot);if(t.startsWith("blipit_sk_"))return _e("error",st);if(m=new U({...e,key:t}),e.user){let{id:n,name:i,email:r,username:o}=e.user;m.setUser({id:n===void 0?void 0:String(n),email:r,username:o??i})}le(m),e.webVitals!==!1&&typeof window<"u"&&me(e.endpoint??D,t,e.instance),e.replay&&(m.replay=ge(e.replay,e.endpoint??D,t,e.instance,P)),typeof window<"u"&&Q(m),e.debug&&console.log(`[blipit] ${H}@${M} initialized`)}function dt(e){return m?.captureException(e,!0)}function ct(e,t){return m?.captureMessage(e,t)}function ut(e){return m?.captureSecurity(e)}function pt(e){m?.setUser(e)}function lt(e,t){m?.setTag(e,t)}function ft(e){m?.addBreadcrumb(e)}function mt(e={}){m&&z(S(m.endpoint,"/api/v1/feedback"),m.options.key,{...e,eventId:e.eventId??m.lastEventId})}function ee(){m&&K(m)}function gt(e){e.addEventListener("click",t=>{t.preventDefault(),ee()})}function ht(e={}){let t=Se(e.label,ee);return Be(t,e),t}function bt(e){m&&Re(m,e)}function yt(){return m?.flush()??Promise.resolve()}0&&(module.exports={addBreadcrumb,attachReport,captureException,captureMessage,captureSecurity,flush,init,openReport,reportButton,setReportMetadata,setTag,setUser,showFeedback,updateWidget});
|
package/dist/index.d.cts
CHANGED
|
@@ -68,6 +68,13 @@ interface FeedbackOptions {
|
|
|
68
68
|
email?: string;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
interface ReportButtonOptions {
|
|
72
|
+
label?: string;
|
|
73
|
+
variant?: "solid" | "outline" | "ghost";
|
|
74
|
+
size?: "sm" | "md";
|
|
75
|
+
theme?: "auto" | "light" | "dark";
|
|
76
|
+
}
|
|
77
|
+
|
|
71
78
|
declare function init(options: BlipitOptions): void;
|
|
72
79
|
declare function captureException(error: unknown): string | undefined;
|
|
73
80
|
declare function captureMessage(message: string, level?: Level): string | undefined;
|
|
@@ -78,7 +85,9 @@ declare function addBreadcrumb(crumb: Omit<Breadcrumb, "timestamp">): void;
|
|
|
78
85
|
declare function showFeedback(options?: FeedbackOptions): void;
|
|
79
86
|
declare function openReport(): void;
|
|
80
87
|
declare function attachReport(element: Element): void;
|
|
88
|
+
declare function reportButton(options?: ReportButtonOptions): HTMLButtonElement;
|
|
81
89
|
|
|
90
|
+
declare function updateWidget(options: WidgetOptions | false): void;
|
|
82
91
|
declare function flush(): Promise<void>;
|
|
83
92
|
|
|
84
|
-
export { type BlipitOptions, type FeedbackOptions, type ReplayOptions, type SecurityReport, type UserContext, type WidgetOptions, addBreadcrumb, attachReport, captureException, captureMessage, captureSecurity, flush, init, openReport, setReportMetadata, setTag, setUser, showFeedback };
|
|
93
|
+
export { type BlipitOptions, type FeedbackOptions, type ReplayOptions, type ReportButtonOptions, type SecurityReport, type UserContext, type WidgetOptions, addBreadcrumb, attachReport, captureException, captureMessage, captureSecurity, flush, init, openReport, reportButton, setReportMetadata, setTag, setUser, showFeedback, updateWidget };
|
package/dist/index.d.ts
CHANGED
|
@@ -68,6 +68,13 @@ interface FeedbackOptions {
|
|
|
68
68
|
email?: string;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
interface ReportButtonOptions {
|
|
72
|
+
label?: string;
|
|
73
|
+
variant?: "solid" | "outline" | "ghost";
|
|
74
|
+
size?: "sm" | "md";
|
|
75
|
+
theme?: "auto" | "light" | "dark";
|
|
76
|
+
}
|
|
77
|
+
|
|
71
78
|
declare function init(options: BlipitOptions): void;
|
|
72
79
|
declare function captureException(error: unknown): string | undefined;
|
|
73
80
|
declare function captureMessage(message: string, level?: Level): string | undefined;
|
|
@@ -78,7 +85,9 @@ declare function addBreadcrumb(crumb: Omit<Breadcrumb, "timestamp">): void;
|
|
|
78
85
|
declare function showFeedback(options?: FeedbackOptions): void;
|
|
79
86
|
declare function openReport(): void;
|
|
80
87
|
declare function attachReport(element: Element): void;
|
|
88
|
+
declare function reportButton(options?: ReportButtonOptions): HTMLButtonElement;
|
|
81
89
|
|
|
90
|
+
declare function updateWidget(options: WidgetOptions | false): void;
|
|
82
91
|
declare function flush(): Promise<void>;
|
|
83
92
|
|
|
84
|
-
export { type BlipitOptions, type FeedbackOptions, type ReplayOptions, type SecurityReport, type UserContext, type WidgetOptions, addBreadcrumb, attachReport, captureException, captureMessage, captureSecurity, flush, init, openReport, setReportMetadata, setTag, setUser, showFeedback };
|
|
93
|
+
export { type BlipitOptions, type FeedbackOptions, type ReplayOptions, type ReportButtonOptions, type SecurityReport, type UserContext, type WidgetOptions, addBreadcrumb, attachReport, captureException, captureMessage, captureSecurity, flush, init, openReport, reportButton, setReportMetadata, setTag, setUser, showFeedback, updateWidget };
|
package/dist/index.global.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var Blipit=(()=>{var
|
|
2
|
-
`)){if(!n||/^\s*(Error|TypeError|RangeError|SyntaxError|ReferenceError)\b/.test(n))continue;let i=Re.exec(n)??_e.exec(n);if(!i)continue;let[,r,a,d,c]=i;if(!a)continue;let s={filename:p(a,1024),in_app:Be(a)};r&&(s.function=p(r,512)),d&&(s.lineno=Number(d)),c&&(s.colno=Number(c)),t.push(s)}return t.reverse(),t.slice(-128)}function ne(e){return e.length===0?!1:e.every(t=>ee.test(t.filename))}var j="@blipit/browser",B="0.3.3",A=Q(typeof document<"u"?document.currentScript?.src:void 0,B),N="https://in.blipit.io/api/v1/events",Ce=[/ResizeObserver loop/i,/^Script error\.?$/,/__gCrWeb|__firefox__/],Le={login_failed:"Failed login",login_succeeded:"Successful login",login_blocked:"Blocked login",password_reset_requested:"Password reset requested",privilege_granted:"Privilege granted"},Ie={login_failed:"warning",login_succeeded:"info",login_blocked:"warning",password_reset_requested:"info",privilege_granted:"warning"};function Me(e){if(!J.includes(e?.kind))return;let t=p(String(e.actor??"").trim(),256);if(!t)return;let n={kind:e.kind,actor:t};return e.actorId&&(n.actor_id=p(String(e.actorId),128)),e.ip&&(n.ip=p(String(e.ip).trim(),45)),e.userAgent&&(n.user_agent=p(String(e.userAgent),512)),e.database&&(n.database=p(String(e.database),64)),e.outcome&&(n.outcome=p(String(e.outcome),64)),e.target&&(n.target=p(String(e.target),256)),n}var $=class{constructor(t){this.options=t;this.endpoint=t.endpoint??N,this.transport=new M(this.endpoint,t.key,t.debug??!1,t.instance),t.autoSessionTracking&&(t.release?this.session=new O(x(this.endpoint,"/api/v1/sessions"),t.key,t.release,t.environment??"production"):t.debug&&console.warn("[blipit] session tracking needs the release option")),this.maxBreadcrumbs=Math.min(t.maxBreadcrumbs??50,100),this.ignoreErrors=[...Ce,...t.ignoreErrors??[]]}options;transport;breadcrumbs=[];user;tags={};maxBreadcrumbs;ignoreErrors;seen=new Set;session;lastEventId;errorIds=[];logs={console:[],network:[],actions:[]};endpoint;replay;setUser(t){this.user=t,this.session?.setUser(t?.id??t?.email)}setTag(t,n){this.tags[p(t,64)]=p(n,256)}addBreadcrumb(t){let n={timestamp:y(),...t};n.message&&(n.message=Y(n.message)),n.data&&typeof n.data.url=="string"&&(n.data={...n.data,url:_(n.data.url)}),this.breadcrumbs.push(n),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift()}captureException(t,n=!0){let i=t instanceof Error?t:new Error(String(t)),r={type:i.name||"Error",value:p(i.message||String(i),4096),handled:n},a=te(i.stack);return a.length>0&&(r.stacktrace={frames:a}),this.processAndSend({exception:r,level:"error"})}captureMessage(t,n="info"){return this.processAndSend({message:p(t,8192),level:n})}captureSecurity(t){let n=Me(t);if(!n){this.options.debug&&console.warn("[blipit] security event dropped, needs a known kind and an actor");return}return this.processAndSend({message:`${Le[n.kind]} for ${n.actor}`,level:Ie[n.kind],security:n},!1)}processAndSend(t,n=!0){if(n&&this.options.sampleRate!==void 0&&Math.random()>this.options.sampleRate)return;let i=t.exception?.value??t.message??"";if(n){for(let c of this.ignoreErrors)if(typeof c=="string"?i.includes(c):c.test(i))return;if((this.options.autoMuteExtensions??!0)&&t.exception?.stacktrace&&ne(t.exception.stacktrace.frames))return;let d=`${t.exception?.type??""}|${i}`;if(t.exception?.handled===!1){if(this.seen.has(d)&&this.seen.size<100)return;this.seen.add(d),setTimeout(()=>this.seen.delete(d),5e3)}}let r={event_id:T(),timestamp:y(),platform:"javascript",release:this.options.release,environment:this.options.environment??"production",user:this.user,tags:Object.keys(this.tags).length>0?{...this.tags}:void 0,breadcrumbs:this.breadcrumbs.length>0?[...this.breadcrumbs]:void 0,request:typeof location<"u"?{url:_(location.href)}:void 0,contexts:this.collectContexts(),sdk:{name:j,version:B},...t};for(let d of Object.keys(r))r[d]===void 0&&delete r[d];let a=this.replay?.active()&&(r.level==="error"||r.level==="fatal")?this.replay:void 0;if(a&&(r.tags={...r.tags,replay_id:a.id}),this.options.beforeSend){let d=this.options.beforeSend(r);if(!d)return;r=d}return this.transport.enqueue(r),this.lastEventId=r.event_id,(r.level==="error"||r.level==="fatal")&&w(this.errorIds,r.event_id,20),r.exception&&this.session?.markError(r.exception.handled===!1),a?.error(r.event_id),r.event_id}collectContexts(){if(typeof navigator>"u")return;let t={},n=navigator.userAgent??"",i=/(Edg|OPR|Chrome|Firefox|Safari)\/(\d+[\d.]*)/.exec(n)??void 0;i&&(t.browser={name:i[1],version:i[2]});let r=/\(([^)]+)\)/.exec(n);return r&&r[1]&&(t.os={name:p(r[1],64)}),typeof screen<"u"&&(t.device={screen:`${screen.width}x${screen.height}`}),Object.keys(t).length>0?t:void 0}flush(){return this.transport.flush()}};function q(e){return typeof e=="string"?e.length:e?.size}function ie(e){return e&&Number(e)||void 0}function Oe(e,t){return async(n,i)=>{let r=typeof n=="string"?n:n instanceof URL?n.href:n.url,a=(i?.method??n.method??"GET").toUpperCase(),d=Date.now();try{let c=await e(n,i);return t(a,r,c.status,d,q(i?.body),ie(c.headers.get("content-length"))),c}catch(c){throw t(a,r,0,d,q(i?.body)),c}}}function $e(e,t){let n=e.open,i=e.send;e.open=function(r,a){return this._blipit=[String(r).toUpperCase(),String(a)],n.apply(this,arguments)},e.send=function(r){let a=this._blipit;if(a){let d=Date.now();this.addEventListener("loadend",()=>t(a[0],a[1],this.status,d,q(r),ie(this.getResponseHeader("content-length"))))}return i.apply(this,arguments)}}function re(e){if(typeof window>"u")return;let t=x(e.endpoint,""),{console:n,network:i,actions:r}=e.logs;window.addEventListener("error",s=>{e.captureException(s.error??s.message,!1)}),window.addEventListener("unhandledrejection",s=>{e.captureException(s.reason,!1)}),typeof document<"u"&&(document.addEventListener("click",s=>{let o=s.target;if(!(o instanceof Element)||o.closest("[data-blipit-ui]"))return;let u=K(o);e.addBreadcrumb({category:"ui.click",message:`Clicked ${u}`});let g=o.closest(G)?"***":p((o.textContent??"").trim().replace(/\s+/g," "),80);w(r,{timestamp:y(),type:"click",selector:u,text:g},50)},{capture:!0,passive:!0}),document.addEventListener("focusin",s=>{let o=s.target;o instanceof Element&&/^(INPUT|TEXTAREA|SELECT)$/.test(o.tagName)&&w(r,{timestamp:y(),type:"focus",selector:K(o)},50)},{capture:!0,passive:!0}));let a=(s,o,u,g,l,f)=>{t&&o.startsWith(t)||(e.addBreadcrumb({category:"http",message:`${s} ${_(o)} \u2192 ${u||"network error"}`,level:u>=400||!u?"error":"info",data:{url:_(o),method:s,status_code:u||void 0}}),w(i,{timestamp:y(),method:s,url:F(o),status:u,duration:Date.now()-g,request_size:l,response_size:f},50))};typeof window.fetch=="function"&&(window.fetch=Oe(window.fetch.bind(window),a)),typeof XMLHttpRequest<"u"&&$e(XMLHttpRequest.prototype,a);for(let s of["log","info","debug","warn","error"]){let o=console[s].bind(console);console[s]=(...u)=>{let g=p(u.map(l=>typeof l=="string"?l:Ae(l)).join(" "),1024);if(s==="warn"||s==="error"){e.addBreadcrumb({category:"console",level:s==="warn"?"warning":"error",message:g});let l=u.find(f=>f instanceof Error);w(n,{timestamp:y(),level:s,message:g,stack:p((l??new Error).stack??"",2e3)},100)}else w(n,{timestamp:y(),level:s,message:g},100);o(...u)}}let d=()=>w(r,{timestamp:y(),type:"navigation",url:F(location.href)},50),c=()=>{e.addBreadcrumb({category:"navigation",message:`Navigated to ${_(location.href)}`}),d()};if(d(),window.history){let s=window.history.pushState.bind(window.history);window.history.pushState=(...o)=>{s(...o),c()},window.addEventListener("popstate",c)}}function Ae(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function oe(){let e=0,t=0,n=0,i=0;return r=>(r.hadRecentInput||(t>0&&r.startTime-i<1e3&&r.startTime-n<5e3?t+=r.value:(t=r.value,n=r.startTime),i=r.startTime,t>e&&(e=t)),e)}function Ne(e){if(e.size===0)return;let t=[...e.values()].sort((n,i)=>i-n);return t[Math.min(t.length-1,Math.floor(e.size/50))]}function Ue(e){return/iPad|Tablet|Android(?!.*Mobile)/i.test(e)?"tablet":/Mobi|iPhone|Android/i.test(e)?"mobile":"desktop"}function I(e,t,n){try{new PerformanceObserver(i=>i.getEntries().forEach(r=>t(r))).observe({type:e,buffered:!0,...n})}catch{}}function se(e,t,n){if(typeof PerformanceObserver>"u"||typeof document>"u")return;let i=performance.getEntriesByType("navigation")[0],r=i?.activationStart??0,a=h=>Math.max(0,Math.round(h-r)),d=document.visibilityState==="hidden",c=location.pathname,s=i?.type,o={},u=oe(),g=new Map,l=!1,f=!1;i&&i.responseStart>0&&(o.ttfb=a(i.responseStart)),d||(I("paint",h=>{h.name==="first-contentful-paint"&&(o.fcp=a(h.startTime))}),I("largest-contentful-paint",h=>{l||(o.lcp=a(h.startTime))}));let E=()=>{l=!0};addEventListener("keydown",E,{once:!0,capture:!0}),addEventListener("pointerdown",E,{once:!0,capture:!0}),I("layout-shift",h=>{o.cls=Math.round(u(h)*1e4)/1e4});let b=h=>{if(!h.interactionId)return;g.set(h.interactionId,Math.max(g.get(h.interactionId)??0,h.duration));let V=Ne(g);V!==void 0&&(o.inp=Math.round(V))};I("event",b,{durationThreshold:40}),I("first-input",b);let R=navigator.connection?.effectiveType,k=`${new URL("/api/v1/vitals",e).href}?key=${encodeURIComponent(t)}${n?`&instance=${encodeURIComponent(n)}`:""}`,S=()=>{if(f||Object.keys(o).length===0)return;f=!0;let h=JSON.stringify({path:c.slice(0,512),metrics:o,nav:s,connection:R&&/^(slow-2g|2g|3g|4g)$/.test(R)?R:void 0,device:Ue(navigator.userAgent)});try{if(navigator.sendBeacon?.(k,h))return}catch{}fetch(k,{method:"POST",body:h,keepalive:!0}).catch(()=>{})},L=()=>{location.pathname!==c&&(S(),c=location.pathname,s="route",o={},u=oe(),g=new Map,l=!0,f=!1)};document.addEventListener("visibilitychange",()=>document.visibilityState==="hidden"&&S()),addEventListener("pagehide",S),addEventListener("popstate",L);let he=history.pushState;history.pushState=function(...h){he.apply(this,h),L()}}function Pe(e,t=Math.random){return t()<(e.sessionSampleRate??0)?"session":t()<(e.onErrorSampleRate??1)?"buffer":null}function ae(e,t,n,i,r){let a=Pe(e);if(!a||typeof document>"u")return;let d=T(),c,s=document.createElement("script");return s.src=e.src??`${r}blipit-replay.js`,s.async=!0,s.onload=()=>{let o=window.BlipitReplay?.start;c=o?.({id:d,mode:a,endpoint:t,key:n,instance:i})},document.head.appendChild(s),{id:d,active:()=>c?.active()??!1,error:o=>c?.error(o),report:o=>c?.report?.(o)}}function v(e,t,n){let i=document.createElement(e);return i.style.cssText=t,n!==void 0&&(i.textContent=n),i}var z="display:block;width:100%;box-sizing:border-box;margin:4px 0 12px;padding:8px 10px;font:inherit;border:1px solid #c5ccd6;border-radius:6px;background:#fff;color:#111",de="font:inherit;padding:8px 14px;border-radius:6px;cursor:pointer;border:1px solid #c5ccd6;background:#fff;color:#111",H=!1;function U(e,t,n){if(H||typeof document>"u"||!document.body)return;H=!0;let i=v("dialog","max-width:420px;width:calc(100% - 32px);padding:20px;border:1px solid #c5ccd6;border-radius:10px;font:14px/1.45 system-ui,sans-serif;color:#111;background:#fff");i.setAttribute("aria-labelledby","blipit-fb-title");let r=v("form","margin:0"),a=v("h2","margin:0 0 12px;font-size:17px",n.title??"Tell us what happened");a.id="blipit-fb-title";let d=(R,k,S)=>{let L=v("label","display:block;font-weight:600",R);L.htmlFor=S,k.id=S,r.append(L,k)},c=v("input",z);c.type="text",c.maxLength=128,c.autocomplete="name",c.value=n.name??"";let s=v("input",z);s.type="email",s.maxLength=254,s.autocomplete="email",s.value=n.email??"";let o=v("textarea",`${z};min-height:110px;resize:vertical`);o.required=!0,o.maxLength=5e3;let u=v("p","margin:0 0 12px;min-height:1.2em;font-size:13px");u.setAttribute("role","status"),u.setAttribute("aria-live","polite");let g=v("div","display:flex;gap:8px;justify-content:flex-end"),l=v("button",de,"Cancel");l.type="button";let f=v("button",`${de};background:#111;color:#fff;border-color:#111`,"Send");f.type="submit",r.append(a),d("Name (optional)",c,"blipit-fb-name"),d("Email (optional)",s,"blipit-fb-email"),d("What went wrong?",o,"blipit-fb-message"),g.append(l,f),r.append(u,g),i.append(r),document.body.append(i);let E=()=>{H=!1,i.remove()},b=()=>typeof i.close=="function"&&i.open?i.close():E();l.addEventListener("click",b),i.addEventListener("close",E),r.addEventListener("submit",async R=>{R.preventDefault();let k=o.value.trim();if(!k){u.textContent="Please describe what happened.",o.focus();return}f.disabled=!0,l.disabled=!0,f.setAttribute("aria-busy","true"),f.textContent="Sending\u2026",u.textContent="";try{let S=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":t},body:JSON.stringify({name:c.value.trim()||void 0,email:s.value.trim()||void 0,message:k,event_id:n.eventId,url:typeof location<"u"?location.href.split(/[?#]/)[0]:void 0})});if(!S.ok)throw new Error(String(S.status));u.textContent="Thanks, your message was sent.",f.textContent="Sent",setTimeout(b,1200)}catch{u.textContent="That did not send. Please try again.",f.disabled=!1,l.disabled=!1,f.removeAttribute("aria-busy"),f.textContent="Send"}}),typeof i.showModal=="function"?i.showModal():i.setAttribute("open",""),o.focus()}var ce={en:["Report a bug","Loading\u2026"],ar:["\u0623\u0628\u0644\u063A \u0639\u0646 \u062E\u0637\u0623","\u062C\u0627\u0631\u064D \u0627\u0644\u062A\u062D\u0645\u064A\u0644\u2026"],de:["Fehler melden","Wird geladen\u2026"],es:["Reportar un error","Cargando\u2026"],fr:["Signaler un bug","Chargement\u2026"],it:["Segnala un bug","Caricamento\u2026"],ja:["\u4E0D\u5177\u5408\u3092\u5831\u544A","\u8AAD\u307F\u8FBC\u307F\u4E2D\u2026"],nl:["Bug melden","Laden\u2026"],pt:["Reportar erro","Carregando\u2026"],tr:["Hata bildir","Y\xFCkleniyor\u2026"],zh:["\u62A5\u544A\u95EE\u9898","\u52A0\u8F7D\u4E2D\u2026"]},De="button{all:initial;position:fixed;z-index:2147483646;display:flex;align-items:center;gap:8px;padding:11px 18px;border-radius:99px;background:var(--c,linear-gradient(135deg,#3882F6,#2F5BEA));color:#fff;font:600 14px system-ui,-apple-system,sans-serif;letter-spacing:-.01em;cursor:pointer;box-shadow:0 14px 32px -12px rgba(56,130,246,.75),0 2px 6px rgba(11,26,58,.18),inset 0 1px 0 rgba(255,255,255,.22);transition:transform .2s,box-shadow .2s;animation:in .35s cubic-bezier(.2,.8,.2,1)}button:hover{transform:translateY(-2px);box-shadow:0 20px 40px -12px rgba(56,130,246,.85),0 3px 8px rgba(11,26,58,.2),inset 0 1px 0 rgba(255,255,255,.22)}button:active{transform:scale(.97)}button:focus-visible{outline:3px solid #00C2FF;outline-offset:3px}button:disabled{cursor:progress}svg,i{width:18px;height:18px}i{box-sizing:border-box;border:2px solid;border-right-color:transparent;border-radius:50%;animation:r .8s linear infinite}@keyframes r{to{transform:rotate(1turn)}}@keyframes in{from{opacity:0;transform:translateY(12px) scale(.94)}}.o span{display:none}.o{padding:13px}@media(max-width:480px){span{display:none}button{padding:13px}}@media(pointer:coarse){button{min-height:44px;box-sizing:border-box}}@media(prefers-reduced-motion:reduce){button{animation:none;transition:none}i{animation-duration:3s}}",Fe='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h16v12H9l-5 4zM12 7v4M12 13.5v.5"/></svg>',ue,X,pe,C,W=()=>{};function le(e){ue=e}function Ke(e){return X??=new Promise((t,n)=>{let i=document.createElement("script");i.src=e,i.async=!0,i.onload=()=>{let r=window.BlipitReport;r?t(r):n(new Error("report"))},i.onerror=n,document.head.appendChild(i)}).catch(t=>{throw X=void 0,t}),X}function P(e){if(typeof document>"u")return;let t=typeof e.options.feedbackWidget=="object"?e.options.feedbackWidget:{};W(!0),Promise.all([Ke(t.src??`${A}blipit-report.js`),pe??=fe(e)]).then(([n,i])=>i.enabled!==!1&&n.open(e,{metadata:ue,recording:i.recording===!0,recordingMaxMs:i.recording_max_ms,storageFull:i.storage_full===!0,reportsFull:i.reports_full===!0,theme:i.theme,hide:r=>C&&(C.style.display=r?"none":"")}),()=>U(x(e.endpoint,"/api/v1/feedback"),e.options.key,{eventId:e.lastEventId,name:e.user?.username,email:e.user?.email})).finally(()=>W(!1))}async function fe(e){let t=`blipit_fb_${B}_${e.options.key}`;try{let n=JSON.parse(localStorage.getItem(t)??"null");if(n&&Date.now()-n.t<36e5)return n.s}catch{}try{let n=await fetch(x(e.endpoint,"/api/v1/feedback/settings"),{headers:{"X-Blipit-Key":e.options.key,...e.options.instance?{"X-Blipit-Instance":e.options.instance}:{}}});if(!n.ok)return{};let i=await n.json();try{localStorage.setItem(t,JSON.stringify({t:Date.now(),s:i}))}catch{}return i}catch{return{}}}async function me(e){let t=e.options.feedbackWidget;if(t===!1||typeof document>"u")return;let n=await(pe??=fe(e));if(n.enabled===!1)return;let i={...n,...typeof t=="object"?t:{}},[r,a]=ce[(navigator.language??"en").slice(0,2)]??ce.en,d=i.text||r;C=document.createElement("div"),C.setAttribute("data-blipit-ui","");let c=C.attachShadow({mode:"open"}),s=document.createElement("style");s.textContent=De;let o=document.createElement("button");o.type="button";let[u,g]=(/^(bottom|middle)-(left|right)$/.test(i.position??"")?i.position:"bottom-right").split("-");o.style.cssText=`${i.color?`--c:${i.color};`:""}${g}:calc(20px + env(safe-area-inset-${g},0px));${u==="bottom"?"bottom:calc(20px + env(safe-area-inset-bottom,0px))":"top:50%;margin-top:-22px"}`,o.setAttribute("aria-haspopup","dialog"),i.style==="icon"&&(o.className="o",o.title=d);let l=b=>{o.disabled=b,o.setAttribute("aria-label",b?a:d),o.innerHTML=b?"<i></i><span></span>":`${Fe}<span></span>`,o.lastChild.textContent=b?a:d};W=l,l(!1),o.addEventListener("click",()=>P(e)),c.append(s,o);let f=i.shortcut?.toLowerCase().replace(/\s/g,"");f&&document.addEventListener("keydown",b=>{[b.ctrlKey&&"ctrl",b.shiftKey&&"shift",b.altKey&&"alt",b.metaKey&&"meta",b.key.toLowerCase()].filter(Boolean).join("+")===f&&(b.preventDefault(),P(e))});let E=()=>document.body.append(C);document.body?E():document.addEventListener("DOMContentLoaded",E)}var m;function je(e){if(!m){if(m=new $(e),e.user){let{id:t,name:n,email:i,username:r}=e.user;m.setUser({id:t===void 0?void 0:String(t),email:i,username:r??n})}re(m),e.webVitals!==!1&&typeof window<"u"&&se(e.endpoint??N,e.key,e.instance),e.replay&&(m.replay=ae(e.replay,e.endpoint??N,e.key,e.instance,A)),typeof window<"u"&&me(m),e.debug&&console.log(`[blipit] ${j}@${B} initialized`)}}function qe(e){return m?.captureException(e,!0)}function ze(e,t){return m?.captureMessage(e,t)}function He(e){return m?.captureSecurity(e)}function Xe(e){m?.setUser(e)}function We(e,t){m?.setTag(e,t)}function Ve(e){m?.addBreadcrumb(e)}function Je(e={}){m&&U(x(m.endpoint,"/api/v1/feedback"),m.options.key,{...e,eventId:e.eventId??m.lastEventId})}function ge(){m&&P(m)}function Ye(e){e.addEventListener("click",t=>{t.preventDefault(),ge()})}function Ge(){return m?.flush()??Promise.resolve()}return we(Qe);})();
|
|
1
|
+
"use strict";var Blipit=(()=>{var q=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var Ce=Object.prototype.hasOwnProperty;var Le=(e,t)=>{for(var n in t)q(e,n,{get:t[n],enumerable:!0})},Oe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Be(t))!Ce.call(e,i)&&i!==n&&q(e,i,{get:()=>t[i],enumerable:!(r=Te(t,i))||r.enumerable});return e};var Me=e=>Oe(q({},"__esModule",{value:!0}),e);var lt={};Le(lt,{addBreadcrumb:()=>st,attachReport:()=>dt,captureException:()=>tt,captureMessage:()=>nt,captureSecurity:()=>it,flush:()=>ut,init:()=>et,openReport:()=>F,reportButton:()=>pt,setReportMetadata:()=>we,setTag:()=>ot,setUser:()=>rt,showFeedback:()=>at,updateWidget:()=>ct});var ie=["login_failed","login_succeeded","login_blocked","password_reset_requested","privilege_granted"];var N=class{constructor(t,n,r,i){this.endpoint=t;this.key=n;this.debug=r;this.instance=i;typeof document<"u"&&document.addEventListener&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.flushWithBeacon()})}endpoint;key;debug;instance;queue=[];timer;sending=!1;enqueue(t){this.queue.push(t),this.queue.length>30&&this.queue.shift(),this.timer||(this.timer=setTimeout(()=>{this.timer=void 0,this.flush()},1e3))}async flush(){if(!this.sending){this.sending=!0;try{for(;this.queue.length>0;){let t=this.queue[0];if(!await this.send(t))break;this.queue.shift()}}finally{this.sending=!1}}}async send(t,n=0){try{let r=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":this.key,...this.instance?{"X-Blipit-Instance":this.instance}:{}},body:JSON.stringify(t),keepalive:!0});return r.status===429||r.status>=500?this.retry(t,n):(this.debug&&r.status>=400&&console.warn("[blipit] event rejected",r.status,await r.text()),!0)}catch{return this.retry(t,n)}}async retry(t,n){return n>=2?(this.debug&&console.warn("[blipit] dropping event after retries",t.event_id),!0):(await new Promise(r=>setTimeout(r,1e3*2**n)),this.send(t,n+1))}flushWithBeacon(){if(!(typeof navigator>"u"||!navigator.sendBeacon))for(;this.queue.length>0;){let t=this.queue.shift(),n=`key=${encodeURIComponent(this.key)}${this.instance?`&instance=${encodeURIComponent(this.instance)}`:""}`,r=`${this.endpoint}${this.endpoint.includes("?")?"&":"?"}${n}`;navigator.sendBeacon(r,JSON.stringify(t))}}};function L(){let e=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(e);else for(let n=0;n<16;n++)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0");return t}function y(){return new Date().toISOString()}var Ie=/token|key|password|secret|auth|session|passwd|api/i;function C(e){let t=e.indexOf("?");if(t===-1)return e.slice(0,2048);let n=e.slice(0,t),i=e.slice(t+1).split("&").map(o=>{let c=o.indexOf("=");if(c===-1)return o;let d=o.slice(0,c);return Ie.test(d)?`${d}=[redacted]`:o}).join("&");return`${n}?${i}`.slice(0,2048)}var $e=/\b((?:[a-zA-Z0-9_-]*(?:token|key|password|secret|auth|session|passwd|api)[a-zA-Z0-9_-]*)=)[^&\s"']+/gi;function re(e){return e.replace($e,"$1[redacted]")}function l(e,t){return e.length>t?e.slice(0,t):e}var oe=".blipit-mask,[data-blipit-mask]";function W(e){return e.replace(/#.*/,"").replace(/([?&][^=&]*)=[^&]*/g,"$1=").slice(0,2048)}function k(e,t,n){e.push(t),e.length>n&&e.shift()}function z(e){let t=e.id?`#${e.id}`:"",n=typeof e.className=="string"&&e.className.trim()?`.${e.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";return l(`${e.tagName.toLowerCase()}${t}${n}`,128)}function S(e,t){return`${e.replace(/\/api\/v1\/events.*$/,"").replace(/\/$/,"")}${t}`}function se(e,t){let n=e?/^(https?:\/\/[^?#]*\/)blipit(?:\.min)?\.js(?:[?#].*)?$/.exec(e):null;return n?n[1]:`https://blipit.io/sdk/${t}/`}var ae={ok:0,errored:1,crashed:2},P=class{constructor(t,n,r,i){this.url=t;this.key=n;this.release=r;this.environment=i;this.start(),typeof document<"u"&&document.addEventListener&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.end():this.sid||this.start()})}url;key;release;environment;sid="";started="";status="ok";errors=0;did;setUser(t){this.did=t}markError(t){if(!this.sid)return;this.errors+=1;let n=t?"crashed":"errored";ae[n]<=ae[this.status]||(this.status=n,this.send(!1))}start(){this.sid=L(),this.started=y(),this.status="ok",this.errors=0,this.send(!1)}end(){this.sid&&(this.send(!0),this.sid="")}send(t){let n=JSON.stringify({sid:this.sid,did:this.did,status:this.status==="ok"&&t?"exited":this.status,errors:this.errors,started:this.started,release:this.release,environment:this.environment}),r=`${this.url}?key=${encodeURIComponent(this.key)}`;try{if(t&&typeof navigator<"u"&&navigator.sendBeacon){navigator.sendBeacon(r,n);return}if(typeof fetch>"u")return;fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":this.key},body:n,keepalive:!0}).catch(()=>{})}catch{return}}};var Ae=/^\s*at (?:async )?(?:new )?(?:(.+?) )?\(?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack):.*?|[^()]+?)(?::(\d+))?(?::(\d+))?\)?\s*$/,Ne=/^\s*(?:(.*?)@)?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack).*?|[^@]*?)(?::(\d+))?(?::(\d+))?\s*$/,de=/^(chrome|moz|safari-web)-extension:/;function Pe(){if(typeof location<"u"&&location.origin)return location.origin}function Ue(e){if(de.test(e)||e==="<anonymous>"||e==="[native code]")return!1;let t=Pe();return!!(!t||e.startsWith(t)||!/^[a-z]+:/i.test(e))}function ce(e){if(!e)return[];let t=[];for(let n of e.split(`
|
|
2
|
+
`)){if(!n||/^\s*(Error|TypeError|RangeError|SyntaxError|ReferenceError)\b/.test(n))continue;let r=Ae.exec(n)??Ne.exec(n);if(!r)continue;let[,i,o,c,d]=r;if(!o)continue;let s={filename:l(o,1024),in_app:Ue(o)};i&&(s.function=l(i,512)),c&&(s.lineno=Number(c)),d&&(s.colno=Number(d)),t.push(s)}return t.reverse(),t.slice(-128)}function ue(e){return e.length===0?!1:e.every(t=>de.test(t.filename))}var H="@blipit/browser",O="0.3.7",M=se(typeof document<"u"?document.currentScript?.src:void 0,O),D="https://in.blipit.io/api/v1/events",De=[/ResizeObserver loop/i,/^Script error\.?$/,/__gCrWeb|__firefox__/],Ke={login_failed:"Failed login",login_succeeded:"Successful login",login_blocked:"Blocked login",password_reset_requested:"Password reset requested",privilege_granted:"Privilege granted"},je={login_failed:"warning",login_succeeded:"info",login_blocked:"warning",password_reset_requested:"info",privilege_granted:"warning"};function Fe(e){if(!ie.includes(e?.kind))return;let t=l(String(e.actor??"").trim(),256);if(!t)return;let n={kind:e.kind,actor:t};return e.actorId&&(n.actor_id=l(String(e.actorId),128)),e.ip&&(n.ip=l(String(e.ip).trim(),45)),e.userAgent&&(n.user_agent=l(String(e.userAgent),512)),e.database&&(n.database=l(String(e.database),64)),e.outcome&&(n.outcome=l(String(e.outcome),64)),e.target&&(n.target=l(String(e.target),256)),n}var U=class{constructor(t){this.options=t;this.endpoint=t.endpoint??D,this.transport=new N(this.endpoint,t.key,t.debug??!1,t.instance),t.autoSessionTracking&&(t.release?this.session=new P(S(this.endpoint,"/api/v1/sessions"),t.key,t.release,t.environment??"production"):t.debug&&console.warn("[blipit] session tracking needs the release option")),this.maxBreadcrumbs=Math.min(t.maxBreadcrumbs??50,100),this.ignoreErrors=[...De,...t.ignoreErrors??[]]}options;transport;breadcrumbs=[];user;tags={};maxBreadcrumbs;ignoreErrors;seen=new Set;session;lastEventId;errorIds=[];logs={console:[],network:[],actions:[]};endpoint;replay;setUser(t){this.user=t,this.session?.setUser(t?.id??t?.email)}setTag(t,n){this.tags[l(t,64)]=l(n,256)}addBreadcrumb(t){let n={timestamp:y(),...t};n.message&&(n.message=re(n.message)),n.data&&typeof n.data.url=="string"&&(n.data={...n.data,url:C(n.data.url)}),this.breadcrumbs.push(n),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift()}captureException(t,n=!0){let r=t instanceof Error?t:new Error(String(t)),i={type:r.name||"Error",value:l(r.message||String(r),4096),handled:n},o=ce(r.stack);return o.length>0&&(i.stacktrace={frames:o}),this.processAndSend({exception:i,level:"error"})}captureMessage(t,n="info"){return this.processAndSend({message:l(t,8192),level:n})}captureSecurity(t){let n=Fe(t);if(!n){this.options.debug&&console.warn("[blipit] security event dropped, needs a known kind and an actor");return}return this.processAndSend({message:`${Ke[n.kind]} for ${n.actor}`,level:je[n.kind],security:n},!1)}processAndSend(t,n=!0){if(n&&this.options.sampleRate!==void 0&&Math.random()>this.options.sampleRate)return;let r=t.exception?.value??t.message??"";if(n){for(let d of this.ignoreErrors)if(typeof d=="string"?r.includes(d):d.test(r))return;if((this.options.autoMuteExtensions??!0)&&t.exception?.stacktrace&&ue(t.exception.stacktrace.frames))return;let c=`${t.exception?.type??""}|${r}`;if(t.exception?.handled===!1){if(this.seen.has(c)&&this.seen.size<100)return;this.seen.add(c),setTimeout(()=>this.seen.delete(c),5e3)}}let i={event_id:L(),timestamp:y(),platform:"javascript",release:this.options.release,environment:this.options.environment??"production",user:this.user,tags:Object.keys(this.tags).length>0?{...this.tags}:void 0,breadcrumbs:this.breadcrumbs.length>0?[...this.breadcrumbs]:void 0,request:typeof location<"u"?{url:C(location.href)}:void 0,contexts:this.collectContexts(),sdk:{name:H,version:O},...t};for(let c of Object.keys(i))i[c]===void 0&&delete i[c];let o=this.replay?.active()&&(i.level==="error"||i.level==="fatal")?this.replay:void 0;if(o&&(i.tags={...i.tags,replay_id:o.id}),this.options.beforeSend){let c=this.options.beforeSend(i);if(!c)return;i=c}return this.transport.enqueue(i),this.lastEventId=i.event_id,(i.level==="error"||i.level==="fatal")&&k(this.errorIds,i.event_id,20),i.exception&&this.session?.markError(i.exception.handled===!1),o?.error(i.event_id),i.event_id}collectContexts(){if(typeof navigator>"u")return;let t={},n=navigator.userAgent??"",r=/(Edg|OPR|Chrome|Firefox|Safari)\/(\d+[\d.]*)/.exec(n)??void 0;r&&(t.browser={name:r[1],version:r[2]});let i=/\(([^)]+)\)/.exec(n);return i&&i[1]&&(t.os={name:l(i[1],64)}),typeof screen<"u"&&(t.device={screen:`${screen.width}x${screen.height}`}),Object.keys(t).length>0?t:void 0}flush(){return this.transport.flush()}};function X(e){return typeof e=="string"?e.length:e?.size}function pe(e){return e&&Number(e)||void 0}function qe(e,t){return async(n,r)=>{let i=typeof n=="string"?n:n instanceof URL?n.href:n.url,o=(r?.method??n.method??"GET").toUpperCase(),c=Date.now();try{let d=await e(n,r);return t(o,i,d.status,c,X(r?.body),pe(d.headers.get("content-length"))),d}catch(d){throw t(o,i,0,c,X(r?.body)),d}}}function We(e,t){let n=e.open,r=e.send;e.open=function(i,o){return this._blipit=[String(i).toUpperCase(),String(o)],n.apply(this,arguments)},e.send=function(i){let o=this._blipit;if(o){let c=Date.now();this.addEventListener("loadend",()=>t(o[0],o[1],this.status,c,X(i),pe(this.getResponseHeader("content-length"))))}return r.apply(this,arguments)}}function le(e){if(typeof window>"u")return;let t=S(e.endpoint,""),{console:n,network:r,actions:i}=e.logs;window.addEventListener("error",s=>{e.captureException(s.error??s.message,!1)}),window.addEventListener("unhandledrejection",s=>{e.captureException(s.reason,!1)}),typeof document<"u"&&(document.addEventListener("click",s=>{let a=s.target;if(!(a instanceof Element)||a.closest("[data-blipit-ui]"))return;let u=z(a);e.addBreadcrumb({category:"ui.click",message:`Clicked ${u}`});let h=a.closest(oe)?"***":l((a.textContent??"").trim().replace(/\s+/g," "),80);k(i,{timestamp:y(),type:"click",selector:u,text:h},50)},{capture:!0,passive:!0}),document.addEventListener("focusin",s=>{let a=s.target;a instanceof Element&&/^(INPUT|TEXTAREA|SELECT)$/.test(a.tagName)&&k(i,{timestamp:y(),type:"focus",selector:z(a)},50)},{capture:!0,passive:!0}));let o=(s,a,u,h,p,m)=>{t&&a.startsWith(t)||(e.addBreadcrumb({category:"http",message:`${s} ${C(a)} \u2192 ${u||"network error"}`,level:u>=400||!u?"error":"info",data:{url:C(a),method:s,status_code:u||void 0}}),k(r,{timestamp:y(),method:s,url:W(a),status:u,duration:Date.now()-h,request_size:p,response_size:m},50))};typeof window.fetch=="function"&&(window.fetch=qe(window.fetch.bind(window),o)),typeof XMLHttpRequest<"u"&&We(XMLHttpRequest.prototype,o);for(let s of["log","info","debug","warn","error"]){let a=console[s].bind(console);console[s]=(...u)=>{let h=l(u.map(p=>typeof p=="string"?p:ze(p)).join(" "),1024);if(s==="warn"||s==="error"){e.addBreadcrumb({category:"console",level:s==="warn"?"warning":"error",message:h});let p=u.find(m=>m instanceof Error);k(n,{timestamp:y(),level:s,message:h,stack:l((p??new Error).stack??"",2e3)},100)}else k(n,{timestamp:y(),level:s,message:h},100);a(...u)}}let c=()=>k(i,{timestamp:y(),type:"navigation",url:W(location.href)},50),d=()=>{e.addBreadcrumb({category:"navigation",message:`Navigated to ${C(location.href)}`}),c()};if(c(),window.history){let s=window.history.pushState.bind(window.history);window.history.pushState=(...a)=>{s(...a),d()},window.addEventListener("popstate",d)}}function ze(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function fe(){let e=0,t=0,n=0,r=0;return i=>(i.hadRecentInput||(t>0&&i.startTime-r<1e3&&i.startTime-n<5e3?t+=i.value:(t=i.value,n=i.startTime),r=i.startTime,t>e&&(e=t)),e)}function He(e){if(e.size===0)return;let t=[...e.values()].sort((n,r)=>r-n);return t[Math.min(t.length-1,Math.floor(e.size/50))]}function Xe(e){return/iPad|Tablet|Android(?!.*Mobile)/i.test(e)?"tablet":/Mobi|iPhone|Android/i.test(e)?"mobile":"desktop"}function I(e,t,n){try{new PerformanceObserver(r=>r.getEntries().forEach(i=>t(i))).observe({type:e,buffered:!0,...n})}catch{}}function me(e,t,n){if(typeof PerformanceObserver>"u"||typeof document>"u")return;let r=performance.getEntriesByType("navigation")[0],i=r?.activationStart??0,o=b=>Math.max(0,Math.round(b-i)),c=document.visibilityState==="hidden",d=location.pathname,s=r?.type,a={},u=fe(),h=new Map,p=!1,m=!1;r&&r.responseStart>0&&(a.ttfb=o(r.responseStart)),c||(I("paint",b=>{b.name==="first-contentful-paint"&&(a.fcp=o(b.startTime))}),I("largest-contentful-paint",b=>{p||(a.lcp=o(b.startTime))}));let R=()=>{p=!0};addEventListener("keydown",R,{once:!0,capture:!0}),addEventListener("pointerdown",R,{once:!0,capture:!0}),I("layout-shift",b=>{a.cls=Math.round(u(b)*1e4)/1e4});let _=b=>{if(!b.interactionId)return;h.set(b.interactionId,Math.max(h.get(b.interactionId)??0,b.duration));let ne=He(h);ne!==void 0&&(a.inp=Math.round(ne))};I("event",_,{durationThreshold:40}),I("first-input",_);let x=navigator.connection?.effectiveType,g=`${new URL("/api/v1/vitals",e).href}?key=${encodeURIComponent(t)}${n?`&instance=${encodeURIComponent(n)}`:""}`,w=()=>{if(m||Object.keys(a).length===0)return;m=!0;let b=JSON.stringify({path:d.slice(0,512),metrics:a,nav:s,connection:x&&/^(slow-2g|2g|3g|4g)$/.test(x)?x:void 0,device:Xe(navigator.userAgent)});try{if(navigator.sendBeacon?.(g,b))return}catch{}fetch(g,{method:"POST",body:b,keepalive:!0}).catch(()=>{})},T=()=>{location.pathname!==d&&(w(),d=location.pathname,s="route",a={},u=fe(),h=new Map,p=!0,m=!1)};document.addEventListener("visibilitychange",()=>document.visibilityState==="hidden"&&w()),addEventListener("pagehide",w),addEventListener("popstate",T);let A=history.pushState;history.pushState=function(...b){A.apply(this,b),T()}}function Ve(e,t=Math.random){return t()<(e.sessionSampleRate??0)?"session":t()<(e.onErrorSampleRate??1)?"buffer":null}function ge(e,t,n,r,i){let o=Ve(e);if(!o||typeof document>"u")return;let c=L(),d,s=document.createElement("script");return s.src=e.src??`${i}blipit-replay.js`,s.async=!0,s.onload=()=>{let a=window.BlipitReplay?.start;d=a?.({id:c,mode:o,endpoint:t,key:n,instance:r})},document.head.appendChild(s),{id:c,active:()=>d?.active()??!1,error:a=>d?.error(a),report:a=>d?.report?.(a)}}var he={en:["Report {ref} sent.","We will email you updates."],ar:["\u062A\u0645 \u0625\u0631\u0633\u0627\u0644 \u0627\u0644\u0628\u0644\u0627\u063A {ref}.","\u0633\u0646\u0631\u0627\u0633\u0644\u0643 \u0628\u0627\u0644\u062A\u062D\u062F\u064A\u062B\u0627\u062A."],de:["Meldung {ref} gesendet.","Wir informieren Sie per E-Mail."],es:["Reporte {ref} enviado.","Te enviaremos novedades por correo."],fr:["Signalement {ref} envoy\xE9.","Nous vous tiendrons au courant par e-mail."],it:["Segnalazione {ref} inviata.","Ti invieremo aggiornamenti via email."],ja:["\u5831\u544A {ref} \u3092\u9001\u4FE1\u3057\u307E\u3057\u305F\u3002","\u9032\u6357\u306F\u30E1\u30FC\u30EB\u3067\u304A\u77E5\u3089\u305B\u3057\u307E\u3059\u3002"],nl:["Melding {ref} verstuurd.","We mailen je updates."],pt:["Relato {ref} enviado.","Vamos enviar novidades por e-mail."],tr:["{ref} numaral\u0131 bildirim g\xF6nderildi.","Geli\u015Fmeleri e-postayla bildirece\u011Fiz."],zh:["\u62A5\u544A {ref} \u5DF2\u53D1\u9001\u3002","\u6211\u4EEC\u4F1A\u901A\u8FC7\u90AE\u4EF6\u544A\u77E5\u8FDB\u5C55\u3002"]};function Ye(e,t,n){if(typeof e!="string"||!/^BR-\d{1,12}$/.test(e))return null;let[r,i]=he[n.toLowerCase().split(/[-_]/)[0]]??he.en;return`${r.replace("{ref}",e)}${t===!0?` ${i}`:""}`}function v(e,t,n){let r=document.createElement(e);return r.style.cssText=t,n!==void 0&&(r.textContent=n),r}var V="display:block;width:100%;box-sizing:border-box;margin:4px 0 12px;padding:8px 10px;font:inherit;border:1px solid #c5ccd6;border-radius:6px;background:#fff;color:#111",be="font:inherit;padding:8px 14px;border-radius:6px;cursor:pointer;border:1px solid #c5ccd6;background:#fff;color:#111",Y=!1;function K(e,t,n){if(Y||typeof document>"u"||!document.body)return;Y=!0;let r=v("dialog","max-width:420px;width:calc(100% - 32px);padding:20px;border:1px solid #c5ccd6;border-radius:10px;font:14px/1.45 system-ui,sans-serif;color:#111;background:#fff");r.setAttribute("aria-labelledby","blipit-fb-title");let i=v("form","margin:0"),o=v("h2","margin:0 0 12px;font-size:17px",n.title??"Tell us what happened");o.id="blipit-fb-title";let c=(x,g,w)=>{let T=v("label","display:block;font-weight:600",x);T.htmlFor=w,g.id=w,i.append(T,g)},d=v("input",V);d.type="text",d.maxLength=128,d.autocomplete="name",d.value=n.name??"";let s=v("input",V);s.type="email",s.maxLength=254,s.autocomplete="email",s.value=n.email??"";let a=v("textarea",`${V};min-height:110px;resize:vertical`);a.required=!0,a.maxLength=5e3;let u=v("p","margin:0 0 12px;min-height:1.2em;font-size:13px");u.setAttribute("role","status"),u.setAttribute("aria-live","polite");let h=v("div","display:flex;gap:8px;justify-content:flex-end"),p=v("button",be,"Cancel");p.type="button";let m=v("button",`${be};background:#111;color:#fff;border-color:#111`,"Send");m.type="submit",i.append(o),c("Name (optional)",d,"blipit-fb-name"),c("Email (optional)",s,"blipit-fb-email"),c("What went wrong?",a,"blipit-fb-message"),h.append(p,m),i.append(u,h),r.append(i),document.body.append(r);let R=()=>{Y=!1,r.remove()},_=()=>typeof r.close=="function"&&r.open?r.close():R();p.addEventListener("click",_),r.addEventListener("close",R),i.addEventListener("submit",async x=>{x.preventDefault();let g=a.value.trim();if(!g){u.textContent="Please describe what happened.",a.focus();return}m.disabled=!0,p.disabled=!0,m.setAttribute("aria-busy","true"),m.textContent="Sending\u2026",u.textContent="";try{let w=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":t},body:JSON.stringify({name:d.value.trim()||void 0,email:s.value.trim()||void 0,message:g,event_id:n.eventId,url:typeof location<"u"?location.href.split(/[?#]/)[0]:void 0})});if(!w.ok)throw new Error(String(w.status));let T=await w.json().catch(()=>({})),A=Ye(T.ref,T.emails,typeof navigator>"u"?"en":navigator.language??"en");u.textContent=A??"Thanks, your message was sent.",m.textContent="Sent",setTimeout(_,A?4e3:1200)}catch{u.textContent="That did not send. Please try again.",m.disabled=!1,p.disabled=!1,m.removeAttribute("aria-busy"),m.textContent="Send"}}),typeof r.showModal=="function"?r.showModal():r.setAttribute("open",""),a.focus()}var G={en:["Report a bug","Loading\u2026"],ar:["\u0623\u0628\u0644\u063A \u0639\u0646 \u062E\u0637\u0623","\u062C\u0627\u0631\u064D \u0627\u0644\u062A\u062D\u0645\u064A\u0644\u2026"],de:["Fehler melden","Wird geladen\u2026"],es:["Reportar un error","Cargando\u2026"],fr:["Signaler un bug","Chargement\u2026"],it:["Segnala un bug","Caricamento\u2026"],ja:["\u4E0D\u5177\u5408\u3092\u5831\u544A","\u8AAD\u307F\u8FBC\u307F\u4E2D\u2026"],nl:["Bug melden","Laden\u2026"],pt:["Reportar erro","Carregando\u2026"],tr:["Hata bildir","Y\xFCkleniyor\u2026"],zh:["\u62A5\u544A\u95EE\u9898","\u52A0\u8F7D\u4E2D\u2026"]},Je="button{all:initial;position:fixed;z-index:2147483646;display:flex;align-items:center;gap:8px;padding:11px 18px;border-radius:99px;background:var(--c,linear-gradient(135deg,#3882F6,#2F5BEA));color:#fff;font:600 14px system-ui,-apple-system,sans-serif;letter-spacing:-.01em;cursor:pointer;box-shadow:0 14px 32px -12px rgba(56,130,246,.75),0 2px 6px rgba(11,26,58,.18),inset 0 1px 0 rgba(255,255,255,.22);transition:transform .2s,box-shadow .2s;animation:in .35s cubic-bezier(.2,.8,.2,1)}button:hover{transform:translateY(-2px);box-shadow:0 20px 40px -12px rgba(56,130,246,.85),0 3px 8px rgba(11,26,58,.2),inset 0 1px 0 rgba(255,255,255,.22)}button:active{transform:scale(.97)}button:focus-visible{outline:3px solid #00C2FF;outline-offset:3px}button:disabled{cursor:progress}svg,i{width:18px;height:18px}i{box-sizing:border-box;border:2px solid;border-right-color:transparent;border-radius:50%;animation:r .8s linear infinite}@keyframes r{to{transform:rotate(1turn)}}@keyframes in{from{opacity:0;transform:translateY(12px) scale(.94)}}.o span{display:none}.o{padding:13px}@media(max-width:480px){span{display:none}button{padding:13px}}@media(pointer:coarse){button{min-height:44px;box-sizing:border-box}}@media(prefers-reduced-motion:reduce){button{animation:none;transition:none}i{animation-duration:3s}}",Ge='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h16v12H9l-5 4zM12 7v4M12 13.5v.5"/></svg>',ve,J={},xe,E,Q=()=>{},B,ye=0;function $(e,t){e.options.debug&&console.log(`[blipit] ${t}`)}function we(e){ve=e}function Z(e,t){return J[t]??=new Promise((n,r)=>{let i=document.createElement("script");i.src=e,i.async=!0,i.onload=()=>{let o=window[t];o?n(o):r(new Error(t))},i.onerror=r,document.head.appendChild(i)}).catch(n=>{throw delete J[t],n}),J[t]}function Se(){let e=(navigator.language??"en").slice(0,2);return G[e]?e:"en"}function ee(e,t){let n=document.createElement("button");return n.type="button",n.className="blipit-rb",n.setAttribute("aria-haspopup","dialog"),e?n.textContent=e:(n.lang=Se(),n.textContent=G[n.lang][0]),n.addEventListener("click",()=>n.hasAttribute("aria-busy")||t()),n}function j(e){if(typeof document>"u")return;let t=typeof e.options.feedbackWidget=="object"?e.options.feedbackWidget:{},n=document.querySelectorAll("button.blipit-rb"),r=i=>{Q(i),n.forEach(o=>i?o.setAttribute("aria-busy","true"):o.removeAttribute("aria-busy"))};r(!0),Promise.all([Z(t.src??`${M}blipit-report.js`,"BlipitReport"),xe??=ke(e)]).then(([i,o])=>o.enabled!==!1&&i.open(e,{metadata:ve,recording:o.recording===!0,recordingMaxMs:o.recording_max_ms,storageFull:o.storage_full===!0,reportsFull:o.reports_full===!0,theme:o.theme,hide:c=>E&&(E.style.display=c?"none":"")}),()=>K(S(e.endpoint,"/api/v1/feedback"),e.options.key,{eventId:e.lastEventId,name:e.user?.username,email:e.user?.email})).finally(()=>r(!1))}async function ke(e){let t=`blipit_fb_${O}_${e.options.key}`;try{let n=JSON.parse(localStorage.getItem(t)??"null");if(n&&Date.now()-n.t<36e5)return n.s}catch{}try{let n=await fetch(S(e.endpoint,"/api/v1/feedback/settings"),{headers:{"X-Blipit-Key":e.options.key,...e.options.instance?{"X-Blipit-Instance":e.options.instance}:{}}});if(!n.ok)return $(e,`widget settings failed (HTTP ${n.status}), using defaults`),{};let r=await n.json();try{localStorage.setItem(t,JSON.stringify({t:Date.now(),s:r}))}catch{}return r}catch{return $(e,"widget settings unreachable (offline, ad blocker or CSP connect-src), using defaults"),{}}}async function te(e){let t=e.options.feedbackWidget,n=++ye;if(typeof document>"u")return;if(t===!1)return $(e,"Report a bug button off: feedbackWidget is false");let r=await(xe??=ke(e));if(n!==ye)return;if(r.enabled===!1)return $(e,"Report a bug button hidden by the project's Bug report widget setting");let i={...r,...typeof t=="object"?t:{}},[o,c]=G[Se()],d=i.text||o;E=document.createElement("div"),E.setAttribute("data-blipit-ui","");let s=E.attachShadow({mode:"open"}),a=document.createElement("style");a.textContent=Je;let u=document.createElement("button");u.type="button";let[h,p]=(/^(bottom|middle)-(left|right)$/.test(i.position??"")?i.position:"bottom-right").split("-");u.style.cssText=`${i.color?`--c:${i.color};`:""}${p}:calc(20px + env(safe-area-inset-${p},0px));${h==="bottom"?"bottom:calc(20px + env(safe-area-inset-bottom,0px))":"top:50%;margin-top:-22px"}`,u.setAttribute("aria-haspopup","dialog"),i.style==="icon"&&(u.className="o",u.title=d);let m=g=>{u.disabled=g,u.setAttribute("aria-label",g?c:d),u.innerHTML=g?"<i></i><span></span>":`${Ge}<span></span>`,u.lastChild.textContent=g?c:d};Q=m,m(!1),u.addEventListener("click",()=>j(e)),s.append(a,u);let R=i.shortcut?.toLowerCase().replace(/\s/g,"");B&&document.removeEventListener("keydown",B),B=void 0,R&&(B=g=>{[g.ctrlKey&&"ctrl",g.shiftKey&&"shift",g.altKey&&"alt",g.metaKey&&"meta",g.key.toLowerCase()].filter(Boolean).join("+")===R&&(g.preventDefault(),j(e))},document.addEventListener("keydown",B));let _=E,x=()=>{E===_&&(document.body.append(_),$(e,`Report a bug button shown at ${h}-${p}`))};document.body?x():document.addEventListener("DOMContentLoaded",x)}function Ee(e,t){let n=e.options.feedbackWidget;e.options.feedbackWidget=t===!1?!1:{...typeof n=="object"?n:{},...t},E?.remove(),E=void 0,B&&document.removeEventListener("keydown",B),B=void 0,Q=()=>{},te(e)}var f,Re=new Set;function _e(e,t){Re.has(t)||(Re.add(t),console[e](t))}var Qe="[blipit] init() has no key, so error tracking and the Report a bug button are off. Pass your public key (blipit_pk_...) from app.blipit.io, API keys.",Ze="[blipit] init() got a secret key (blipit_sk_...), so Blipit did not start: secret keys must never be in browser code. Use the public key (blipit_pk_...) and create a new secret key in app.blipit.io, API keys.";function et(e){if(f)return;let t=typeof e?.key=="string"?e.key.trim():"";if(!t)return _e("warn",Qe);if(t.startsWith("blipit_sk_"))return _e("error",Ze);if(f=new U({...e,key:t}),e.user){let{id:n,name:r,email:i,username:o}=e.user;f.setUser({id:n===void 0?void 0:String(n),email:i,username:o??r})}le(f),e.webVitals!==!1&&typeof window<"u"&&me(e.endpoint??D,t,e.instance),e.replay&&(f.replay=ge(e.replay,e.endpoint??D,t,e.instance,M)),typeof window<"u"&&te(f),e.debug&&console.log(`[blipit] ${H}@${O} initialized`)}function tt(e){return f?.captureException(e,!0)}function nt(e,t){return f?.captureMessage(e,t)}function it(e){return f?.captureSecurity(e)}function rt(e){f?.setUser(e)}function ot(e,t){f?.setTag(e,t)}function st(e){f?.addBreadcrumb(e)}function at(e={}){f&&K(S(f.endpoint,"/api/v1/feedback"),f.options.key,{...e,eventId:e.eventId??f.lastEventId})}function F(){f&&j(f)}function dt(e){e.addEventListener("click",t=>{t.preventDefault(),F()})}function ct(e){f&&Ee(f,e)}function ut(){return f?.flush()??Promise.resolve()}function pt(e={}){let t=ee(e.label,F);return t.style.visibility="hidden",Z(`${M}blipit-button.js`,"BlipitButton").then(n=>n.paint(t,e)).catch(()=>{}).then(()=>t.style.removeProperty("visibility")),t}return Me(lt);})();
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)){if(!n||/^\s*(Error|TypeError|RangeError|SyntaxError|ReferenceError)\b/.test(n))continue;let i=he.exec(n)??be.exec(n);if(!i)continue;let[,r,a,d,c]=i;if(!a)continue;let s={filename:p(a,1024),in_app:ve(a)};r&&(s.function=p(r,512)),d&&(s.lineno=Number(d)),c&&(s.colno=Number(c)),t.push(s)}return t.reverse(),t.slice(-128)}function te(e){return e.length===0?!1:e.every(t=>Z.test(t.filename))}var K="@blipit/browser",B="0.3.3",A=G(typeof document<"u"?document.currentScript?.src:void 0,B),N="https://in.blipit.io/api/v1/events",xe=[/ResizeObserver loop/i,/^Script error\.?$/,/__gCrWeb|__firefox__/],Se={login_failed:"Failed login",login_succeeded:"Successful login",login_blocked:"Blocked login",password_reset_requested:"Password reset requested",privilege_granted:"Privilege granted"},we={login_failed:"warning",login_succeeded:"info",login_blocked:"warning",password_reset_requested:"info",privilege_granted:"warning"};function Ee(e){if(!V.includes(e?.kind))return;let t=p(String(e.actor??"").trim(),256);if(!t)return;let n={kind:e.kind,actor:t};return e.actorId&&(n.actor_id=p(String(e.actorId),128)),e.ip&&(n.ip=p(String(e.ip).trim(),45)),e.userAgent&&(n.user_agent=p(String(e.userAgent),512)),e.database&&(n.database=p(String(e.database),64)),e.outcome&&(n.outcome=p(String(e.outcome),64)),e.target&&(n.target=p(String(e.target),256)),n}var $=class{constructor(t){this.options=t;this.endpoint=t.endpoint??N,this.transport=new M(this.endpoint,t.key,t.debug??!1,t.instance),t.autoSessionTracking&&(t.release?this.session=new O(x(this.endpoint,"/api/v1/sessions"),t.key,t.release,t.environment??"production"):t.debug&&console.warn("[blipit] session tracking needs the release option")),this.maxBreadcrumbs=Math.min(t.maxBreadcrumbs??50,100),this.ignoreErrors=[...xe,...t.ignoreErrors??[]]}options;transport;breadcrumbs=[];user;tags={};maxBreadcrumbs;ignoreErrors;seen=new Set;session;lastEventId;errorIds=[];logs={console:[],network:[],actions:[]};endpoint;replay;setUser(t){this.user=t,this.session?.setUser(t?.id??t?.email)}setTag(t,n){this.tags[p(t,64)]=p(n,256)}addBreadcrumb(t){let n={timestamp:y(),...t};n.message&&(n.message=J(n.message)),n.data&&typeof n.data.url=="string"&&(n.data={...n.data,url:_(n.data.url)}),this.breadcrumbs.push(n),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift()}captureException(t,n=!0){let i=t instanceof Error?t:new Error(String(t)),r={type:i.name||"Error",value:p(i.message||String(i),4096),handled:n},a=ee(i.stack);return a.length>0&&(r.stacktrace={frames:a}),this.processAndSend({exception:r,level:"error"})}captureMessage(t,n="info"){return this.processAndSend({message:p(t,8192),level:n})}captureSecurity(t){let n=Ee(t);if(!n){this.options.debug&&console.warn("[blipit] security event dropped, needs a known kind and an actor");return}return this.processAndSend({message:`${Se[n.kind]} for ${n.actor}`,level:we[n.kind],security:n},!1)}processAndSend(t,n=!0){if(n&&this.options.sampleRate!==void 0&&Math.random()>this.options.sampleRate)return;let i=t.exception?.value??t.message??"";if(n){for(let c of this.ignoreErrors)if(typeof c=="string"?i.includes(c):c.test(i))return;if((this.options.autoMuteExtensions??!0)&&t.exception?.stacktrace&&te(t.exception.stacktrace.frames))return;let d=`${t.exception?.type??""}|${i}`;if(t.exception?.handled===!1){if(this.seen.has(d)&&this.seen.size<100)return;this.seen.add(d),setTimeout(()=>this.seen.delete(d),5e3)}}let r={event_id:T(),timestamp:y(),platform:"javascript",release:this.options.release,environment:this.options.environment??"production",user:this.user,tags:Object.keys(this.tags).length>0?{...this.tags}:void 0,breadcrumbs:this.breadcrumbs.length>0?[...this.breadcrumbs]:void 0,request:typeof location<"u"?{url:_(location.href)}:void 0,contexts:this.collectContexts(),sdk:{name:K,version:B},...t};for(let d of Object.keys(r))r[d]===void 0&&delete r[d];let a=this.replay?.active()&&(r.level==="error"||r.level==="fatal")?this.replay:void 0;if(a&&(r.tags={...r.tags,replay_id:a.id}),this.options.beforeSend){let d=this.options.beforeSend(r);if(!d)return;r=d}return this.transport.enqueue(r),this.lastEventId=r.event_id,(r.level==="error"||r.level==="fatal")&&w(this.errorIds,r.event_id,20),r.exception&&this.session?.markError(r.exception.handled===!1),a?.error(r.event_id),r.event_id}collectContexts(){if(typeof navigator>"u")return;let t={},n=navigator.userAgent??"",i=/(Edg|OPR|Chrome|Firefox|Safari)\/(\d+[\d.]*)/.exec(n)??void 0;i&&(t.browser={name:i[1],version:i[2]});let r=/\(([^)]+)\)/.exec(n);return r&&r[1]&&(t.os={name:p(r[1],64)}),typeof screen<"u"&&(t.device={screen:`${screen.width}x${screen.height}`}),Object.keys(t).length>0?t:void 0}flush(){return this.transport.flush()}};function j(e){return typeof e=="string"?e.length:e?.size}function ne(e){return e&&Number(e)||void 0}function ke(e,t){return async(n,i)=>{let r=typeof n=="string"?n:n instanceof URL?n.href:n.url,a=(i?.method??n.method??"GET").toUpperCase(),d=Date.now();try{let c=await e(n,i);return t(a,r,c.status,d,j(i?.body),ne(c.headers.get("content-length"))),c}catch(c){throw t(a,r,0,d,j(i?.body)),c}}}function Re(e,t){let n=e.open,i=e.send;e.open=function(r,a){return this._blipit=[String(r).toUpperCase(),String(a)],n.apply(this,arguments)},e.send=function(r){let a=this._blipit;if(a){let d=Date.now();this.addEventListener("loadend",()=>t(a[0],a[1],this.status,d,j(r),ne(this.getResponseHeader("content-length"))))}return i.apply(this,arguments)}}function ie(e){if(typeof window>"u")return;let t=x(e.endpoint,""),{console:n,network:i,actions:r}=e.logs;window.addEventListener("error",s=>{e.captureException(s.error??s.message,!1)}),window.addEventListener("unhandledrejection",s=>{e.captureException(s.reason,!1)}),typeof document<"u"&&(document.addEventListener("click",s=>{let o=s.target;if(!(o instanceof Element)||o.closest("[data-blipit-ui]"))return;let u=F(o);e.addBreadcrumb({category:"ui.click",message:`Clicked ${u}`});let g=o.closest(Y)?"***":p((o.textContent??"").trim().replace(/\s+/g," "),80);w(r,{timestamp:y(),type:"click",selector:u,text:g},50)},{capture:!0,passive:!0}),document.addEventListener("focusin",s=>{let o=s.target;o instanceof Element&&/^(INPUT|TEXTAREA|SELECT)$/.test(o.tagName)&&w(r,{timestamp:y(),type:"focus",selector:F(o)},50)},{capture:!0,passive:!0}));let a=(s,o,u,g,l,f)=>{t&&o.startsWith(t)||(e.addBreadcrumb({category:"http",message:`${s} ${_(o)} \u2192 ${u||"network error"}`,level:u>=400||!u?"error":"info",data:{url:_(o),method:s,status_code:u||void 0}}),w(i,{timestamp:y(),method:s,url:D(o),status:u,duration:Date.now()-g,request_size:l,response_size:f},50))};typeof window.fetch=="function"&&(window.fetch=ke(window.fetch.bind(window),a)),typeof XMLHttpRequest<"u"&&Re(XMLHttpRequest.prototype,a);for(let s of["log","info","debug","warn","error"]){let o=console[s].bind(console);console[s]=(...u)=>{let g=p(u.map(l=>typeof l=="string"?l:_e(l)).join(" "),1024);if(s==="warn"||s==="error"){e.addBreadcrumb({category:"console",level:s==="warn"?"warning":"error",message:g});let l=u.find(f=>f instanceof Error);w(n,{timestamp:y(),level:s,message:g,stack:p((l??new Error).stack??"",2e3)},100)}else w(n,{timestamp:y(),level:s,message:g},100);o(...u)}}let d=()=>w(r,{timestamp:y(),type:"navigation",url:D(location.href)},50),c=()=>{e.addBreadcrumb({category:"navigation",message:`Navigated to ${_(location.href)}`}),d()};if(d(),window.history){let s=window.history.pushState.bind(window.history);window.history.pushState=(...o)=>{s(...o),c()},window.addEventListener("popstate",c)}}function _e(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function re(){let e=0,t=0,n=0,i=0;return r=>(r.hadRecentInput||(t>0&&r.startTime-i<1e3&&r.startTime-n<5e3?t+=r.value:(t=r.value,n=r.startTime),i=r.startTime,t>e&&(e=t)),e)}function Te(e){if(e.size===0)return;let t=[...e.values()].sort((n,i)=>i-n);return t[Math.min(t.length-1,Math.floor(e.size/50))]}function Be(e){return/iPad|Tablet|Android(?!.*Mobile)/i.test(e)?"tablet":/Mobi|iPhone|Android/i.test(e)?"mobile":"desktop"}function I(e,t,n){try{new PerformanceObserver(i=>i.getEntries().forEach(r=>t(r))).observe({type:e,buffered:!0,...n})}catch{}}function oe(e,t,n){if(typeof PerformanceObserver>"u"||typeof document>"u")return;let i=performance.getEntriesByType("navigation")[0],r=i?.activationStart??0,a=h=>Math.max(0,Math.round(h-r)),d=document.visibilityState==="hidden",c=location.pathname,s=i?.type,o={},u=re(),g=new Map,l=!1,f=!1;i&&i.responseStart>0&&(o.ttfb=a(i.responseStart)),d||(I("paint",h=>{h.name==="first-contentful-paint"&&(o.fcp=a(h.startTime))}),I("largest-contentful-paint",h=>{l||(o.lcp=a(h.startTime))}));let E=()=>{l=!0};addEventListener("keydown",E,{once:!0,capture:!0}),addEventListener("pointerdown",E,{once:!0,capture:!0}),I("layout-shift",h=>{o.cls=Math.round(u(h)*1e4)/1e4});let b=h=>{if(!h.interactionId)return;g.set(h.interactionId,Math.max(g.get(h.interactionId)??0,h.duration));let W=Te(g);W!==void 0&&(o.inp=Math.round(W))};I("event",b,{durationThreshold:40}),I("first-input",b);let R=navigator.connection?.effectiveType,k=`${new URL("/api/v1/vitals",e).href}?key=${encodeURIComponent(t)}${n?`&instance=${encodeURIComponent(n)}`:""}`,S=()=>{if(f||Object.keys(o).length===0)return;f=!0;let h=JSON.stringify({path:c.slice(0,512),metrics:o,nav:s,connection:R&&/^(slow-2g|2g|3g|4g)$/.test(R)?R:void 0,device:Be(navigator.userAgent)});try{if(navigator.sendBeacon?.(k,h))return}catch{}fetch(k,{method:"POST",body:h,keepalive:!0}).catch(()=>{})},L=()=>{location.pathname!==c&&(S(),c=location.pathname,s="route",o={},u=re(),g=new Map,l=!0,f=!1)};document.addEventListener("visibilitychange",()=>document.visibilityState==="hidden"&&S()),addEventListener("pagehide",S),addEventListener("popstate",L);let fe=history.pushState;history.pushState=function(...h){fe.apply(this,h),L()}}function Ce(e,t=Math.random){return t()<(e.sessionSampleRate??0)?"session":t()<(e.onErrorSampleRate??1)?"buffer":null}function se(e,t,n,i,r){let a=Ce(e);if(!a||typeof document>"u")return;let d=T(),c,s=document.createElement("script");return s.src=e.src??`${r}blipit-replay.js`,s.async=!0,s.onload=()=>{let o=window.BlipitReplay?.start;c=o?.({id:d,mode:a,endpoint:t,key:n,instance:i})},document.head.appendChild(s),{id:d,active:()=>c?.active()??!1,error:o=>c?.error(o),report:o=>c?.report?.(o)}}function v(e,t,n){let i=document.createElement(e);return i.style.cssText=t,n!==void 0&&(i.textContent=n),i}var q="display:block;width:100%;box-sizing:border-box;margin:4px 0 12px;padding:8px 10px;font:inherit;border:1px solid #c5ccd6;border-radius:6px;background:#fff;color:#111",ae="font:inherit;padding:8px 14px;border-radius:6px;cursor:pointer;border:1px solid #c5ccd6;background:#fff;color:#111",z=!1;function U(e,t,n){if(z||typeof document>"u"||!document.body)return;z=!0;let i=v("dialog","max-width:420px;width:calc(100% - 32px);padding:20px;border:1px solid #c5ccd6;border-radius:10px;font:14px/1.45 system-ui,sans-serif;color:#111;background:#fff");i.setAttribute("aria-labelledby","blipit-fb-title");let r=v("form","margin:0"),a=v("h2","margin:0 0 12px;font-size:17px",n.title??"Tell us what happened");a.id="blipit-fb-title";let d=(R,k,S)=>{let L=v("label","display:block;font-weight:600",R);L.htmlFor=S,k.id=S,r.append(L,k)},c=v("input",q);c.type="text",c.maxLength=128,c.autocomplete="name",c.value=n.name??"";let s=v("input",q);s.type="email",s.maxLength=254,s.autocomplete="email",s.value=n.email??"";let o=v("textarea",`${q};min-height:110px;resize:vertical`);o.required=!0,o.maxLength=5e3;let u=v("p","margin:0 0 12px;min-height:1.2em;font-size:13px");u.setAttribute("role","status"),u.setAttribute("aria-live","polite");let g=v("div","display:flex;gap:8px;justify-content:flex-end"),l=v("button",ae,"Cancel");l.type="button";let f=v("button",`${ae};background:#111;color:#fff;border-color:#111`,"Send");f.type="submit",r.append(a),d("Name (optional)",c,"blipit-fb-name"),d("Email (optional)",s,"blipit-fb-email"),d("What went wrong?",o,"blipit-fb-message"),g.append(l,f),r.append(u,g),i.append(r),document.body.append(i);let E=()=>{z=!1,i.remove()},b=()=>typeof i.close=="function"&&i.open?i.close():E();l.addEventListener("click",b),i.addEventListener("close",E),r.addEventListener("submit",async R=>{R.preventDefault();let k=o.value.trim();if(!k){u.textContent="Please describe what happened.",o.focus();return}f.disabled=!0,l.disabled=!0,f.setAttribute("aria-busy","true"),f.textContent="Sending\u2026",u.textContent="";try{let S=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":t},body:JSON.stringify({name:c.value.trim()||void 0,email:s.value.trim()||void 0,message:k,event_id:n.eventId,url:typeof location<"u"?location.href.split(/[?#]/)[0]:void 0})});if(!S.ok)throw new Error(String(S.status));u.textContent="Thanks, your message was sent.",f.textContent="Sent",setTimeout(b,1200)}catch{u.textContent="That did not send. Please try again.",f.disabled=!1,l.disabled=!1,f.removeAttribute("aria-busy"),f.textContent="Send"}}),typeof i.showModal=="function"?i.showModal():i.setAttribute("open",""),o.focus()}var de={en:["Report a bug","Loading\u2026"],ar:["\u0623\u0628\u0644\u063A \u0639\u0646 \u062E\u0637\u0623","\u062C\u0627\u0631\u064D \u0627\u0644\u062A\u062D\u0645\u064A\u0644\u2026"],de:["Fehler melden","Wird geladen\u2026"],es:["Reportar un error","Cargando\u2026"],fr:["Signaler un bug","Chargement\u2026"],it:["Segnala un bug","Caricamento\u2026"],ja:["\u4E0D\u5177\u5408\u3092\u5831\u544A","\u8AAD\u307F\u8FBC\u307F\u4E2D\u2026"],nl:["Bug melden","Laden\u2026"],pt:["Reportar erro","Carregando\u2026"],tr:["Hata bildir","Y\xFCkleniyor\u2026"],zh:["\u62A5\u544A\u95EE\u9898","\u52A0\u8F7D\u4E2D\u2026"]},Le="button{all:initial;position:fixed;z-index:2147483646;display:flex;align-items:center;gap:8px;padding:11px 18px;border-radius:99px;background:var(--c,linear-gradient(135deg,#3882F6,#2F5BEA));color:#fff;font:600 14px system-ui,-apple-system,sans-serif;letter-spacing:-.01em;cursor:pointer;box-shadow:0 14px 32px -12px rgba(56,130,246,.75),0 2px 6px rgba(11,26,58,.18),inset 0 1px 0 rgba(255,255,255,.22);transition:transform .2s,box-shadow .2s;animation:in .35s cubic-bezier(.2,.8,.2,1)}button:hover{transform:translateY(-2px);box-shadow:0 20px 40px -12px rgba(56,130,246,.85),0 3px 8px rgba(11,26,58,.2),inset 0 1px 0 rgba(255,255,255,.22)}button:active{transform:scale(.97)}button:focus-visible{outline:3px solid #00C2FF;outline-offset:3px}button:disabled{cursor:progress}svg,i{width:18px;height:18px}i{box-sizing:border-box;border:2px solid;border-right-color:transparent;border-radius:50%;animation:r .8s linear infinite}@keyframes r{to{transform:rotate(1turn)}}@keyframes in{from{opacity:0;transform:translateY(12px) scale(.94)}}.o span{display:none}.o{padding:13px}@media(max-width:480px){span{display:none}button{padding:13px}}@media(pointer:coarse){button{min-height:44px;box-sizing:border-box}}@media(prefers-reduced-motion:reduce){button{animation:none;transition:none}i{animation-duration:3s}}",Ie='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h16v12H9l-5 4zM12 7v4M12 13.5v.5"/></svg>',ce,H,ue,C,X=()=>{};function Me(e){ce=e}function Oe(e){return H??=new Promise((t,n)=>{let i=document.createElement("script");i.src=e,i.async=!0,i.onload=()=>{let r=window.BlipitReport;r?t(r):n(new Error("report"))},i.onerror=n,document.head.appendChild(i)}).catch(t=>{throw H=void 0,t}),H}function P(e){if(typeof document>"u")return;let t=typeof e.options.feedbackWidget=="object"?e.options.feedbackWidget:{};X(!0),Promise.all([Oe(t.src??`${A}blipit-report.js`),ue??=pe(e)]).then(([n,i])=>i.enabled!==!1&&n.open(e,{metadata:ce,recording:i.recording===!0,recordingMaxMs:i.recording_max_ms,storageFull:i.storage_full===!0,reportsFull:i.reports_full===!0,theme:i.theme,hide:r=>C&&(C.style.display=r?"none":"")}),()=>U(x(e.endpoint,"/api/v1/feedback"),e.options.key,{eventId:e.lastEventId,name:e.user?.username,email:e.user?.email})).finally(()=>X(!1))}async function pe(e){let t=`blipit_fb_${B}_${e.options.key}`;try{let n=JSON.parse(localStorage.getItem(t)??"null");if(n&&Date.now()-n.t<36e5)return n.s}catch{}try{let n=await fetch(x(e.endpoint,"/api/v1/feedback/settings"),{headers:{"X-Blipit-Key":e.options.key,...e.options.instance?{"X-Blipit-Instance":e.options.instance}:{}}});if(!n.ok)return{};let i=await n.json();try{localStorage.setItem(t,JSON.stringify({t:Date.now(),s:i}))}catch{}return i}catch{return{}}}async function le(e){let t=e.options.feedbackWidget;if(t===!1||typeof document>"u")return;let n=await(ue??=pe(e));if(n.enabled===!1)return;let i={...n,...typeof t=="object"?t:{}},[r,a]=de[(navigator.language??"en").slice(0,2)]??de.en,d=i.text||r;C=document.createElement("div"),C.setAttribute("data-blipit-ui","");let c=C.attachShadow({mode:"open"}),s=document.createElement("style");s.textContent=Le;let o=document.createElement("button");o.type="button";let[u,g]=(/^(bottom|middle)-(left|right)$/.test(i.position??"")?i.position:"bottom-right").split("-");o.style.cssText=`${i.color?`--c:${i.color};`:""}${g}:calc(20px + env(safe-area-inset-${g},0px));${u==="bottom"?"bottom:calc(20px + env(safe-area-inset-bottom,0px))":"top:50%;margin-top:-22px"}`,o.setAttribute("aria-haspopup","dialog"),i.style==="icon"&&(o.className="o",o.title=d);let l=b=>{o.disabled=b,o.setAttribute("aria-label",b?a:d),o.innerHTML=b?"<i></i><span></span>":`${Ie}<span></span>`,o.lastChild.textContent=b?a:d};X=l,l(!1),o.addEventListener("click",()=>P(e)),c.append(s,o);let f=i.shortcut?.toLowerCase().replace(/\s/g,"");f&&document.addEventListener("keydown",b=>{[b.ctrlKey&&"ctrl",b.shiftKey&&"shift",b.altKey&&"alt",b.metaKey&&"meta",b.key.toLowerCase()].filter(Boolean).join("+")===f&&(b.preventDefault(),P(e))});let E=()=>document.body.append(C);document.body?E():document.addEventListener("DOMContentLoaded",E)}var m;function lt(e){if(!m){if(m=new $(e),e.user){let{id:t,name:n,email:i,username:r}=e.user;m.setUser({id:t===void 0?void 0:String(t),email:i,username:r??n})}ie(m),e.webVitals!==!1&&typeof window<"u"&&oe(e.endpoint??N,e.key,e.instance),e.replay&&(m.replay=se(e.replay,e.endpoint??N,e.key,e.instance,A)),typeof window<"u"&&le(m),e.debug&&console.log(`[blipit] ${K}@${B} initialized`)}}function ft(e){return m?.captureException(e,!0)}function mt(e,t){return m?.captureMessage(e,t)}function gt(e){return m?.captureSecurity(e)}function ht(e){m?.setUser(e)}function bt(e,t){m?.setTag(e,t)}function yt(e){m?.addBreadcrumb(e)}function vt(e={}){m&&U(x(m.endpoint,"/api/v1/feedback"),m.options.key,{...e,eventId:e.eventId??m.lastEventId})}function $e(){m&&P(m)}function xt(e){e.addEventListener("click",t=>{t.preventDefault(),$e()})}function St(){return m?.flush()??Promise.resolve()}export{yt as addBreadcrumb,xt as attachReport,ft as captureException,mt as captureMessage,gt as captureSecurity,St as flush,lt as init,$e as openReport,Me as setReportMetadata,bt as setTag,ht as setUser,vt as showFeedback};
|
|
1
|
+
var ee=["login_failed","login_succeeded","login_blocked","password_reset_requested","privilege_granted"];var N=class{constructor(t,n,i,r){this.endpoint=t;this.key=n;this.debug=i;this.instance=r;typeof document<"u"&&document.addEventListener&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.flushWithBeacon()})}endpoint;key;debug;instance;queue=[];timer;sending=!1;enqueue(t){this.queue.push(t),this.queue.length>30&&this.queue.shift(),this.timer||(this.timer=setTimeout(()=>{this.timer=void 0,this.flush()},1e3))}async flush(){if(!this.sending){this.sending=!0;try{for(;this.queue.length>0;){let t=this.queue[0];if(!await this.send(t))break;this.queue.shift()}}finally{this.sending=!1}}}async send(t,n=0){try{let i=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":this.key,...this.instance?{"X-Blipit-Instance":this.instance}:{}},body:JSON.stringify(t),keepalive:!0});return i.status===429||i.status>=500?this.retry(t,n):(this.debug&&i.status>=400&&console.warn("[blipit] event rejected",i.status,await i.text()),!0)}catch{return this.retry(t,n)}}async retry(t,n){return n>=2?(this.debug&&console.warn("[blipit] dropping event after retries",t.event_id),!0):(await new Promise(i=>setTimeout(i,1e3*2**n)),this.send(t,n+1))}flushWithBeacon(){if(!(typeof navigator>"u"||!navigator.sendBeacon))for(;this.queue.length>0;){let t=this.queue.shift(),n=`key=${encodeURIComponent(this.key)}${this.instance?`&instance=${encodeURIComponent(this.instance)}`:""}`,i=`${this.endpoint}${this.endpoint.includes("?")?"&":"?"}${n}`;navigator.sendBeacon(i,JSON.stringify(t))}}};function L(){let e=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(e);else for(let n=0;n<16;n++)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<16;n++)t+=e[n].toString(16).padStart(2,"0");return t}function v(){return new Date().toISOString()}var Te=/token|key|password|secret|auth|session|passwd|api/i;function C(e){let t=e.indexOf("?");if(t===-1)return e.slice(0,2048);let n=e.slice(0,t),r=e.slice(t+1).split("&").map(o=>{let c=o.indexOf("=");if(c===-1)return o;let d=o.slice(0,c);return Te.test(d)?`${d}=[redacted]`:o}).join("&");return`${n}?${r}`.slice(0,2048)}var _e=/\b((?:[a-zA-Z0-9_-]*(?:token|key|password|secret|auth|session|passwd|api)[a-zA-Z0-9_-]*)=)[^&\s"']+/gi;function te(e){return e.replace(_e,"$1[redacted]")}function f(e,t){return e.length>t?e.slice(0,t):e}var ne=".blipit-mask,[data-blipit-mask]";function j(e){return e.replace(/#.*/,"").replace(/([?&][^=&]*)=[^&]*/g,"$1=").slice(0,2048)}function E(e,t,n){e.push(t),e.length>n&&e.shift()}function q(e){let t=e.id?`#${e.id}`:"",n=typeof e.className=="string"&&e.className.trim()?`.${e.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";return f(`${e.tagName.toLowerCase()}${t}${n}`,128)}function S(e,t){return`${e.replace(/\/api\/v1\/events.*$/,"").replace(/\/$/,"")}${t}`}function ie(e,t){let n=e?/^(https?:\/\/[^?#]*\/)blipit(?:\.min)?\.js(?:[?#].*)?$/.exec(e):null;return n?n[1]:`https://blipit.io/sdk/${t}/`}function Ce(e){let t=e.match(/rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,\s/]+([\d.]+%?))?/);if(!t||(t[4]===void 0?1:t[4].endsWith("%")?parseFloat(t[4])/100:parseFloat(t[4]))<.5)return null;let[i,r,o]=[t[1],t[2],t[3]].map(c=>{let d=parseFloat(c)/255;return d<=.03928?d/12.92:((d+.055)/1.055)**2.4});return .2126*i+.7152*r+.0722*o}function re(e){if(e==="light"||e==="dark")return e;if(typeof document<"u"){for(let n of[document.body,document.documentElement]){if(!n)continue;let i=Ce(getComputedStyle(n).backgroundColor);if(i!==null)return i<.4?"dark":"light"}let t=getComputedStyle(document.documentElement).colorScheme;if(t==="dark")return"dark";if(t&&t!=="normal"&&!t.includes("dark"))return"light"}return typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var oe={ok:0,errored:1,crashed:2},F=class{constructor(t,n,i,r){this.url=t;this.key=n;this.release=i;this.environment=r;this.start(),typeof document<"u"&&document.addEventListener&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?this.end():this.sid||this.start()})}url;key;release;environment;sid="";started="";status="ok";errors=0;did;setUser(t){this.did=t}markError(t){if(!this.sid)return;this.errors+=1;let n=t?"crashed":"errored";oe[n]<=oe[this.status]||(this.status=n,this.send(!1))}start(){this.sid=L(),this.started=v(),this.status="ok",this.errors=0,this.send(!1)}end(){this.sid&&(this.send(!0),this.sid="")}send(t){let n=JSON.stringify({sid:this.sid,did:this.did,status:this.status==="ok"&&t?"exited":this.status,errors:this.errors,started:this.started,release:this.release,environment:this.environment}),i=`${this.url}?key=${encodeURIComponent(this.key)}`;try{if(t&&typeof navigator<"u"&&navigator.sendBeacon){navigator.sendBeacon(i,n);return}if(typeof fetch>"u")return;fetch(this.url,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":this.key},body:n,keepalive:!0}).catch(()=>{})}catch{return}}};var Le=/^\s*at (?:async )?(?:new )?(?:(.+?) )?\(?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack):.*?|[^()]+?)(?::(\d+))?(?::(\d+))?\)?\s*$/,Me=/^\s*(?:(.*?)@)?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack).*?|[^@]*?)(?::(\d+))?(?::(\d+))?\s*$/,se=/^(chrome|moz|safari-web)-extension:/;function Oe(){if(typeof location<"u"&&location.origin)return location.origin}function Ie(e){if(se.test(e)||e==="<anonymous>"||e==="[native code]")return!1;let t=Oe();return!!(!t||e.startsWith(t)||!/^[a-z]+:/i.test(e))}function ae(e){if(!e)return[];let t=[];for(let n of e.split(`
|
|
2
|
+
`)){if(!n||/^\s*(Error|TypeError|RangeError|SyntaxError|ReferenceError)\b/.test(n))continue;let i=Le.exec(n)??Me.exec(n);if(!i)continue;let[,r,o,c,d]=i;if(!o)continue;let s={filename:f(o,1024),in_app:Ie(o)};r&&(s.function=f(r,512)),c&&(s.lineno=Number(c)),d&&(s.colno=Number(d)),t.push(s)}return t.reverse(),t.slice(-128)}function de(e){return e.length===0?!1:e.every(t=>se.test(t.filename))}var W="@blipit/browser",M="0.3.7",P=ie(typeof document<"u"?document.currentScript?.src:void 0,M),D="https://in.blipit.io/api/v1/events",Ae=[/ResizeObserver loop/i,/^Script error\.?$/,/__gCrWeb|__firefox__/],Ne={login_failed:"Failed login",login_succeeded:"Successful login",login_blocked:"Blocked login",password_reset_requested:"Password reset requested",privilege_granted:"Privilege granted"},Fe={login_failed:"warning",login_succeeded:"info",login_blocked:"warning",password_reset_requested:"info",privilege_granted:"warning"};function Ue(e){if(!ee.includes(e?.kind))return;let t=f(String(e.actor??"").trim(),256);if(!t)return;let n={kind:e.kind,actor:t};return e.actorId&&(n.actor_id=f(String(e.actorId),128)),e.ip&&(n.ip=f(String(e.ip).trim(),45)),e.userAgent&&(n.user_agent=f(String(e.userAgent),512)),e.database&&(n.database=f(String(e.database),64)),e.outcome&&(n.outcome=f(String(e.outcome),64)),e.target&&(n.target=f(String(e.target),256)),n}var U=class{constructor(t){this.options=t;this.endpoint=t.endpoint??D,this.transport=new N(this.endpoint,t.key,t.debug??!1,t.instance),t.autoSessionTracking&&(t.release?this.session=new F(S(this.endpoint,"/api/v1/sessions"),t.key,t.release,t.environment??"production"):t.debug&&console.warn("[blipit] session tracking needs the release option")),this.maxBreadcrumbs=Math.min(t.maxBreadcrumbs??50,100),this.ignoreErrors=[...Ae,...t.ignoreErrors??[]]}options;transport;breadcrumbs=[];user;tags={};maxBreadcrumbs;ignoreErrors;seen=new Set;session;lastEventId;errorIds=[];logs={console:[],network:[],actions:[]};endpoint;replay;setUser(t){this.user=t,this.session?.setUser(t?.id??t?.email)}setTag(t,n){this.tags[f(t,64)]=f(n,256)}addBreadcrumb(t){let n={timestamp:v(),...t};n.message&&(n.message=te(n.message)),n.data&&typeof n.data.url=="string"&&(n.data={...n.data,url:C(n.data.url)}),this.breadcrumbs.push(n),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift()}captureException(t,n=!0){let i=t instanceof Error?t:new Error(String(t)),r={type:i.name||"Error",value:f(i.message||String(i),4096),handled:n},o=ae(i.stack);return o.length>0&&(r.stacktrace={frames:o}),this.processAndSend({exception:r,level:"error"})}captureMessage(t,n="info"){return this.processAndSend({message:f(t,8192),level:n})}captureSecurity(t){let n=Ue(t);if(!n){this.options.debug&&console.warn("[blipit] security event dropped, needs a known kind and an actor");return}return this.processAndSend({message:`${Ne[n.kind]} for ${n.actor}`,level:Fe[n.kind],security:n},!1)}processAndSend(t,n=!0){if(n&&this.options.sampleRate!==void 0&&Math.random()>this.options.sampleRate)return;let i=t.exception?.value??t.message??"";if(n){for(let d of this.ignoreErrors)if(typeof d=="string"?i.includes(d):d.test(i))return;if((this.options.autoMuteExtensions??!0)&&t.exception?.stacktrace&&de(t.exception.stacktrace.frames))return;let c=`${t.exception?.type??""}|${i}`;if(t.exception?.handled===!1){if(this.seen.has(c)&&this.seen.size<100)return;this.seen.add(c),setTimeout(()=>this.seen.delete(c),5e3)}}let r={event_id:L(),timestamp:v(),platform:"javascript",release:this.options.release,environment:this.options.environment??"production",user:this.user,tags:Object.keys(this.tags).length>0?{...this.tags}:void 0,breadcrumbs:this.breadcrumbs.length>0?[...this.breadcrumbs]:void 0,request:typeof location<"u"?{url:C(location.href)}:void 0,contexts:this.collectContexts(),sdk:{name:W,version:M},...t};for(let c of Object.keys(r))r[c]===void 0&&delete r[c];let o=this.replay?.active()&&(r.level==="error"||r.level==="fatal")?this.replay:void 0;if(o&&(r.tags={...r.tags,replay_id:o.id}),this.options.beforeSend){let c=this.options.beforeSend(r);if(!c)return;r=c}return this.transport.enqueue(r),this.lastEventId=r.event_id,(r.level==="error"||r.level==="fatal")&&E(this.errorIds,r.event_id,20),r.exception&&this.session?.markError(r.exception.handled===!1),o?.error(r.event_id),r.event_id}collectContexts(){if(typeof navigator>"u")return;let t={},n=navigator.userAgent??"",i=/(Edg|OPR|Chrome|Firefox|Safari)\/(\d+[\d.]*)/.exec(n)??void 0;i&&(t.browser={name:i[1],version:i[2]});let r=/\(([^)]+)\)/.exec(n);return r&&r[1]&&(t.os={name:f(r[1],64)}),typeof screen<"u"&&(t.device={screen:`${screen.width}x${screen.height}`}),Object.keys(t).length>0?t:void 0}flush(){return this.transport.flush()}};function H(e){return typeof e=="string"?e.length:e?.size}function ce(e){return e&&Number(e)||void 0}function Pe(e,t){return async(n,i)=>{let r=typeof n=="string"?n:n instanceof URL?n.href:n.url,o=(i?.method??n.method??"GET").toUpperCase(),c=Date.now();try{let d=await e(n,i);return t(o,r,d.status,c,H(i?.body),ce(d.headers.get("content-length"))),d}catch(d){throw t(o,r,0,c,H(i?.body)),d}}}function De(e,t){let n=e.open,i=e.send;e.open=function(r,o){return this._blipit=[String(r).toUpperCase(),String(o)],n.apply(this,arguments)},e.send=function(r){let o=this._blipit;if(o){let c=Date.now();this.addEventListener("loadend",()=>t(o[0],o[1],this.status,c,H(r),ce(this.getResponseHeader("content-length"))))}return i.apply(this,arguments)}}function ue(e){if(typeof window>"u")return;let t=S(e.endpoint,""),{console:n,network:i,actions:r}=e.logs;window.addEventListener("error",s=>{e.captureException(s.error??s.message,!1)}),window.addEventListener("unhandledrejection",s=>{e.captureException(s.reason,!1)}),typeof document<"u"&&(document.addEventListener("click",s=>{let a=s.target;if(!(a instanceof Element)||a.closest("[data-blipit-ui]"))return;let u=q(a);e.addBreadcrumb({category:"ui.click",message:`Clicked ${u}`});let b=a.closest(ne)?"***":f((a.textContent??"").trim().replace(/\s+/g," "),80);E(r,{timestamp:v(),type:"click",selector:u,text:b},50)},{capture:!0,passive:!0}),document.addEventListener("focusin",s=>{let a=s.target;a instanceof Element&&/^(INPUT|TEXTAREA|SELECT)$/.test(a.tagName)&&E(r,{timestamp:v(),type:"focus",selector:q(a)},50)},{capture:!0,passive:!0}));let o=(s,a,u,b,l,g)=>{t&&a.startsWith(t)||(e.addBreadcrumb({category:"http",message:`${s} ${C(a)} \u2192 ${u||"network error"}`,level:u>=400||!u?"error":"info",data:{url:C(a),method:s,status_code:u||void 0}}),E(i,{timestamp:v(),method:s,url:j(a),status:u,duration:Date.now()-b,request_size:l,response_size:g},50))};typeof window.fetch=="function"&&(window.fetch=Pe(window.fetch.bind(window),o)),typeof XMLHttpRequest<"u"&&De(XMLHttpRequest.prototype,o);for(let s of["log","info","debug","warn","error"]){let a=console[s].bind(console);console[s]=(...u)=>{let b=f(u.map(l=>typeof l=="string"?l:ze(l)).join(" "),1024);if(s==="warn"||s==="error"){e.addBreadcrumb({category:"console",level:s==="warn"?"warning":"error",message:b});let l=u.find(g=>g instanceof Error);E(n,{timestamp:v(),level:s,message:b,stack:f((l??new Error).stack??"",2e3)},100)}else E(n,{timestamp:v(),level:s,message:b},100);a(...u)}}let c=()=>E(r,{timestamp:v(),type:"navigation",url:j(location.href)},50),d=()=>{e.addBreadcrumb({category:"navigation",message:`Navigated to ${C(location.href)}`}),c()};if(c(),window.history){let s=window.history.pushState.bind(window.history);window.history.pushState=(...a)=>{s(...a),d()},window.addEventListener("popstate",d)}}function ze(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function pe(){let e=0,t=0,n=0,i=0;return r=>(r.hadRecentInput||(t>0&&r.startTime-i<1e3&&r.startTime-n<5e3?t+=r.value:(t=r.value,n=r.startTime),i=r.startTime,t>e&&(e=t)),e)}function Ke(e){if(e.size===0)return;let t=[...e.values()].sort((n,i)=>i-n);return t[Math.min(t.length-1,Math.floor(e.size/50))]}function je(e){return/iPad|Tablet|Android(?!.*Mobile)/i.test(e)?"tablet":/Mobi|iPhone|Android/i.test(e)?"mobile":"desktop"}function O(e,t,n){try{new PerformanceObserver(i=>i.getEntries().forEach(r=>t(r))).observe({type:e,buffered:!0,...n})}catch{}}function le(e,t,n){if(typeof PerformanceObserver>"u"||typeof document>"u")return;let i=performance.getEntriesByType("navigation")[0],r=i?.activationStart??0,o=y=>Math.max(0,Math.round(y-r)),c=document.visibilityState==="hidden",d=location.pathname,s=i?.type,a={},u=pe(),b=new Map,l=!1,g=!1;i&&i.responseStart>0&&(a.ttfb=o(i.responseStart)),c||(O("paint",y=>{y.name==="first-contentful-paint"&&(a.fcp=o(y.startTime))}),O("largest-contentful-paint",y=>{l||(a.lcp=o(y.startTime))}));let $=()=>{l=!0};addEventListener("keydown",$,{once:!0,capture:!0}),addEventListener("pointerdown",$,{once:!0,capture:!0}),O("layout-shift",y=>{a.cls=Math.round(u(y)*1e4)/1e4});let B=y=>{if(!y.interactionId)return;b.set(y.interactionId,Math.max(b.get(y.interactionId)??0,y.duration));let Q=Ke(b);Q!==void 0&&(a.inp=Math.round(Q))};O("event",B,{durationThreshold:40}),O("first-input",B);let w=navigator.connection?.effectiveType,h=`${new URL("/api/v1/vitals",e).href}?key=${encodeURIComponent(t)}${n?`&instance=${encodeURIComponent(n)}`:""}`,k=()=>{if(g||Object.keys(a).length===0)return;g=!0;let y=JSON.stringify({path:d.slice(0,512),metrics:a,nav:s,connection:w&&/^(slow-2g|2g|3g|4g)$/.test(w)?w:void 0,device:je(navigator.userAgent)});try{if(navigator.sendBeacon?.(h,y))return}catch{}fetch(h,{method:"POST",body:y,keepalive:!0}).catch(()=>{})},T=()=>{location.pathname!==d&&(k(),d=location.pathname,s="route",a={},u=pe(),b=new Map,l=!0,g=!1)};document.addEventListener("visibilitychange",()=>document.visibilityState==="hidden"&&k()),addEventListener("pagehide",k),addEventListener("popstate",T);let A=history.pushState;history.pushState=function(...y){A.apply(this,y),T()}}function qe(e,t=Math.random){return t()<(e.sessionSampleRate??0)?"session":t()<(e.onErrorSampleRate??1)?"buffer":null}function fe(e,t,n,i,r){let o=qe(e);if(!o||typeof document>"u")return;let c=L(),d,s=document.createElement("script");return s.src=e.src??`${r}blipit-replay.js`,s.async=!0,s.onload=()=>{let a=window.BlipitReplay?.start;d=a?.({id:c,mode:o,endpoint:t,key:n,instance:i})},document.head.appendChild(s),{id:c,active:()=>d?.active()??!1,error:a=>d?.error(a),report:a=>d?.report?.(a)}}var me={en:["Report {ref} sent.","We will email you updates."],ar:["\u062A\u0645 \u0625\u0631\u0633\u0627\u0644 \u0627\u0644\u0628\u0644\u0627\u063A {ref}.","\u0633\u0646\u0631\u0627\u0633\u0644\u0643 \u0628\u0627\u0644\u062A\u062D\u062F\u064A\u062B\u0627\u062A."],de:["Meldung {ref} gesendet.","Wir informieren Sie per E-Mail."],es:["Reporte {ref} enviado.","Te enviaremos novedades por correo."],fr:["Signalement {ref} envoy\xE9.","Nous vous tiendrons au courant par e-mail."],it:["Segnalazione {ref} inviata.","Ti invieremo aggiornamenti via email."],ja:["\u5831\u544A {ref} \u3092\u9001\u4FE1\u3057\u307E\u3057\u305F\u3002","\u9032\u6357\u306F\u30E1\u30FC\u30EB\u3067\u304A\u77E5\u3089\u305B\u3057\u307E\u3059\u3002"],nl:["Melding {ref} verstuurd.","We mailen je updates."],pt:["Relato {ref} enviado.","Vamos enviar novidades por e-mail."],tr:["{ref} numaral\u0131 bildirim g\xF6nderildi.","Geli\u015Fmeleri e-postayla bildirece\u011Fiz."],zh:["\u62A5\u544A {ref} \u5DF2\u53D1\u9001\u3002","\u6211\u4EEC\u4F1A\u901A\u8FC7\u90AE\u4EF6\u544A\u77E5\u8FDB\u5C55\u3002"]};function We(e,t,n){if(typeof e!="string"||!/^BR-\d{1,12}$/.test(e))return null;let[i,r]=me[n.toLowerCase().split(/[-_]/)[0]]??me.en;return`${i.replace("{ref}",e)}${t===!0?` ${r}`:""}`}function x(e,t,n){let i=document.createElement(e);return i.style.cssText=t,n!==void 0&&(i.textContent=n),i}var X="display:block;width:100%;box-sizing:border-box;margin:4px 0 12px;padding:8px 10px;font:inherit;border:1px solid #c5ccd6;border-radius:6px;background:#fff;color:#111",ge="font:inherit;padding:8px 14px;border-radius:6px;cursor:pointer;border:1px solid #c5ccd6;background:#fff;color:#111",V=!1;function z(e,t,n){if(V||typeof document>"u"||!document.body)return;V=!0;let i=x("dialog","max-width:420px;width:calc(100% - 32px);padding:20px;border:1px solid #c5ccd6;border-radius:10px;font:14px/1.45 system-ui,sans-serif;color:#111;background:#fff");i.setAttribute("aria-labelledby","blipit-fb-title");let r=x("form","margin:0"),o=x("h2","margin:0 0 12px;font-size:17px",n.title??"Tell us what happened");o.id="blipit-fb-title";let c=(w,h,k)=>{let T=x("label","display:block;font-weight:600",w);T.htmlFor=k,h.id=k,r.append(T,h)},d=x("input",X);d.type="text",d.maxLength=128,d.autocomplete="name",d.value=n.name??"";let s=x("input",X);s.type="email",s.maxLength=254,s.autocomplete="email",s.value=n.email??"";let a=x("textarea",`${X};min-height:110px;resize:vertical`);a.required=!0,a.maxLength=5e3;let u=x("p","margin:0 0 12px;min-height:1.2em;font-size:13px");u.setAttribute("role","status"),u.setAttribute("aria-live","polite");let b=x("div","display:flex;gap:8px;justify-content:flex-end"),l=x("button",ge,"Cancel");l.type="button";let g=x("button",`${ge};background:#111;color:#fff;border-color:#111`,"Send");g.type="submit",r.append(o),c("Name (optional)",d,"blipit-fb-name"),c("Email (optional)",s,"blipit-fb-email"),c("What went wrong?",a,"blipit-fb-message"),b.append(l,g),r.append(u,b),i.append(r),document.body.append(i);let $=()=>{V=!1,i.remove()},B=()=>typeof i.close=="function"&&i.open?i.close():$();l.addEventListener("click",B),i.addEventListener("close",$),r.addEventListener("submit",async w=>{w.preventDefault();let h=a.value.trim();if(!h){u.textContent="Please describe what happened.",a.focus();return}g.disabled=!0,l.disabled=!0,g.setAttribute("aria-busy","true"),g.textContent="Sending\u2026",u.textContent="";try{let k=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Blipit-Key":t},body:JSON.stringify({name:d.value.trim()||void 0,email:s.value.trim()||void 0,message:h,event_id:n.eventId,url:typeof location<"u"?location.href.split(/[?#]/)[0]:void 0})});if(!k.ok)throw new Error(String(k.status));let T=await k.json().catch(()=>({})),A=We(T.ref,T.emails,typeof navigator>"u"?"en":navigator.language??"en");u.textContent=A??"Thanks, your message was sent.",g.textContent="Sent",setTimeout(B,A?4e3:1200)}catch{u.textContent="That did not send. Please try again.",g.disabled=!1,l.disabled=!1,g.removeAttribute("aria-busy"),g.textContent="Send"}}),typeof i.showModal=="function"?i.showModal():i.setAttribute("open",""),a.focus()}var Y={en:["Report a bug","Loading\u2026"],ar:["\u0623\u0628\u0644\u063A \u0639\u0646 \u062E\u0637\u0623","\u062C\u0627\u0631\u064D \u0627\u0644\u062A\u062D\u0645\u064A\u0644\u2026"],de:["Fehler melden","Wird geladen\u2026"],es:["Reportar un error","Cargando\u2026"],fr:["Signaler un bug","Chargement\u2026"],it:["Segnala un bug","Caricamento\u2026"],ja:["\u4E0D\u5177\u5408\u3092\u5831\u544A","\u8AAD\u307F\u8FBC\u307F\u4E2D\u2026"],nl:["Bug melden","Laden\u2026"],pt:["Reportar erro","Carregando\u2026"],tr:["Hata bildir","Y\xFCkleniyor\u2026"],zh:["\u62A5\u544A\u95EE\u9898","\u52A0\u8F7D\u4E2D\u2026"]},He="button{all:initial;position:fixed;z-index:2147483646;display:flex;align-items:center;gap:8px;padding:11px 18px;border-radius:99px;background:var(--c,linear-gradient(135deg,#3882F6,#2F5BEA));color:#fff;font:600 14px system-ui,-apple-system,sans-serif;letter-spacing:-.01em;cursor:pointer;box-shadow:0 14px 32px -12px rgba(56,130,246,.75),0 2px 6px rgba(11,26,58,.18),inset 0 1px 0 rgba(255,255,255,.22);transition:transform .2s,box-shadow .2s;animation:in .35s cubic-bezier(.2,.8,.2,1)}button:hover{transform:translateY(-2px);box-shadow:0 20px 40px -12px rgba(56,130,246,.85),0 3px 8px rgba(11,26,58,.2),inset 0 1px 0 rgba(255,255,255,.22)}button:active{transform:scale(.97)}button:focus-visible{outline:3px solid #00C2FF;outline-offset:3px}button:disabled{cursor:progress}svg,i{width:18px;height:18px}i{box-sizing:border-box;border:2px solid;border-right-color:transparent;border-radius:50%;animation:r .8s linear infinite}@keyframes r{to{transform:rotate(1turn)}}@keyframes in{from{opacity:0;transform:translateY(12px) scale(.94)}}.o span{display:none}.o{padding:13px}@media(max-width:480px){span{display:none}button{padding:13px}}@media(pointer:coarse){button{min-height:44px;box-sizing:border-box}}@media(prefers-reduced-motion:reduce){button{animation:none;transition:none}i{animation-duration:3s}}",Xe='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" aria-hidden="true"><path d="M4 4h16v12H9l-5 4zM12 7v4M12 13.5v.5"/></svg>',be,G={},ye,R,J=()=>{},_,he=0;function I(e,t){e.options.debug&&console.log(`[blipit] ${t}`)}function Ve(e){be=e}function Ge(e,t){return G[t]??=new Promise((n,i)=>{let r=document.createElement("script");r.src=e,r.async=!0,r.onload=()=>{let o=window[t];o?n(o):i(new Error(t))},r.onerror=i,document.head.appendChild(r)}).catch(n=>{throw delete G[t],n}),G[t]}function ve(){let e=(navigator.language??"en").slice(0,2);return Y[e]?e:"en"}function xe(e,t){let n=document.createElement("button");return n.type="button",n.className="blipit-rb",n.setAttribute("aria-haspopup","dialog"),e?n.textContent=e:(n.lang=ve(),n.textContent=Y[n.lang][0]),n.addEventListener("click",()=>n.hasAttribute("aria-busy")||t()),n}function K(e){if(typeof document>"u")return;let t=typeof e.options.feedbackWidget=="object"?e.options.feedbackWidget:{},n=document.querySelectorAll("button.blipit-rb"),i=r=>{J(r),n.forEach(o=>r?o.setAttribute("aria-busy","true"):o.removeAttribute("aria-busy"))};i(!0),Promise.all([Ge(t.src??`${P}blipit-report.js`,"BlipitReport"),ye??=we(e)]).then(([r,o])=>o.enabled!==!1&&r.open(e,{metadata:be,recording:o.recording===!0,recordingMaxMs:o.recording_max_ms,storageFull:o.storage_full===!0,reportsFull:o.reports_full===!0,theme:o.theme,hide:c=>R&&(R.style.display=c?"none":"")}),()=>z(S(e.endpoint,"/api/v1/feedback"),e.options.key,{eventId:e.lastEventId,name:e.user?.username,email:e.user?.email})).finally(()=>i(!1))}async function we(e){let t=`blipit_fb_${M}_${e.options.key}`;try{let n=JSON.parse(localStorage.getItem(t)??"null");if(n&&Date.now()-n.t<36e5)return n.s}catch{}try{let n=await fetch(S(e.endpoint,"/api/v1/feedback/settings"),{headers:{"X-Blipit-Key":e.options.key,...e.options.instance?{"X-Blipit-Instance":e.options.instance}:{}}});if(!n.ok)return I(e,`widget settings failed (HTTP ${n.status}), using defaults`),{};let i=await n.json();try{localStorage.setItem(t,JSON.stringify({t:Date.now(),s:i}))}catch{}return i}catch{return I(e,"widget settings unreachable (offline, ad blocker or CSP connect-src), using defaults"),{}}}async function Z(e){let t=e.options.feedbackWidget,n=++he;if(typeof document>"u")return;if(t===!1)return I(e,"Report a bug button off: feedbackWidget is false");let i=await(ye??=we(e));if(n!==he)return;if(i.enabled===!1)return I(e,"Report a bug button hidden by the project's Bug report widget setting");let r={...i,...typeof t=="object"?t:{}},[o,c]=Y[ve()],d=r.text||o;R=document.createElement("div"),R.setAttribute("data-blipit-ui","");let s=R.attachShadow({mode:"open"}),a=document.createElement("style");a.textContent=He;let u=document.createElement("button");u.type="button";let[b,l]=(/^(bottom|middle)-(left|right)$/.test(r.position??"")?r.position:"bottom-right").split("-");u.style.cssText=`${r.color?`--c:${r.color};`:""}${l}:calc(20px + env(safe-area-inset-${l},0px));${b==="bottom"?"bottom:calc(20px + env(safe-area-inset-bottom,0px))":"top:50%;margin-top:-22px"}`,u.setAttribute("aria-haspopup","dialog"),r.style==="icon"&&(u.className="o",u.title=d);let g=h=>{u.disabled=h,u.setAttribute("aria-label",h?c:d),u.innerHTML=h?"<i></i><span></span>":`${Xe}<span></span>`,u.lastChild.textContent=h?c:d};J=g,g(!1),u.addEventListener("click",()=>K(e)),s.append(a,u);let $=r.shortcut?.toLowerCase().replace(/\s/g,"");_&&document.removeEventListener("keydown",_),_=void 0,$&&(_=h=>{[h.ctrlKey&&"ctrl",h.shiftKey&&"shift",h.altKey&&"alt",h.metaKey&&"meta",h.key.toLowerCase()].filter(Boolean).join("+")===$&&(h.preventDefault(),K(e))},document.addEventListener("keydown",_));let B=R,w=()=>{R===B&&(document.body.append(B),I(e,`Report a bug button shown at ${b}-${l}`))};document.body?w():document.addEventListener("DOMContentLoaded",w)}function ke(e,t){let n=e.options.feedbackWidget;e.options.feedbackWidget=t===!1?!1:{...typeof n=="object"?n:{},...t},R?.remove(),R=void 0,_&&document.removeEventListener("keydown",_),_=void 0,J=()=>{},Z(e)}var Se='<svg viewBox="0 0 242.4 208.7" aria-hidden="true"><defs><linearGradient id="bm1" x1="0" y1="1" x2=".5" y2="0"><stop offset="0" stop-color="#00C2FF"/><stop offset=".35" stop-color="#3882F6"/><stop offset="1" stop-color="#0F172A"/></linearGradient><linearGradient id="bm2" x1="0" y1="1" x2="1" y2="0"><stop offset="0" stop-color="#3882F6"/><stop offset=".5" stop-color="#00C2FF"/><stop offset="1" stop-color="#3882F6"/></linearGradient></defs><path fill="url(#bm1)" d="M115.5,164.5c-3.9,0-7.8-.4-11.5-1.2-3.7-.8-7.3-1.9-10.8-3.4-3.4-1.4-6.7-3.2-9.7-5.3-3.0-2.0-5.9-4.4-8.5-7.0s-4.9-5.4-7.0-8.5c-2.1-3.1-3.9-6.3-5.3-9.8-1.5-3.5-2.6-7.1-3.4-10.8-.8-3.8-1.2-7.7-1.2-11.5V19.1c0-6.6,5.4-12.0,12.0-12.0s12.0,5.4,12.0,12.0v88.2c0,2.2.2,4.5.7,6.7.4,2.1,1.1,4.2,1.9,6.2.8,2.0,1.9,3.9,3.1,5.7,1.2,1.8,2.6,3.4,4.1,4.9s3.2,2.9,4.9,4.1c1.8,1.2,3.7,2.2,5.6,3.1,2.0.8,4.1,1.5,6.2,1.9,4.4.9,9.1.9,13.4,0,2.1-.4,4.2-1.1,6.2-1.9,2.0-.8,3.9-1.9,5.7-3.1,1.8-1.2,3.4-2.6,4.9-4.1s2.9-3.2,4.1-4.9c1.2-1.8,2.2-3.7,3.1-5.7.8-2.0,1.5-4.1,1.9-6.2.5-2.2.7-4.5.7-6.7s-.2-4.5-.7-6.7c-.4-2.1-1.1-4.2-1.9-6.2-.8-2.0-1.9-3.9-3.1-5.7-1.2-1.8-2.6-3.4-4.1-4.9s-3.2-2.9-4.9-4.1c-1.8-1.2-3.7-2.2-5.7-3.1-2.0-.8-4.1-1.5-6.2-1.9-4.4-.9-9.1-.9-13.4,0-6.5,1.3-12.9-2.9-14.2-9.4-1.3-6.5,2.9-12.9,9.4-14.2,7.6-1.6,15.5-1.6,23.1,0,3.7.8,7.3,1.9,10.8,3.4,3.4,1.4,6.7,3.2,9.7,5.3,3.0,2.0,5.9,4.4,8.5,7.0s4.9,5.4,7.0,8.5c2.1,3.1,3.9,6.3,5.3,9.8,1.5,3.5,2.6,7.1,3.4,10.8.8,3.8,1.2,7.7,1.2,11.5s-.4,7.8-1.2,11.5c-.8,3.7-1.9,7.3-3.4,10.8-1.4,3.4-3.2,6.7-5.3,9.7-2.0,3.0-4.4,5.9-7.0,8.5s-5.4,4.9-8.5,7.0c-3.1,2.1-6.3,3.9-9.8,5.3-3.5,1.5-7.1,2.6-10.8,3.4-3.8.8-7.7,1.2-11.5,1.2Z"/><path fill="url(#bm2)" d="M208.1,103.0c-.0-.6-.8-.9-1.2-.5-3.2,3.1-7.6,5.0-12.4,5.0-3.9,0-9.1-1.6-10.2-2.5-.3-.1-.1,1.4-.1,2.5,0,40.5-34.4,73.0-75.5,70.0-33.4-2.5-60.8-28.8-64.4-62.1-1.0-9.4-.2-18.6,2.2-27.0,1.6-5.6,2.6-11.4,2.6-17.3v-22.4c0-3.4-4.3-5.0-6.5-2.4-13.2,15.4-21.6,35.1-22.7,56.6-2.6,54.1,40.6,98.9,94.1,98.9s94.2-42.3,94.2-94.2c0-1.5-.1-3.0-.1-4.5Z"/><path fill="url(#bm2)" d="M201.2,70.1c-14.8-35.8-50.9-60.5-92.3-58.3h-.1c-8.2.5-14.6,7.4-14.6,15.7v.1c0,5.4,4.7,9.6,10.0,8.8,3.2-.5,6.5-.7,9.9-.7,28.7,0,53.5,17.4,64.3,42.1.2.5.9.6,1.2.1,3.2-4.8,8.7-7.9,14.9-7.9,2.0,0,4.0.3,5.8,1.0.6.2,1.1-.4.9-1.0Z"/><circle fill="#00C2FF" cx="194.5" cy="88" r="15.8"/></svg>';var p=".blipit-rb.blipit-rb",Ye=`${p}{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:9px;height:40px;padding-inline:5px 17px;border-radius:99px;font:600 14px/1 system-ui,-apple-system,"Segoe UI",sans-serif;letter-spacing:-.01em;white-space:nowrap;cursor:pointer;user-select:none;-webkit-tap-highlight-color:transparent;color:#fff;background:linear-gradient(135deg,#3882F6,#2F5BEA);box-shadow:0 10px 24px -12px rgba(56,130,246,.8),0 1px 3px rgba(11,26,58,.16),inset 0 1px 0 rgba(255,255,255,.22);transition:transform .2s,box-shadow .2s}${p}:hover{transform:translateY(-1px);box-shadow:0 16px 32px -12px rgba(56,130,246,.85),0 2px 6px rgba(11,26,58,.18),inset 0 1px 0 rgba(255,255,255,.22)}${p}:active{transform:scale(.97)}${p}:focus-visible{outline:3px solid #00C2FF;outline-offset:3px}${p}[aria-busy=true]{cursor:progress}${p}>span{all:unset}${p}>.blipit-rb-m{position:relative;display:grid;place-items:center;flex:none;width:30px;height:30px;border-radius:99px;background:#fff;box-shadow:0 0 0 1px rgba(11,26,58,.08),0 1px 2px rgba(11,26,58,.12)}${p} svg{display:block;width:19px;height:17px}${p}[data-size=sm]{height:32px;gap:7px;padding-inline:4px 13px;font-size:13px}${p}[data-size=sm]>.blipit-rb-m{width:24px;height:24px}${p}[data-size=sm] svg{width:15px;height:13px}${p}[data-variant=outline],${p}[data-variant=ghost]{color:#0B1A3A;background:transparent;box-shadow:inset 0 0 0 1px #CBD7EA}${p}[data-variant=ghost]{box-shadow:none}${p}[data-variant=outline]:hover,${p}[data-variant=ghost]:hover{transform:none;background:rgba(56,130,246,.08);box-shadow:inset 0 0 0 1px rgba(56,130,246,.45)}${p}[data-variant=ghost]:hover{box-shadow:none}${p}[data-theme=dark]{background:linear-gradient(135deg,#5B9BFF,#3D6BF0);box-shadow:0 10px 24px -12px rgba(91,155,255,.7),inset 0 1px 0 rgba(255,255,255,.2)}${p}[data-theme=dark][data-variant=outline],${p}[data-theme=dark][data-variant=ghost]{color:#E8EEF8;background:transparent;box-shadow:inset 0 0 0 1px rgba(255,255,255,.16)}${p}[data-theme=dark][data-variant=ghost]{box-shadow:none}${p}[data-theme=dark][data-variant=outline]:hover,${p}[data-theme=dark][data-variant=ghost]:hover{background:rgba(91,155,255,.16);box-shadow:inset 0 0 0 1px rgba(91,155,255,.45)}${p}[data-theme=dark][data-variant=ghost]:hover{box-shadow:none}${p}[data-theme=dark]>.blipit-rb-m{box-shadow:0 0 0 1px rgba(255,255,255,.1)}${p}[aria-busy=true] svg{visibility:hidden}${p}[aria-busy=true]>.blipit-rb-m::after{content:"";position:absolute;inset:4px;border:2px solid #3882F6;border-right-color:transparent;border-radius:50%;animation:blipit-rb-r .8s linear infinite}@keyframes blipit-rb-r{to{transform:rotate(1turn)}}@media(pointer:coarse){${p}{min-height:44px}}@media(prefers-reduced-motion:reduce){${p}{transition:none}${p}:hover,${p}:active{transform:none}${p}[aria-busy=true]>.blipit-rb-m::after{animation-duration:3s}}@media(forced-colors:active){${p}{border:1px solid ButtonText}}`,Je=0;function Ee(e,t={}){if(!document.getElementById("blipit-rb-css")){let o=document.createElement("style");o.id="blipit-rb-css",o.textContent=Ye,document.head.append(o)}let n=++Je,i=document.createElement("span");i.className="blipit-rb-m",i.innerHTML=Se.replace(/bm(\d)/g,`bm$1-${n}`);let r=document.createElement("span");r.textContent=e.textContent,e.replaceChildren(i,r),e.classList.add("blipit-rb"),e.setAttribute("data-variant",t.variant==="outline"||t.variant==="ghost"?t.variant:"solid"),e.setAttribute("data-size",t.size==="sm"?"sm":"md"),e.setAttribute("data-theme",re(t.theme==="light"||t.theme==="dark"?t.theme:void 0))}var m,Re=new Set;function $e(e,t){Re.has(t)||(Re.add(t),console[e](t))}var Ze="[blipit] init() has no key, so error tracking and the Report a bug button are off. Pass your public key (blipit_pk_...) from app.blipit.io, API keys.",Qe="[blipit] init() got a secret key (blipit_sk_...), so Blipit did not start: secret keys must never be in browser code. Use the public key (blipit_pk_...) and create a new secret key in app.blipit.io, API keys.";function Nt(e){if(m)return;let t=typeof e?.key=="string"?e.key.trim():"";if(!t)return $e("warn",Ze);if(t.startsWith("blipit_sk_"))return $e("error",Qe);if(m=new U({...e,key:t}),e.user){let{id:n,name:i,email:r,username:o}=e.user;m.setUser({id:n===void 0?void 0:String(n),email:r,username:o??i})}ue(m),e.webVitals!==!1&&typeof window<"u"&&le(e.endpoint??D,t,e.instance),e.replay&&(m.replay=fe(e.replay,e.endpoint??D,t,e.instance,P)),typeof window<"u"&&Z(m),e.debug&&console.log(`[blipit] ${W}@${M} initialized`)}function Ft(e){return m?.captureException(e,!0)}function Ut(e,t){return m?.captureMessage(e,t)}function Pt(e){return m?.captureSecurity(e)}function Dt(e){m?.setUser(e)}function zt(e,t){m?.setTag(e,t)}function Kt(e){m?.addBreadcrumb(e)}function jt(e={}){m&&z(S(m.endpoint,"/api/v1/feedback"),m.options.key,{...e,eventId:e.eventId??m.lastEventId})}function Be(){m&&K(m)}function qt(e){e.addEventListener("click",t=>{t.preventDefault(),Be()})}function Wt(e={}){let t=xe(e.label,Be);return Ee(t,e),t}function Ht(e){m&&ke(m,e)}function Xt(){return m?.flush()??Promise.resolve()}export{Kt as addBreadcrumb,qt as attachReport,Ft as captureException,Ut as captureMessage,Pt as captureSecurity,Xt as flush,Nt as init,Be as openReport,Wt as reportButton,Ve as setReportMetadata,zt as setTag,Dt as setUser,jt as showFeedback,Ht as updateWidget};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blipit/browser",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "Blipit error monitoring SDK for browsers. Know your app broke before your users tell you.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
|
-
"dist"
|
|
18
|
+
"dist",
|
|
19
|
+
"CHANGELOG.md"
|
|
19
20
|
],
|
|
20
21
|
"sideEffects": false,
|
|
21
22
|
"devDependencies": {
|
|
@@ -46,8 +47,8 @@
|
|
|
46
47
|
"logging"
|
|
47
48
|
],
|
|
48
49
|
"scripts": {
|
|
49
|
-
"build": "tsup src/index.ts --format esm,cjs
|
|
50
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --minify --clean && tsup --entry.index src/global.ts --format iife --global-name Blipit --minify --no-dts && tsup src/replay.ts --format iife --global-name BlipitReplay --minify --no-dts --out-dir served --clean && tsup src/report.ts --format iife --global-name BlipitReport --minify --no-dts --out-dir served && tsup src/button.ts --format iife --global-name BlipitButton --minify --no-dts --out-dir served && node scripts/serve-files.mjs",
|
|
50
51
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
51
|
-
"size": "gzip -c dist/index.global.js | wc -c && gzip -c served/replay.global.js | wc -c && gzip -c served/report.global.js | wc -c"
|
|
52
|
+
"size": "gzip -c dist/index.global.js | wc -c && gzip -c served/replay.global.js | wc -c && gzip -c served/report.global.js | wc -c && gzip -c served/button.global.js | wc -c"
|
|
52
53
|
}
|
|
53
54
|
}
|