✅ added spanning methods for insights in logic + logger is fully otel-ified as well 🥳
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { FlowExecCtx } from "@/core/flow.execution.context";
|
||||
import { traceResultAsync } from "@core/observability";
|
||||
import { AccountRepository } from "./account.repository";
|
||||
import { UserRepository } from "./repository";
|
||||
import { db } from "@pkg/db";
|
||||
@@ -10,19 +11,39 @@ export class UserController {
|
||||
) {}
|
||||
|
||||
getUserInfo(fctx: FlowExecCtx, userId: string) {
|
||||
return this.userRepository.getUserInfo(fctx, userId);
|
||||
return traceResultAsync({
|
||||
name: "logic.user.controller.getUserInfo",
|
||||
fctx,
|
||||
attributes: { "app.user.id": userId },
|
||||
fn: () => this.userRepository.getUserInfo(fctx, userId),
|
||||
});
|
||||
}
|
||||
|
||||
ensureAccountExists(fctx: FlowExecCtx, userId: string) {
|
||||
return this.accountRepo.ensureAccountExists(fctx, userId);
|
||||
return traceResultAsync({
|
||||
name: "logic.user.controller.ensureAccountExists",
|
||||
fctx,
|
||||
attributes: { "app.user.id": userId },
|
||||
fn: () => this.accountRepo.ensureAccountExists(fctx, userId),
|
||||
});
|
||||
}
|
||||
|
||||
isUsernameAvailable(fctx: FlowExecCtx, username: string) {
|
||||
return this.userRepository.isUsernameAvailable(fctx, username);
|
||||
return traceResultAsync({
|
||||
name: "logic.user.controller.isUsernameAvailable",
|
||||
fctx,
|
||||
attributes: { "app.user.username": username },
|
||||
fn: () => this.userRepository.isUsernameAvailable(fctx, username),
|
||||
});
|
||||
}
|
||||
|
||||
updateLastVerified2FaAtToNow(fctx: FlowExecCtx, userId: string) {
|
||||
return this.userRepository.updateLastVerified2FaAtToNow(fctx, userId);
|
||||
return traceResultAsync({
|
||||
name: "logic.user.controller.updateLastVerified2FaAtToNow",
|
||||
fctx,
|
||||
attributes: { "app.user.id": userId },
|
||||
fn: () => this.userRepository.updateLastVerified2FaAtToNow(fctx, userId),
|
||||
});
|
||||
}
|
||||
|
||||
banUser(
|
||||
@@ -31,19 +52,39 @@ export class UserController {
|
||||
reason: string,
|
||||
banExpiresAt: Date,
|
||||
) {
|
||||
return this.userRepository.banUser(fctx, userId, reason, banExpiresAt);
|
||||
return traceResultAsync({
|
||||
name: "logic.user.controller.banUser",
|
||||
fctx,
|
||||
attributes: { "app.user.id": userId },
|
||||
fn: () => this.userRepository.banUser(fctx, userId, reason, banExpiresAt),
|
||||
});
|
||||
}
|
||||
|
||||
isUserBanned(fctx: FlowExecCtx, userId: string) {
|
||||
return this.userRepository.isUserBanned(fctx, userId);
|
||||
return traceResultAsync({
|
||||
name: "logic.user.controller.isUserBanned",
|
||||
fctx,
|
||||
attributes: { "app.user.id": userId },
|
||||
fn: () => this.userRepository.isUserBanned(fctx, userId),
|
||||
});
|
||||
}
|
||||
|
||||
getBanInfo(fctx: FlowExecCtx, userId: string) {
|
||||
return this.userRepository.getBanInfo(fctx, userId);
|
||||
return traceResultAsync({
|
||||
name: "logic.user.controller.getBanInfo",
|
||||
fctx,
|
||||
attributes: { "app.user.id": userId },
|
||||
fn: () => this.userRepository.getBanInfo(fctx, userId),
|
||||
});
|
||||
}
|
||||
|
||||
rotatePassword(fctx: FlowExecCtx, userId: string, password: string) {
|
||||
return this.accountRepo.rotatePassword(fctx, userId, password);
|
||||
return traceResultAsync({
|
||||
name: "logic.user.controller.rotatePassword",
|
||||
fctx,
|
||||
attributes: { "app.user.id": userId },
|
||||
fn: () => this.accountRepo.rotatePassword(fctx, userId, password),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user