|
| 1 | +--- |
| 2 | +"@bigcommerce/catalyst-core": minor |
| 3 | +--- |
| 4 | + |
| 5 | +Upgrade c15t to 1.8.2, migrate from custom mode to offline mode, refactor consent cookie handling to use c15t's compact format, add script location support for HEAD/BODY rendering, and add privacy policy link support to CookieBanner. |
| 6 | + |
| 7 | +## What Changed |
| 8 | + |
| 9 | +- Upgraded `@c15t/nextjs` to version `1.8.2` |
| 10 | +- Changed consent manager mode from `custom` (with endpoint handlers) to `offline` mode |
| 11 | + - Removed custom `handlers.ts` implementation |
| 12 | +- Added `enabled` prop to `C15TConsentManagerProvider` to control consent manager functionality |
| 13 | +- Removed custom consent cookie encoder/decoder implementations (`decoder.ts`, `encoder.ts`) |
| 14 | +- Added `parse-compact-format.ts` to handle c15t's compact cookie format |
| 15 | + - Compact format: `i.t:timestamp,c.necessary:1,c.functionality:1,etc...` |
| 16 | +- Updated cookie parsing logic in both client and server to use the new compact format parser |
| 17 | +- Scripts now support `location` field from BigCommerce API and can be rendered in `<head>` or `<body>` based on the `target` property |
| 18 | +- `CookieBanner` now supports the `privacyPolicyUrl` field from BigCommerce API and will be rendered in the banner description if available. |
| 19 | + |
| 20 | +## Migration Path |
| 21 | + |
| 22 | +### Consent Manager Provider Changes |
| 23 | + |
| 24 | +The `ConsentManagerProvider` now uses `offline` mode instead of `custom` mode with endpoint handlers. The provider configuration has been simplified: |
| 25 | + |
| 26 | +**Before:** |
| 27 | +```typescript |
| 28 | +<C15TConsentManagerProvider |
| 29 | + options={{ |
| 30 | + mode: 'custom', |
| 31 | + consentCategories: ['necessary', 'functionality', 'marketing', 'measurement'], |
| 32 | + endpointHandlers: { |
| 33 | + showConsentBanner: () => showConsentBanner(isCookieConsentEnabled), |
| 34 | + setConsent, |
| 35 | + verifyConsent, |
| 36 | + }, |
| 37 | + }} |
| 38 | +> |
| 39 | + <ClientSideOptionsProvider scripts={scripts}> |
| 40 | + {children} |
| 41 | + </ClientSideOptionsProvider> |
| 42 | +</C15TConsentManagerProvider> |
| 43 | +``` |
| 44 | + |
| 45 | +**After:** |
| 46 | +```typescript |
| 47 | +<C15TConsentManagerProvider |
| 48 | + options={{ |
| 49 | + mode: 'offline', |
| 50 | + storageConfig: { |
| 51 | + storageKey: CONSENT_COOKIE_NAME, |
| 52 | + crossSubdomain: true, |
| 53 | + }, |
| 54 | + consentCategories: ['necessary', 'functionality', 'marketing', 'measurement'], |
| 55 | + enabled: isCookieConsentEnabled, |
| 56 | + }} |
| 57 | +> |
| 58 | + <ClientSideOptionsProvider scripts={scripts}> |
| 59 | + {children} |
| 60 | + </ClientSideOptionsProvider> |
| 61 | +</C15TConsentManagerProvider> |
| 62 | +``` |
| 63 | + |
| 64 | +**Key changes:** |
| 65 | +- `mode` changed from `'custom'` to `'offline'` |
| 66 | +- Removed `endpointHandlers` - no longer needed in offline mode |
| 67 | +- Added `enabled` prop to control consent manager functionality |
| 68 | +- Added `storageConfig` for cookie storage configuration |
| 69 | + |
| 70 | +### Cookie Handling |
| 71 | + |
| 72 | +If you have custom code that directly reads or writes consent cookies, you'll need to update it: |
| 73 | + |
| 74 | +**Before:** |
| 75 | +The previous implementation used custom encoding/decoding. If you were directly accessing consent cookie values, you would have needed to use the custom decoder. |
| 76 | + |
| 77 | +**After:** |
| 78 | +The consent cookie now uses c15t's compact format. The public API for reading cookies remains the same: |
| 79 | + |
| 80 | +```typescript |
| 81 | +import { getConsentCookie } from '~/lib/consent-manager/cookies/client'; // client-side |
| 82 | +// or |
| 83 | +import { getConsentCookie } from '~/lib/consent-manager/cookies/server'; // server-side |
| 84 | + |
| 85 | +const consent = getConsentCookie(); |
| 86 | +``` |
| 87 | + |
| 88 | +The `getConsentCookie()` function now internally uses `parseCompactFormat()` to parse the compact format cookie string. If you were directly parsing cookie values, you should now use the `getConsentCookie()` helper instead. |
| 89 | + |
| 90 | +`getConsentCookie` now returns a compact version of the consent values: |
| 91 | + |
| 92 | +```typescript |
| 93 | +{ |
| 94 | + i.t: 123456789, |
| 95 | + c.necessary: true, |
| 96 | + c.functionality: true, |
| 97 | + c.marketing: false, |
| 98 | + c.measurment: false |
| 99 | +} |
| 100 | +``` |
| 101 | + |
| 102 | +Updated instances where `getConsentCookie` is used to reflect this new schema. |
| 103 | + |
| 104 | +Removed `setConsentCookie` from server and client since this is now handled by the c15t library. |
| 105 | + |
| 106 | +### Script Location Support |
| 107 | + |
| 108 | +Scripts now support rendering in either `<head>` or `<body>` based on the `location` field from the BigCommerce API: |
| 109 | + |
| 110 | +```typescript |
| 111 | +// Scripts transformer now includes target based on location |
| 112 | +target: script.location === 'HEAD' ? 'head' : 'body' |
| 113 | +``` |
| 114 | + |
| 115 | +The `ScriptsFragment` GraphQL query now includes the `location` field, allowing scripts to be placed in the appropriate DOM location. `FOOTER` location is still not supported. |
| 116 | + |
| 117 | +### Privacy Policy |
| 118 | + |
| 119 | +The `RootLayoutMetadataQuery` GraphQL query now includes the `privacyPolicyUrl` field, which renders a provicy policy link in the `CookieBanner` description. |
| 120 | + |
| 121 | +```typescript |
| 122 | +<CookieBanner |
| 123 | + privacyPolicyUrl="https://example.com/privacy-policy" |
| 124 | + // ... other props |
| 125 | +/> |
| 126 | +``` |
| 127 | + |
| 128 | +The privacy policy link: |
| 129 | +- Opens in a new tab (`target="_blank"`) |
| 130 | +- Only renders if `privacyPolicyUrl` is provided as a non-empty string |
| 131 | + |
| 132 | +Add translatable `privacyPolicy` field to `Components.ConsentManager.CookieBanner` translation namespace for the privacy policy link text. |
0 commit comments