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

[fix] Initialize Cookie Values #7

Merged
merged 2 commits into from
Jan 8, 2024
Merged
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
4 changes: 2 additions & 2 deletions apps/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"test": "jest --passWithNoTests"
},
"dependencies": {
"@coinbase/cookie-banner": "1.0.2",
"@coinbase/cookie-manager": "1.1.0",
"@coinbase/cookie-banner": "1.0.3",
"@coinbase/cookie-manager": "1.1.1",
"next": "14.0.0",
"react": "^18",
"react-dom": "^18"
Expand Down
6 changes: 6 additions & 0 deletions packages/cookie-banner/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.0.2 (01/05/2024)

#### Bug

- Update the cookie manager version

## 1.0.2 (12/11/2023 PST)

#### Chore
Expand Down
4 changes: 2 additions & 2 deletions packages/cookie-banner/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coinbase/cookie-banner",
"version": "1.0.2",
"version": "1.0.3",
"main": "dist/index.js",
"license": "Apache-2.0",
"scripts": {
Expand All @@ -26,7 +26,7 @@
"react-dom": "^18.1.0"
},
"dependencies": {
"@coinbase/cookie-manager": "1.1.0",
"@coinbase/cookie-manager": "1.1.1",
"react-intl": "^6.5.1",
"styled-components": "^5.3.6"
}
Expand Down
8 changes: 8 additions & 0 deletions packages/cookie-manager/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# Changelog

## 1.1.1 (01/05/2024)

#### Bug

- Initialized the Cookie values

## 1.1.0 (12/14/2023)

#### 🚀 Updates

- Updated cookie config to include retention durations at both category and cookie levels.
- Introduced an optional boolean field `sessionCookie` in cookie config to accommodate session cookies.
- Implemented a setExpiryForCookie hook that adjusts the cookie's expiration in the following manner:
Expand Down
2 changes: 1 addition & 1 deletion packages/cookie-manager/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coinbase/cookie-manager",
"version": "1.1.0",
"version": "1.1.1",
"description": "Coinbase Cookie Manager",
"main": "dist/index.js",
"license": "Apache-2.0",
Expand Down
12 changes: 6 additions & 6 deletions packages/cookie-manager/src/CookieContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Cookies, { CookieAttributes } from 'js-cookie';
import React, { createContext, useCallback, useContext, useEffect } from 'react';
import React, { createContext, useCallback, useContext, useEffect, useState } from 'react';

import {
ADVERTISING_SHARING_ALLOWED,
Expand Down Expand Up @@ -39,7 +39,7 @@ export const CookieProvider = ({ children }: Props) => {
const { config, region, shadowMode, log, onPreferenceChange } = useTrackingManager();

const POLL_INTERVAL = 500;
let cookieValues: Record<string, any> = {};
const [cookieValues, setCookieValues] = useState(() => getAllCookies());
let trackingPreference: TrackingPreference;
let adTrackingPreference: AdTrackingPreference;

Expand All @@ -63,12 +63,12 @@ export const CookieProvider = ({ children }: Props) => {
const checkCookies = () => {
const currentCookie = getAllCookies();
if (!areRecordsEqual(cookieValues, currentCookie)) {
cookieValues = currentCookie;
trackingPreference = getTrackingPreference(cookieValues, region, config);
adTrackingPreference = getAdTrackingPreference(cookieValues);
setCookieValues(currentCookie);
trackingPreference = getTrackingPreference(currentCookie, region, config);
adTrackingPreference = getAdTrackingPreference(currentCookie);
setGTMVariables(trackingPreference, adTrackingPreference);
const cookiesToRemove: Array<string> = [];
Object.keys(cookieValues).forEach((c) => {
Object.keys(currentCookie).forEach((c) => {
const trackerInfo = getTrackerInfo(c, config);
if (REQUIRED_COOKIE_MANAGER_COOKIES.includes(c)) {
return;
Expand Down
Loading