diff --git a/.changeset/icy-walls-beg.md b/.changeset/icy-walls-beg.md new file mode 100644 index 000000000..ef2126edc --- /dev/null +++ b/.changeset/icy-walls-beg.md @@ -0,0 +1,6 @@ +--- +"@gitbook/browser-types": patch +"gitbook": patch +--- + +Use isCookiesTrackingDisabled for cookie consent integrations diff --git a/packages/browser-types/src/index.ts b/packages/browser-types/src/index.ts index 53aa0b006..0dfc14dd7 100644 --- a/packages/browser-types/src/index.ts +++ b/packages/browser-types/src/index.ts @@ -85,10 +85,11 @@ export type GitBookGlobal = { registerCookieBanner: (handler: GitBookCookieBannerHandler) => void; /** - * Whether the user has granted cookie consent. - * Returns true if cookies are granted, false if rejected or unknown. + * Indicates whether cookies tracking is disabled for the current user. + * Returns `true` when tracking is disabled, `false` when tracking is enabled, + * and `undefined` when the tracking preference is unknown or not yet determined. */ - hasApprovedCookies: () => boolean; + isCookiesTrackingDisabled: () => boolean | undefined; }; declare global { diff --git a/packages/gitbook/src/components/Insights/cookies.ts b/packages/gitbook/src/components/Insights/cookies.ts index 98f5806d3..658ed4f83 100644 --- a/packages/gitbook/src/components/Insights/cookies.ts +++ b/packages/gitbook/src/components/Insights/cookies.ts @@ -31,12 +31,3 @@ export function isCookiesTrackingDisabled() { return undefined; } - -/** - * Return true if cookies are accepted. - * Return false if cookies are rejected or unknown. - */ -export function hasApprovedCookies() { - const state = getBrowserCookie(GRANTED_COOKIE); - return state === 'yes'; -} diff --git a/packages/gitbook/src/components/Integrations/LoadIntegrations.tsx b/packages/gitbook/src/components/Integrations/LoadIntegrations.tsx index 090ed89bf..dd17ed2a2 100644 --- a/packages/gitbook/src/components/Integrations/LoadIntegrations.tsx +++ b/packages/gitbook/src/components/Integrations/LoadIntegrations.tsx @@ -1,6 +1,6 @@ 'use client'; -import { hasApprovedCookies, setCookiesTracking } from '@/components/Insights'; +import { isCookiesTrackingDisabled, setCookiesTracking } from '@/components/Insights'; import type { GitBookGlobal, GitBookIntegrationEvent, @@ -102,7 +102,7 @@ if (typeof window !== 'undefined') { }, }); }, - hasApprovedCookies: hasApprovedCookies, + isCookiesTrackingDisabled: isCookiesTrackingDisabled, }; window.GitBook = gitbookGlobal; }