@flareapp/js 2.7.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/browser.cjs +52 -2
- package/dist/browser.d.cts +7 -3
- package/dist/browser.d.mts +7 -3
- package/dist/browser.mjs +31 -3
- package/dist/catchWindowErrors-C0gSVGiF.mjs +2641 -0
- package/dist/catchWindowErrors-cR2D7kju.cjs +2802 -0
- package/dist/index.cjs +20 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +3 -3
- package/dist/spanTypes-7-nEycOc.d.mts +155 -0
- package/dist/spanTypes-TMgJEZ7G.d.cts +155 -0
- package/package.json +3 -2
- package/dist/BrowserFlushScheduler-CR7L8-z6.d.cts +0 -43
- package/dist/BrowserFlushScheduler-CZiDvxtf.d.mts +0 -43
- package/dist/catchWindowErrors-2a2z2zr2.cjs +0 -153
- package/dist/catchWindowErrors-CSc-dC37.mjs +0 -124
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { redactUrlQuery, routeRejection } from "@flareapp/core";
|
|
2
|
-
|
|
3
|
-
//#region src/browser/BrowserFlushScheduler.ts
|
|
4
|
-
var BrowserFlushScheduler = class {
|
|
5
|
-
register(flush) {
|
|
6
|
-
if (typeof document === "undefined" || !document) return;
|
|
7
|
-
document.addEventListener("visibilitychange", () => {
|
|
8
|
-
if (document.visibilityState === "hidden") flush({ keepalive: true });
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/browser/context/cookie.ts
|
|
15
|
-
function cookie() {
|
|
16
|
-
if (!window.document.cookie) return {};
|
|
17
|
-
const cookies = {};
|
|
18
|
-
window.document.cookie.split("; ").forEach((rawCookie) => {
|
|
19
|
-
const idx = rawCookie.indexOf("=");
|
|
20
|
-
if (idx === -1) {
|
|
21
|
-
cookies[rawCookie] = "";
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const name = rawCookie.slice(0, idx);
|
|
25
|
-
cookies[name] = rawCookie.slice(idx + 1);
|
|
26
|
-
});
|
|
27
|
-
return { "http.request.cookies": cookies };
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/browser/context/request.ts
|
|
32
|
-
function request(urlDenylist) {
|
|
33
|
-
return {
|
|
34
|
-
"url.full": redactUrlQuery(window.location.href, urlDenylist),
|
|
35
|
-
"user_agent.original": window.navigator.userAgent,
|
|
36
|
-
"http.request.referrer": redactUrlQuery(window.document.referrer, urlDenylist),
|
|
37
|
-
"document.ready_state": window.document.readyState
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region src/browser/context/requestData.ts
|
|
43
|
-
function requestData(urlDenylist) {
|
|
44
|
-
if (!window.location.search) return {};
|
|
45
|
-
return { "url.query": redactUrlQuery(window.location.search, urlDenylist).replace(/^\?/, "") };
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/browser/context/collectBrowser.ts
|
|
50
|
-
const collectBrowser = (config) => {
|
|
51
|
-
if (typeof window === "undefined") return { "flare.entry_point.type": "server" };
|
|
52
|
-
const attrs = { "flare.entry_point.type": "web" };
|
|
53
|
-
if (window?.location?.href) {
|
|
54
|
-
attrs["flare.entry_point.value"] = redactUrlQuery(window.location.href, config.urlDenylist);
|
|
55
|
-
if (window.location.pathname) {
|
|
56
|
-
attrs["flare.entry_point.handler.identifier"] = window.location.pathname;
|
|
57
|
-
attrs["flare.entry_point.handler.type"] = "browser";
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
if (window?.location?.hostname) attrs["host.name"] = window.location.hostname;
|
|
61
|
-
Object.assign(attrs, request(config.urlDenylist));
|
|
62
|
-
Object.assign(attrs, requestData(config.urlDenylist));
|
|
63
|
-
Object.assign(attrs, cookie());
|
|
64
|
-
return attrs;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region src/browser/FetchFileReader.ts
|
|
69
|
-
/**
|
|
70
|
-
* Browser `FileReader` implementation that fetches source files over HTTP(S).
|
|
71
|
-
*
|
|
72
|
-
* Wired into `@flareapp/js`'s singleton so the stack-trace builder can pull
|
|
73
|
-
* the original source for each frame and render a code snippet around the
|
|
74
|
-
* offending line. The source URL comes from the frame (usually the URL of
|
|
75
|
-
* the JS bundle that produced the error, post-sourcemap resolution).
|
|
76
|
-
*
|
|
77
|
-
* Three safety gates:
|
|
78
|
-
*
|
|
79
|
-
* 1. **Scheme allowlist.** Only `http:` and `https:` URLs are fetched. Other
|
|
80
|
-
* schemes (`chrome-extension://`, `file://`, `blob:`, `data:`) return
|
|
81
|
-
* `null` immediately. This avoids surprise privilege boundaries (e.g.,
|
|
82
|
-
* pages should not read extension-internal files) and dodges CORS/CSP
|
|
83
|
-
* walls that would error noisily.
|
|
84
|
-
* 2. **Status check.** Only `200 OK` responses are used. 3xx redirects are
|
|
85
|
-
* handled transparently by `fetch`; 4xx/5xx fall back to `null` so the
|
|
86
|
-
* snippet is simply omitted from the report.
|
|
87
|
-
* 3. **Catch-all.** Network failures, CORS errors, and aborted requests
|
|
88
|
-
* return `null`. We never let a source-fetch failure leak as an error
|
|
89
|
-
* that the consumer page would see.
|
|
90
|
-
*
|
|
91
|
-
* The `read()` contract returns `null` on any failure path, never throws.
|
|
92
|
-
*/
|
|
93
|
-
var FetchFileReader = class {
|
|
94
|
-
read(url) {
|
|
95
|
-
if (!/^https?:\/\//i.test(url)) return Promise.resolve(null);
|
|
96
|
-
return fetch(url).then((response) => {
|
|
97
|
-
if (response.status !== 200) return null;
|
|
98
|
-
return response.text();
|
|
99
|
-
}).catch(() => null);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
//#endregion
|
|
104
|
-
//#region src/env/index.ts
|
|
105
|
-
const CLIENT_VERSION = typeof process !== "undefined" && true ? "2.7.0" : "?";
|
|
106
|
-
|
|
107
|
-
//#endregion
|
|
108
|
-
//#region src/browser/catchWindowErrors.ts
|
|
109
|
-
function catchWindowErrors() {
|
|
110
|
-
if (typeof window === "undefined") return;
|
|
111
|
-
window.addEventListener("error", (event) => {
|
|
112
|
-
const flare = window.flare;
|
|
113
|
-
if (!flare) return;
|
|
114
|
-
if (event.error instanceof Error) flare.reportSilently(event.error);
|
|
115
|
-
});
|
|
116
|
-
window.addEventListener("unhandledrejection", (event) => {
|
|
117
|
-
const flare = window.flare;
|
|
118
|
-
if (!flare) return;
|
|
119
|
-
routeRejection(flare, event.reason);
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
//#endregion
|
|
124
|
-
export { BrowserFlushScheduler as a, collectBrowser as i, CLIENT_VERSION as n, FetchFileReader as r, catchWindowErrors as t };
|