@flareapp/js 2.6.0 → 2.8.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.
@@ -1,153 +0,0 @@
1
- let _flareapp_core = require("@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": (0, _flareapp_core.redactUrlQuery)(window.location.href, urlDenylist),
35
- "user_agent.original": window.navigator.userAgent,
36
- "http.request.referrer": (0, _flareapp_core.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": (0, _flareapp_core.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"] = (0, _flareapp_core.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.6.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
- (0, _flareapp_core.routeRejection)(flare, event.reason);
120
- });
121
- }
122
-
123
- //#endregion
124
- Object.defineProperty(exports, 'BrowserFlushScheduler', {
125
- enumerable: true,
126
- get: function () {
127
- return BrowserFlushScheduler;
128
- }
129
- });
130
- Object.defineProperty(exports, 'CLIENT_VERSION', {
131
- enumerable: true,
132
- get: function () {
133
- return CLIENT_VERSION;
134
- }
135
- });
136
- Object.defineProperty(exports, 'FetchFileReader', {
137
- enumerable: true,
138
- get: function () {
139
- return FetchFileReader;
140
- }
141
- });
142
- Object.defineProperty(exports, 'catchWindowErrors', {
143
- enumerable: true,
144
- get: function () {
145
- return catchWindowErrors;
146
- }
147
- });
148
- Object.defineProperty(exports, 'collectBrowser', {
149
- enumerable: true,
150
- get: function () {
151
- return collectBrowser;
152
- }
153
- });