Skip to content

Commit

Permalink
Add more information about size of the generated payload (#1653)
Browse files Browse the repository at this point in the history
* Add more information regarting size of the payload

* Changeset
  • Loading branch information
andrzejewsky authored Nov 27, 2024
1 parent c214072 commit 0fac242
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/little-zoos-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"products-feed": patch
---

Now the total amount of loaded attributes and the size of generated XML is present within the logs.
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,13 @@ export const handler = async (req: NextApiRequest, res: NextApiResponse) => {
try {
productVariants = await fetchProductData({ client, channel, imageSize });

const totalAttributes = productVariants
.map((e) => e.product.attributes.length)
.reduce((a, b) => a + b, 0);

logger.info("Product data fetched successfully", {
productVariantsLength: productVariants.length,
totalAttributes,
});
} catch (error) {
logger.error("Error during the product data fetch", { error });
Expand All @@ -219,6 +224,10 @@ export const handler = async (req: NextApiRequest, res: NextApiResponse) => {
titleTemplate,
});

logger.info("Generated XML size", {
size: xmlContent.length,
});

if (!bucketConfiguration) {
logger.info("Bucket configuration not found, returning feed directly");

Expand Down

0 comments on commit 0fac242

Please sign in to comment.