@sentienguard/apm 1.0.2 → 1.0.3
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/package.json +6 -2
- package/src/browser.js +107 -0
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentienguard/apm",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "SentienGuard APM SDK - Minimal, production-safe application performance monitoring",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"browser": "./src/browser.js",
|
|
7
8
|
"exports": {
|
|
8
|
-
".":
|
|
9
|
+
".": {
|
|
10
|
+
"browser": "./src/browser.js",
|
|
11
|
+
"default": "./src/index.js"
|
|
12
|
+
}
|
|
9
13
|
},
|
|
10
14
|
"scripts": {
|
|
11
15
|
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
package/src/browser.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SentienGuard APM SDK - Browser No-Op
|
|
3
|
+
*
|
|
4
|
+
* This module is automatically used when the SDK is imported in a browser
|
|
5
|
+
* environment (via bundlers like Webpack, Vite, Rsbuild, etc.).
|
|
6
|
+
*
|
|
7
|
+
* The APM SDK only works in Node.js (it patches http/https modules),
|
|
8
|
+
* so in the browser we export no-op stubs to avoid build errors.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const noop = () => {};
|
|
12
|
+
const asyncNoop = async () => {};
|
|
13
|
+
const noopMiddleware = (_req, _res, next) => next?.();
|
|
14
|
+
|
|
15
|
+
function initialize() {}
|
|
16
|
+
async function shutdown() {}
|
|
17
|
+
function getStatus() {
|
|
18
|
+
return {
|
|
19
|
+
enabled: false,
|
|
20
|
+
initialized: false,
|
|
21
|
+
config: { service: '', environment: '', flushInterval: 0 },
|
|
22
|
+
stats: {}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function flush() {}
|
|
26
|
+
function getConfig() {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
function isEnabled() {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
function normalizeRoute(route) {
|
|
33
|
+
return route;
|
|
34
|
+
}
|
|
35
|
+
function extractRoute(req) {
|
|
36
|
+
return req?.url || '/';
|
|
37
|
+
}
|
|
38
|
+
function getAggregator() {
|
|
39
|
+
return {
|
|
40
|
+
getStats: () => ({}),
|
|
41
|
+
recordRequest: noop,
|
|
42
|
+
recordDependency: noop,
|
|
43
|
+
recordError: noop
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function instrumentMongoDB() {}
|
|
47
|
+
function instrumentOpenAI() {}
|
|
48
|
+
function createBreaker(fn) {
|
|
49
|
+
return fn;
|
|
50
|
+
}
|
|
51
|
+
function wrapMongoOperation(fn) {
|
|
52
|
+
return fn;
|
|
53
|
+
}
|
|
54
|
+
function getBreakerStats() {
|
|
55
|
+
return {};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const RouteRegistry = {
|
|
59
|
+
register: noop,
|
|
60
|
+
match: () => null
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const expressMiddleware = noopMiddleware;
|
|
64
|
+
const expressErrorMiddleware = (_err, _req, _res, next) => next?.();
|
|
65
|
+
const fastifyPlugin = noop;
|
|
66
|
+
const fastifyErrorHandler = noop;
|
|
67
|
+
|
|
68
|
+
export {
|
|
69
|
+
initialize,
|
|
70
|
+
shutdown,
|
|
71
|
+
getStatus,
|
|
72
|
+
flush,
|
|
73
|
+
getConfig,
|
|
74
|
+
isEnabled,
|
|
75
|
+
expressMiddleware,
|
|
76
|
+
expressErrorMiddleware,
|
|
77
|
+
fastifyPlugin,
|
|
78
|
+
fastifyErrorHandler,
|
|
79
|
+
normalizeRoute,
|
|
80
|
+
extractRoute,
|
|
81
|
+
RouteRegistry,
|
|
82
|
+
getAggregator,
|
|
83
|
+
instrumentMongoDB,
|
|
84
|
+
instrumentOpenAI,
|
|
85
|
+
createBreaker,
|
|
86
|
+
wrapMongoOperation,
|
|
87
|
+
getBreakerStats
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export default {
|
|
91
|
+
initialize,
|
|
92
|
+
shutdown,
|
|
93
|
+
getStatus,
|
|
94
|
+
flush,
|
|
95
|
+
expressMiddleware,
|
|
96
|
+
expressErrorMiddleware,
|
|
97
|
+
fastifyPlugin,
|
|
98
|
+
fastifyErrorHandler,
|
|
99
|
+
normalizeRoute,
|
|
100
|
+
extractRoute,
|
|
101
|
+
getAggregator,
|
|
102
|
+
instrumentMongoDB,
|
|
103
|
+
instrumentOpenAI,
|
|
104
|
+
createBreaker,
|
|
105
|
+
wrapMongoOperation,
|
|
106
|
+
getBreakerStats
|
|
107
|
+
};
|