Attach authenticated user to DataDog spans.
This commit is contained in:
parent
66f040a295
commit
69bfd01bf0
|
@ -15,6 +15,7 @@ import * as identity from "../context/identity"
|
||||||
import env from "../environment"
|
import env from "../environment"
|
||||||
import { Ctx, EndpointMatcher, SessionCookie } from "@budibase/types"
|
import { Ctx, EndpointMatcher, SessionCookie } from "@budibase/types"
|
||||||
import { InvalidAPIKeyError, ErrorCode } from "../errors"
|
import { InvalidAPIKeyError, ErrorCode } from "../errors"
|
||||||
|
import tracer from "dd-trace"
|
||||||
|
|
||||||
const ONE_MINUTE = env.SESSION_UPDATE_PERIOD
|
const ONE_MINUTE = env.SESSION_UPDATE_PERIOD
|
||||||
? parseInt(env.SESSION_UPDATE_PERIOD)
|
? parseInt(env.SESSION_UPDATE_PERIOD)
|
||||||
|
@ -166,6 +167,20 @@ export default function (
|
||||||
if (!authenticated) {
|
if (!authenticated) {
|
||||||
authenticated = false
|
authenticated = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (user) {
|
||||||
|
tracer.setUser({
|
||||||
|
id: user?.id,
|
||||||
|
email: user?.email,
|
||||||
|
tenantId: user?.tenantId,
|
||||||
|
admin: user?.admin,
|
||||||
|
builder: user?.builder,
|
||||||
|
budibaseAccess: user?.budibaseAccess,
|
||||||
|
status: user?.status,
|
||||||
|
roles: user?.roles,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// isAuthenticated is a function, so use a variable to be able to check authed state
|
// isAuthenticated is a function, so use a variable to be able to check authed state
|
||||||
finalise(ctx, { authenticated, user, internal, version, publicEndpoint })
|
finalise(ctx, { authenticated, user, internal, version, publicEndpoint })
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue