@@ -9,7 +9,7 @@ import { useRerenderOnChange } from "../tools/StatefulObservable/hooks";
99import { createConsentBannerAndConsentManagement } from "./ConsentBannerAndConsentManagement" ;
1010import { isBrowser } from "../tools/isBrowser" ;
1111
12- export const localStorageKey = "@codegouvfr/react-dsfr consent management finalityConsent" ;
12+ export const localStorageKeyPrefix = "@codegouvfr/react-dsfr finalityConsent" ;
1313
1414export function createConsentManagement <
1515 FinalityDescription extends Record <
@@ -26,6 +26,15 @@ export function createConsentManagement<
2626
2727 const { finalityDescription, personalDataPolicyLinkProps, consentCallback } = params ;
2828
29+ const finalities = getFinalitiesFromFinalityDescription ( {
30+ "finalityDescription" :
31+ typeof finalityDescription === "function"
32+ ? finalityDescription ( { "lang" : "fr" } )
33+ : finalityDescription
34+ } ) ;
35+
36+ const localStorageKey = `${ localStorageKeyPrefix } ${ finalities . join ( "-" ) } ` ;
37+
2938 const $finalityConsent = createStatefulObservable < FinalityConsent < Finality > | undefined > ( ( ) => {
3039 if ( ! isBrowser ) {
3140 return undefined ;
@@ -40,12 +49,6 @@ export function createConsentManagement<
4049 return JSON . parse ( serializedFinalityConsent ) ;
4150 } ) ;
4251
43- const finalities = getFinalitiesFromFinalityDescription ( {
44- "finalityDescription" :
45- typeof finalityDescription === "function"
46- ? finalityDescription ( { "lang" : "fr" } )
47- : finalityDescription
48- } ) ;
4952
5053 const { processConsentChanges, useConsentCallback } = createProcessConsentChanges < Finality > ( {
5154 consentCallback,
0 commit comments