From 7152b50c88af79d8e9633358f72826f8e1f56de5 Mon Sep 17 00:00:00 2001 From: Divyansh Pratap Date: Mon, 2 Sep 2024 23:36:44 +0530 Subject: [PATCH] feat: adding info log --- src/metatags/handler.js | 6 +++++- test/audits/metatags.test.js | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/metatags/handler.js b/src/metatags/handler.js index 942b217a..33a7e634 100644 --- a/src/metatags/handler.js +++ b/src/metatags/handler.js @@ -20,7 +20,11 @@ import SeoChecks from './seo-checks.js'; async function fetchAndProcessPageObject(s3Client, bucketName, key, prefix, log) { const object = await getObjectFromKey(s3Client, bucketName, key, log); if (!object?.scrapeResult?.tags || typeof object.scrapeResult.tags !== 'object') { - log.error(`No Scraped tags found in S3 ${key} object, body ${JSON.stringify(object)}`); + if (object && object.scrapeResult) { + log.error(`No Scraped tags found in S3 ${key} object, body ${JSON.stringify(object)} & type ${typeof object.scrapeResult.tags}`); + } else { + log.error(`No Scraped tags found in S3 ${key} object, body ${JSON.stringify(object)}`); + } return null; } const pageUrl = key.slice(prefix.length - 1).replace('scrape.json', ''); // Remove the prefix and .json suffix diff --git a/test/audits/metatags.test.js b/test/audits/metatags.test.js index 1fbe5595..a66e924a 100644 --- a/test/audits/metatags.test.js +++ b/test/audits/metatags.test.js @@ -534,7 +534,9 @@ describe('Meta Tags', () => { .returns({ Body: { transformToString: () => JSON.stringify({ - tags: 5, + scrapeResult: { + tags: 5, + }, }), }, });