From 9f601d58971088ad1a9957a6eda99bd08a46e26d Mon Sep 17 00:00:00 2001 From: Sneh1999 Date: Wed, 6 Dec 2023 09:57:32 -0500 Subject: [PATCH 01/10] Turn off advertising sharing if do not track enabled --- .codeflow.yml | 9 ++++ .github/ISSUE_TEMPLATE/bug_report.yml | 50 +++++++++++++++++++ .../ISSUE_TEMPLATE/documentation_request.yml | 16 ++++++ .github/ISSUE_TEMPLATE/feature_request.yml | 36 +++++++++++++ .github/workflows/node.js.yml | 29 +++++++++++ .../src/components/CookieBanner.tsx | 20 ++++++++ packages/cb-cookie-banner/src/constants.ts | 3 ++ packages/cb-cookie-manager/src/index.ts | 1 + 8 files changed, 164 insertions(+) create mode 100644 .codeflow.yml create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/documentation_request.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml create mode 100644 .github/workflows/node.js.yml diff --git a/.codeflow.yml b/.codeflow.yml new file mode 100644 index 0000000..181d0d9 --- /dev/null +++ b/.codeflow.yml @@ -0,0 +1,9 @@ +secure: + codeowners_enabled: true + codeowners_allow_admin_override: true + codeowners_slack_channel_required: false + required_reviews: 1 + requires_mfa: true + branches: + - main + auto_assign_reviewers: true diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..7464368 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,50 @@ +name: Bug report +description: Create a report to help us improve +title: 'Bug: ' +labels: ['type: bug'] + +body: + - type: input + id: description + attributes: + label: Describe the bug + description: A clear and concise description of what the bug is. + placeholder: Tell us what you see! + validations: + required: true + + - type: textarea + id: steps + attributes: + label: Steps + description: Steps to reproduce the behavior. + placeholder: | + 1. Go to '...' + 2. Click on '....' + 3. Scroll down to '....' + 4. See error + validations: + required: true + + - type: textarea + id: expected + attributes: + label: Expected behavior + description: A clear and concise description of what you expected to happen. + validations: + required: true + + - type: textarea + id: additional + attributes: + label: Additional info + description: If applicable, include links to screenshots or error logs + + - type: textarea + id: environment + attributes: + label: Environment + description: Please fill in details for bugs reported in your environment + placeholder: | + - OS: [e.g. Fedora] + - Version [e.g. 37] diff --git a/.github/ISSUE_TEMPLATE/documentation_request.yml b/.github/ISSUE_TEMPLATE/documentation_request.yml new file mode 100644 index 0000000..6fd6052 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation_request.yml @@ -0,0 +1,16 @@ +name: Documentation request +description: Suggest a documentation for this project +title: 'Documentation Request: ' +labels: ['type: documentation'] + +body: + - type: markdown + attributes: + value: | + This issue form is for documentation requests only! + If you've found a bug, please use [bug_report](/new?template=bug_report.yml) + - type: textarea + id: problem + attributes: + label: Is your documentation request related to a problem? Please describe. + description: A clear and concise description of what the problem is. Ex. It's not clear when [...] diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..b9f535f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,36 @@ +name: Feature request +description: Suggest an idea for this project +title: 'Feature Request: ' +labels: ['type: enhancement'] + +body: + - type: markdown + attributes: + value: | + This issue form is for feature requests only! + If you've found a bug, please use [bug_report](/new?template=bug_report.yml) + - type: textarea + id: problem + attributes: + label: Is your feature request related to a problem? Please describe. + description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + + - type: textarea + id: solution + attributes: + label: Describe the solution you'd like + description: A clear and concise description of what you want to happen. + validations: + required: true + + - type: textarea + id: alternatives + attributes: + label: Describe alternatives you've considered + description: Describe any alternative solutions or features you've considered. + + - type: textarea + id: other + attributes: + label: Additional context + description: Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..ae8165e --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,29 @@ +# This workflow will do a clean installation of node dependencies, +# cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: Node.js CI +on: + push: + branches: ['main'] + pull_request: + branches: ['main'] +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - name: Install dependencies + run: npm install + - name: Lint Check + # When fails, please run "npm run lint" to your code + run: npm run lint diff --git a/packages/cb-cookie-banner/src/components/CookieBanner.tsx b/packages/cb-cookie-banner/src/components/CookieBanner.tsx index dfbe999..e137acc 100644 --- a/packages/cb-cookie-banner/src/components/CookieBanner.tsx +++ b/packages/cb-cookie-banner/src/components/CookieBanner.tsx @@ -1,8 +1,10 @@ import { getDefaultTrackingPreference, + getDomainWithoutSubdomain, isOptOut, persistMobileAppPreferences, Region, + useCookie, useSavedTrackingPreference, useSavedTrackingPreferenceFromMobileApp, useSetTrackingPreference, @@ -10,6 +12,7 @@ import { } from 'cb-cookie-manager'; import React, { memo, useCallback, useEffect, useState } from 'react'; +import { EXPIRATION_DAYS } from '../constants'; import defaultTheme from '../utils/defaultTheme'; import BannerContent from './CookieBannerContent'; import CookiePreferencesModal from './CookiePreferencesModal'; @@ -24,6 +27,12 @@ type Props = { | undefined; }; +const cookieOptions = { + expires: EXPIRATION_DAYS, + domain: getDomainWithoutSubdomain(), + path: '/', +}; + export const useBanner = () => { const savedPreference = useSavedTrackingPreference(); const mobileAppPreference = useSavedTrackingPreferenceFromMobileApp(); @@ -34,6 +43,7 @@ export const useBanner = () => { const optOutRegion = isOptOut(region); const defaultPreferences = getDefaultTrackingPreference(region, config); const setTrackingPreference = useSetTrackingPreference(); + const [, setAdvertisingSharingAllowedCookie] = useCookie('ADVERTISING_SHARING_ALLOWED'); const handleBannerDismiss = useCallback(() => { // Only set default tracking preferences on dismiss if we are in an opt out @@ -65,6 +75,16 @@ export const useBanner = () => { if (shouldSaveMobileAppPreferences && mobileAppPreference) { // Set the is_mobile_app cookie. persistMobileAppPreferences(); + // advertising sharing disabled, if `is_mobile_app` is set + const isEnabled = false; + const updatedAt = Date.now(); + setAdvertisingSharingAllowedCookie( + { + value: isEnabled, + updatedAt, + }, + cookieOptions + ); // Set the cookie banner preferences. setTrackingPreference(mobileAppPreference); } diff --git a/packages/cb-cookie-banner/src/constants.ts b/packages/cb-cookie-banner/src/constants.ts index b92078a..40a55cb 100644 --- a/packages/cb-cookie-banner/src/constants.ts +++ b/packages/cb-cookie-banner/src/constants.ts @@ -1 +1,4 @@ export const TRANSITION_TIME_MS = 100; +const PREFERENCE_EXPIRATION_YEAR = 1; +export const EXPIRATION_DAYS = PREFERENCE_EXPIRATION_YEAR * 365; +export const ADVERTISING_SHARING_ALLOWED = 'advertising_sharing_allowed'; diff --git a/packages/cb-cookie-manager/src/index.ts b/packages/cb-cookie-manager/src/index.ts index c58927d..5af034e 100644 --- a/packages/cb-cookie-manager/src/index.ts +++ b/packages/cb-cookie-manager/src/index.ts @@ -13,6 +13,7 @@ export { useTrackingManager } from './TrackingManagerContext'; export { Framework, Region, TrackerType, TrackingCategory, TrackingPreference } from './types'; export { default as areCookiesEnabled } from './utils/areCookiesEnabled'; export { default as getDefaultTrackingPreference } from './utils/getDefaultTrackingPreference'; +export { getDomainWithoutSubdomain } from './utils/getDomain'; export { default as isOptOut } from './utils/isOptOut'; export { getIsMobileAppFromQueryParams, From 7d11be8eb9097a21c8054062256e96a512a916b3 Mon Sep 17 00:00:00 2001 From: Sneh1999 Date: Wed, 6 Dec 2023 10:03:42 -0500 Subject: [PATCH 02/10] remove codeowners --- CODEOWNERS | 1 - 1 file changed, 1 deletion(-) delete mode 100644 CODEOWNERS diff --git a/CODEOWNERS b/CODEOWNERS deleted file mode 100644 index 4a40578..0000000 --- a/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @coinbase/cb-cookie-manager From 7807049f76e35a9592bdd303d5ac907d4e498fef Mon Sep 17 00:00:00 2001 From: Sneh1999 Date: Wed, 6 Dec 2023 11:30:28 -0500 Subject: [PATCH 03/10] update cli --- .eslintrc.js | 2 +- .github/workflows/node.js.yml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index b95784e..65a692e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -59,6 +59,6 @@ module.exports = { useTabs: false, }, ], - '@typescript-eslint/no-explicit-any': 'warn', + '@typescript-eslint/no-explicit-unknown': 'off', }, }; diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index ae8165e..a98926b 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -27,3 +27,7 @@ jobs: - name: Lint Check # When fails, please run "npm run lint" to your code run: npm run lint + - name: tests Check + # When fails, please run "npm run test" to your code + run: npm run test + From 7a1e88b7e6684df091803bc0b549fa2fe156f9f7 Mon Sep 17 00:00:00 2001 From: Sneh1999 Date: Wed, 6 Dec 2023 11:31:28 -0500 Subject: [PATCH 04/10] fix typo --- .eslintrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 65a692e..6c97f44 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -59,6 +59,6 @@ module.exports = { useTabs: false, }, ], - '@typescript-eslint/no-explicit-unknown': 'off', + '@typescript-eslint/no-explicit-any': 'off', }, }; From 631e78b4f6a0c3a256274ee2f4997c2e9c1a32de Mon Sep 17 00:00:00 2001 From: Sneh1999 Date: Wed, 6 Dec 2023 11:45:27 -0500 Subject: [PATCH 05/10] fix lint --- .github/workflows/node.js.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index a98926b..6a0207a 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -27,7 +27,6 @@ jobs: - name: Lint Check # When fails, please run "npm run lint" to your code run: npm run lint - - name: tests Check + - name: tests Check # When fails, please run "npm run test" to your code run: npm run test - From eb71cdc02bf66f414a5e7acd6973ce5c5dd3826b Mon Sep 17 00:00:00 2001 From: Sneh1999 Date: Wed, 6 Dec 2023 11:58:57 -0500 Subject: [PATCH 06/10] fix CI --- .github/workflows/node.js.yml | 8 ++++---- packages/cb-cookie-banner/package.json | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 6a0207a..d5117b3 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -23,10 +23,10 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'npm' - name: Install dependencies - run: npm install + run: yarn - name: Lint Check - # When fails, please run "npm run lint" to your code - run: npm run lint + # When fails, please run "yarn lint" to your code + run: yarn lint - name: tests Check # When fails, please run "npm run test" to your code - run: npm run test + run: yarn test diff --git a/packages/cb-cookie-banner/package.json b/packages/cb-cookie-banner/package.json index 71e35ad..2b222e5 100644 --- a/packages/cb-cookie-banner/package.json +++ b/packages/cb-cookie-banner/package.json @@ -22,10 +22,10 @@ }, "peerDependencies": { "react": "^18.2.0", - "react-dom": "^18.1.0" + "react-dom": "^18.1.0", + "cb-cookie-manager": "1.0.0" }, "dependencies": { - "cb-cookie-manager": "1.0.0", "react-intl": "^6.5.1", "styled-components": "^5.3.6" } From 7308e45cdff36c5c53f86f4b08e5563b00e14592 Mon Sep 17 00:00:00 2001 From: Sneh1999 Date: Wed, 6 Dec 2023 12:38:38 -0500 Subject: [PATCH 07/10] fix CI --- .github/workflows/node.js.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index d5117b3..5f27c1b 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -27,6 +27,12 @@ jobs: - name: Lint Check # When fails, please run "yarn lint" to your code run: yarn lint - - name: tests Check - # When fails, please run "npm run test" to your code + - name: Test cb-cookie-manager + working-directory: ./packages/cb-cookie-manager run: yarn test + - name: Test cb-cookie-banner + run: | + PACKAGE_VERSION=$(node -p "require('../packages/cb-cookie-manager').version") + cd packages/cb-cookie-banner + yarn add cb-cookie-manager@${PACKAGE_VERSION} + yarn test From 1ef1f30ff1fe035fcfacfc98045b985c081328e3 Mon Sep 17 00:00:00 2001 From: Sneh1999 Date: Wed, 6 Dec 2023 12:38:56 -0500 Subject: [PATCH 08/10] fix CI --- .github/workflows/node.js.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 5f27c1b..28e3887 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -32,7 +32,7 @@ jobs: run: yarn test - name: Test cb-cookie-banner run: | - PACKAGE_VERSION=$(node -p "require('../packages/cb-cookie-manager').version") + PACKAGE_VERSION=$(node -p "require('./packages/cb-cookie-manager').version") cd packages/cb-cookie-banner yarn add cb-cookie-manager@${PACKAGE_VERSION} yarn test From d4cca3f67cc2d4f35809b0a138afe8dd32eb8d43 Mon Sep 17 00:00:00 2001 From: Sneh1999 Date: Wed, 6 Dec 2023 12:44:32 -0500 Subject: [PATCH 09/10] fix CI --- .github/workflows/node.js.yml | 5 ++--- packages/cb-cookie-banner/package.json | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 28e3887..06b31d6 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -31,8 +31,7 @@ jobs: working-directory: ./packages/cb-cookie-manager run: yarn test - name: Test cb-cookie-banner + working-directory: ./packages/cb-cookie-banner run: | - PACKAGE_VERSION=$(node -p "require('./packages/cb-cookie-manager').version") - cd packages/cb-cookie-banner - yarn add cb-cookie-manager@${PACKAGE_VERSION} + yarn add cb-cookie-manager@1.0.0 yarn test diff --git a/packages/cb-cookie-banner/package.json b/packages/cb-cookie-banner/package.json index 2b222e5..71e35ad 100644 --- a/packages/cb-cookie-banner/package.json +++ b/packages/cb-cookie-banner/package.json @@ -22,10 +22,10 @@ }, "peerDependencies": { "react": "^18.2.0", - "react-dom": "^18.1.0", - "cb-cookie-manager": "1.0.0" + "react-dom": "^18.1.0" }, "dependencies": { + "cb-cookie-manager": "1.0.0", "react-intl": "^6.5.1", "styled-components": "^5.3.6" } From 6cda658622e3e372a327e7e57317db454d05ce73 Mon Sep 17 00:00:00 2001 From: Sneh1999 Date: Wed, 6 Dec 2023 12:46:38 -0500 Subject: [PATCH 10/10] fix CI --- .github/workflows/node.js.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 06b31d6..9cebfba 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -27,11 +27,3 @@ jobs: - name: Lint Check # When fails, please run "yarn lint" to your code run: yarn lint - - name: Test cb-cookie-manager - working-directory: ./packages/cb-cookie-manager - run: yarn test - - name: Test cb-cookie-banner - working-directory: ./packages/cb-cookie-banner - run: | - yarn add cb-cookie-manager@1.0.0 - yarn test