Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] Turn off advertising sharing if do not track enabled #1

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .codeflow.yml
Original file line number Diff line number Diff line change
@@ -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
50 changes: 50 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -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]
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/documentation_request.yml
Original file line number Diff line number Diff line change
@@ -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 [...]
36 changes: 36 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -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.
29 changes: 29 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions packages/cb-cookie-banner/src/components/CookieBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import {
getDefaultTrackingPreference,
getDomainWithoutSubdomain,
isOptOut,
persistMobileAppPreferences,
Region,
useCookie,
useSavedTrackingPreference,
useSavedTrackingPreferenceFromMobileApp,
useSetTrackingPreference,
useTrackingManager,
} 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';
Expand All @@ -24,6 +27,12 @@ type Props = {
| undefined;
};

const cookieOptions = {
expires: EXPIRATION_DAYS,
domain: getDomainWithoutSubdomain(),
path: '/',
};

export const useBanner = () => {
const savedPreference = useSavedTrackingPreference();
const mobileAppPreference = useSavedTrackingPreferenceFromMobileApp();
Expand All @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/cb-cookie-banner/src/constants.ts
Original file line number Diff line number Diff line change
@@ -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';
1 change: 1 addition & 0 deletions packages/cb-cookie-manager/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading