diff --git a/apps/example/package.json b/apps/example/package.json index 5dae562..4ca30ee 100644 --- a/apps/example/package.json +++ b/apps/example/package.json @@ -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" diff --git a/packages/cookie-banner/CHANGELOG.md b/packages/cookie-banner/CHANGELOG.md index cc7f275..f318d8c 100644 --- a/packages/cookie-banner/CHANGELOG.md +++ b/packages/cookie-banner/CHANGELOG.md @@ -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 diff --git a/packages/cookie-banner/package.json b/packages/cookie-banner/package.json index 1bd129b..5f57b8f 100644 --- a/packages/cookie-banner/package.json +++ b/packages/cookie-banner/package.json @@ -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": { @@ -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" } diff --git a/packages/cookie-manager/CHANGELOG.md b/packages/cookie-manager/CHANGELOG.md index 64de425..2890d27 100644 --- a/packages/cookie-manager/CHANGELOG.md +++ b/packages/cookie-manager/CHANGELOG.md @@ -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: diff --git a/packages/cookie-manager/package.json b/packages/cookie-manager/package.json index 65cb805..27de423 100644 --- a/packages/cookie-manager/package.json +++ b/packages/cookie-manager/package.json @@ -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", diff --git a/packages/cookie-manager/src/CookieContext.tsx b/packages/cookie-manager/src/CookieContext.tsx index 2ae9f04..f65a454 100644 --- a/packages/cookie-manager/src/CookieContext.tsx +++ b/packages/cookie-manager/src/CookieContext.tsx @@ -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, @@ -39,7 +39,7 @@ export const CookieProvider = ({ children }: Props) => { const { config, region, shadowMode, log, onPreferenceChange } = useTrackingManager(); const POLL_INTERVAL = 500; - let cookieValues: Record = {}; + const [cookieValues, setCookieValues] = useState(() => getAllCookies()); let trackingPreference: TrackingPreference; let adTrackingPreference: AdTrackingPreference; @@ -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 = []; - Object.keys(cookieValues).forEach((c) => { + Object.keys(currentCookie).forEach((c) => { const trackerInfo = getTrackerInfo(c, config); if (REQUIRED_COOKIE_MANAGER_COOKIES.includes(c)) { return;