Add support for custom cookie banner registration#3925
Conversation
🦋 Changeset detectedLatest commit: 8819aab The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
This PR introduces support for custom cookie banner handling by allowing integrations to register their own cookie banner implementations. When a custom banner is registered, the built-in GitBook cookie banner will not be displayed.
Changes:
- Added new API method
registerCookieBannerto the GitBook global object for integrations to register custom cookie banner handlers - Created Zustand stores to track integration loading status and custom cookie banner registration
- Modified
CookiesToastcomponent to conditionally hide the built-in banner when a custom banner is registered - Added e2e tests to verify built-in banner behavior with and without custom banner registration
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| packages/browser-types/src/index.ts | Added type definitions for cookie banner handler and registerCookieBanner API method |
| packages/gitbook/src/components/Integrations/LoadIntegrations.tsx | Implemented cookie banner registration logic, added stores for tracking integration load state and custom banner registration, created hooks for accessing these states |
| packages/gitbook/src/components/Cookies/CookiesToast.tsx | Modified to wait for integrations to load and hide built-in banner when custom banner is registered |
| packages/gitbook/e2e/cookie-banner.spec.ts | Added e2e tests for cookie banner behavior with and without custom banner registration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
87a5fda to
31e1584
Compare
31e1584 to
0a68e45
Compare
f6956d2 to
006dec7
Compare
SamyPesse
left a comment
There was a problem hiding this comment.
Good start!
I think we'll probably also need to think about providing an API for integrations to create footer button or something as Onetrust will need to add a link to edit permissions.
|
@SamyPesse for the footer button, I guess we could do something like this : window.GitBook.registerFooterItem({
label: 'Cookie Preferences',
onClick: () => {
OneTrust.ToggleInfoDisplay();
}
});the only issue I see is what happens if the footer is disabled, and where should we put the button? Under the copyright section ? Inside a dedicated “Policies” group ? I’m not sure what the best approach is |
4b832c3 to
8819aab
Compare
This PR introduces support for custom cookie banner handling. This is a v1 and is subject to change once we start using it.