mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-26 04:07:07 +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;
|
registerCookieBanner: (handler: GitBookCookieBannerHandler) => void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the user has granted cookie consent.
|
* Indicates whether cookies tracking is disabled for the current user.
|
||||||
* Returns true if cookies are granted, false if rejected or unknown.
|
* 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 {
|
declare global {
|
||||||
|
|||||||
@@ -31,12 +31,3 @@ export function isCookiesTrackingDisabled() {
|
|||||||
|
|
||||||
return undefined;
|
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';
|
'use client';
|
||||||
|
|
||||||
import { hasApprovedCookies, setCookiesTracking } from '@/components/Insights';
|
import { isCookiesTrackingDisabled, setCookiesTracking } from '@/components/Insights';
|
||||||
import type {
|
import type {
|
||||||
GitBookGlobal,
|
GitBookGlobal,
|
||||||
GitBookIntegrationEvent,
|
GitBookIntegrationEvent,
|
||||||
@@ -102,7 +102,7 @@ if (typeof window !== 'undefined') {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
hasApprovedCookies: hasApprovedCookies,
|
isCookiesTrackingDisabled: isCookiesTrackingDisabled,
|
||||||
};
|
};
|
||||||
window.GitBook = gitbookGlobal;
|
window.GitBook = gitbookGlobal;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user