@crashlensorg/browser 0.1.0 → 0.3.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/dist/index.js CHANGED
@@ -59,6 +59,9 @@ function getOrCreateDeviceId() {
59
59
  }
60
60
  }
61
61
  function collectBrowserInfo() {
62
+ if (typeof navigator === "undefined") {
63
+ return { deviceId: getOrCreateDeviceId(), deviceOs: "web", deviceType: "web" };
64
+ }
62
65
  const nav = navigator;
63
66
  const ua = nav?.userAgent ?? "";
64
67
  const { browserName, browserVersion } = parseUserAgent(ua);
@@ -86,6 +89,7 @@ function collectBrowserInfo() {
86
89
 
87
90
  // src/integrations.ts
88
91
  function installGlobalErrorHandlers(hooks) {
92
+ if (typeof window === "undefined") return () => void 0;
89
93
  const onError = (event) => {
90
94
  let error = event.error;
91
95
  if (!(error instanceof Error) && event.message) {
@@ -131,6 +135,7 @@ function initGlobalHandlers(client) {
131
135
  // src/http-breadcrumbs.ts
132
136
  var xhrMeta = /* @__PURE__ */ new WeakMap();
133
137
  function instrumentHttpBreadcrumbs(client) {
138
+ if (typeof window === "undefined" || typeof XMLHttpRequest === "undefined") return () => void 0;
134
139
  const addRequest = (method, url, status) => {
135
140
  client.addBreadcrumb({
136
141
  message: `${method} ${url}`,
package/dist/index.mjs CHANGED
@@ -34,6 +34,9 @@ function getOrCreateDeviceId() {
34
34
  }
35
35
  }
36
36
  function collectBrowserInfo() {
37
+ if (typeof navigator === "undefined") {
38
+ return { deviceId: getOrCreateDeviceId(), deviceOs: "web", deviceType: "web" };
39
+ }
37
40
  const nav = navigator;
38
41
  const ua = nav?.userAgent ?? "";
39
42
  const { browserName, browserVersion } = parseUserAgent(ua);
@@ -61,6 +64,7 @@ function collectBrowserInfo() {
61
64
 
62
65
  // src/integrations.ts
63
66
  function installGlobalErrorHandlers(hooks) {
67
+ if (typeof window === "undefined") return () => void 0;
64
68
  const onError = (event) => {
65
69
  let error = event.error;
66
70
  if (!(error instanceof Error) && event.message) {
@@ -106,6 +110,7 @@ function initGlobalHandlers(client) {
106
110
  // src/http-breadcrumbs.ts
107
111
  var xhrMeta = /* @__PURE__ */ new WeakMap();
108
112
  function instrumentHttpBreadcrumbs(client) {
113
+ if (typeof window === "undefined" || typeof XMLHttpRequest === "undefined") return () => void 0;
109
114
  const addRequest = (method, url, status) => {
110
115
  client.addBreadcrumb({
111
116
  message: `${method} ${url}`,
package/package.json CHANGED
@@ -1,28 +1,28 @@
1
- {
2
- "name": "@crashlensorg/browser",
3
- "version": "0.1.0",
4
- "description": "CrashLens SDK para o browser — window.onerror, unhandledrejection, fetch/XHR, breadcrumbs e info de dispositivo web",
5
- "license": "MIT",
6
- "main": "./dist/index.js",
7
- "module": "./dist/index.mjs",
8
- "types": "./dist/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.mjs",
13
- "require": "./dist/index.js"
14
- }
15
- },
16
- "files": ["dist"],
17
- "publishConfig": {
18
- "access": "public"
19
- },
20
- "scripts": {
21
- "build": "tsup src/index.ts --format cjs,esm --dts --clean",
22
- "typecheck": "tsc --noEmit"
23
- },
24
- "dependencies": {
25
- "@crashlensorg/core": "0.1.0"
26
- },
27
- "keywords": ["crashlens", "browser", "react", "javascript", "error-monitoring", "sentry-alternative"]
1
+ {
2
+ "name": "@crashlensorg/browser",
3
+ "version": "0.3.0",
4
+ "description": "CrashLens SDK para o browser — window.onerror, unhandledrejection, fetch/XHR, breadcrumbs e info de dispositivo web",
5
+ "license": "MIT",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.mjs",
13
+ "require": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": ["dist"],
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "scripts": {
21
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean",
22
+ "typecheck": "tsc --noEmit"
23
+ },
24
+ "dependencies": {
25
+ "@crashlensorg/core": "0.3.0"
26
+ },
27
+ "keywords": ["crashlens", "browser", "react", "javascript", "error-monitoring", "sentry-alternative"]
28
28
  }