feat: add more api logs (#1870)

Adds more detailed API logging using Pino
This commit is contained in:
David Nguyen
2025-06-30 19:46:32 +10:00
committed by GitHub
parent 0cc729e9bd
commit 7487399123
74 changed files with 1395 additions and 544 deletions

View File

@ -24,6 +24,12 @@ export const createOrganisationGroupRoute = authenticatedProcedure
const { organisationId, organisationRole, name, memberIds } = input;
const { user } = ctx;
ctx.logger.info({
input: {
organisationId,
},
});
const organisation = await prisma.organisation.findFirst({
where: buildOrganisationWhereQuery({
organisationId,

View File

@ -14,6 +14,12 @@ export const createOrganisationMemberInvitesRoute = authenticatedProcedure
const userId = ctx.user.id;
const userName = ctx.user.name || '';
ctx.logger.info({
input: {
organisationId,
},
});
await createOrganisationMemberInvites({
userId,
userName,

View File

@ -23,6 +23,12 @@ export const createOrganisationRoute = authenticatedProcedure
const { name, priceId } = input;
const { user } = ctx;
ctx.logger.info({
input: {
priceId,
},
});
// Check if user can create a free organiastion.
if (IS_BILLING_ENABLED() && !priceId) {
const userOrganisations = await prisma.organisation.findMany({

View File

@ -19,6 +19,13 @@ export const deleteOrganisationGroupRoute = authenticatedProcedure
const { groupId, organisationId } = input;
const { user } = ctx;
ctx.logger.info({
input: {
groupId,
organisationId,
},
});
const organisation = await prisma.organisation.findFirst({
where: buildOrganisationWhereQuery({
organisationId,

View File

@ -19,6 +19,13 @@ export const deleteOrganisationMemberInvitesRoute = authenticatedProcedure
const { organisationId, invitationIds } = input;
const userId = ctx.user.id;
ctx.logger.info({
input: {
organisationId,
invitationIds,
},
});
const organisation = await prisma.organisation.findFirst({
where: buildOrganisationWhereQuery({
organisationId,

View File

@ -13,6 +13,13 @@ export const deleteOrganisationMemberRoute = authenticatedProcedure
const { organisationId, organisationMemberId } = input;
const userId = ctx.user.id;
ctx.logger.info({
input: {
organisationId,
organisationMemberId,
},
});
await deleteOrganisationMembers({
userId,
organisationId,

View File

@ -21,6 +21,13 @@ export const deleteOrganisationMembersRoute = authenticatedProcedure
const { organisationId, organisationMemberIds } = input;
const userId = ctx.user.id;
ctx.logger.info({
input: {
organisationId,
organisationMemberIds,
},
});
await deleteOrganisationMembers({
userId,
organisationId,

View File

@ -17,6 +17,12 @@ export const deleteOrganisationRoute = authenticatedProcedure
const { organisationId } = input;
const { user } = ctx;
ctx.logger.info({
input: {
organisationId,
},
});
const organisation = await prisma.organisation.findFirst({
where: buildOrganisationWhereQuery({
organisationId,

View File

@ -21,6 +21,12 @@ export const findOrganisationGroupsRoute = authenticatedProcedure
input;
const { user } = ctx;
ctx.logger.info({
input: {
organisationId,
},
});
return await findOrganisationGroups({
userId: user.id,
organisationId,

View File

@ -21,6 +21,12 @@ export const findOrganisationMemberInvitesRoute = authenticatedProcedure
const { organisationId, query, page, perPage, status } = input;
const { user } = ctx;
ctx.logger.info({
input: {
organisationId,
},
});
return await findOrganisationMemberInvites({
userId: user.id,
organisationId,

View File

@ -14,6 +14,12 @@ export const getOrganisationRoute = authenticatedProcedure
.query(async ({ input, ctx }) => {
const { organisationReference } = input;
ctx.logger.info({
input: {
organisationReference,
},
});
return await getOrganisation({
userId: ctx.user.id,
organisationReference,

View File

@ -17,9 +17,14 @@ export const leaveOrganisationRoute = authenticatedProcedure
.output(ZLeaveOrganisationResponseSchema)
.mutation(async ({ ctx, input }) => {
const { organisationId } = input;
const userId = ctx.user.id;
ctx.logger.info({
input: {
organisationId,
},
});
const organisation = await prisma.organisation.findFirst({
where: buildOrganisationWhereQuery({ organisationId, userId }),
include: {

View File

@ -20,6 +20,13 @@ export const resendOrganisationMemberInviteRoute = authenticatedProcedure
const userId = ctx.user.id;
const userName = ctx.user.name || '';
ctx.logger.info({
input: {
organisationId,
invitationId,
},
});
await resendOrganisationMemberInvitation({
userId,
userName,

View File

@ -25,6 +25,12 @@ export const updateOrganisationGroupRoute = authenticatedProcedure
const { id, ...data } = input;
const { user } = ctx;
ctx.logger.info({
input: {
id,
},
});
const organisationGroup = await prisma.organisationGroup.findFirst({
where: {
id,

View File

@ -24,6 +24,13 @@ export const updateOrganisationMemberRoute = authenticatedProcedure
const { organisationId, organisationMemberId, data } = input;
const userId = ctx.user.id;
ctx.logger.info({
input: {
organisationId,
organisationMemberId,
},
});
const organisation = await prisma.organisation.findFirst({
where: buildOrganisationWhereQuery({
organisationId,

View File

@ -16,6 +16,12 @@ export const updateOrganisationSettingsRoute = authenticatedProcedure
const { user } = ctx;
const { organisationId, data } = input;
ctx.logger.info({
input: {
organisationId,
},
});
const {
// Document related settings.
documentVisibility,

View File

@ -15,9 +15,14 @@ export const updateOrganisationRoute = authenticatedProcedure
.output(ZUpdateOrganisationResponseSchema)
.mutation(async ({ input, ctx }) => {
const { organisationId, data } = input;
const userId = ctx.user.id;
ctx.logger.info({
input: {
organisationId,
},
});
// Check if organisation exists and user has access to it
const existingOrganisation = await prisma.organisation.findFirst({
where: buildOrganisationWhereQuery({