Skip to content

Commit 0fac242

Browse files
authored
Add more information about size of the generated payload (#1653)
* Add more information regarting size of the payload * Changeset
1 parent c214072 commit 0fac242

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

.changeset/little-zoos-tan.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"products-feed": patch
3+
---
4+
5+
Now the total amount of loaded attributes and the size of generated XML is present within the logs.

apps/products-feed/src/pages/api/feed/[url]/[channel]/google.xml.ts

+9
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,13 @@ export const handler = async (req: NextApiRequest, res: NextApiResponse) => {
199199
try {
200200
productVariants = await fetchProductData({ client, channel, imageSize });
201201

202+
const totalAttributes = productVariants
203+
.map((e) => e.product.attributes.length)
204+
.reduce((a, b) => a + b, 0);
205+
202206
logger.info("Product data fetched successfully", {
203207
productVariantsLength: productVariants.length,
208+
totalAttributes,
204209
});
205210
} catch (error) {
206211
logger.error("Error during the product data fetch", { error });
@@ -219,6 +224,10 @@ export const handler = async (req: NextApiRequest, res: NextApiResponse) => {
219224
titleTemplate,
220225
});
221226

227+
logger.info("Generated XML size", {
228+
size: xmlContent.length,
229+
});
230+
222231
if (!bucketConfiguration) {
223232
logger.info("Bucket configuration not found, returning feed directly");
224233

0 commit comments

Comments
 (0)