@bugmail-js/core 0.1.6 → 0.1.7
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 +2 -2
- package/bugmail-core-client.js +8 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Quick example (capture an exception)
|
|
|
23
23
|
import { BugMailCoreClient } from '@bugmail-js/core';
|
|
24
24
|
|
|
25
25
|
const client = new BugMailCoreClient({
|
|
26
|
-
baseUrl: '
|
|
26
|
+
baseUrl: process.env.BUGMAIL_ENDPOINT || '<your-bugmail-endpoint>',
|
|
27
27
|
apiPath: '/api/sdk/v1/errors',
|
|
28
28
|
onError: (info) => console.warn('Reporting failed', info),
|
|
29
29
|
});
|
|
@@ -40,7 +40,7 @@ await client.captureException(new Error('Test error'), {
|
|
|
40
40
|
API reference (important parts)
|
|
41
41
|
|
|
42
42
|
- `new BugMailCoreClient(config)`
|
|
43
|
-
- `config.baseUrl` — backend base URL (default: env `BUGMAIL_API_BASE_URL` or
|
|
43
|
+
- `config.baseUrl` — backend base URL (default: env `BUGMAIL_API_BASE_URL` or `<your-bugmail-endpoint>`)
|
|
44
44
|
- `config.apiPath` — ingestion path (default: `/api/sdk/v1/errors`)
|
|
45
45
|
- `config.onError` — optional callback invoked when report fails
|
|
46
46
|
|
package/bugmail-core-client.js
CHANGED
|
@@ -15,7 +15,14 @@ export class BugMailCoreClient {
|
|
|
15
15
|
* @param {Object} context - { headers, payload, ... }
|
|
16
16
|
*/
|
|
17
17
|
async captureException(error, context = {}) {
|
|
18
|
-
const
|
|
18
|
+
const isProd = (typeof process !== 'undefined' && process.env?.NODE_ENV === 'production');
|
|
19
|
+
const baseUrl = this.config.baseUrl ||
|
|
20
|
+
(typeof process !== 'undefined' ? (process.env?.BUGMAIL_API_BASE_URL || process.env?.API_BASE_URL || process.env?.BUGMAIL_API_URL) : '') ||
|
|
21
|
+
'';
|
|
22
|
+
|
|
23
|
+
if (isProd && !baseUrl) {
|
|
24
|
+
console.warn('[BugMail] BUGMAIL API base URL missing in production. Reporting might default to localhost.');
|
|
25
|
+
}
|
|
19
26
|
const apiPath = this.config.apiPath || '/api/sdk/v1/errors';
|
|
20
27
|
const url = baseUrl.replace(/\/$/, '') + apiPath;
|
|
21
28
|
const headers = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bugmail-js/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"module": "index.js",
|
|
6
6
|
"exports": {
|
|
@@ -35,4 +35,4 @@
|
|
|
35
35
|
"url": "https://github.com/MarcorpAI/Bugmail-SDKs/issues"
|
|
36
36
|
},
|
|
37
37
|
"sideEffects": false
|
|
38
|
-
}
|
|
38
|
+
}
|