From d2c6320dbf05e6a423e1c5f0b2d6560b70c660e2 Mon Sep 17 00:00:00 2001 From: Amoghavarsha Kudaligi Date: Mon, 29 Jul 2024 15:55:52 +0530 Subject: [PATCH] Add size and priority to cookies with issues csv --- .../generateCookiesWithIssuesCSV.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/common/src/utils/generateReports/generateCookiesWithIssuesCSV.ts b/packages/common/src/utils/generateReports/generateCookiesWithIssuesCSV.ts index ee068400f..e5a9f56c8 100644 --- a/packages/common/src/utils/generateReports/generateCookiesWithIssuesCSV.ts +++ b/packages/common/src/utils/generateReports/generateCookiesWithIssuesCSV.ts @@ -43,6 +43,15 @@ export const COOKIES_WITH_ISSUES_DATA_HEADERS = [ const generateCookiesWithIssuesCSV = ( siteAnalysisData: CompleteJson ): string => { + //@ts-ignore -- PSAT_EXTENSTION is added only when the report is downloaded from the extension. Since optional chaining is done it will return false if it doesnt exist. + const isExtension = Boolean(globalThis?.PSAT_EXTENSION); + if (isExtension) { + COOKIES_WITH_ISSUES_DATA_HEADERS.push( + () => I18n.getMessage('priority'), + () => I18n.getMessage('size') + ); + } + const frameCookieDataMap = siteAnalysisData.cookieData; const CookieWithIssueMap: Map = new Map(); @@ -82,8 +91,16 @@ const generateCookiesWithIssuesCSV = ( cookie.parsedCookie.path, calculateEffectiveExpiryDate(cookie.parsedCookie.expires), cookie.analytics.GDPR || 'NA', - ].map(sanitizeCsvRecord); + ]; + + if (isExtension) { + recordsArray.push( + cookie.parsedCookie?.priority || ' ', + cookie.parsedCookie?.size?.toString() ?? ' ' + ); + } + recordsArray.map(sanitizeCsvRecord); cookieRecords += recordsArray.join(',') + '\r\n'; }