added stack trace to some logging

This commit is contained in:
jackiettran
2025-12-25 18:41:42 -05:00
parent b02ec19d5c
commit 76e4039ba8
15 changed files with 307 additions and 173 deletions

View File

@@ -89,6 +89,7 @@ class UserService {
"Failed to send personal information changed notification",
{
error: emailError.message,
stack: emailError.stack,
userId: user.id,
email: user.email,
changedFields,
@@ -138,6 +139,7 @@ class UserService {
} catch (emailError) {
logger.error("Failed to send notification for address creation", {
error: emailError.message,
stack: emailError.stack,
userId: user.id,
addressId: address.id,
});
@@ -181,6 +183,7 @@ class UserService {
} catch (emailError) {
logger.error("Failed to send notification for address update", {
error: emailError.message,
stack: emailError.stack,
userId,
addressId: address.id,
});
@@ -223,6 +226,7 @@ class UserService {
} catch (emailError) {
logger.error("Failed to send notification for address deletion", {
error: emailError.message,
stack: emailError.stack,
userId,
addressId,
});

View File

@@ -1,5 +1,6 @@
const EmailClient = require("../core/EmailClient");
const TemplateManager = require("../core/TemplateManager");
const logger = require("../../../utils/logger");
/**
* RentalFlowEmailService handles rental lifecycle flow emails
@@ -997,10 +998,12 @@ class RentalFlowEmailService {
);
}
} catch (emailError) {
console.error(
`Failed to send rental completion email to renter (${renter.email}):`,
emailError.message
);
logger.error("Failed to send rental completion email to renter", {
error: emailError.message,
stack: emailError.stack,
renterEmail: renter.email,
rentalId: rental.id
});
}
// Prepare owner email
@@ -1114,13 +1117,19 @@ class RentalFlowEmailService {
);
}
} catch (emailError) {
console.error(
`Failed to send rental completion email to owner (${owner.email}):`,
emailError.message
);
logger.error("Failed to send rental completion email to owner", {
error: emailError.message,
stack: emailError.stack,
ownerEmail: owner.email,
rentalId: rental.id
});
}
} catch (error) {
console.error("Error sending rental completion emails:", error);
logger.error("Error sending rental completion emails", {
error: error.message,
stack: error.stack,
rentalId: rental?.id
});
}
return results;

View File

@@ -1,6 +1,7 @@
const { Rental, User, Item } = require("../models");
const StripeService = require("./stripeService");
const emailServices = require("./email");
const logger = require("../utils/logger");
const { Op } = require("sequelize");
class PayoutService {
@@ -78,15 +79,18 @@ class PayoutService {
// Send payout notification email to owner
try {
await emailServices.rentalFlow.sendPayoutReceivedEmail(rental.owner, rental);
console.log(
`Payout notification email sent to owner for rental ${rental.id}`
);
logger.info("Payout notification email sent to owner", {
rentalId: rental.id,
ownerId: rental.ownerId
});
} catch (emailError) {
// Log error but don't fail the payout
console.error(
`Failed to send payout notification email for rental ${rental.id}:`,
emailError.message
);
logger.error("Failed to send payout notification email", {
error: emailError.message,
stack: emailError.stack,
rentalId: rental.id,
ownerId: rental.ownerId
});
}
return {