Skip to content

Commit e5e80b3

Browse files
committed
fix: ambassador logs
1 parent f6b9f07 commit e5e80b3

File tree

3 files changed

+21
-197
lines changed

3 files changed

+21
-197
lines changed

apps/docs/app/api/ambassador/submit/route.ts

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import { createLogger } from "@databuddy/shared/logger";
12
import { type NextRequest, NextResponse } from "next/server";
2-
import { logger } from "@/lib/discord-webhook";
33
import { formRateLimit } from "@/lib/rate-limit";
44

5-
// Type for ambassador form data
6-
interface AmbassadorFormData {
5+
const logger = createLogger("ambassador-form");
6+
7+
type AmbassadorFormData = {
78
name: string;
89
email: string;
910
xHandle?: string;
@@ -115,10 +116,9 @@ export async function POST(request: NextRequest) {
115116
const rateLimitResult = formRateLimit.check(clientIP);
116117

117118
if (!rateLimitResult.allowed) {
118-
await logger.warning(
119-
"Ambassador Form Rate Limited",
120-
`IP ${clientIP} exceeded rate limit for ambassador form submissions`,
121-
{ ip: clientIP, resetTime: rateLimitResult.resetTime }
119+
logger.info(
120+
{ ip: clientIP, resetTime: rateLimitResult.resetTime },
121+
`IP ${clientIP} exceeded rate limit for ambassador form submissions`
122122
);
123123

124124
return NextResponse.json(
@@ -135,10 +135,9 @@ export async function POST(request: NextRequest) {
135135
const validation = validateFormData(formData);
136136

137137
if (!validation.valid) {
138-
await logger.warning(
139-
"Ambassador Form Validation Failed",
140-
"Form submission failed validation",
141-
{ errors: validation.errors, ip: clientIP }
138+
logger.info(
139+
{ errors: validation.errors, ip: clientIP },
140+
"Form submission failed validation"
142141
);
143142

144143
return NextResponse.json(
@@ -149,10 +148,7 @@ export async function POST(request: NextRequest) {
149148

150149
const ambassadorData = formData as AmbassadorFormData;
151150

152-
// Log successful submission
153-
await logger.success(
154-
"New Ambassador Application",
155-
`${ambassadorData.name} (${ambassadorData.email}) submitted an ambassador application`,
151+
logger.info(
156152
{
157153
name: ambassadorData.name,
158154
email: ambassadorData.email,
@@ -164,23 +160,22 @@ export async function POST(request: NextRequest) {
164160
referralSource: ambassadorData.referralSource || "Not provided",
165161
ip: clientIP,
166162
userAgent: request.headers.get("user-agent"),
167-
timestamp: new Date().toISOString(),
168-
}
163+
},
164+
`${ambassadorData.name} (${ambassadorData.email}) submitted an ambassador application`
169165
);
170166

171167
return NextResponse.json({
172168
success: true,
173169
message: "Ambassador application submitted successfully",
174170
});
175171
} catch (error) {
176-
await logger.exception(
177-
error instanceof Error
178-
? error
179-
: new Error("Unknown error in ambassador form submission"),
172+
logger.error(
180173
{
181174
ip: getClientIP(request),
182-
userAgent: request.headers.get("user-agent"),
183-
}
175+
userAgent: request.headers.get("user-agent") || "unknown",
176+
error: error instanceof Error ? error.message : String(error),
177+
},
178+
"Unknown error in ambassador form submission"
184179
);
185180

186181
return NextResponse.json(

apps/docs/lib/discord-webhook.ts

Lines changed: 0 additions & 170 deletions
This file was deleted.

packages/rpc/src/services/website-service.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,15 @@ export class WebsiteService {
182182
return pipe(
183183
Effect.try({
184184
try: () =>
185-
logger.success(
186-
"Website Created",
187-
`New website "${createdWebsite.name}" was created with domain "${createdWebsite.domain}"`,
185+
logger.info(
188186
{
189187
websiteId: createdWebsite.id,
190188
domain: createdWebsite.domain,
191189
userId: createdWebsite.userId,
192190
organizationId: createdWebsite.organizationId,
193191
...logContext,
194-
}
192+
},
193+
`Website Created: "${createdWebsite.name}" with domain "${createdWebsite.domain}"`
195194
),
196195
catch: (error) =>
197196
new Error(`Logging failed: ${String(error)}`) as WebsiteError,

0 commit comments

Comments
 (0)