Skip to content

Add support for custom cookie banner registration#3925

Merged
nolannbiron merged 7 commits intomainfrom
nolann/implement-custom-cookie-integration
Feb 10, 2026
Merged

Add support for custom cookie banner registration#3925
nolannbiron merged 7 commits intomainfrom
nolann/implement-custom-cookie-integration

Conversation

@nolannbiron
Copy link
Copy Markdown
Member

This PR introduces support for custom cookie banner handling. This is a v1 and is subject to change once we start using it.

@nolannbiron nolannbiron requested a review from Copilot January 21, 2026 13:53
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 21, 2026

🦋 Changeset detected

Latest commit: 8819aab

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@gitbook/browser-types Patch
gitbook Patch

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 registerCookieBanner to 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 CookiesToast component 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.

Comment thread packages/gitbook/e2e/cookie-banner.spec.ts Outdated
Comment thread packages/gitbook/src/components/Integrations/LoadIntegrations.tsx Outdated
Comment thread packages/gitbook/src/components/Integrations/LoadIntegrations.tsx
Comment thread packages/browser-types/src/index.ts
Comment thread packages/gitbook/src/components/Integrations/LoadIntegrations.tsx
Comment thread packages/gitbook/src/components/Cookies/CookiesToast.tsx
@argos-ci
Copy link
Copy Markdown

argos-ci Bot commented Jan 21, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
customers-v2 (Inspect) 👍 Changes approved 17 changed Feb 10, 2026, 10:23 AM
v2-cloudflare (Inspect) 👍 Changes approved 105 changed, 8 added Feb 10, 2026, 10:27 AM
v2-vercel (Inspect) 👍 Changes approved 109 changed, 8 added Feb 10, 2026, 10:26 AM

@nolannbiron nolannbiron marked this pull request as ready for review January 21, 2026 14:18
@nolannbiron nolannbiron requested a review from SamyPesse January 21, 2026 14:18
@nolannbiron nolannbiron force-pushed the nolann/implement-custom-cookie-integration branch from 87a5fda to 31e1584 Compare January 21, 2026 14:27
@nolannbiron nolannbiron force-pushed the nolann/implement-custom-cookie-integration branch from 31e1584 to 0a68e45 Compare January 21, 2026 14:34
@nolannbiron nolannbiron force-pushed the nolann/implement-custom-cookie-integration branch from f6956d2 to 006dec7 Compare January 21, 2026 15:23
Copy link
Copy Markdown
Member

@SamyPesse SamyPesse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/gitbook/src/components/Integrations/LoadIntegrations.tsx Outdated
Comment thread packages/gitbook/src/components/Integrations/LoadIntegrations.tsx Outdated
Comment thread packages/gitbook/src/components/Integrations/LoadIntegrations.tsx Outdated
@nolannbiron
Copy link
Copy Markdown
Member Author

@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

Comment thread packages/browser-types/src/index.ts
Comment thread packages/browser-types/src/index.ts Outdated
@nolannbiron nolannbiron force-pushed the nolann/implement-custom-cookie-integration branch from 4b832c3 to 8819aab Compare February 10, 2026 10:15
@nolannbiron nolannbiron merged commit 7a11861 into main Feb 10, 2026
17 checks passed
@nolannbiron nolannbiron deleted the nolann/implement-custom-cookie-integration branch February 10, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants