Use isCookiesTrackingDisabled for cookie consent integrations (#3997)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Nolann B.
2026-02-12 20:40:18 +01:00
committed by GitHub
parent 9c762065f2
commit 5f668605c2
4 changed files with 12 additions and 14 deletions
+6
View File
@@ -0,0 +1,6 @@
---
"@gitbook/browser-types": patch
"gitbook": patch
---
Use isCookiesTrackingDisabled for cookie consent integrations
+4 -3
View File
@@ -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 {
@@ -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';
}
@@ -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;
}