usetraceforge 0.1.19 → 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.
Files changed (2) hide show
  1. package/dist/index.js +25 -15
  2. 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 === "undefined")
106
- return;
107
- window.addEventListener("error", (event) => {
108
- if (event.error) {
109
- capture(event.error, { environment: "browser" }).catch(() => undefined);
110
- }
111
- else if (event.message) {
112
- capture(new Error(event.message), { environment: "browser" }).catch(() => undefined);
113
- }
114
- });
115
- window.addEventListener("unhandledrejection", (event) => {
116
- capture(event.reason ?? new Error("Unhandled promise rejection"), {
117
- environment: "browser"
118
- }).catch(() => undefined);
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 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "usetraceforge",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "private": false,
5
5
  "description": "TraceForge JavaScript SDK for sending errors to a TraceForge ingest endpoint.",
6
6
  "type": "module",