@drawbridge/drawbridge-telemetry 0.0.3 → 0.0.4
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/express.cjs +5 -6
- package/dist/express.d.cts +16 -11
- package/dist/express.d.ts +16 -11
- package/dist/express.js +5 -6
- package/package.json +5 -2
package/dist/express.cjs
CHANGED
|
@@ -35,29 +35,28 @@ __export(express_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(express_exports);
|
|
36
36
|
var Sentry = __toESM(require("@sentry/core"), 1);
|
|
37
37
|
var applyRequestContext = (req) => {
|
|
38
|
-
const scope = Sentry.getCurrentScope();
|
|
39
38
|
if (req == null ? void 0 : req.id) {
|
|
40
|
-
|
|
39
|
+
Sentry.setTag("traceId", req.id);
|
|
41
40
|
}
|
|
42
41
|
;
|
|
43
42
|
if (req == null ? void 0 : req.method) {
|
|
44
|
-
|
|
43
|
+
Sentry.setTag("method", req.method);
|
|
45
44
|
}
|
|
46
45
|
;
|
|
47
46
|
if (req == null ? void 0 : req.path) {
|
|
48
|
-
|
|
47
|
+
Sentry.setTag("route", req.path);
|
|
49
48
|
}
|
|
50
49
|
;
|
|
51
50
|
const user = (req == null ? void 0 : req.authenticated) || (req == null ? void 0 : req.user);
|
|
52
51
|
if (user) {
|
|
53
|
-
|
|
52
|
+
Sentry.setUser({
|
|
54
53
|
id: user.id || user._id,
|
|
55
54
|
email: user.email
|
|
56
55
|
});
|
|
57
56
|
}
|
|
58
57
|
;
|
|
59
58
|
if (req == null ? void 0 : req.organization) {
|
|
60
|
-
|
|
59
|
+
Sentry.setTag("organization", req.organization.id || req.organization._id);
|
|
61
60
|
}
|
|
62
61
|
;
|
|
63
62
|
};
|
package/dist/express.d.cts
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import * as Sentry from '@sentry/core';
|
|
2
2
|
|
|
3
|
-
// Apply all available context tags from a request to the
|
|
4
|
-
// scope. Idempotent — safe to call multiple times as
|
|
5
|
-
// (e.g. once at request entry for
|
|
6
|
-
// middleware once req.authenticated
|
|
3
|
+
// Apply all available context tags from a request to the per-request
|
|
4
|
+
// Sentry isolation scope. Idempotent — safe to call multiple times as
|
|
5
|
+
// the request enriches (e.g. once at request entry for
|
|
6
|
+
// traceId/method/path, again from auth middleware once req.authenticated
|
|
7
|
+
// and req.organization are populated).
|
|
7
8
|
//
|
|
8
9
|
// Reads from req.authenticated first (drawbridge-api convention) and
|
|
9
10
|
// falls back to req.user for compatibility with other services.
|
|
11
|
+
//
|
|
12
|
+
// Uses Sentry.setTag / Sentry.setUser (which target the isolation scope
|
|
13
|
+
// in v8+) rather than getCurrentScope().setTag, because errors captured
|
|
14
|
+
// later in the request from a different async fork only inherit the
|
|
15
|
+
// isolation scope. Setting tags on the current scope at middleware time
|
|
16
|
+
// can leave them out of the captureException event payload.
|
|
10
17
|
|
|
11
18
|
const applyRequestContext = ( req ) => {
|
|
12
19
|
|
|
13
|
-
const scope = Sentry.getCurrentScope();
|
|
14
|
-
|
|
15
20
|
if( req?.id ){
|
|
16
21
|
|
|
17
|
-
|
|
22
|
+
Sentry.setTag( 'traceId', req.id );
|
|
18
23
|
|
|
19
24
|
}
|
|
20
25
|
if( req?.method ){
|
|
21
26
|
|
|
22
|
-
|
|
27
|
+
Sentry.setTag( 'method', req.method );
|
|
23
28
|
|
|
24
29
|
}
|
|
25
30
|
// req.route is set by Express only AFTER route matching, which hasn't
|
|
@@ -28,14 +33,14 @@ const applyRequestContext = ( req ) => {
|
|
|
28
33
|
// future res.on('finish') refinement.
|
|
29
34
|
if( req?.path ){
|
|
30
35
|
|
|
31
|
-
|
|
36
|
+
Sentry.setTag( 'route', req.path );
|
|
32
37
|
|
|
33
38
|
}
|
|
34
39
|
const user = req?.authenticated || req?.user;
|
|
35
40
|
|
|
36
41
|
if( user ){
|
|
37
42
|
|
|
38
|
-
|
|
43
|
+
Sentry.setUser({
|
|
39
44
|
id : user.id || user._id,
|
|
40
45
|
email : user.email
|
|
41
46
|
});
|
|
@@ -43,7 +48,7 @@ const applyRequestContext = ( req ) => {
|
|
|
43
48
|
}
|
|
44
49
|
if( req?.organization ){
|
|
45
50
|
|
|
46
|
-
|
|
51
|
+
Sentry.setTag( 'organization', req.organization.id || req.organization._id );
|
|
47
52
|
|
|
48
53
|
}
|
|
49
54
|
};
|
package/dist/express.d.ts
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import * as Sentry from '@sentry/core';
|
|
2
2
|
|
|
3
|
-
// Apply all available context tags from a request to the
|
|
4
|
-
// scope. Idempotent — safe to call multiple times as
|
|
5
|
-
// (e.g. once at request entry for
|
|
6
|
-
// middleware once req.authenticated
|
|
3
|
+
// Apply all available context tags from a request to the per-request
|
|
4
|
+
// Sentry isolation scope. Idempotent — safe to call multiple times as
|
|
5
|
+
// the request enriches (e.g. once at request entry for
|
|
6
|
+
// traceId/method/path, again from auth middleware once req.authenticated
|
|
7
|
+
// and req.organization are populated).
|
|
7
8
|
//
|
|
8
9
|
// Reads from req.authenticated first (drawbridge-api convention) and
|
|
9
10
|
// falls back to req.user for compatibility with other services.
|
|
11
|
+
//
|
|
12
|
+
// Uses Sentry.setTag / Sentry.setUser (which target the isolation scope
|
|
13
|
+
// in v8+) rather than getCurrentScope().setTag, because errors captured
|
|
14
|
+
// later in the request from a different async fork only inherit the
|
|
15
|
+
// isolation scope. Setting tags on the current scope at middleware time
|
|
16
|
+
// can leave them out of the captureException event payload.
|
|
10
17
|
|
|
11
18
|
const applyRequestContext = ( req ) => {
|
|
12
19
|
|
|
13
|
-
const scope = Sentry.getCurrentScope();
|
|
14
|
-
|
|
15
20
|
if( req?.id ){
|
|
16
21
|
|
|
17
|
-
|
|
22
|
+
Sentry.setTag( 'traceId', req.id );
|
|
18
23
|
|
|
19
24
|
}
|
|
20
25
|
if( req?.method ){
|
|
21
26
|
|
|
22
|
-
|
|
27
|
+
Sentry.setTag( 'method', req.method );
|
|
23
28
|
|
|
24
29
|
}
|
|
25
30
|
// req.route is set by Express only AFTER route matching, which hasn't
|
|
@@ -28,14 +33,14 @@ const applyRequestContext = ( req ) => {
|
|
|
28
33
|
// future res.on('finish') refinement.
|
|
29
34
|
if( req?.path ){
|
|
30
35
|
|
|
31
|
-
|
|
36
|
+
Sentry.setTag( 'route', req.path );
|
|
32
37
|
|
|
33
38
|
}
|
|
34
39
|
const user = req?.authenticated || req?.user;
|
|
35
40
|
|
|
36
41
|
if( user ){
|
|
37
42
|
|
|
38
|
-
|
|
43
|
+
Sentry.setUser({
|
|
39
44
|
id : user.id || user._id,
|
|
40
45
|
email : user.email
|
|
41
46
|
});
|
|
@@ -43,7 +48,7 @@ const applyRequestContext = ( req ) => {
|
|
|
43
48
|
}
|
|
44
49
|
if( req?.organization ){
|
|
45
50
|
|
|
46
|
-
|
|
51
|
+
Sentry.setTag( 'organization', req.organization.id || req.organization._id );
|
|
47
52
|
|
|
48
53
|
}
|
|
49
54
|
};
|
package/dist/express.js
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
// express.js
|
|
2
2
|
import * as Sentry from "@sentry/core";
|
|
3
3
|
var applyRequestContext = (req) => {
|
|
4
|
-
const scope = Sentry.getCurrentScope();
|
|
5
4
|
if (req == null ? void 0 : req.id) {
|
|
6
|
-
|
|
5
|
+
Sentry.setTag("traceId", req.id);
|
|
7
6
|
}
|
|
8
7
|
;
|
|
9
8
|
if (req == null ? void 0 : req.method) {
|
|
10
|
-
|
|
9
|
+
Sentry.setTag("method", req.method);
|
|
11
10
|
}
|
|
12
11
|
;
|
|
13
12
|
if (req == null ? void 0 : req.path) {
|
|
14
|
-
|
|
13
|
+
Sentry.setTag("route", req.path);
|
|
15
14
|
}
|
|
16
15
|
;
|
|
17
16
|
const user = (req == null ? void 0 : req.authenticated) || (req == null ? void 0 : req.user);
|
|
18
17
|
if (user) {
|
|
19
|
-
|
|
18
|
+
Sentry.setUser({
|
|
20
19
|
id: user.id || user._id,
|
|
21
20
|
email: user.email
|
|
22
21
|
});
|
|
23
22
|
}
|
|
24
23
|
;
|
|
25
24
|
if (req == null ? void 0 : req.organization) {
|
|
26
|
-
|
|
25
|
+
Sentry.setTag("organization", req.organization.id || req.organization._id);
|
|
27
26
|
}
|
|
28
27
|
;
|
|
29
28
|
};
|
package/package.json
CHANGED
|
@@ -46,9 +46,12 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
|
-
"sync": ". \"$HOME/.nvm/nvm.sh\" && nvm use && npm prune && npm install",
|
|
49
|
+
"sync": ". \"$HOME/.nvm/nvm.sh\" && nvm use && npm prune && npm install && npx drawbridge-agents-sync",
|
|
50
50
|
"build": "tsup && npm publish"
|
|
51
51
|
},
|
|
52
52
|
"types": "dist/index.d.ts",
|
|
53
|
-
"version": "0.0.
|
|
53
|
+
"version": "0.0.4",
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@drawbridge/drawbridge-agents": "0.0.4"
|
|
56
|
+
}
|
|
54
57
|
}
|