@orbitai/orbitrace 1.2.0 → 1.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/README.md +47 -9
- package/dist/browser.cjs +520 -0
- package/dist/browser.mjs +525 -0
- package/dist/index.js +480 -503
- package/package.json +16 -4
- package/dist/index.mjs +0 -131
package/package.json
CHANGED
|
@@ -1,15 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbitai/orbitrace",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Error tracking for Node.js services: manual and automatic capture with breadcrumbs",
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "Error tracking for Node.js services and browser apps: manual and automatic capture with breadcrumbs",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./dist/index.js",
|
|
8
|
+
"./browser": {
|
|
9
|
+
"import": "./dist/browser.mjs",
|
|
10
|
+
"require": "./dist/browser.cjs",
|
|
11
|
+
"default": "./dist/browser.mjs"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
6
15
|
"files": [
|
|
7
16
|
"dist"
|
|
8
17
|
],
|
|
9
18
|
"scripts": {
|
|
10
19
|
"test": "node --test test/*.test.js",
|
|
11
|
-
"build": "
|
|
12
|
-
"deploy": "npm version patch && npm run build && npm publish --access public"
|
|
20
|
+
"build": "esbuild src/index.js --bundle --platform=node --target=node18 --format=cjs --outfile=dist/index.js && esbuild src/browser.js --bundle --platform=browser --target=es2020 --format=esm --outfile=dist/browser.mjs && esbuild src/browser.js --bundle --platform=browser --target=es2020 --format=cjs --outfile=dist/browser.cjs",
|
|
21
|
+
"deploy": "npm test && npm version patch && npm run build && npm publish --access public"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"esbuild": "^0.24.2"
|
|
13
25
|
},
|
|
14
26
|
"publishConfig": {
|
|
15
27
|
"access": "public"
|
package/dist/index.mjs
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
-
};
|
|
5
|
-
var __accessCheck = (obj, member, msg) => {
|
|
6
|
-
if (!member.has(obj))
|
|
7
|
-
throw TypeError("Cannot " + msg);
|
|
8
|
-
};
|
|
9
|
-
var __privateGet = (obj, member, getter) => {
|
|
10
|
-
__accessCheck(obj, member, "read from private field");
|
|
11
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
12
|
-
};
|
|
13
|
-
var __privateAdd = (obj, member, value) => {
|
|
14
|
-
if (member.has(obj))
|
|
15
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
16
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
17
|
-
};
|
|
18
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
19
|
-
__accessCheck(obj, member, "write to private field");
|
|
20
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
21
|
-
return value;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// src/index.js
|
|
25
|
-
var require_src = __commonJS({
|
|
26
|
-
"src/index.js"(exports, module) {
|
|
27
|
-
var _config;
|
|
28
|
-
var Orbitrace = class {
|
|
29
|
-
static init(config) {
|
|
30
|
-
this.validateConfig(config);
|
|
31
|
-
__privateSet(this, _config, {
|
|
32
|
-
apiKey: config.apiKey,
|
|
33
|
-
orgId: config.orgId,
|
|
34
|
-
projectId: config.projectId,
|
|
35
|
-
endpoint: config.endpoint,
|
|
36
|
-
environment: config.environment || "production",
|
|
37
|
-
version: config.version || "1.0.0",
|
|
38
|
-
service: config.service || "not-specified",
|
|
39
|
-
disabled: config.disabled || false
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
static validateConfig(config) {
|
|
43
|
-
const requiredFields = ["apiKey", "orgId", "projectId", "endpoint"];
|
|
44
|
-
const missingFields = requiredFields.filter((field) => !config[field]);
|
|
45
|
-
if (missingFields.length > 0) {
|
|
46
|
-
throw new Error(
|
|
47
|
-
`Missing required configuration fields: ${missingFields.join(", ")}`
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
static checkInitialized() {
|
|
52
|
-
if (!__privateGet(this, _config)) {
|
|
53
|
-
throw new Error(
|
|
54
|
-
"Orbitrace must be initialized with Orbitrace.init() before use"
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
static async captureException(error, metadata = {}) {
|
|
59
|
-
this.checkInitialized();
|
|
60
|
-
if (__privateGet(this, _config).disabled) {
|
|
61
|
-
console.log("Orbitrace: Logging is disabled");
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
try {
|
|
65
|
-
const payload = {
|
|
66
|
-
message: error.message,
|
|
67
|
-
stack: error.stack,
|
|
68
|
-
metadata: {
|
|
69
|
-
...metadata,
|
|
70
|
-
env: __privateGet(this, _config).environment,
|
|
71
|
-
version: __privateGet(this, _config).version,
|
|
72
|
-
service: __privateGet(this, _config).service
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
return this.sendToApi("capture_exception", payload);
|
|
76
|
-
} catch (err) {
|
|
77
|
-
console.error("Orbitrace: Error capturing exception", err);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
static async captureMessage(message, metadata = {}) {
|
|
81
|
-
this.checkInitialized();
|
|
82
|
-
if (__privateGet(this, _config).disabled) {
|
|
83
|
-
console.log("Orbitrace: Logging is disabled");
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
try {
|
|
87
|
-
const payload = {
|
|
88
|
-
message,
|
|
89
|
-
metadata: {
|
|
90
|
-
...metadata,
|
|
91
|
-
env: __privateGet(this, _config).environment,
|
|
92
|
-
version: __privateGet(this, _config).version,
|
|
93
|
-
service: __privateGet(this, _config).service
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
return this.sendToApi("capture_message", payload);
|
|
97
|
-
} catch (err) {
|
|
98
|
-
console.error("Orbitrace: Error capturing message", err);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
static async sendToApi(event, payload) {
|
|
102
|
-
try {
|
|
103
|
-
const response = await fetch(__privateGet(this, _config).endpoint, {
|
|
104
|
-
method: "POST",
|
|
105
|
-
headers: {
|
|
106
|
-
"Content-Type": "application/json",
|
|
107
|
-
"x-orbitrace-api-key": __privateGet(this, _config).apiKey,
|
|
108
|
-
"x-orbitrace-org-id": __privateGet(this, _config).orgId,
|
|
109
|
-
"x-orbitrace-project-id": __privateGet(this, _config).projectId
|
|
110
|
-
},
|
|
111
|
-
body: JSON.stringify({
|
|
112
|
-
event,
|
|
113
|
-
payload
|
|
114
|
-
})
|
|
115
|
-
});
|
|
116
|
-
if (!response.ok) {
|
|
117
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
118
|
-
}
|
|
119
|
-
return await response.json();
|
|
120
|
-
} catch (error) {
|
|
121
|
-
console.error("Orbitrace: Error sending data to API", error);
|
|
122
|
-
throw error;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
_config = new WeakMap();
|
|
127
|
-
__privateAdd(Orbitrace, _config, null);
|
|
128
|
-
module.exports = Orbitrace;
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
export default require_src();
|