@blipit/browser 0.3.3 → 0.3.8
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 +23 -0
- package/README.md +110 -7
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +15 -6
- package/dist/index.d.ts +15 -6
- 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,23 @@
|
|
|
1
|
+
## 0.3.8
|
|
2
|
+
|
|
3
|
+
- Works with a strict Content Security Policy: the Report a bug button, `reportButton()`, the reporter and the video editor use constructable stylesheets and CSSOM styles instead of `<style>` elements and `style` attributes, so `style-src` needs no `'unsafe-inline'`. The screenshot no longer fails in Chromium when the page has web fonts and `style-src` blocks inline styles.
|
|
4
|
+
- If `img-src` does not allow `data:`, the reporter says the screenshot could not be taken instead of showing a blank one; with `debug` the console names the blocked directive. Any screenshot failure is logged with `debug`.
|
|
5
|
+
- Videos keep their place and size in the screenshot: an empty or still loading `<video>` is drawn as an empty box and a live camera stream (`srcObject`) as its current frame, so the layout and the picked element's highlight line up. This replaces the 0.3.6 filter that left such videos out.
|
|
6
|
+
- The same `Error` object captured twice (for example by `error.tsx` under React StrictMode, or by an error boundary and `onCaughtError`) is sent once.
|
|
7
|
+
- The script tag build loads the simple fallback form (shown when the reporter cannot load, and by `showFeedback()`) from `blipit-feedback.js` on first use, so `blipit.js` is 9.8 KB gzipped; npm builds still bundle it.
|
|
8
|
+
|
|
9
|
+
## 0.3.7
|
|
10
|
+
|
|
11
|
+
- `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.
|
|
12
|
+
- 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.
|
|
13
|
+
|
|
14
|
+
## 0.3.6
|
|
15
|
+
|
|
16
|
+
- 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.
|
|
17
|
+
|
|
18
|
+
## 0.3.5
|
|
19
|
+
|
|
20
|
+
- `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.
|
|
21
|
+
- 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.
|
|
22
|
+
- `updateWidget(options)` changes the button while the page runs; `updateWidget(false)` removes it.
|
|
23
|
+
- `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. 10 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 D=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var ve=Object.prototype.hasOwnProperty;var xe=(e,t)=>{for(var n in t)D(e,n,{get:t[n],enumerable:!0})},Se=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ye(t))!ve.call(e,r)&&r!==n&&D(e,r,{get:()=>t[r],enumerable:!(i=be(t,r))||i.enumerable});return e};var we=e=>Se(D({},"__esModule",{value:!0}),e);var Qe={};xe(Qe,{addBreadcrumb:()=>Ve,attachReport:()=>Ye,captureException:()=>qe,captureMessage:()=>ze,captureSecurity:()=>He,flush:()=>Ge,init:()=>je,openReport:()=>ge,setReportMetadata:()=>le,setTag:()=>We,setUser:()=>Xe,showFeedback:()=>Je});module.exports=we(Qe);var J=["login_failed","login_succeeded","login_blocked","password_reset_requested","privilege_granted"];var M=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 T(){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 Ee=/token|key|password|secret|auth|session|passwd|api/i;function _(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(a=>{let d=a.indexOf("=");if(d===-1)return a;let c=a.slice(0,d);return Ee.test(c)?`${c}=[redacted]`:a}).join("&");return`${n}?${r}`.slice(0,2048)}var ke=/\b((?:[a-zA-Z0-9_-]*(?:token|key|password|secret|auth|session|passwd|api)[a-zA-Z0-9_-]*)=)[^&\s"']+/gi;function Y(e){return e.replace(ke,"$1[redacted]")}function p(e,t){return e.length>t?e.slice(0,t):e}var G=".blipit-mask,[data-blipit-mask]";function F(e){return e.replace(/#.*/,"").replace(/([?&][^=&]*)=[^&]*/g,"$1=").slice(0,2048)}function w(e,t,n){e.push(t),e.length>n&&e.shift()}function K(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 p(`${e.tagName.toLowerCase()}${t}${n}`,128)}function x(e,t){return`${e.replace(/\/api\/v1\/events.*$/,"").replace(/\/$/,"")}${t}`}function Q(e,t){let n=e?/^(https?:\/\/[^?#]*\/)blipit(?:\.min)?\.js(?:[?#].*)?$/.exec(e):null;return n?n[1]:`https://blipit.io/sdk/${t}/`}var Z={ok:0,errored:1,crashed:2},O=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";Z[n]<=Z[this.status]||(this.status=n,this.send(!1))}start(){this.sid=T(),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}),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 Re=/^\s*at (?:async )?(?:new )?(?:(.+?) )?\(?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack):.*?|[^()]+?)(?::(\d+))?(?::(\d+))?\)?\s*$/,_e=/^\s*(?:(.*?)@)?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack).*?|[^@]*?)(?::(\d+))?(?::(\d+))?\s*$/,ee=/^(chrome|moz|safari-web)-extension:/;function Te(){if(typeof location<"u"&&location.origin)return location.origin}function Be(e){if(ee.test(e)||e==="<anonymous>"||e==="[native code]")return!1;let t=Te();return!!(!t||e.startsWith(t)||!/^[a-z]+:/i.test(e))}function te(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=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 Ae=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var De=(e,t)=>{for(var n in t)j(e,n,{get:t[n],enumerable:!0})},Pe=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Fe(t))!Ne.call(e,r)&&r!==n&&j(e,r,{get:()=>t[r],enumerable:!(i=Ae(t,r))||i.enumerable});return e};var Ue=e=>Pe(j({},"__esModule",{value:!0}),e);var St={};De(St,{addBreadcrumb:()=>bt,attachReport:()=>vt,captureException:()=>lt,captureMessage:()=>ft,captureSecurity:()=>mt,flush:()=>wt,init:()=>pt,openReport:()=>te,reportButton:()=>xt,setReportMetadata:()=>ye,setTag:()=>ht,setUser:()=>gt,showFeedback:()=>yt,updateWidget:()=>kt});module.exports=Ue(St);var ie={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 ze(e,t,n){if(typeof e!="string"||!/^BR-\d{1,12}$/.test(e))return null;let[i,r]=ie[n.toLowerCase().split(/[-_]/)[0]]??ie.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 W="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",re="font:inherit;padding:8px 14px;border-radius:6px;cursor:pointer;border:1px solid #c5ccd6;background:#fff;color:#111",q=!1;function oe(e,t,n){if(q||typeof document>"u"||!document.body)return;q=!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=(b,$,k)=>{let B=x("label","display:block;font-weight:600",b);B.htmlFor=k,$.id=k,r.append(B,$)},d=x("input",W);d.type="text",d.maxLength=128,d.autocomplete="name",d.value=n.name??"";let a=x("input",W);a.type="email",a.maxLength=254,a.autocomplete="email",a.value=n.email??"";let s=x("textarea",`${W};min-height:110px;resize:vertical`);s.required=!0,s.maxLength=5e3;let p=x("p","margin:0 0 12px;min-height:1.2em;font-size:13px");p.setAttribute("role","status"),p.setAttribute("aria-live","polite");let h=x("div","display:flex;gap:8px;justify-content:flex-end"),f=x("button",re,"Cancel");f.type="button";let m=x("button",`${re};background:#111;color:#fff;border-color:#111`,"Send");m.type="submit",r.append(o),c("Name (optional)",d,"blipit-fb-name"),c("Email (optional)",a,"blipit-fb-email"),c("What went wrong?",s,"blipit-fb-message"),h.append(f,m),r.append(p,h),i.append(r),document.body.append(i);let E=()=>{q=!1,i.remove()},R=()=>typeof i.close=="function"&&i.open?i.close():E();f.addEventListener("click",R),i.addEventListener("close",E),r.addEventListener("submit",async b=>{b.preventDefault();let $=s.value.trim();if(!$){p.textContent="Please describe what happened.",s.focus();return}m.disabled=!0,f.disabled=!0,m.setAttribute("aria-busy","true"),m.textContent="Sending\u2026",p.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:a.value.trim()||void 0,message:$,event_id:n.eventId,url:typeof location<"u"?location.href.split(/[?#]/)[0]:void 0})});if(!k.ok)throw new Error(String(k.status));let B=await k.json().catch(()=>({})),A=ze(B.ref,B.emails,typeof navigator>"u"?"en":navigator.language??"en");p.textContent=A??"Thanks, your message was sent.",m.textContent="Sent",setTimeout(R,A?4e3:1200)}catch{p.textContent="That did not send. Please try again.",m.disabled=!1,f.disabled=!1,m.removeAttribute("aria-busy"),m.textContent="Send"}}),typeof i.showModal=="function"?i.showModal():i.setAttribute("open",""),s.focus()}var se=["login_failed","login_succeeded","login_blocked","password_reset_requested","privilege_granted"];var F=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 Ke=/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 Ke.test(d)?`${d}=[redacted]`:o}).join("&");return`${n}?${r}`.slice(0,2048)}var je=/\b((?:[a-zA-Z0-9_-]*(?:token|key|password|secret|auth|session|passwd|api)[a-zA-Z0-9_-]*)=)[^&\s"']+/gi;function ae(e){return e.replace(je,"$1[redacted]")}function l(e,t){return e.length>t?e.slice(0,t):e}var de=".blipit-mask,[data-blipit-mask]";function H(e){return e.replace(/#.*/,"").replace(/([?&][^=&]*)=[^&]*/g,"$1=").slice(0,2048)}function w(e,t,n){e.push(t),e.length>n&&e.shift()}function X(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 N(e,t){try{let n=new CSSStyleSheet;n.replaceSync(t),e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]}catch{let n=document.createElement("style");n.textContent=t,(e===document?document.head:e).append(n)}}function T(e,t){return`${e.replace(/\/api\/v1\/events.*$/,"").replace(/\/$/,"")}${t}`}function ce(e,t){let n=e?/^(https?:\/\/[^?#]*\/)blipit(?:\.min)?\.js(?:[?#].*)?$/.exec(e):null;return n?n[1]:`https://blipit.io/sdk/${t}/`}function We(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 ue(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=We(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 pe={ok:0,errored:1,crashed:2},D=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";pe[n]<=pe[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 qe=/^\s*at (?:async )?(?:new )?(?:(.+?) )?\(?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack):.*?|[^()]+?)(?::(\d+))?(?::(\d+))?\)?\s*$/,He=/^\s*(?:(.*?)@)?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack).*?|[^@]*?)(?::(\d+))?(?::(\d+))?\s*$/,le=/^(chrome|moz|safari-web)-extension:/;function Xe(){if(typeof location<"u"&&location.origin)return location.origin}function Ve(e){if(le.test(e)||e==="<anonymous>"||e==="[native code]")return!1;let t=Xe();return!!(!t||e.startsWith(t)||!/^[a-z]+:/i.test(e))}function fe(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=qe.exec(n)??He.exec(n);if(!i)continue;let[,r,o,c,d]=i;if(!o)continue;let a={filename:l(o,1024),in_app:Ve(o)};r&&(a.function=l(r,512)),c&&(a.lineno=Number(c)),d&&(a.colno=Number(d)),t.push(a)}return t.reverse(),t.slice(-128)}function me(e){return e.length===0?!1:e.every(t=>le.test(t.filename))}var V="@blipit/browser",M="0.3.8",U=ce(typeof document<"u"?document.currentScript?.src:void 0,M),z="https://in.blipit.io/api/v1/events",Ge=[/ResizeObserver loop/i,/^Script error\.?$/,/__gCrWeb|__firefox__/],Ye={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 Ze(e){if(!se.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 P=class{constructor(t){this.options=t;this.endpoint=t.endpoint??z,this.transport=new F(this.endpoint,t.key,t.debug??!1,t.instance),t.autoSessionTracking&&(t.release?this.session=new D(T(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=[...Ge,...t.ignoreErrors??[]]}options;transport;breadcrumbs=[];user;tags={};maxBreadcrumbs;ignoreErrors;seen=new Set;captured=new WeakSet;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:v(),...t};n.message&&(n.message=ae(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){if(t&&typeof t=="object"){if(this.captured.has(t))return;this.captured.add(t)}let i=t instanceof Error?t:new Error(String(t)),r={type:i.name||"Error",value:l(i.message||String(i),4096),handled:n},o=fe(i.stack);return o.length>0&&(r.stacktrace={frames:o}),this.processAndSend({exception:r,level:"error"})}captureMessage(t,n="info"){return this.processAndSend({message:l(t,8192),level:n})}captureSecurity(t){let n=Ze(t);if(!n){this.options.debug&&console.warn("[blipit] security event dropped, needs a known kind and an actor");return}return this.processAndSend({message:`${Ye[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 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&&me(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:V,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")&&w(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:l(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()}};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"]},Qe="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}}",et='<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>',he,G={},be,S,J=()=>{},_,ge=0;function O(e,t){e.options.debug&&console.log(`[blipit] ${t}`)}function ye(e){he=e}function tt(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}var ke=()=>{};function we(e){ke=e}function Z(e,t){ke(T(e.endpoint,"/api/v1/feedback"),e.options.key,t)}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([tt(t.src??`${U}blipit-report.js`,"BlipitReport"),be??=Se(e)]).then(([r,o])=>o.enabled!==!1&&r.open(e,{metadata:he,recording:o.recording===!0,recordingMaxMs:o.recording_max_ms,storageFull:o.storage_full===!0,reportsFull:o.reports_full===!0,theme:o.theme,hide:c=>S&&(S.style.display=c?"none":"")}),()=>Z(e,{eventId:e.lastEventId,name:e.user?.username,email:e.user?.email})).finally(()=>i(!1))}async function Se(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(T(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 O(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 O(e,"widget settings unreachable (offline, ad blocker or CSP connect-src), using defaults"),{}}}async function Q(e){let t=e.options.feedbackWidget,n=++ge;if(typeof document>"u")return;if(t===!1)return O(e,"Report a bug button off: feedbackWidget is false");let i=await(be??=Se(e));if(n!==ge)return;if(i.enabled===!1)return O(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;S=document.createElement("div"),S.setAttribute("data-blipit-ui","");let a=S.attachShadow({mode:"open"}),s=document.createElement("button");s.type="button";let[p,h]=(/^(bottom|middle)-(left|right)$/.test(r.position??"")?r.position:"bottom-right").split("-");s.style.cssText=`${r.color?`--c:${r.color};`:""}${h}:calc(20px + env(safe-area-inset-${h},0px));${p==="bottom"?"bottom:calc(20px + env(safe-area-inset-bottom,0px))":"top:50%;margin-top:-22px"}`,s.setAttribute("aria-haspopup","dialog"),r.style==="icon"&&(s.className="o",s.title=d);let f=b=>{s.disabled=b,s.setAttribute("aria-label",b?c:d),s.innerHTML=b?"<i></i><span></span>":`${et}<span></span>`,s.lastChild.textContent=b?c:d};J=f,f(!1),s.addEventListener("click",()=>K(e)),N(a,Qe),a.append(s);let m=r.shortcut?.toLowerCase().replace(/\s/g,"");_&&document.removeEventListener("keydown",_),_=void 0,m&&(_=b=>{[b.ctrlKey&&"ctrl",b.shiftKey&&"shift",b.altKey&&"alt",b.metaKey&&"meta",b.key.toLowerCase()].filter(Boolean).join("+")===m&&(b.preventDefault(),K(e))},document.addEventListener("keydown",_));let E=S,R=()=>{S===E&&(document.body.append(E),O(e,`Report a bug button shown at ${p}-${h}`))};document.body?R():document.addEventListener("DOMContentLoaded",R)}function Ee(e,t){let n=e.options.feedbackWidget;e.options.feedbackWidget=t===!1?!1:{...typeof n=="object"?n:{},...t},S?.remove(),S=void 0,_&&document.removeEventListener("keydown",_),_=void 0,J=()=>{},Q(e)}function ee(e){return typeof e=="string"?e.length:e?.size}function Re(e){return e&&Number(e)||void 0}function nt(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,ee(i?.body),Re(d.headers.get("content-length"))),d}catch(d){throw t(o,r,0,c,ee(i?.body)),d}}}function it(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,ee(r),Re(this.getResponseHeader("content-length"))))}return i.apply(this,arguments)}}function $e(e){if(typeof window>"u")return;let t=T(e.endpoint,""),{console:n,network:i,actions:r}=e.logs;window.addEventListener("error",a=>{e.captureException(a.error??a.message,!1)}),window.addEventListener("unhandledrejection",a=>{e.captureException(a.reason,!1)}),typeof document<"u"&&(document.addEventListener("click",a=>{let s=a.target;if(!(s instanceof Element)||s.closest("[data-blipit-ui]"))return;let p=X(s);e.addBreadcrumb({category:"ui.click",message:`Clicked ${p}`});let h=s.closest(de)?"***":l((s.textContent??"").trim().replace(/\s+/g," "),80);w(r,{timestamp:v(),type:"click",selector:p,text:h},50)},{capture:!0,passive:!0}),document.addEventListener("focusin",a=>{let s=a.target;s instanceof Element&&/^(INPUT|TEXTAREA|SELECT)$/.test(s.tagName)&&w(r,{timestamp:v(),type:"focus",selector:X(s)},50)},{capture:!0,passive:!0}));let o=(a,s,p,h,f,m)=>{t&&s.startsWith(t)||(e.addBreadcrumb({category:"http",message:`${a} ${C(s)} \u2192 ${p||"network error"}`,level:p>=400||!p?"error":"info",data:{url:C(s),method:a,status_code:p||void 0}}),w(i,{timestamp:v(),method:a,url:H(s),status:p,duration:Date.now()-h,request_size:f,response_size:m},50))};typeof window.fetch=="function"&&(window.fetch=nt(window.fetch.bind(window),o)),typeof XMLHttpRequest<"u"&&it(XMLHttpRequest.prototype,o);for(let a of["log","info","debug","warn","error"]){let s=console[a].bind(console);console[a]=(...p)=>{let h=l(p.map(f=>typeof f=="string"?f:rt(f)).join(" "),1024);if(a==="warn"||a==="error"){e.addBreadcrumb({category:"console",level:a==="warn"?"warning":"error",message:h});let f=p.find(m=>m instanceof Error);w(n,{timestamp:v(),level:a,message:h,stack:l((f??new Error).stack??"",2e3)},100)}else w(n,{timestamp:v(),level:a,message:h},100);s(...p)}}let c=()=>w(r,{timestamp:v(),type:"navigation",url:H(location.href)},50),d=()=>{e.addBreadcrumb({category:"navigation",message:`Navigated to ${C(location.href)}`}),c()};if(c(),window.history){let a=window.history.pushState.bind(window.history);window.history.pushState=(...s)=>{a(...s),d()},window.addEventListener("popstate",d)}}function rt(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function Be(){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 ot(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 st(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 Te(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,a=i?.type,s={},p=Be(),h=new Map,f=!1,m=!1;i&&i.responseStart>0&&(s.ttfb=o(i.responseStart)),c||(I("paint",y=>{y.name==="first-contentful-paint"&&(s.fcp=o(y.startTime))}),I("largest-contentful-paint",y=>{f||(s.lcp=o(y.startTime))}));let E=()=>{f=!0};addEventListener("keydown",E,{once:!0,capture:!0}),addEventListener("pointerdown",E,{once:!0,capture:!0}),I("layout-shift",y=>{s.cls=Math.round(p(y)*1e4)/1e4});let R=y=>{if(!y.interactionId)return;h.set(y.interactionId,Math.max(h.get(y.interactionId)??0,y.duration));let ne=ot(h);ne!==void 0&&(s.inp=Math.round(ne))};I("event",R,{durationThreshold:40}),I("first-input",R);let b=navigator.connection?.effectiveType,$=`${new URL("/api/v1/vitals",e).href}?key=${encodeURIComponent(t)}${n?`&instance=${encodeURIComponent(n)}`:""}`,k=()=>{if(m||Object.keys(s).length===0)return;m=!0;let y=JSON.stringify({path:d.slice(0,512),metrics:s,nav:a,connection:b&&/^(slow-2g|2g|3g|4g)$/.test(b)?b:void 0,device:st(navigator.userAgent)});try{if(navigator.sendBeacon?.($,y))return}catch{}fetch($,{method:"POST",body:y,keepalive:!0}).catch(()=>{})},B=()=>{location.pathname!==d&&(k(),d=location.pathname,a="route",s={},p=Be(),h=new Map,f=!0,m=!1)};document.addEventListener("visibilitychange",()=>document.visibilityState==="hidden"&&k()),addEventListener("pagehide",k),addEventListener("popstate",B);let A=history.pushState;history.pushState=function(...y){A.apply(this,y),B()}}function at(e,t=Math.random){return t()<(e.sessionSampleRate??0)?"session":t()<(e.onErrorSampleRate??1)?"buffer":null}function _e(e,t,n,i,r){let o=at(e);if(!o||typeof document>"u")return;let c=L(),d,a=document.createElement("script");return a.src=e.src??`${r}blipit-replay.js`,a.async=!0,a.onload=()=>{let s=window.BlipitReplay?.start;d=s?.({id:c,mode:o,endpoint:t,key:n,instance:i})},document.head.appendChild(a),{id:c,active:()=>d?.active()??!1,error:s=>d?.error(s),report:s=>d?.report?.(s)}}var Ce='<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 u=".blipit-rb.blipit-rb",dt=`${u}{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}${u}: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)}${u}:active{transform:scale(.97)}${u}:focus-visible{outline:3px solid #00C2FF;outline-offset:3px}${u}[aria-busy=true]{cursor:progress}${u}>span{all:unset}${u}>.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)}${u} svg{display:block;width:19px;height:17px}${u}[data-size=sm]{height:32px;gap:7px;padding-inline:4px 13px;font-size:13px}${u}[data-size=sm]>.blipit-rb-m{width:24px;height:24px}${u}[data-size=sm] svg{width:15px;height:13px}${u}[data-variant=outline],${u}[data-variant=ghost]{color:#0B1A3A;background:transparent;box-shadow:inset 0 0 0 1px #CBD7EA}${u}[data-variant=ghost]{box-shadow:none}${u}[data-variant=outline]:hover,${u}[data-variant=ghost]:hover{transform:none;background:rgba(56,130,246,.08);box-shadow:inset 0 0 0 1px rgba(56,130,246,.45)}${u}[data-variant=ghost]:hover{box-shadow:none}${u}[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)}${u}[data-theme=dark][data-variant=outline],${u}[data-theme=dark][data-variant=ghost]{color:#E8EEF8;background:transparent;box-shadow:inset 0 0 0 1px rgba(255,255,255,.16)}${u}[data-theme=dark][data-variant=ghost]{box-shadow:none}${u}[data-theme=dark][data-variant=outline]:hover,${u}[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)}${u}[data-theme=dark][data-variant=ghost]:hover{box-shadow:none}${u}[data-theme=dark]>.blipit-rb-m{box-shadow:0 0 0 1px rgba(255,255,255,.1)}${u}[aria-busy=true] svg{visibility:hidden}${u}[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){${u}{min-height:44px}}@media(prefers-reduced-motion:reduce){${u}{transition:none}${u}:hover,${u}:active{transform:none}${u}[aria-busy=true]>.blipit-rb-m::after{animation-duration:3s}}@media(forced-colors:active){${u}{border:1px solid ButtonText}}`,Le=0;function Me(e,t={}){Le||N(document,dt);let n=++Le,i=document.createElement("span");i.className="blipit-rb-m",i.innerHTML=Ce.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",ue(t.theme==="light"||t.theme==="dark"?t.theme:void 0))}var g,Oe=new Set;function Ie(e,t){Oe.has(t)||(Oe.add(t),console[e](t))}var ct="[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.",ut="[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 pt(e){if(g)return;let t=typeof e?.key=="string"?e.key.trim():"";if(!t)return Ie("warn",ct);if(t.startsWith("blipit_sk_"))return Ie("error",ut);if(g=new P({...e,key:t}),e.user){let{id:n,name:i,email:r,username:o}=e.user;g.setUser({id:n===void 0?void 0:String(n),email:r,username:o??i})}$e(g),e.webVitals!==!1&&typeof window<"u"&&Te(e.endpoint??z,t,e.instance),e.replay&&(g.replay=_e(e.replay,e.endpoint??z,t,e.instance,U)),typeof window<"u"&&Q(g),e.debug&&console.log(`[blipit] ${V}@${M} initialized`)}function lt(e){return g?.captureException(e,!0)}function ft(e,t){return g?.captureMessage(e,t)}function mt(e){return g?.captureSecurity(e)}function gt(e){g?.setUser(e)}function ht(e,t){g?.setTag(e,t)}function bt(e){g?.addBreadcrumb(e)}function yt(e={}){g&&Z(g,{...e,eventId:e.eventId??g.lastEventId})}function te(){g&&K(g)}function vt(e){e.addEventListener("click",t=>{t.preventDefault(),te()})}function xt(e={}){let t=xe(e.label,te);return Me(t,e),t}function kt(e){g&&Ee(g,e)}function wt(){return g?.flush()??Promise.resolve()}we(oe);0&&(module.exports={addBreadcrumb,attachReport,captureException,captureMessage,captureSecurity,flush,init,openReport,reportButton,setReportMetadata,setTag,setUser,showFeedback,updateWidget});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { BlipitEvent, SecurityKind, Breadcrumb, Level } from '@blipit/schema';
|
|
2
2
|
export { BlipitEvent, BlipitSecurity, Breadcrumb, Level, SecurityKind } from '@blipit/schema';
|
|
3
3
|
|
|
4
|
+
interface FeedbackOptions {
|
|
5
|
+
eventId?: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
email?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
4
11
|
interface WidgetOptions {
|
|
5
12
|
position?: "bottom-right" | "bottom-left" | "middle-right" | "middle-left";
|
|
6
13
|
color?: string;
|
|
@@ -61,11 +68,11 @@ interface SecurityReport {
|
|
|
61
68
|
target?: string;
|
|
62
69
|
}
|
|
63
70
|
|
|
64
|
-
interface
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
interface ReportButtonOptions {
|
|
72
|
+
label?: string;
|
|
73
|
+
variant?: "solid" | "outline" | "ghost";
|
|
74
|
+
size?: "sm" | "md";
|
|
75
|
+
theme?: "auto" | "light" | "dark";
|
|
69
76
|
}
|
|
70
77
|
|
|
71
78
|
declare function init(options: BlipitOptions): void;
|
|
@@ -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
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { BlipitEvent, SecurityKind, Breadcrumb, Level } from '@blipit/schema';
|
|
2
2
|
export { BlipitEvent, BlipitSecurity, Breadcrumb, Level, SecurityKind } from '@blipit/schema';
|
|
3
3
|
|
|
4
|
+
interface FeedbackOptions {
|
|
5
|
+
eventId?: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
email?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
4
11
|
interface WidgetOptions {
|
|
5
12
|
position?: "bottom-right" | "bottom-left" | "middle-right" | "middle-left";
|
|
6
13
|
color?: string;
|
|
@@ -61,11 +68,11 @@ interface SecurityReport {
|
|
|
61
68
|
target?: string;
|
|
62
69
|
}
|
|
63
70
|
|
|
64
|
-
interface
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
interface ReportButtonOptions {
|
|
72
|
+
label?: string;
|
|
73
|
+
variant?: "solid" | "outline" | "ghost";
|
|
74
|
+
size?: "sm" | "md";
|
|
75
|
+
theme?: "auto" | "light" | "dark";
|
|
69
76
|
}
|
|
70
77
|
|
|
71
78
|
declare function init(options: BlipitOptions): void;
|
|
@@ -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 U=Object.defineProperty;var Re=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Be=Object.prototype.hasOwnProperty;var Te=(e,t)=>{for(var n in t)U(e,n,{get:t[n],enumerable:!0})},Oe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of _e(t))!Be.call(e,i)&&i!==n&&U(e,i,{get:()=>t[i],enumerable:!(r=Re(t,i))||r.enumerable});return e};var Ce=e=>Oe(U({},"__esModule",{value:!0}),e);var ct={};Te(ct,{addBreadcrumb:()=>it,attachReport:()=>ot,captureException:()=>Qe,captureMessage:()=>Ze,captureSecurity:()=>et,flush:()=>at,init:()=>Ge,openReport:()=>D,reportButton:()=>dt,setReportMetadata:()=>he,setTag:()=>nt,setUser:()=>tt,showFeedback:()=>rt,updateWidget:()=>st});var Z=["login_failed","login_succeeded","login_blocked","password_reset_requested","privilege_granted"];var I=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 R(){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 b(){return new Date().toISOString()}var Ie=/token|key|password|secret|auth|session|passwd|api/i;function w(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 d=o.indexOf("=");if(d===-1)return o;let c=o.slice(0,d);return Ie.test(c)?`${c}=[redacted]`:o}).join("&");return`${n}?${i}`.slice(0,2048)}var Le=/\b((?:[a-zA-Z0-9_-]*(?:token|key|password|secret|auth|session|passwd|api)[a-zA-Z0-9_-]*)=)[^&\s"']+/gi;function ee(e){return e.replace(Le,"$1[redacted]")}function u(e,t){return e.length>t?e.slice(0,t):e}var te=".blipit-mask,[data-blipit-mask]";function F(e){return e.replace(/#.*/,"").replace(/([?&][^=&]*)=[^&]*/g,"$1=").slice(0,2048)}function v(e,t,n){e.push(t),e.length>n&&e.shift()}function j(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 u(`${e.tagName.toLowerCase()}${t}${n}`,128)}function ne(e,t){try{let n=new CSSStyleSheet;n.replaceSync(t),e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]}catch{let n=document.createElement("style");n.textContent=t,(e===document?document.head:e).append(n)}}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}/`}var re={ok:0,errored:1,crashed:2},L=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";re[n]<=re[this.status]||(this.status=n,this.send(!1))}start(){this.sid=R(),this.started=b(),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 $e=/^\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*$/,oe=/^(chrome|moz|safari-web)-extension:/;function Ae(){if(typeof location<"u"&&location.origin)return location.origin}function Ne(e){if(oe.test(e)||e==="<anonymous>"||e==="[native code]")return!1;let t=Ae();return!!(!t||e.startsWith(t)||!/^[a-z]+:/i.test(e))}function se(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=$e.exec(n)??Me.exec(n);if(!r)continue;let[,i,o,d,c]=r;if(!o)continue;let a={filename:u(o,1024),in_app:Ne(o)};i&&(a.function=u(i,512)),d&&(a.lineno=Number(d)),c&&(a.colno=Number(c)),t.push(a)}return t.reverse(),t.slice(-128)}function ae(e){return e.length===0?!1:e.every(t=>oe.test(t.filename))}var K="@blipit/browser",_="0.3.8",E=ie(typeof document<"u"?document.currentScript?.src:void 0,_),M="https://in.blipit.io/api/v1/events",De=[/ResizeObserver loop/i,/^Script error\.?$/,/__gCrWeb|__firefox__/],Pe={login_failed:"Failed login",login_succeeded:"Successful login",login_blocked:"Blocked login",password_reset_requested:"Password reset requested",privilege_granted:"Privilege granted"},Ue={login_failed:"warning",login_succeeded:"info",login_blocked:"warning",password_reset_requested:"info",privilege_granted:"warning"};function Fe(e){if(!Z.includes(e?.kind))return;let t=u(String(e.actor??"").trim(),256);if(!t)return;let n={kind:e.kind,actor:t};return e.actorId&&(n.actor_id=u(String(e.actorId),128)),e.ip&&(n.ip=u(String(e.ip).trim(),45)),e.userAgent&&(n.user_agent=u(String(e.userAgent),512)),e.database&&(n.database=u(String(e.database),64)),e.outcome&&(n.outcome=u(String(e.outcome),64)),e.target&&(n.target=u(String(e.target),256)),n}var $=class{constructor(t){this.options=t;this.endpoint=t.endpoint??M,this.transport=new I(this.endpoint,t.key,t.debug??!1,t.instance),t.autoSessionTracking&&(t.release?this.session=new L(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;captured=new WeakSet;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[u(t,64)]=u(n,256)}addBreadcrumb(t){let n={timestamp:b(),...t};n.message&&(n.message=ee(n.message)),n.data&&typeof n.data.url=="string"&&(n.data={...n.data,url:w(n.data.url)}),this.breadcrumbs.push(n),this.breadcrumbs.length>this.maxBreadcrumbs&&this.breadcrumbs.shift()}captureException(t,n=!0){if(t&&typeof t=="object"){if(this.captured.has(t))return;this.captured.add(t)}let r=t instanceof Error?t:new Error(String(t)),i={type:r.name||"Error",value:u(r.message||String(r),4096),handled:n},o=se(r.stack);return o.length>0&&(i.stacktrace={frames:o}),this.processAndSend({exception:i,level:"error"})}captureMessage(t,n="info"){return this.processAndSend({message:u(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:`${Pe[n.kind]} for ${n.actor}`,level:Ue[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 c of this.ignoreErrors)if(typeof c=="string"?r.includes(c):c.test(r))return;if((this.options.autoMuteExtensions??!0)&&t.exception?.stacktrace&&ae(t.exception.stacktrace.frames))return;let d=`${t.exception?.type??""}|${r}`;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 i={event_id:R(),timestamp:b(),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:w(location.href)}:void 0,contexts:this.collectContexts(),sdk:{name:K,version:_},...t};for(let d of Object.keys(i))i[d]===void 0&&delete i[d];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 d=this.options.beforeSend(i);if(!d)return;i=d}return this.transport.enqueue(i),this.lastEventId=i.event_id,(i.level==="error"||i.level==="fatal")&&v(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:u(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 q(e){return typeof e=="string"?e.length:e?.size}function de(e){return e&&Number(e)||void 0}function je(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(),d=Date.now();try{let c=await e(n,r);return t(o,i,c.status,d,q(r?.body),de(c.headers.get("content-length"))),c}catch(c){throw t(o,i,0,d,q(r?.body)),c}}}function Ke(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 d=Date.now();this.addEventListener("loadend",()=>t(o[0],o[1],this.status,d,q(i),de(this.getResponseHeader("content-length"))))}return r.apply(this,arguments)}}function ce(e){if(typeof window>"u")return;let t=S(e.endpoint,""),{console:n,network:r,actions:i}=e.logs;window.addEventListener("error",a=>{e.captureException(a.error??a.message,!1)}),window.addEventListener("unhandledrejection",a=>{e.captureException(a.reason,!1)}),typeof document<"u"&&(document.addEventListener("click",a=>{let s=a.target;if(!(s instanceof Element)||s.closest("[data-blipit-ui]"))return;let l=j(s);e.addBreadcrumb({category:"ui.click",message:`Clicked ${l}`});let m=s.closest(te)?"***":u((s.textContent??"").trim().replace(/\s+/g," "),80);v(i,{timestamp:b(),type:"click",selector:l,text:m},50)},{capture:!0,passive:!0}),document.addEventListener("focusin",a=>{let s=a.target;s instanceof Element&&/^(INPUT|TEXTAREA|SELECT)$/.test(s.tagName)&&v(i,{timestamp:b(),type:"focus",selector:j(s)},50)},{capture:!0,passive:!0}));let o=(a,s,l,m,h,y)=>{t&&s.startsWith(t)||(e.addBreadcrumb({category:"http",message:`${a} ${w(s)} \u2192 ${l||"network error"}`,level:l>=400||!l?"error":"info",data:{url:w(s),method:a,status_code:l||void 0}}),v(r,{timestamp:b(),method:a,url:F(s),status:l,duration:Date.now()-m,request_size:h,response_size:y},50))};typeof window.fetch=="function"&&(window.fetch=je(window.fetch.bind(window),o)),typeof XMLHttpRequest<"u"&&Ke(XMLHttpRequest.prototype,o);for(let a of["log","info","debug","warn","error"]){let s=console[a].bind(console);console[a]=(...l)=>{let m=u(l.map(h=>typeof h=="string"?h:qe(h)).join(" "),1024);if(a==="warn"||a==="error"){e.addBreadcrumb({category:"console",level:a==="warn"?"warning":"error",message:m});let h=l.find(y=>y instanceof Error);v(n,{timestamp:b(),level:a,message:m,stack:u((h??new Error).stack??"",2e3)},100)}else v(n,{timestamp:b(),level:a,message:m},100);s(...l)}}let d=()=>v(i,{timestamp:b(),type:"navigation",url:F(location.href)},50),c=()=>{e.addBreadcrumb({category:"navigation",message:`Navigated to ${w(location.href)}`}),d()};if(d(),window.history){let a=window.history.pushState.bind(window.history);window.history.pushState=(...s)=>{a(...s),c()},window.addEventListener("popstate",c)}}function qe(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function ue(){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 We(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 He(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(r=>r.getEntries().forEach(i=>t(i))).observe({type:e,buffered:!0,...n})}catch{}}function pe(e,t,n){if(typeof PerformanceObserver>"u"||typeof document>"u")return;let r=performance.getEntriesByType("navigation")[0],i=r?.activationStart??0,o=f=>Math.max(0,Math.round(f-i)),d=document.visibilityState==="hidden",c=location.pathname,a=r?.type,s={},l=ue(),m=new Map,h=!1,y=!1;r&&r.responseStart>0&&(s.ttfb=o(r.responseStart)),d||(O("paint",f=>{f.name==="first-contentful-paint"&&(s.fcp=o(f.startTime))}),O("largest-contentful-paint",f=>{h||(s.lcp=o(f.startTime))}));let B=()=>{h=!0};addEventListener("keydown",B,{once:!0,capture:!0}),addEventListener("pointerdown",B,{once:!0,capture:!0}),O("layout-shift",f=>{s.cls=Math.round(l(f)*1e4)/1e4});let T=f=>{if(!f.interactionId)return;m.set(f.interactionId,Math.max(m.get(f.interactionId)??0,f.duration));let Q=We(m);Q!==void 0&&(s.inp=Math.round(Q))};O("event",T,{durationThreshold:40}),O("first-input",T);let g=navigator.connection?.effectiveType,J=`${new URL("/api/v1/vitals",e).href}?key=${encodeURIComponent(t)}${n?`&instance=${encodeURIComponent(n)}`:""}`,P=()=>{if(y||Object.keys(s).length===0)return;y=!0;let f=JSON.stringify({path:c.slice(0,512),metrics:s,nav:a,connection:g&&/^(slow-2g|2g|3g|4g)$/.test(g)?g:void 0,device:He(navigator.userAgent)});try{if(navigator.sendBeacon?.(J,f))return}catch{}fetch(J,{method:"POST",body:f,keepalive:!0}).catch(()=>{})},G=()=>{location.pathname!==c&&(P(),c=location.pathname,a="route",s={},l=ue(),m=new Map,h=!0,y=!1)};document.addEventListener("visibilitychange",()=>document.visibilityState==="hidden"&&P()),addEventListener("pagehide",P),addEventListener("popstate",G);let Ee=history.pushState;history.pushState=function(...f){Ee.apply(this,f),G()}}function ze(e,t=Math.random){return t()<(e.sessionSampleRate??0)?"session":t()<(e.onErrorSampleRate??1)?"buffer":null}function le(e,t,n,r,i){let o=ze(e);if(!o||typeof document>"u")return;let d=R(),c,a=document.createElement("script");return a.src=e.src??`${i}blipit-replay.js`,a.async=!0,a.onload=()=>{let s=window.BlipitReplay?.start;c=s?.({id:d,mode:o,endpoint:t,key:n,instance:r})},document.head.appendChild(a),{id:d,active:()=>c?.active()??!1,error:s=>c?.error(s),report:s=>c?.report?.(s)}}var H={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"]},Xe="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}}",Ve='<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>',me,W={},ge,x,z=()=>{},k,fe=0;function C(e,t){e.options.debug&&console.log(`[blipit] ${t}`)}function he(e){me=e}function N(e,t){return W[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 W[t],n}),W[t]}function be(){let e=(navigator.language??"en").slice(0,2);return H[e]?e:"en"}function X(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=be(),n.textContent=H[n.lang][0]),n.addEventListener("click",()=>n.hasAttribute("aria-busy")||t()),n}var ye=()=>{};function ve(e){ye=e}function V(e,t){ye(S(e.endpoint,"/api/v1/feedback"),e.options.key,t)}function A(e){if(typeof document>"u")return;let t=typeof e.options.feedbackWidget=="object"?e.options.feedbackWidget:{},n=document.querySelectorAll("button.blipit-rb"),r=i=>{z(i),n.forEach(o=>i?o.setAttribute("aria-busy","true"):o.removeAttribute("aria-busy"))};r(!0),Promise.all([N(t.src??`${E}blipit-report.js`,"BlipitReport"),ge??=xe(e)]).then(([i,o])=>o.enabled!==!1&&i.open(e,{metadata:me,recording:o.recording===!0,recordingMaxMs:o.recording_max_ms,storageFull:o.storage_full===!0,reportsFull:o.reports_full===!0,theme:o.theme,hide:d=>x&&(x.style.display=d?"none":"")}),()=>V(e,{eventId:e.lastEventId,name:e.user?.username,email:e.user?.email})).finally(()=>r(!1))}async function xe(e){let t=`blipit_fb_${_}_${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 C(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 C(e,"widget settings unreachable (offline, ad blocker or CSP connect-src), using defaults"),{}}}async function Y(e){let t=e.options.feedbackWidget,n=++fe;if(typeof document>"u")return;if(t===!1)return C(e,"Report a bug button off: feedbackWidget is false");let r=await(ge??=xe(e));if(n!==fe)return;if(r.enabled===!1)return C(e,"Report a bug button hidden by the project's Bug report widget setting");let i={...r,...typeof t=="object"?t:{}},[o,d]=H[be()],c=i.text||o;x=document.createElement("div"),x.setAttribute("data-blipit-ui","");let a=x.attachShadow({mode:"open"}),s=document.createElement("button");s.type="button";let[l,m]=(/^(bottom|middle)-(left|right)$/.test(i.position??"")?i.position:"bottom-right").split("-");s.style.cssText=`${i.color?`--c:${i.color};`:""}${m}:calc(20px + env(safe-area-inset-${m},0px));${l==="bottom"?"bottom:calc(20px + env(safe-area-inset-bottom,0px))":"top:50%;margin-top:-22px"}`,s.setAttribute("aria-haspopup","dialog"),i.style==="icon"&&(s.className="o",s.title=c);let h=g=>{s.disabled=g,s.setAttribute("aria-label",g?d:c),s.innerHTML=g?"<i></i><span></span>":`${Ve}<span></span>`,s.lastChild.textContent=g?d:c};z=h,h(!1),s.addEventListener("click",()=>A(e)),ne(a,Xe),a.append(s);let y=i.shortcut?.toLowerCase().replace(/\s/g,"");k&&document.removeEventListener("keydown",k),k=void 0,y&&(k=g=>{[g.ctrlKey&&"ctrl",g.shiftKey&&"shift",g.altKey&&"alt",g.metaKey&&"meta",g.key.toLowerCase()].filter(Boolean).join("+")===y&&(g.preventDefault(),A(e))},document.addEventListener("keydown",k));let B=x,T=()=>{x===B&&(document.body.append(B),C(e,`Report a bug button shown at ${l}-${m}`))};document.body?T():document.addEventListener("DOMContentLoaded",T)}function Se(e,t){let n=e.options.feedbackWidget;e.options.feedbackWidget=t===!1?!1:{...typeof n=="object"?n:{},...t},x?.remove(),x=void 0,k&&document.removeEventListener("keydown",k),k=void 0,z=()=>{},Y(e)}var p,ke=new Set;function we(e,t){ke.has(t)||(ke.add(t),console[e](t))}var Ye="[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.",Je="[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 Ge(e){if(p)return;let t=typeof e?.key=="string"?e.key.trim():"";if(!t)return we("warn",Ye);if(t.startsWith("blipit_sk_"))return we("error",Je);if(p=new $({...e,key:t}),e.user){let{id:n,name:r,email:i,username:o}=e.user;p.setUser({id:n===void 0?void 0:String(n),email:i,username:o??r})}ce(p),e.webVitals!==!1&&typeof window<"u"&&pe(e.endpoint??M,t,e.instance),e.replay&&(p.replay=le(e.replay,e.endpoint??M,t,e.instance,E)),typeof window<"u"&&Y(p),e.debug&&console.log(`[blipit] ${K}@${_} initialized`)}function Qe(e){return p?.captureException(e,!0)}function Ze(e,t){return p?.captureMessage(e,t)}function et(e){return p?.captureSecurity(e)}function tt(e){p?.setUser(e)}function nt(e,t){p?.setTag(e,t)}function it(e){p?.addBreadcrumb(e)}function rt(e={}){p&&V(p,{...e,eventId:e.eventId??p.lastEventId})}function D(){p&&A(p)}function ot(e){e.addEventListener("click",t=>{t.preventDefault(),D()})}function st(e){p&&Se(p,e)}function at(){return p?.flush()??Promise.resolve()}ve((e,t,n)=>N(`${E}blipit-feedback.js`,"BlipitFeedback").then(r=>r.showFeedbackDialog(e,t,n),()=>{}));function dt(e={}){let t=X(e.label,D);return t.style.visibility="hidden",N(`${E}blipit-button.js`,"BlipitButton").then(n=>n.paint(t,e)).catch(()=>{}).then(()=>t.style.removeProperty("visibility")),t}return Ce(ct);})();
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var V=["login_failed","login_succeeded","login_blocked","password_reset_requested","privilege_granted"];var M=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 T(){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 me=/token|key|password|secret|auth|session|passwd|api/i;function _(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(a=>{let d=a.indexOf("=");if(d===-1)return a;let c=a.slice(0,d);return me.test(c)?`${c}=[redacted]`:a}).join("&");return`${n}?${r}`.slice(0,2048)}var ge=/\b((?:[a-zA-Z0-9_-]*(?:token|key|password|secret|auth|session|passwd|api)[a-zA-Z0-9_-]*)=)[^&\s"']+/gi;function J(e){return e.replace(ge,"$1[redacted]")}function p(e,t){return e.length>t?e.slice(0,t):e}var Y=".blipit-mask,[data-blipit-mask]";function D(e){return e.replace(/#.*/,"").replace(/([?&][^=&]*)=[^&]*/g,"$1=").slice(0,2048)}function w(e,t,n){e.push(t),e.length>n&&e.shift()}function F(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 p(`${e.tagName.toLowerCase()}${t}${n}`,128)}function x(e,t){return`${e.replace(/\/api\/v1\/events.*$/,"").replace(/\/$/,"")}${t}`}function G(e,t){let n=e?/^(https?:\/\/[^?#]*\/)blipit(?:\.min)?\.js(?:[?#].*)?$/.exec(e):null;return n?n[1]:`https://blipit.io/sdk/${t}/`}var Q={ok:0,errored:1,crashed:2},O=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";Q[n]<=Q[this.status]||(this.status=n,this.send(!1))}start(){this.sid=T(),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}),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 he=/^\s*at (?:async )?(?:new )?(?:(.+?) )?\(?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack):.*?|[^()]+?)(?::(\d+))?(?::(\d+))?\)?\s*$/,be=/^\s*(?:(.*?)@)?((?:file|https?|blob|chrome-extension|moz-extension|safari-web-extension|node|webpack).*?|[^@]*?)(?::(\d+))?(?::(\d+))?\s*$/,Z=/^(chrome|moz|safari-web)-extension:/;function ye(){if(typeof location<"u"&&location.origin)return location.origin}function ve(e){if(Z.test(e)||e==="<anonymous>"||e==="[native code]")return!1;let t=ye();return!!(!t||e.startsWith(t)||!/^[a-z]+:/i.test(e))}function ee(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=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 te={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 Oe(e,t,n){if(typeof e!="string"||!/^BR-\d{1,12}$/.test(e))return null;let[i,r]=te[n.toLowerCase().split(/[-_]/)[0]]??te.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 j="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",ne="font:inherit;padding:8px 14px;border-radius:6px;cursor:pointer;border:1px solid #c5ccd6;background:#fff;color:#111",W=!1;function ie(e,t,n){if(W||typeof document>"u"||!document.body)return;W=!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=(b,$,k)=>{let B=x("label","display:block;font-weight:600",b);B.htmlFor=k,$.id=k,r.append(B,$)},d=x("input",j);d.type="text",d.maxLength=128,d.autocomplete="name",d.value=n.name??"";let a=x("input",j);a.type="email",a.maxLength=254,a.autocomplete="email",a.value=n.email??"";let s=x("textarea",`${j};min-height:110px;resize:vertical`);s.required=!0,s.maxLength=5e3;let p=x("p","margin:0 0 12px;min-height:1.2em;font-size:13px");p.setAttribute("role","status"),p.setAttribute("aria-live","polite");let h=x("div","display:flex;gap:8px;justify-content:flex-end"),f=x("button",ne,"Cancel");f.type="button";let m=x("button",`${ne};background:#111;color:#fff;border-color:#111`,"Send");m.type="submit",r.append(o),c("Name (optional)",d,"blipit-fb-name"),c("Email (optional)",a,"blipit-fb-email"),c("What went wrong?",s,"blipit-fb-message"),h.append(f,m),r.append(p,h),i.append(r),document.body.append(i);let E=()=>{W=!1,i.remove()},R=()=>typeof i.close=="function"&&i.open?i.close():E();f.addEventListener("click",R),i.addEventListener("close",E),r.addEventListener("submit",async b=>{b.preventDefault();let $=s.value.trim();if(!$){p.textContent="Please describe what happened.",s.focus();return}m.disabled=!0,f.disabled=!0,m.setAttribute("aria-busy","true"),m.textContent="Sending\u2026",p.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:a.value.trim()||void 0,message:$,event_id:n.eventId,url:typeof location<"u"?location.href.split(/[?#]/)[0]:void 0})});if(!k.ok)throw new Error(String(k.status));let B=await k.json().catch(()=>({})),A=Oe(B.ref,B.emails,typeof navigator>"u"?"en":navigator.language??"en");p.textContent=A??"Thanks, your message was sent.",m.textContent="Sent",setTimeout(R,A?4e3:1200)}catch{p.textContent="That did not send. Please try again.",m.disabled=!1,f.disabled=!1,m.removeAttribute("aria-busy"),m.textContent="Send"}}),typeof i.showModal=="function"?i.showModal():i.setAttribute("open",""),s.focus()}var re=["login_failed","login_succeeded","login_blocked","password_reset_requested","privilege_granted"];var F=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 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),r=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}?${r}`.slice(0,2048)}var Ae=/\b((?:[a-zA-Z0-9_-]*(?:token|key|password|secret|auth|session|passwd|api)[a-zA-Z0-9_-]*)=)[^&\s"']+/gi;function oe(e){return e.replace(Ae,"$1[redacted]")}function l(e,t){return e.length>t?e.slice(0,t):e}var se=".blipit-mask,[data-blipit-mask]";function q(e){return e.replace(/#.*/,"").replace(/([?&][^=&]*)=[^&]*/g,"$1=").slice(0,2048)}function w(e,t,n){e.push(t),e.length>n&&e.shift()}function H(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 N(e,t){try{let n=new CSSStyleSheet;n.replaceSync(t),e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]}catch{let n=document.createElement("style");n.textContent=t,(e===document?document.head:e).append(n)}}function T(e,t){return`${e.replace(/\/api\/v1\/events.*$/,"").replace(/\/$/,"")}${t}`}function ae(e,t){let n=e?/^(https?:\/\/[^?#]*\/)blipit(?:\.min)?\.js(?:[?#].*)?$/.exec(e):null;return n?n[1]:`https://blipit.io/sdk/${t}/`}function Fe(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 de(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=Fe(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 ce={ok:0,errored:1,crashed:2},D=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";ce[n]<=ce[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 Ne=/^\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*$/,ue=/^(chrome|moz|safari-web)-extension:/;function Pe(){if(typeof location<"u"&&location.origin)return location.origin}function Ue(e){if(ue.test(e)||e==="<anonymous>"||e==="[native code]")return!1;let t=Pe();return!!(!t||e.startsWith(t)||!/^[a-z]+:/i.test(e))}function pe(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=Ne.exec(n)??De.exec(n);if(!i)continue;let[,r,o,c,d]=i;if(!o)continue;let a={filename:l(o,1024),in_app:Ue(o)};r&&(a.function=l(r,512)),c&&(a.lineno=Number(c)),d&&(a.colno=Number(d)),t.push(a)}return t.reverse(),t.slice(-128)}function le(e){return e.length===0?!1:e.every(t=>ue.test(t.filename))}var X="@blipit/browser",M="0.3.8",U=ae(typeof document<"u"?document.currentScript?.src:void 0,M),z="https://in.blipit.io/api/v1/events",ze=[/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 We(e){if(!re.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 P=class{constructor(t){this.options=t;this.endpoint=t.endpoint??z,this.transport=new F(this.endpoint,t.key,t.debug??!1,t.instance),t.autoSessionTracking&&(t.release?this.session=new D(T(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=[...ze,...t.ignoreErrors??[]]}options;transport;breadcrumbs=[];user;tags={};maxBreadcrumbs;ignoreErrors;seen=new Set;captured=new WeakSet;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:v(),...t};n.message&&(n.message=oe(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){if(t&&typeof t=="object"){if(this.captured.has(t))return;this.captured.add(t)}let i=t instanceof Error?t:new Error(String(t)),r={type:i.name||"Error",value:l(i.message||String(i),4096),handled:n},o=pe(i.stack);return o.length>0&&(r.stacktrace={frames:o}),this.processAndSend({exception:r,level:"error"})}captureMessage(t,n="info"){return this.processAndSend({message:l(t,8192),level:n})}captureSecurity(t){let n=We(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 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&&le(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:X,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")&&w(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:l(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()}};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"]},qe="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}}",He='<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>',me,V={},ge,S,Y=()=>{},_,fe=0;function O(e,t){e.options.debug&&console.log(`[blipit] ${t}`)}function Xe(e){me=e}function Ve(e,t){return V[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 V[t],n}),V[t]}function he(){let e=(navigator.language??"en").slice(0,2);return G[e]?e:"en"}function be(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=he(),n.textContent=G[n.lang][0]),n.addEventListener("click",()=>n.hasAttribute("aria-busy")||t()),n}var ye=()=>{};function ve(e){ye=e}function J(e,t){ye(T(e.endpoint,"/api/v1/feedback"),e.options.key,t)}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=>{Y(r),n.forEach(o=>r?o.setAttribute("aria-busy","true"):o.removeAttribute("aria-busy"))};i(!0),Promise.all([Ve(t.src??`${U}blipit-report.js`,"BlipitReport"),ge??=xe(e)]).then(([r,o])=>o.enabled!==!1&&r.open(e,{metadata:me,recording:o.recording===!0,recordingMaxMs:o.recording_max_ms,storageFull:o.storage_full===!0,reportsFull:o.reports_full===!0,theme:o.theme,hide:c=>S&&(S.style.display=c?"none":"")}),()=>J(e,{eventId:e.lastEventId,name:e.user?.username,email:e.user?.email})).finally(()=>i(!1))}async function xe(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(T(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 O(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 O(e,"widget settings unreachable (offline, ad blocker or CSP connect-src), using defaults"),{}}}async function Z(e){let t=e.options.feedbackWidget,n=++fe;if(typeof document>"u")return;if(t===!1)return O(e,"Report a bug button off: feedbackWidget is false");let i=await(ge??=xe(e));if(n!==fe)return;if(i.enabled===!1)return O(e,"Report a bug button hidden by the project's Bug report widget setting");let r={...i,...typeof t=="object"?t:{}},[o,c]=G[he()],d=r.text||o;S=document.createElement("div"),S.setAttribute("data-blipit-ui","");let a=S.attachShadow({mode:"open"}),s=document.createElement("button");s.type="button";let[p,h]=(/^(bottom|middle)-(left|right)$/.test(r.position??"")?r.position:"bottom-right").split("-");s.style.cssText=`${r.color?`--c:${r.color};`:""}${h}:calc(20px + env(safe-area-inset-${h},0px));${p==="bottom"?"bottom:calc(20px + env(safe-area-inset-bottom,0px))":"top:50%;margin-top:-22px"}`,s.setAttribute("aria-haspopup","dialog"),r.style==="icon"&&(s.className="o",s.title=d);let f=b=>{s.disabled=b,s.setAttribute("aria-label",b?c:d),s.innerHTML=b?"<i></i><span></span>":`${He}<span></span>`,s.lastChild.textContent=b?c:d};Y=f,f(!1),s.addEventListener("click",()=>K(e)),N(a,qe),a.append(s);let m=r.shortcut?.toLowerCase().replace(/\s/g,"");_&&document.removeEventListener("keydown",_),_=void 0,m&&(_=b=>{[b.ctrlKey&&"ctrl",b.shiftKey&&"shift",b.altKey&&"alt",b.metaKey&&"meta",b.key.toLowerCase()].filter(Boolean).join("+")===m&&(b.preventDefault(),K(e))},document.addEventListener("keydown",_));let E=S,R=()=>{S===E&&(document.body.append(E),O(e,`Report a bug button shown at ${p}-${h}`))};document.body?R():document.addEventListener("DOMContentLoaded",R)}function ke(e,t){let n=e.options.feedbackWidget;e.options.feedbackWidget=t===!1?!1:{...typeof n=="object"?n:{},...t},S?.remove(),S=void 0,_&&document.removeEventListener("keydown",_),_=void 0,Y=()=>{},Z(e)}function Q(e){return typeof e=="string"?e.length:e?.size}function we(e){return e&&Number(e)||void 0}function Ge(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,Q(i?.body),we(d.headers.get("content-length"))),d}catch(d){throw t(o,r,0,c,Q(i?.body)),d}}}function Ye(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,Q(r),we(this.getResponseHeader("content-length"))))}return i.apply(this,arguments)}}function Se(e){if(typeof window>"u")return;let t=T(e.endpoint,""),{console:n,network:i,actions:r}=e.logs;window.addEventListener("error",a=>{e.captureException(a.error??a.message,!1)}),window.addEventListener("unhandledrejection",a=>{e.captureException(a.reason,!1)}),typeof document<"u"&&(document.addEventListener("click",a=>{let s=a.target;if(!(s instanceof Element)||s.closest("[data-blipit-ui]"))return;let p=H(s);e.addBreadcrumb({category:"ui.click",message:`Clicked ${p}`});let h=s.closest(se)?"***":l((s.textContent??"").trim().replace(/\s+/g," "),80);w(r,{timestamp:v(),type:"click",selector:p,text:h},50)},{capture:!0,passive:!0}),document.addEventListener("focusin",a=>{let s=a.target;s instanceof Element&&/^(INPUT|TEXTAREA|SELECT)$/.test(s.tagName)&&w(r,{timestamp:v(),type:"focus",selector:H(s)},50)},{capture:!0,passive:!0}));let o=(a,s,p,h,f,m)=>{t&&s.startsWith(t)||(e.addBreadcrumb({category:"http",message:`${a} ${C(s)} \u2192 ${p||"network error"}`,level:p>=400||!p?"error":"info",data:{url:C(s),method:a,status_code:p||void 0}}),w(i,{timestamp:v(),method:a,url:q(s),status:p,duration:Date.now()-h,request_size:f,response_size:m},50))};typeof window.fetch=="function"&&(window.fetch=Ge(window.fetch.bind(window),o)),typeof XMLHttpRequest<"u"&&Ye(XMLHttpRequest.prototype,o);for(let a of["log","info","debug","warn","error"]){let s=console[a].bind(console);console[a]=(...p)=>{let h=l(p.map(f=>typeof f=="string"?f:Je(f)).join(" "),1024);if(a==="warn"||a==="error"){e.addBreadcrumb({category:"console",level:a==="warn"?"warning":"error",message:h});let f=p.find(m=>m instanceof Error);w(n,{timestamp:v(),level:a,message:h,stack:l((f??new Error).stack??"",2e3)},100)}else w(n,{timestamp:v(),level:a,message:h},100);s(...p)}}let c=()=>w(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 a=window.history.pushState.bind(window.history);window.history.pushState=(...s)=>{a(...s),d()},window.addEventListener("popstate",d)}}function Je(e){try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function Ee(){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 Ze(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 Qe(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 Re(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,a=i?.type,s={},p=Ee(),h=new Map,f=!1,m=!1;i&&i.responseStart>0&&(s.ttfb=o(i.responseStart)),c||(I("paint",y=>{y.name==="first-contentful-paint"&&(s.fcp=o(y.startTime))}),I("largest-contentful-paint",y=>{f||(s.lcp=o(y.startTime))}));let E=()=>{f=!0};addEventListener("keydown",E,{once:!0,capture:!0}),addEventListener("pointerdown",E,{once:!0,capture:!0}),I("layout-shift",y=>{s.cls=Math.round(p(y)*1e4)/1e4});let R=y=>{if(!y.interactionId)return;h.set(y.interactionId,Math.max(h.get(y.interactionId)??0,y.duration));let ee=Ze(h);ee!==void 0&&(s.inp=Math.round(ee))};I("event",R,{durationThreshold:40}),I("first-input",R);let b=navigator.connection?.effectiveType,$=`${new URL("/api/v1/vitals",e).href}?key=${encodeURIComponent(t)}${n?`&instance=${encodeURIComponent(n)}`:""}`,k=()=>{if(m||Object.keys(s).length===0)return;m=!0;let y=JSON.stringify({path:d.slice(0,512),metrics:s,nav:a,connection:b&&/^(slow-2g|2g|3g|4g)$/.test(b)?b:void 0,device:Qe(navigator.userAgent)});try{if(navigator.sendBeacon?.($,y))return}catch{}fetch($,{method:"POST",body:y,keepalive:!0}).catch(()=>{})},B=()=>{location.pathname!==d&&(k(),d=location.pathname,a="route",s={},p=Ee(),h=new Map,f=!0,m=!1)};document.addEventListener("visibilitychange",()=>document.visibilityState==="hidden"&&k()),addEventListener("pagehide",k),addEventListener("popstate",B);let A=history.pushState;history.pushState=function(...y){A.apply(this,y),B()}}function et(e,t=Math.random){return t()<(e.sessionSampleRate??0)?"session":t()<(e.onErrorSampleRate??1)?"buffer":null}function $e(e,t,n,i,r){let o=et(e);if(!o||typeof document>"u")return;let c=L(),d,a=document.createElement("script");return a.src=e.src??`${r}blipit-replay.js`,a.async=!0,a.onload=()=>{let s=window.BlipitReplay?.start;d=s?.({id:c,mode:o,endpoint:t,key:n,instance:i})},document.head.appendChild(a),{id:c,active:()=>d?.active()??!1,error:s=>d?.error(s),report:s=>d?.report?.(s)}}var Be='<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 u=".blipit-rb.blipit-rb",tt=`${u}{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}${u}: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)}${u}:active{transform:scale(.97)}${u}:focus-visible{outline:3px solid #00C2FF;outline-offset:3px}${u}[aria-busy=true]{cursor:progress}${u}>span{all:unset}${u}>.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)}${u} svg{display:block;width:19px;height:17px}${u}[data-size=sm]{height:32px;gap:7px;padding-inline:4px 13px;font-size:13px}${u}[data-size=sm]>.blipit-rb-m{width:24px;height:24px}${u}[data-size=sm] svg{width:15px;height:13px}${u}[data-variant=outline],${u}[data-variant=ghost]{color:#0B1A3A;background:transparent;box-shadow:inset 0 0 0 1px #CBD7EA}${u}[data-variant=ghost]{box-shadow:none}${u}[data-variant=outline]:hover,${u}[data-variant=ghost]:hover{transform:none;background:rgba(56,130,246,.08);box-shadow:inset 0 0 0 1px rgba(56,130,246,.45)}${u}[data-variant=ghost]:hover{box-shadow:none}${u}[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)}${u}[data-theme=dark][data-variant=outline],${u}[data-theme=dark][data-variant=ghost]{color:#E8EEF8;background:transparent;box-shadow:inset 0 0 0 1px rgba(255,255,255,.16)}${u}[data-theme=dark][data-variant=ghost]{box-shadow:none}${u}[data-theme=dark][data-variant=outline]:hover,${u}[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)}${u}[data-theme=dark][data-variant=ghost]:hover{box-shadow:none}${u}[data-theme=dark]>.blipit-rb-m{box-shadow:0 0 0 1px rgba(255,255,255,.1)}${u}[aria-busy=true] svg{visibility:hidden}${u}[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){${u}{min-height:44px}}@media(prefers-reduced-motion:reduce){${u}{transition:none}${u}:hover,${u}:active{transform:none}${u}[aria-busy=true]>.blipit-rb-m::after{animation-duration:3s}}@media(forced-colors:active){${u}{border:1px solid ButtonText}}`,Te=0;function _e(e,t={}){Te||N(document,tt);let n=++Te,i=document.createElement("span");i.className="blipit-rb-m",i.innerHTML=Be.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",de(t.theme==="light"||t.theme==="dark"?t.theme:void 0))}var g,Ce=new Set;function Le(e,t){Ce.has(t)||(Ce.add(t),console[e](t))}var nt="[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.",it="[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 Dt(e){if(g)return;let t=typeof e?.key=="string"?e.key.trim():"";if(!t)return Le("warn",nt);if(t.startsWith("blipit_sk_"))return Le("error",it);if(g=new P({...e,key:t}),e.user){let{id:n,name:i,email:r,username:o}=e.user;g.setUser({id:n===void 0?void 0:String(n),email:r,username:o??i})}Se(g),e.webVitals!==!1&&typeof window<"u"&&Re(e.endpoint??z,t,e.instance),e.replay&&(g.replay=$e(e.replay,e.endpoint??z,t,e.instance,U)),typeof window<"u"&&Z(g),e.debug&&console.log(`[blipit] ${X}@${M} initialized`)}function Pt(e){return g?.captureException(e,!0)}function Ut(e,t){return g?.captureMessage(e,t)}function zt(e){return g?.captureSecurity(e)}function Kt(e){g?.setUser(e)}function jt(e,t){g?.setTag(e,t)}function Wt(e){g?.addBreadcrumb(e)}function qt(e={}){g&&J(g,{...e,eventId:e.eventId??g.lastEventId})}function Me(){g&&K(g)}function Ht(e){e.addEventListener("click",t=>{t.preventDefault(),Me()})}function Xt(e={}){let t=be(e.label,Me);return _e(t,e),t}function Vt(e){g&&ke(g,e)}function Gt(){return g?.flush()??Promise.resolve()}ve(ie);export{Wt as addBreadcrumb,Ht as attachReport,Pt as captureException,Ut as captureMessage,zt as captureSecurity,Gt as flush,Dt as init,Me as openReport,Xt as reportButton,Xe as setReportMetadata,jt as setTag,Kt as setUser,qt as showFeedback,Vt 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.8",
|
|
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/
|
|
50
|
+
"build": "tsup --entry.index src/npm.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 && tsup src/feedback.ts --format iife --global-name BlipitFeedback --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 && gzip -c served/feedback.global.js | wc -c"
|
|
52
53
|
}
|
|
53
54
|
}
|