Skip to content

Conversation

@vas3a
Copy link
Collaborator

@vas3a vas3a commented Dec 3, 2025

PS-469 - add more logs in admin service & payment service to track payment changes & payment reconciliation

@vas3a vas3a requested a review from kkartunov December 3, 2025 16:12
this.logger.info(
`updateWinnings called by ${userId} for winningsId=${winningsId}`,
);
this.logger.debug(`updateWinnings payload: ${JSON.stringify(body)}`);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ security]
Consider using a more structured logging approach instead of JSON.stringify(body), as this can potentially log sensitive information. Ensure that sensitive fields are either omitted or masked.


let needsReconciliation = false;
const winningsId = body.winningsId;
this.logger.log(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Consider using logger.info for informational messages instead of logger.log to maintain consistency and clarity in log levels.

this.logger.log(
`updateWinnings called by ${userId} for winningsId=${winningsId}`,
);
this.logger.log(`updateWinnings payload: ${JSON.stringify(body)}`);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ performance]
Switching from logger.debug to logger.log may result in excessive logging in production environments. Ensure that the log level is appropriate for the environment to avoid performance issues and log noise.

body.paymentId,
);

this.logger.log(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Changing the logging level from debug to log may result in more verbose output in production environments. Ensure that this change aligns with the desired logging strategy and does not expose sensitive information or overwhelm log storage.

let releaseDate;
if (body.paymentStatus) {
releaseDate = await this.getPaymentReleaseDateByWinningsId(winningsId);
this.logger.log(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Consider using this.logger.debug instead of this.logger.log if the intention is to log detailed information primarily useful for debugging. log might be too verbose for production logs and could clutter the log files.


// iterate payments and build transaction list
payments.forEach((payment) => {
this.logger.log(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Changing the log level from debug to log may result in more verbose output in production environments. Ensure this change aligns with the intended logging strategy and does not expose sensitive information or overwhelm log storage.


if (body.paymentStatus === PaymentStatus.OWED) {
needsReconciliation = true;
this.logger.log(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Consider using this.logger.debug instead of this.logger.log for this message. Since the message is about internal state changes and not critical information, debug level might be more appropriate to avoid cluttering logs with non-essential information.

}
}

this.logger.log(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Changing this.logger.debug to this.logger.log may result in a loss of granularity in log levels. If log is not equivalent to debug, consider whether this change might affect the ability to filter logs appropriately.

);
});

this.logger.log(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
The change from this.logger.info to this.logger.log could affect the log level semantics. Ensure that log provides the same level of detail and filtering capability as info if that's the intended behavior.

for (const transaction of transactions) {
await transaction(tx);
for (let i = 0; i < transactions.length; i++) {
this.logger.log(`Executing transaction ${i + 1}/${transactions.length}`);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Switching from this.logger.debug to this.logger.log might impact the log level used for transaction execution details. Verify that this change aligns with the desired logging strategy and does not reduce the ability to filter logs by severity.

}
});

this.logger.log(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Replacing this.logger.info with this.logger.log could alter the intended log level. Confirm that log provides the necessary level of detail and filtering as info for successful transaction execution messages.

});

if (winning?.winner_id) {
this.logger.log(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Consider using a more specific logging level than log, such as info or debug, to maintain consistency and clarity in log severity. This helps in filtering logs based on their importance.

`Triggering payments reconciliation for user ${winning.winner_id}`,
);
await this.paymentsService.reconcileUserPayments(winning.winner_id);
this.logger.log(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Consider using a more specific logging level than log, such as info or debug, to maintain consistency and clarity in log severity. This helps in filtering logs based on their importance.

}

result.data = 'Successfully updated winnings';
this.logger.log(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Consider using this.logger.info instead of this.logger.log to maintain consistency with the logging level used throughout the codebase. This ensures that logs are appropriately categorized and filtered based on their importance.

});

if (existingFormAssociation) {
this.logger.log(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Changing the logging level from debug to log may result in more verbose output in production environments. Ensure that this change aligns with the logging strategy and does not expose sensitive information or overwhelm log storage.

`Found existing association id='${existingFormAssociation.id}' status='${existingFormAssociation.tax_form_status}' date_filed='${existingFormAssociation.date_filed}'`,
);
} else {
this.logger.log('No existing tax form association found');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Similar to the previous comment, changing the logging level from debug to log could increase log verbosity. Verify that this change is intentional and appropriate for the environment where this code will run.

@vas3a vas3a merged commit 41706c7 into dev Dec 3, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants