usetraceforge 0.1.18 → 0.1.20
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 +26 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -102,21 +102,31 @@ const sendSetupHandshake = async () => {
|
|
|
102
102
|
const setupAutoCapture = () => {
|
|
103
103
|
if (autoCaptureInitialized)
|
|
104
104
|
return;
|
|
105
|
-
if (typeof window
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
})
|
|
119
|
-
}
|
|
105
|
+
if (typeof window !== "undefined") {
|
|
106
|
+
window.addEventListener("error", (event) => {
|
|
107
|
+
if (event.error) {
|
|
108
|
+
capture(event.error, { environment: "browser" }).catch(() => undefined);
|
|
109
|
+
}
|
|
110
|
+
else if (event.message) {
|
|
111
|
+
capture(new Error(event.message), { environment: "browser" }).catch(() => undefined);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
window.addEventListener("unhandledrejection", (event) => {
|
|
115
|
+
capture(event.reason ?? new Error("Unhandled promise rejection"), {
|
|
116
|
+
environment: "browser"
|
|
117
|
+
}).catch(() => undefined);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
else if (typeof process !== "undefined") {
|
|
121
|
+
process.on("uncaughtException", (error) => {
|
|
122
|
+
capture(error, { environment: "node" }).catch(() => undefined);
|
|
123
|
+
});
|
|
124
|
+
process.on("unhandledRejection", (reason) => {
|
|
125
|
+
capture(reason ?? new Error("Unhandled promise rejection"), {
|
|
126
|
+
environment: "node"
|
|
127
|
+
}).catch(() => undefined);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
120
130
|
autoCaptureInitialized = true;
|
|
121
131
|
};
|
|
122
132
|
const TraceForge = {
|
|
@@ -128,7 +138,7 @@ const TraceForge = {
|
|
|
128
138
|
const previousEndpoint = config?.endpoint ?? defaultEndpoint;
|
|
129
139
|
config = {
|
|
130
140
|
endpoint: defaultEndpoint,
|
|
131
|
-
autoCapture:
|
|
141
|
+
autoCapture: typeof window !== "undefined",
|
|
132
142
|
...options
|
|
133
143
|
};
|
|
134
144
|
const currentEndpoint = config.endpoint || defaultEndpoint;
|