react 0.11.0
This release published @cookieyes/react@0.11.0, @cookieyes/nextjs@0.6.3, @cookieyes/core@0.9.0, @cookieyes/cli@0.3.4, @cookieyes/scripts@0.2.4, @cookieyes/translations@0.4.1 and @cookieyes/test@0.1.1.
Install
Minor changes
Every consent record now carries what you need to prove the decision later.
In self-hosted mode, each record sent to your apiUrl or backend gains five fields:
decidedAt: when the visitor decided (ISO 8601, UTC), not when the record was sent.taxonomyHash: the category set the decision was made against, the same value the consent cookie uses.action:accept_all,reject_all,accept_selectedorsave.source: where the decision was made:banner,preferences,optout, orapifor a call from your own code.recordId: the same decision always gets the same id, so your server can drop a record it already has. Two different decisions never share one, including a visitor who changes their mind and then changes back.
Nothing changes for existing code. The new fields are optional on the ConsentPayload type, because records saved by older versions do not have them.
Recording where a decision came from. The SDK's own banner and dialogs set source for you. In your own UI, pass it once:
- React:
useConsentActions("banner"). The returned actions are unchanged, soonClick={acceptAll}keeps working. - Core:
consentStore.getState().saveConsents("all", "banner")orconsentManager.acceptAll("banner"). An action wired straight to a click handler is recorded as"api".
ConsentSource and ConsentAction are exported as types.
A record that fails to send is now noticed. An HTTP error such as a 500 used to count as sent, because only a network error made the send fail. Now an HTTP error, a network error, or a backend adapter that throws or rejects is treated as a failure, and shows a console warning in development builds. The banner behaves exactly as before.
A record that fails to send is kept and sent again. Each record is saved in localStorage (key cookieyes-consent-records) before it is sent, and removed only once your server confirms it. A kept record is sent again on the next page load, as soon as the browser is back online, and on a timer while the page stays open (about 10 seconds, then 1 minute, then every 5 minutes, each with a random spread). This also covers a visitor closing the tab while a record is still being sent.
- At most 10 records are kept, and a record older than 7 days is removed on the next page load.
- A retried record keeps its
recordId, so your server can store it once. Drop a record whoserecordIdyou already have. - If storage is full or blocked, the record is still sent once, as before, just not kept for a retry.
- Only self-hosted mode keeps records;
cookie-onlystores nothing new.
In @cookieyes/core, @cookieyes/react.
Patch changes
The READMEs now link to the documentation site, developers.cookieyes.com. Their "Docs", "Configuration" and "Which API should I use?" links pointed at Markdown files on GitHub that had moved, so they no longer opened anything; they now open the matching page on the site, for the package's own framework. No code change.
In @cookieyes/cli, @cookieyes/core, @cookieyes/nextjs, @cookieyes/react, @cookieyes/scripts, @cookieyes/test, @cookieyes/translations.
Apps now download only the parts of @cookieyes/react they use.
The package used to ship as one file, and its top-level component definitions looked to bundlers like they might have side effects, so every part was kept. A page showing only <CookieBanner /> still downloaded the preferences and opt-out dialogs. The ES module build is now one file per module, and the package already declares that its JavaScript has no side effects, so a bundler can leave out every file the app never imports.
Measured on real Next.js apps, as compressed JavaScript loaded with the page:
| App | Before | After |
|---|---|---|
<CookieBanner /> alone | 14.26 KB | 11.20 KB |
| Banner, preferences and recall button | 14.74 KB | 13.72 KB |
@cookieyes/nextjs, banner and preferences | 14.75 KB | 12.79 KB |
Nothing changes in how you import or use the package. Every file keeps the "use client" directive, and the CommonJS build is unchanged.
In @cookieyes/react.
Source
Read the full diff and commit history for react 0.11.0 on GitHub.