@google-psat/report 0.9.0-3 → 0.10.1-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/dashboard/components/cookiesWithIssues/index.js +43 -0
  2. package/dist/dashboard/components/header/index.js +26 -0
  3. package/dist/dashboard/components/siteMapReport/cookies.js +73 -0
  4. package/dist/dashboard/components/siteMapReport/index.js +31 -0
  5. package/dist/dashboard/components/siteMapReport/layout.js +140 -0
  6. package/dist/dashboard/components/siteMapReport/sidebarData.js +46 -0
  7. package/dist/dashboard/components/siteMapReport/sitemapCookiesWithIssues.js +9 -0
  8. package/dist/dashboard/components/siteReport/components/layout.js +145 -0
  9. package/dist/dashboard/components/siteReport/index.js +33 -0
  10. package/dist/dashboard/components/siteReport/stateProviders/contentStore/index.js +55 -0
  11. package/dist/dashboard/components/siteReport/tabs/cookies/cookiesLandingContainer/cookieLanding/blockedCookiesSection.js +82 -0
  12. package/dist/dashboard/components/siteReport/tabs/cookies/cookiesLandingContainer/cookieLanding/cookiesSection.js +38 -0
  13. package/dist/dashboard/components/siteReport/tabs/cookies/cookiesLandingContainer/cookieLanding/exemptedCookiesSection.js +63 -0
  14. package/dist/dashboard/components/siteReport/tabs/cookies/cookiesLandingContainer/cookieLanding/framesSection.js +38 -0
  15. package/dist/dashboard/components/siteReport/tabs/cookies/cookiesLandingContainer/cookieLanding/index.js +17 -0
  16. package/dist/dashboard/components/siteReport/tabs/cookies/cookiesLandingContainer/cookieLanding/knownBreakages.js +53 -0
  17. package/dist/dashboard/components/siteReport/tabs/cookies/cookiesLandingContainer/cookieLanding/landing.js +110 -0
  18. package/dist/dashboard/components/siteReport/tabs/cookies/cookiesLandingContainer/index.js +58 -0
  19. package/dist/dashboard/components/siteReport/tabs/cookies/cookiesListing/index.js +47 -0
  20. package/dist/dashboard/components/siteReport/tabs/cookies/index.js +56 -0
  21. package/dist/dashboard/components/siteReport/tabs/index.js +54 -0
  22. package/dist/dashboard/components/siteReport/tabs/siteCookiesWithIssues/index.js +29 -0
  23. package/dist/dashboard/components/siteReport/tabs/technologies/index.js +91 -0
  24. package/dist/dashboard/components/utils/NamePrefixIconSelector.js +67 -0
  25. package/dist/dashboard/components/utils/extractCookies.js +36 -0
  26. package/dist/dashboard/components/utils/extractReportData.js +56 -0
  27. package/dist/dashboard/components/utils/reportDownloader/generateSiteMapReportandDownload.js +44 -0
  28. package/dist/dashboard/components/utils/reportDownloader/generateSiteReportandDownload.js +52 -0
  29. package/dist/dashboard/components/utils/reportDownloader/index.js +17 -0
  30. package/dist/dashboard/components/utils/reportDownloader/utils.js +148 -0
  31. package/dist/dashboard/components/utils/reshapeCookies.js +102 -0
  32. package/dist/dashboard/components/utils/tests/data.mock.js +176 -0
  33. package/dist/dashboard/components/utils/tests/extractCookies.js +84 -0
  34. package/dist/dashboard/components/utils/tests/extractReportData.js +64 -0
  35. package/dist/dashboard/components/utils/tests/reshapeCookies.js +89 -0
  36. package/dist/dashboard/hooks/useCookieListing/index.js +412 -0
  37. package/dist/dashboard/index.js +19 -0
  38. package/dist/index.js +16 -0
  39. package/dist-types/dashboard/components/cookiesWithIssues/index.d.ts +8 -0
  40. package/dist-types/dashboard/components/header/index.d.ts +6 -0
  41. package/dist-types/dashboard/components/siteMapReport/cookies.d.ts +15 -0
  42. package/dist-types/dashboard/components/siteMapReport/index.d.ts +11 -0
  43. package/dist-types/dashboard/components/siteMapReport/layout.d.ts +18 -0
  44. package/dist-types/dashboard/components/siteMapReport/sidebarData.d.ts +3 -0
  45. package/dist-types/dashboard/components/siteMapReport/sitemapCookiesWithIssues.d.ts +10 -0
  46. package/dist-types/dashboard/components/siteReport/components/layout.d.ts +13 -0
  47. package/dist-types/dashboard/components/siteReport/index.d.ts +17 -0
  48. package/dist-types/dashboard/components/siteReport/stateProviders/contentStore/index.d.ts +32 -0
  49. package/dist-types/dashboard/components/siteReport/tabs/cookies/cookiesLandingContainer/cookieLanding/blockedCookiesSection.d.ts +8 -0
  50. package/dist-types/dashboard/components/siteReport/tabs/cookies/cookiesLandingContainer/cookieLanding/cookiesSection.d.ts +7 -0
  51. package/dist-types/dashboard/components/siteReport/tabs/cookies/cookiesLandingContainer/cookieLanding/exemptedCookiesSection.d.ts +7 -0
  52. package/dist-types/dashboard/components/siteReport/tabs/cookies/cookiesLandingContainer/cookieLanding/framesSection.d.ts +9 -0
  53. package/dist-types/dashboard/components/siteReport/tabs/cookies/cookiesLandingContainer/cookieLanding/index.d.ts +2 -0
  54. package/dist-types/dashboard/components/siteReport/tabs/cookies/cookiesLandingContainer/cookieLanding/knownBreakages.d.ts +9 -0
  55. package/dist-types/dashboard/components/siteReport/tabs/cookies/cookiesLandingContainer/cookieLanding/landing.d.ts +15 -0
  56. package/dist-types/dashboard/components/siteReport/tabs/cookies/cookiesLandingContainer/index.d.ts +23 -0
  57. package/dist-types/dashboard/components/siteReport/tabs/cookies/cookiesListing/index.d.ts +9 -0
  58. package/dist-types/dashboard/components/siteReport/tabs/cookies/index.d.ts +9 -0
  59. package/dist-types/dashboard/components/siteReport/tabs/index.d.ts +3 -0
  60. package/dist-types/dashboard/components/siteReport/tabs/siteCookiesWithIssues/index.d.ts +5 -0
  61. package/dist-types/dashboard/components/siteReport/tabs/technologies/index.d.ts +5 -0
  62. package/dist-types/dashboard/components/utils/NamePrefixIconSelector.d.ts +3 -0
  63. package/dist-types/dashboard/components/utils/extractCookies.d.ts +6 -0
  64. package/dist-types/dashboard/components/utils/extractReportData.d.ts +11 -0
  65. package/dist-types/dashboard/components/utils/reportDownloader/generateSiteMapReportandDownload.d.ts +4 -0
  66. package/dist-types/dashboard/components/utils/reportDownloader/generateSiteReportandDownload.d.ts +4 -0
  67. package/dist-types/dashboard/components/utils/reportDownloader/index.d.ts +2 -0
  68. package/dist-types/dashboard/components/utils/reportDownloader/utils.d.ts +9 -0
  69. package/dist-types/dashboard/components/utils/reshapeCookies.d.ts +8 -0
  70. package/dist-types/dashboard/components/utils/tests/data.mock.d.ts +6 -0
  71. package/dist-types/dashboard/components/utils/tests/extractCookies.d.ts +1 -0
  72. package/dist-types/dashboard/components/utils/tests/extractReportData.d.ts +1 -0
  73. package/dist-types/dashboard/components/utils/tests/reshapeCookies.d.ts +1 -0
  74. package/dist-types/dashboard/hooks/useCookieListing/index.d.ts +10 -0
  75. package/dist-types/dashboard/index.d.ts +4 -0
  76. package/dist-types/index.d.ts +1 -0
  77. package/package.json +11 -5
  78. package/public/index.html +1 -0
  79. package/tsconfig.json +19 -3
@@ -0,0 +1,82 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * External dependencies
19
+ */
20
+ import { useCallback } from 'react';
21
+ import { getLegendDescription, } from '@google-psat/common';
22
+ import { I18n } from '@google-psat/i18n';
23
+ import { prepareCookieStatsComponents, prepareCookiesCount, LEGEND_DESCRIPTION, useFiltersMapping, CookiesLandingWrapper, MatrixContainer, } from '@google-psat/design-system';
24
+ const BlockedCookiesSection = ({ tabCookies, cookiesWithIssues, tabFrames, }) => {
25
+ const { selectedItemUpdater, multiSelectItemUpdater } = useFiltersMapping(tabFrames || {});
26
+ const cookieStats = prepareCookiesCount(tabCookies);
27
+ const cookiesStatsComponents = prepareCookieStatsComponents(cookieStats);
28
+ const blockedCookieDataMapping = [
29
+ {
30
+ title: I18n.getMessage('blockedCookies'),
31
+ count: cookieStats.blockedCookies.total,
32
+ data: cookiesStatsComponents.blocked,
33
+ onClick: cookieStats.blockedCookies.total > 0
34
+ ? () => selectedItemUpdater(I18n.getMessage('selectAll'), 'blockedReasons')
35
+ : null,
36
+ },
37
+ ];
38
+ const selectTabFrame = useCallback((blockedReason) => {
39
+ const cookie = Object.values(tabCookies || {}).find((_cookie) => {
40
+ // @ts-ignore - blockedReasons is a string array
41
+ if (_cookie.blockedReasons?.includes(blockedReason)) {
42
+ return true;
43
+ }
44
+ return false;
45
+ });
46
+ return cookie?.pageUrl || '';
47
+ }, [tabCookies]);
48
+ const dataComponents = cookiesStatsComponents.blockedCookiesLegend.map((component) => {
49
+ const legendDescription = LEGEND_DESCRIPTION[component.label] || '';
50
+ return {
51
+ ...component,
52
+ description: getLegendDescription(legendDescription),
53
+ title: component.label,
54
+ containerClasses: '',
55
+ onClick: (title) => selectedItemUpdater(title, 'blockedReasons', selectTabFrame(title)),
56
+ };
57
+ });
58
+ const blockedCookiesStats = prepareCookiesCount(cookiesWithIssues);
59
+ const blockedCookiesStatsComponents = prepareCookieStatsComponents(blockedCookiesStats);
60
+ const blockedDataComponents = blockedCookiesStatsComponents.legend.map((component) => {
61
+ const legendDescription = LEGEND_DESCRIPTION[component.descriptionKey || ''];
62
+ return {
63
+ ...component,
64
+ description: getLegendDescription(legendDescription),
65
+ title: component.label,
66
+ containerClasses: '',
67
+ onClick: (title) => {
68
+ multiSelectItemUpdater({
69
+ blockedReasons: [I18n.getMessage('selectAll')],
70
+ 'analytics.category': [title],
71
+ });
72
+ },
73
+ };
74
+ });
75
+ const description = blockedCookiesStats.blockedCookies.total === 0
76
+ ? 'No cookies were blocked by the browser.'
77
+ : '';
78
+ return (_jsx(CookiesLandingWrapper, { description: description, dataMapping: blockedCookieDataMapping, testId: "blocked-cookies-insights", children: dataComponents.length > 0 && (_jsxs(_Fragment, { children: [_jsx(MatrixContainer, { title: I18n.getMessage('blockedCookies'), matrixData: dataComponents, infoIconTitle: I18n.getMessage('blockedReasonsNote') }),
79
+ //@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.
80
+ !globalThis?.PSAT_EXTENSION && (_jsx("div", { className: "flex flex-col mt-8", children: _jsx("div", { className: "pt-4", children: _jsx(MatrixContainer, { matrixData: blockedDataComponents, allowExpand: false }) }) }))] })) }));
81
+ };
82
+ export default BlockedCookiesSection;
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * External dependencies
19
+ */
20
+ import { useMemo } from 'react';
21
+ import { I18n } from '@google-psat/i18n';
22
+ import { prepareCookieStatsComponents, prepareCookiesCount, useFiltersMapping, CookiesLandingWrapper, prepareCookieDataMapping, MessageBox, CookiesMatrix, } from '@google-psat/design-system';
23
+ const CookiesSection = ({ tabCookies, tabFrames }) => {
24
+ const { selectedItemUpdater } = useFiltersMapping(tabFrames || {});
25
+ const cookieStats = prepareCookiesCount(tabCookies);
26
+ const cookiesStatsComponents = prepareCookieStatsComponents(cookieStats);
27
+ const cookieClassificationDataMapping = prepareCookieDataMapping(cookieStats, cookiesStatsComponents, selectedItemUpdater);
28
+ const cookieComponentData = useMemo(() => {
29
+ return cookiesStatsComponents.legend.map((component) => ({
30
+ ...component,
31
+ onClick: (title) => selectedItemUpdater(title, 'analytics.category'),
32
+ }));
33
+ }, [cookiesStatsComponents.legend, selectedItemUpdater]);
34
+ return (_jsxs(CookiesLandingWrapper, { dataMapping: cookieClassificationDataMapping, testId: "cookies-insights", landingHeaderExtraClasses: "border-t-0", children: [!cookieStats ||
35
+ (cookieStats?.firstParty.total === 0 &&
36
+ cookieStats?.thirdParty.total === 0 && (_jsx(MessageBox, { headerText: I18n.getMessage('noCookies'), bodyText: I18n.getMessage('tryReloading') }))), _jsx(CookiesMatrix, { tabCookies: tabCookies, componentData: cookieComponentData, tabFrames: tabFrames, showHorizontalMatrix: false })] }));
37
+ };
38
+ export default CookiesSection;
@@ -0,0 +1,63 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * External dependencies
19
+ */
20
+ import { useCallback, useMemo } from 'react';
21
+ import { getLegendDescription, } from '@google-psat/common';
22
+ import { I18n } from '@google-psat/i18n';
23
+ import { prepareCookieStatsComponents, prepareCookiesCount, useFiltersMapping, CookiesLandingWrapper, InfoIcon, MatrixContainer, LEGEND_DESCRIPTION, } from '@google-psat/design-system';
24
+ const ExemptedCookiesSection = ({ tabCookies, tabFrames, }) => {
25
+ const { selectedItemUpdater } = useFiltersMapping(tabFrames || {});
26
+ const cookieStats = useMemo(() => prepareCookiesCount(tabCookies), [tabCookies]);
27
+ const cookiesStatsComponents = prepareCookieStatsComponents(cookieStats);
28
+ const selectTabFrame = useCallback((exemptionReason) => {
29
+ const cookie = Object.values(tabCookies || {}).find((_cookie) => {
30
+ // @ts-ignore - exemptionReasons is a string array
31
+ if (_cookie.exemptionReason === exemptionReason) {
32
+ return true;
33
+ }
34
+ return false;
35
+ });
36
+ return cookie?.pageUrl || '';
37
+ }, [tabCookies]);
38
+ const dataComponents = cookiesStatsComponents.exemptedCookiesLegend.map((component) => {
39
+ const legendDescription = LEGEND_DESCRIPTION[component.label] || '';
40
+ return {
41
+ ...component,
42
+ description: getLegendDescription(legendDescription),
43
+ title: component.label,
44
+ containerClasses: '',
45
+ onClick: (title) => {
46
+ selectedItemUpdater(title, 'exemptionReason', selectTabFrame(title));
47
+ },
48
+ };
49
+ });
50
+ const exemptedCookiesDataMapping = [
51
+ {
52
+ title: I18n.getMessage('exemptedCookies'),
53
+ count: cookieStats.exemptedCookies.total,
54
+ data: cookiesStatsComponents.exempted,
55
+ onClick: cookieStats.exemptedCookies.total > 0
56
+ ? () => selectedItemUpdater(I18n.getMessage('selectAll'), 'exemptionReason')
57
+ : null,
58
+ },
59
+ ];
60
+ const description = !cookieStats.exemptedCookies.total ? (_jsxs("div", { className: "flex gap-1 justify-center items-center", children: [I18n.getMessage('noCookiesExempted'), _jsx("span", { title: I18n.getMessage('exemptedCookiesIn3PCD'), children: _jsx(InfoIcon, { className: "fill-granite-gray" }) })] })) : ('');
61
+ return (_jsx(CookiesLandingWrapper, { description: description, dataMapping: exemptedCookiesDataMapping, children: dataComponents.length > 0 && (_jsx(MatrixContainer, { title: I18n.getMessage('exemptionReasons'), matrixData: dataComponents, infoIconTitle: I18n.getMessage('exemptionReasonsNote') })) }));
62
+ };
63
+ export default ExemptedCookiesSection;
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * External dependencies
19
+ */
20
+ import { getLegendDescription } from '@google-psat/common';
21
+ import { I18n } from '@google-psat/i18n';
22
+ import { CookiesLandingWrapper, MatrixContainer, LEGEND_DESCRIPTION, prepareFrameStatsComponentForExtensionDashboard, } from '@google-psat/design-system';
23
+ const FramesSection = ({ tabCookies }) => {
24
+ const framesStats = prepareFrameStatsComponentForExtensionDashboard(
25
+ //@ts-ignore
26
+ globalThis?.PSAT_DATA.json[0] || {}, tabCookies);
27
+ const dataComponents = framesStats.legend.map((component) => {
28
+ const legendDescription = LEGEND_DESCRIPTION[component.descriptionKey] || '';
29
+ return {
30
+ ...component,
31
+ description: getLegendDescription(legendDescription),
32
+ title: component.label,
33
+ containerClasses: '',
34
+ };
35
+ });
36
+ return (_jsx(CookiesLandingWrapper, { dataMapping: framesStats.dataMapping, testId: "frames-insights", children: _jsx(MatrixContainer, { title: I18n.getMessage('frames'), matrixData: dataComponents, infoIconTitle: I18n.getMessage('framesNote') }) }));
37
+ };
38
+ export default FramesSection;
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Copyright 2023 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { default as CookiesSection } from './cookiesSection';
17
+ export { default as BlockedCookiesSection } from './blockedCookiesSection';
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /*
18
+ * External dependencies
19
+ */
20
+ import React from 'react';
21
+ import { LIBRARIES } from '@google-psat/library-detection';
22
+ import { I18n } from '@google-psat/i18n';
23
+ import { COLOR_MAP, CookiesLandingWrapper } from '@google-psat/design-system';
24
+ const KnownBreakages = ({ libraryMatches, libraryMatchesUrlCount, }) => {
25
+ const names = Object.keys(libraryMatches);
26
+ const detectedLibraryNames = names.filter((name) => libraryMatches[name]?.matches?.length ||
27
+ libraryMatches[name]?.domQuerymatches?.length);
28
+ const dataMapping = [
29
+ {
30
+ title: I18n.getMessage('knownBreakages'),
31
+ count: Number(detectedLibraryNames.length),
32
+ data: detectedLibraryNames.map((name) => ({
33
+ count: libraryMatches[name]?.matches?.length ||
34
+ libraryMatches[name]?.domQuerymatches?.length ||
35
+ 0,
36
+ color: COLOR_MAP[name].color,
37
+ })),
38
+ },
39
+ ];
40
+ const result = detectedLibraryNames.length > 0 ? (_jsx(_Fragment, { children: LIBRARIES.map((library) => {
41
+ const Component = library.component;
42
+ const matches = libraryMatches && libraryMatches[library.name]
43
+ ? libraryMatches[library.name]?.matches
44
+ : [];
45
+ const domQueryMatches = libraryMatches && libraryMatches[library.name]
46
+ ? libraryMatches[library.name]
47
+ ?.domQuerymatches
48
+ : null;
49
+ return (_jsx(Component, { matches: matches, domQueryMatches: domQueryMatches, urlCount: libraryMatchesUrlCount?.[library.name] }, library.name));
50
+ }) })) : (_jsx("p", { className: "text-center dark:text-bright-gray", children: I18n.getMessage('noLibraries') }));
51
+ return (_jsx(CookiesLandingWrapper, { dataMapping: dataMapping, testId: "library-detection", description: "", children: _jsx("div", { className: "divide-y divide-hex-gray", children: result }) }));
52
+ };
53
+ export default KnownBreakages;
@@ -0,0 +1,110 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * External dependencies.
19
+ */
20
+ import { useMemo } from 'react';
21
+ import { I18n } from '@google-psat/i18n';
22
+ import { MenuBar, } from '@google-psat/design-system';
23
+ /**
24
+ * Internal dependencies.
25
+ */
26
+ import CookiesSection from './cookiesSection';
27
+ import BlockedCookiesSection from './blockedCookiesSection';
28
+ import KnownBreakages from './knownBreakages';
29
+ import ExemptedCookiesSection from './exemptedCookiesSection';
30
+ import FramesSection from './framesSection';
31
+ const Landing = ({ tabFrames, tabCookies, cookiesWithIssues, downloadReport, libraryMatches, libraryMatchesUrlCount, menuBarScrollContainerId = 'dashboard-layout-container', }) => {
32
+ const sections = useMemo(() => {
33
+ const baseSections = [
34
+ {
35
+ name: I18n.getMessage('cookies'),
36
+ link: 'cookies',
37
+ panel: {
38
+ Element: CookiesSection,
39
+ props: {
40
+ tabCookies,
41
+ tabFrames,
42
+ },
43
+ },
44
+ },
45
+ {
46
+ name: I18n.getMessage('blockedCookies'),
47
+ link: 'blocked-cookies',
48
+ panel: {
49
+ Element: BlockedCookiesSection,
50
+ props: {
51
+ tabCookies,
52
+ cookiesWithIssues,
53
+ tabFrames,
54
+ },
55
+ },
56
+ },
57
+ {
58
+ name: I18n.getMessage('knownBreakages'),
59
+ link: 'known-breakages',
60
+ panel: {
61
+ Element: KnownBreakages,
62
+ props: {
63
+ libraryMatches: libraryMatches ?? {},
64
+ libraryMatchesUrlCount,
65
+ },
66
+ },
67
+ },
68
+ ];
69
+ // @ts-ignore -- PSAT_USING_CDP is added only when the report is downloaded from the extension. Only false value to be considered.
70
+ if (globalThis?.PSAT_USING_CDP !== false) {
71
+ baseSections.splice(2, 0, {
72
+ name: I18n.getMessage('exemptionReasons'),
73
+ link: 'exemption-reasons',
74
+ panel: {
75
+ Element: ExemptedCookiesSection,
76
+ props: {
77
+ tabFrames,
78
+ tabCookies,
79
+ },
80
+ },
81
+ });
82
+ }
83
+ //@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.
84
+ if (globalThis?.PSAT_EXTENSION) {
85
+ baseSections.push({
86
+ name: I18n.getMessage('frames'),
87
+ link: 'frames',
88
+ panel: {
89
+ Element: FramesSection,
90
+ props: {
91
+ tabCookies,
92
+ tabFrames,
93
+ },
94
+ },
95
+ });
96
+ }
97
+ return baseSections;
98
+ }, [
99
+ cookiesWithIssues,
100
+ libraryMatches,
101
+ libraryMatchesUrlCount,
102
+ tabCookies,
103
+ tabFrames,
104
+ ]);
105
+ const menuData = useMemo(() => sections.map(({ name, link }) => ({ name, link })), [sections]);
106
+ return (_jsxs(_Fragment, { children: [_jsx(MenuBar, { disableReportDownload: false, downloadReport:
107
+ // @ts-ignore -- PSAT_DATA is not present in globalThis type.
108
+ globalThis?.PSAT_DATA?.hideDownloadButton ? undefined : downloadReport, menuData: menuData, scrollContainerId: menuBarScrollContainerId, extraClasses: "top-[85px]" }), sections.map(({ link, panel: { Element, props } }) => (_jsx("div", { id: link, className: "cookie-landing-section", children: Element && _jsx(Element, { ...(props || {}) }) }, link)))] }));
109
+ };
110
+ export default Landing;
@@ -0,0 +1,58 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * External dependencies.
19
+ */
20
+ import React, { memo, useEffect, useMemo, useState } from 'react';
21
+ import { getCookieKey, noop, } from '@google-psat/common';
22
+ import { I18n } from '@google-psat/i18n';
23
+ import { Resizable } from 're-resizable';
24
+ import { ChipsBar, FiltersSidebar, useGlobalFiltering, FilterIcon, } from '@google-psat/design-system';
25
+ /**
26
+ * Internal dependencies.
27
+ */
28
+ import Landing from './cookieLanding/landing';
29
+ import Header from '../../../../header';
30
+ const AssembledCookiesLanding = ({ tabCookies, tabFrames, setAppliedFilters, downloadReport, libraryMatches, libraryMatchesUrlCount, menuBarScrollContainerId = 'dashboard-layout-container', query = '', clearQuery = noop, url, }) => {
31
+ const cookies = useMemo(() => Object.values(tabCookies || {}), [tabCookies]);
32
+ const filterOutput = useGlobalFiltering(cookies, query, clearQuery);
33
+ // @ts-ignore Using global variable.
34
+ const { dateTime } = globalThis?.PSAT_DATA || {};
35
+ const cookiesByKey = useMemo(() => {
36
+ return (filterOutput.filteredData.reduce((acc, cookie) => {
37
+ const cookieKey = getCookieKey(cookie.parsedCookie);
38
+ if (!cookieKey) {
39
+ return acc;
40
+ }
41
+ acc[cookieKey] = cookie;
42
+ return acc;
43
+ }, {}) || {});
44
+ }, [filterOutput.filteredData]);
45
+ const cookiesWithIssues = useMemo(() => Object.fromEntries(Object.entries(cookiesByKey).filter(([, cookie]) => cookie.isBlocked)), [cookiesByKey]);
46
+ useEffect(() => {
47
+ setAppliedFilters(filterOutput.selectedFilters);
48
+ }, [filterOutput.selectedFilters, setAppliedFilters]);
49
+ const [showFilterSidebar, setShowFilterSidebar] = useState(false);
50
+ return (_jsxs("div", { className: "h-full flex flex-col", children: [_jsx(Header, { url: url, dateTime: dateTime }), _jsxs("div", { className: "flex justify-center items-center flex-1 border-b border-gray-300 dark:border-quartz bg-anti-flash-white dark:bg-raisin-black", children: [_jsx("button", { className: "w-3 h-3 m-1 pl-1", onClick: () => setShowFilterSidebar(!showFilterSidebar), title: I18n.getMessage('openFilterOptions'), children: _jsx(FilterIcon, { className: showFilterSidebar
51
+ ? 'text-royal-blue dark:text-medium-persian-blue'
52
+ : 'text-mischka' }) }), _jsx(ChipsBar, { selectedFilters: filterOutput.selectedFilters, resetFilters: filterOutput.resetFilters, toggleFilterSelection: filterOutput.toggleFilterSelection })] }), _jsxs("div", { className: "flex grow-0", style: {
53
+ height: 'calc(100% - 82px)',
54
+ }, children: [showFilterSidebar && (_jsx(Resizable, { minWidth: "100px", maxWidth: "50%", enable: {
55
+ right: true,
56
+ }, className: "border border-r border-gray-300 dark:border-quartz", children: _jsx(FiltersSidebar, { filters: filterOutput.filters, toggleFilterSelection: filterOutput.toggleFilterSelection, toggleSelectAllFilter: filterOutput.toggleSelectAllFilter, isSelectAllFilterSelected: filterOutput.isSelectAllFilterSelected }) })), _jsx("div", { className: "flex-1 overflow-auto h-full", id: menuBarScrollContainerId, children: _jsx(Landing, { tabCookies: cookiesByKey, tabFrames: tabFrames, cookiesWithIssues: cookiesWithIssues, downloadReport: downloadReport, libraryMatches: libraryMatches, libraryMatchesUrlCount: libraryMatchesUrlCount, menuBarScrollContainerId: menuBarScrollContainerId }) })] })] }));
57
+ };
58
+ export default memo(AssembledCookiesLanding);
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * External dependencies
19
+ */
20
+ import { useMemo, useState } from 'react';
21
+ import { Resizable } from 're-resizable';
22
+ import {} from '@google-psat/common';
23
+ import { CookieTable, CookieDetails } from '@google-psat/design-system';
24
+ /**
25
+ * Internal dependencies
26
+ */
27
+ import useCookieListing from '../../../../../hooks/useCookieListing';
28
+ import { useContentStore } from '../../../stateProviders/contentStore';
29
+ const CookiesListing = ({ selectedFrameUrl, selectedSite, }) => {
30
+ const [selectedFrameCookie, setSelectedFrameCookie] = useState(null);
31
+ const { tabCookies, path } = useContentStore(({ state }) => ({
32
+ tabCookies: state.tabCookies,
33
+ path: state.path,
34
+ }));
35
+ const cookies = useMemo(() => Object.values(tabCookies).filter((cookie) => cookie.frameUrls.includes(selectedFrameUrl)), [tabCookies, selectedFrameUrl]);
36
+ const memoTabCookies = useMemo(() => Object.values(tabCookies), [tabCookies]);
37
+ const { tableColumns, filters, searchKeys, tablePersistentSettingsKey, isSidebarOpen, } = useCookieListing(memoTabCookies, selectedFrameUrl, 'cookiesListing', selectedSite);
38
+ //@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.
39
+ const isCLI = globalThis?.PSAT_EXTENSION ? false : true;
40
+ return (_jsxs("div", { className: "w-full h-full flex flex-col", children: [_jsx(Resizable, { defaultSize: {
41
+ width: '100%',
42
+ height: '80%',
43
+ }, minHeight: "6%", maxHeight: "95%", enable: {
44
+ bottom: true,
45
+ }, className: "h-full flex", children: _jsx(CookieTable, { data: cookies, tableColumns: tableColumns, tableFilters: filters, tableSearchKeys: searchKeys, tablePersistentSettingsKey: tablePersistentSettingsKey, selectedFrame: selectedFrameUrl, selectedFrameCookie: selectedFrameCookie, setSelectedFrameCookie: setSelectedFrameCookie, isFiltersSidebarOpen: isSidebarOpen, isCLI: isCLI, hostname: path }) }), _jsx(CookieDetails, { isUsingCDP: true, selectedFrameCookie: selectedFrameCookie })] }));
46
+ };
47
+ export default CookiesListing;
@@ -0,0 +1,56 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { useMemo, useCallback, useState } from 'react';
18
+ import { noop } from '@google-psat/common';
19
+ import {} from '@google-psat/design-system';
20
+ /**
21
+ * Internal dependencies.
22
+ */
23
+ import CookiesListing from './cookiesListing';
24
+ import { useContentStore } from '../../stateProviders/contentStore';
25
+ import { generateSiteReportandDownload } from '../../../utils/reportDownloader';
26
+ import AssembledCookiesLanding from './cookiesLandingContainer';
27
+ const CookiesTab = ({ selectedFrameUrl, selectedSite, query = '', clearQuery = noop, url = '', }) => {
28
+ const { tabCookies, completeJson, libraryMatches } = useContentStore(({ state }) => ({
29
+ tabCookies: state.tabCookies,
30
+ completeJson: state.completeJson,
31
+ libraryMatches: state.libraryMatches,
32
+ }));
33
+ const [appliedFilters, setAppliedFilters] = useState({});
34
+ const tabFrames = useMemo(() => {
35
+ const frames = Object.keys(completeJson?.[0].cookieData ?? {}).reduce((acc, _url) => {
36
+ if (_url?.includes('http')) {
37
+ acc[_url] = {};
38
+ }
39
+ return acc;
40
+ }, {});
41
+ return frames;
42
+ }, [completeJson]);
43
+ const downloadReport = useCallback(async () => {
44
+ if (!completeJson) {
45
+ return;
46
+ }
47
+ if (completeJson.length > 1) {
48
+ await generateSiteReportandDownload(completeJson, appliedFilters, selectedSite);
49
+ }
50
+ else {
51
+ await generateSiteReportandDownload(completeJson, appliedFilters);
52
+ }
53
+ }, [appliedFilters, completeJson, selectedSite]);
54
+ return (_jsx("div", { className: "w-full h-full flex items-center justify-center", children: selectedFrameUrl ? (_jsx(CookiesListing, { selectedFrameUrl: selectedFrameUrl, selectedSite: selectedSite })) : (_jsx("div", { className: "flex flex-col h-full w-full", children: _jsx(AssembledCookiesLanding, { tabCookies: tabCookies, libraryMatches: libraryMatches, tabFrames: tabFrames, downloadReport: downloadReport, setAppliedFilters: setAppliedFilters, query: query, clearQuery: clearQuery, url: url }) })) }));
55
+ };
56
+ export default CookiesTab;
@@ -0,0 +1,54 @@
1
+ /*
2
+ * Copyright 2023 Google LLC
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * External dependencies.
18
+ */
19
+ import { I18n } from '@google-psat/i18n';
20
+ import { CookieIcon, CookieIconWhite, WarningBare, SIDEBAR_ITEMS_KEYS, } from '@google-psat/design-system';
21
+ const Tabs = {
22
+ [SIDEBAR_ITEMS_KEYS.COOKIES]: {
23
+ title: () => I18n.getMessage('cookies'),
24
+ children: {},
25
+ icon: {
26
+ //@ts-ignore
27
+ Element: CookieIcon,
28
+ },
29
+ selectedIcon: {
30
+ //@ts-ignore
31
+ Element: CookieIconWhite,
32
+ },
33
+ dropdownOpen: true,
34
+ },
35
+ [SIDEBAR_ITEMS_KEYS.COOKIES_WITH_ISSUES]: {
36
+ title: () => I18n.getMessage('cookieIssues'),
37
+ children: {},
38
+ icon: {
39
+ //@ts-ignore
40
+ Element: WarningBare,
41
+ props: {
42
+ className: 'fill-granite-gray',
43
+ },
44
+ },
45
+ selectedIcon: {
46
+ //@ts-ignore
47
+ Element: WarningBare,
48
+ props: {
49
+ className: 'fill-white',
50
+ },
51
+ },
52
+ },
53
+ };
54
+ export default Tabs;
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Internal dependencies
19
+ */
20
+ import CookiesWithIssues from '../../../cookiesWithIssues';
21
+ import { useContentStore } from '../../stateProviders/contentStore';
22
+ const SiteCookiesWithIssues = ({ selectedSite, }) => {
23
+ const { tabCookies, path } = useContentStore(({ state }) => ({
24
+ tabCookies: Object.values(state.tabCookies).filter((cookie) => cookie.isBlocked || cookie.blockedReasons?.length),
25
+ path: state.path,
26
+ }));
27
+ return (_jsx(CookiesWithIssues, { cookies: tabCookies, selectedSite: selectedSite, hostName: path }));
28
+ };
29
+ export default SiteCookiesWithIssues;