Repository: GoogleChromeLabs/ps-analysis-tool
Pull request #118 (2023-08-21 12:26:26)

Add platform filter and minor text updates.
## Description

This PR adds an additional "platform" filter, renames the retention period, and updates the matrix text to insights.

## Relevant Technical Choices

<!-- Please describe your changes. -->

## Testing Instructions

<!--
How can the changes in this PR be verified?
Please provide step-by-step instructions to test the changes.
-->

## Additional Information:

<!-- Any other information. -->

## Screenshot/Screencast

<!-- Please provide Screenshot/Screencast, if applicable -->

---

<!--
Example:

Fixes #123
Partially addresses #22
See #834
-->

Fixes #



Patch:
diff --git a/packages/extension/src/view/devtools/components/tabContent/cookies/cookiesLanding/cookiesMatrix/index.tsx b/packages/extension/src/view/devtools/components/tabContent/cookies/cookiesLanding/cookiesMatrix/index.tsx
index dce0fa72..708ab5d4 100644
--- a/packages/extension/src/view/devtools/components/tabContent/cookies/cookiesLanding/cookiesMatrix/index.tsx
+++ b/packages/extension/src/view/devtools/components/tabContent/cookies/cookiesLanding/cookiesMatrix/index.tsx
@@ -113,7 +113,7 @@ const CookiesMatrix = ({
       <div>
         <div className="flex gap-x-5 justify-between">
           <h4 className="pb-3 flex-1 grow border-b border-bright-gray dark:border-quartz text-xs font-bold text-darkest-gray dark:text-bright-gray uppercase">
-            Cookies Matrix
+            Cookies Insights
           </h4>
           <h4 className="pb-3 flex-1 grow border-b border-bright-gray dark:border-quartz text-xs font-bold text-darkest-gray dark:text-bright-gray text-right">
             <button onClick={() => setIsExpanded((state) => !state)}>
diff --git a/packages/extension/src/view/devtools/stateProviders/filterManagementStore/constants.ts b/packages/extension/src/view/devtools/stateProviders/filterManagementStore/constants.ts
index 813904e4..9aa764c1 100644
--- a/packages/extension/src/view/devtools/stateProviders/filterManagementStore/constants.ts
+++ b/packages/extension/src/view/devtools/stateProviders/filterManagementStore/constants.ts
@@ -26,6 +26,11 @@ export const FILTER_MAPPING = [
     keys: 'parsedCookie.domain',
     sort: true,
   },
+  {
+    name: 'Platform',
+    keys: 'analytics.platform',
+    sort: true,
+  },
   {
     name: 'Path',
     keys: 'parsedCookie.path',
@@ -62,10 +67,10 @@ export const CUSTOM_FILTER_MAPPING = {
     keys: 'retentionPeriod',
     filters: new Set([
       'Session',
-      'less than a day',
-      'a day to a week',
-      'a week to a month',
-      'more than a month',
+      'Short Term (< 24h)',
+      'Medium Term (24h - 1 week)',
+      'Long Term (1 week - 1 month)',
+      'Extended Term (> 1 month)',
     ]),
   },
 };
diff --git a/packages/extension/src/view/devtools/stateProviders/filterManagementStore/utils/filterCookiesWithRetentionPeriod.ts b/packages/extension/src/view/devtools/stateProviders/filterManagementStore/utils/filterCookiesWithRetentionPeriod.ts
index 5b3b9645..805c7c06 100644
--- a/packages/extension/src/view/devtools/stateProviders/filterManagementStore/utils/filterCookiesWithRetentionPeriod.ts
+++ b/packages/extension/src/view/devtools/stateProviders/filterManagementStore/utils/filterCookiesWithRetentionPeriod.ts
@@ -59,28 +59,28 @@ const filterCookiesWithRetentionPeriod = (
               case 'Session':
                 canShow = cookieData.parsedCookie.expires === 0;
                 break;
-              case 'less than a day':
+              case 'Short Term (< 24h)':
                 if (typeof cookieData.parsedCookie.expires === 'string') {
                   const diff =
                     Date.parse(cookieData.parsedCookie.expires) - Date.now();
                   canShow = diff < 86400000;
                 }
                 break;
-              case 'a day to a week':
+              case 'Medium Term (24h - 1 week)':
                 if (typeof cookieData.parsedCookie.expires === 'string') {
                   const diff =
                     Date.parse(cookieData.parsedCookie.expires) - Date.now();
                   canShow = diff >= 86400000 && diff < 604800000;
                 }
                 break;
-              case 'a week to a month':
+              case 'Long Term (1 week - 1 month)':
                 if (typeof cookieData.parsedCookie.expires === 'string') {
                   const diff =
                     Date.parse(cookieData.parsedCookie.expires) - Date.now();
                   canShow = diff >= 604800000 && diff < 2629743833;
                 }
                 break;
-              case 'more than a month':
+              case 'Extended Term (> 1 month)':
                 if (typeof cookieData.parsedCookie.expires === 'string') {
                   const diff =
                     Date.parse(cookieData.parsedCookie.expires) - Date.now();


Test patch:
diff --git a/packages/extension/src/view/devtools/components/tabContent/cookies/cookiesLanding/cookiesMatrix/tests/cookieMatrix.tsx b/packages/extension/src/view/devtools/components/tabContent/cookies/cookiesLanding/cookiesMatrix/tests/cookieMatrix.tsx
index fe7420b9..cf5e9e4b 100644
--- a/packages/extension/src/view/devtools/components/tabContent/cookies/cookiesLanding/cookiesMatrix/tests/cookieMatrix.tsx
+++ b/packages/extension/src/view/devtools/components/tabContent/cookies/cookiesLanding/cookiesMatrix/tests/cookieMatrix.tsx
@@ -28,7 +28,7 @@ import mockResponse from '../../../../../../../../utils/test-data/cookieMockData
 import cookiesStatsComponents from '../../../../../../../../utils/test-data/cookiesStatsComponents';
 
 describe('CookiesMatrix', () => {
-  it('should render the cookies matrix', () => {
+  it('should render the cookies insights', () => {
     const tabCookies = mockResponse.tabCookies;
     const tabFrames = mockResponse.tabFrames;
 
diff --git a/packages/extension/src/view/devtools/stateProviders/filterManagementStore/utils/tests/filterCookies.ts b/packages/extension/src/view/devtools/stateProviders/filterManagementStore/utils/tests/filterCookies.ts
index fc6e39db..83f35b20 100644
--- a/packages/extension/src/view/devtools/stateProviders/filterManagementStore/utils/tests/filterCookies.ts
+++ b/packages/extension/src/view/devtools/stateProviders/filterManagementStore/utils/tests/filterCookies.ts
@@ -37,7 +37,7 @@ describe('FilterCookies:', () => {
       filterCookies(
         frameFilteredCookies,
         {
-          retentionPeriod: new Set<string>(['less than a day']),
+          retentionPeriod: new Set<string>(['Short Term (< 24h)']),
         },
         ''
       )
@@ -67,7 +67,7 @@ describe('FilterCookies:', () => {
         frameFilteredCookies,
         {
           'analytics.category': new Set<string>(['Analytics']),
-          retentionPeriod: new Set<string>(['more than a month']),
+          retentionPeriod: new Set<string>(['Extended Term (> 1 month)']),
         },
         ''
       )
diff --git a/packages/extension/src/view/devtools/stateProviders/filterManagementStore/utils/tests/filterCookiesWithRetentionPeriod.ts b/packages/extension/src/view/devtools/stateProviders/filterManagementStore/utils/tests/filterCookiesWithRetentionPeriod.ts
index 0dbc0bf2..79ee854a 100644
--- a/packages/extension/src/view/devtools/stateProviders/filterManagementStore/utils/tests/filterCookiesWithRetentionPeriod.ts
+++ b/packages/extension/src/view/devtools/stateProviders/filterManagementStore/utils/tests/filterCookiesWithRetentionPeriod.ts
@@ -36,12 +36,12 @@ describe('FilterCookiesWithoutRetentionPeriod:', () => {
     expect(filterCookiesWithRetentionPeriod({}, {}, '')).toStrictEqual({});
   });
 
-  it('Should return cookies which are going to expire in less than a day', () => {
+  it('Should return cookies which are going to expire in Short Term (< 24h)', () => {
     expect(
       filterCookiesWithRetentionPeriod(
         frameFilteredCookies,
         {
-          retentionPeriod: new Set(['less than a day']),
+          retentionPeriod: new Set(['Short Term (< 24h)']),
         },
         ''
       )
@@ -64,36 +64,36 @@ describe('FilterCookiesWithoutRetentionPeriod:', () => {
     });
   });
 
-  it('Should return nothing for a day to a week cookies', () => {
+  it('Should return nothing for Medium Term (24h - 1 week) cookies', () => {
     expect(
       filterCookiesWithRetentionPeriod(
         frameFilteredCookies,
         {
-          retentionPeriod: new Set(['a day to a week']),
+          retentionPeriod: new Set(['Medium Term (24h - 1 week)']),
         },
         ''
       )
     ).toStrictEqual({});
   });
 
-  it('Should return nothing for a week to a month cookies', () => {
+  it('Should return nothing for Long Term (1 week - 1 month) cookies', () => {
     expect(
       filterCookiesWithRetentionPeriod(
         frameFilteredCookies,
         {
-          retentionPeriod: new Set(['a week to a month']),
+          retentionPeriod: new Set(['Long Term (1 week - 1 month)']),
         },
         ''
       )
     ).toStrictEqual({});
   });
 
-  it('Should return nothing for more than a month cookies', () => {
+  it('Should return nothing for Extended Term (> 1 month) cookies', () => {
     expect(
       filterCookiesWithRetentionPeriod(
         frameFilteredCookies,
         {
-          retentionPeriod: new Set(['more than a month']),
+          retentionPeriod: new Set(['Extended Term (> 1 month)']),
         },
         ''
       )