mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-25 11:52:10 +00:00
Use isCookiesTrackingDisabled for cookie consent integrations (#3997)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@gitbook/browser-types": patch
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Use isCookiesTrackingDisabled for cookie consent integrations
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user