Also instrument appId
This commit is contained in:
parent
899b6707e7
commit
5b880f1d9b
|
@ -12,14 +12,20 @@ import { getCachedSelf } from "../utilities/global"
|
||||||
import env from "../environment"
|
import env from "../environment"
|
||||||
import { isWebhookEndpoint } from "./utils"
|
import { isWebhookEndpoint } from "./utils"
|
||||||
import { UserCtx, ContextUser } from "@budibase/types"
|
import { UserCtx, ContextUser } from "@budibase/types"
|
||||||
|
import tracer from "dd-trace"
|
||||||
|
|
||||||
export default async (ctx: UserCtx, next: any) => {
|
export default async (ctx: UserCtx, next: any) => {
|
||||||
|
return tracer.trace("currentapp middleware", {}, async span => {
|
||||||
// try to get the appID from the request
|
// try to get the appID from the request
|
||||||
let requestAppId = await utils.getAppIdFromCtx(ctx)
|
let requestAppId = await utils.getAppIdFromCtx(ctx)
|
||||||
if (!requestAppId) {
|
if (!requestAppId) {
|
||||||
return next()
|
return next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (requestAppId) {
|
||||||
|
span?.addTags({ appId: requestAppId })
|
||||||
|
}
|
||||||
|
|
||||||
// deny access to application preview
|
// deny access to application preview
|
||||||
if (!env.isTest()) {
|
if (!env.isTest()) {
|
||||||
if (
|
if (
|
||||||
|
@ -57,7 +63,9 @@ export default async (ctx: UserCtx, next: any) => {
|
||||||
roleId = roleHeader
|
roleId = roleHeader
|
||||||
|
|
||||||
// Delete admin and builder flags so that the specified role is honoured
|
// Delete admin and builder flags so that the specified role is honoured
|
||||||
ctx.user = users.removePortalUserPermissions(ctx.user) as ContextUser
|
ctx.user = users.removePortalUserPermissions(
|
||||||
|
ctx.user
|
||||||
|
) as ContextUser
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Swallow error and do nothing
|
// Swallow error and do nothing
|
||||||
|
@ -111,4 +119,5 @@ export default async (ctx: UserCtx, next: any) => {
|
||||||
|
|
||||||
return next()
|
return next()
|
||||||
})
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue