diff --git a/src/consentManagement/createConsentManagement.ts b/src/consentManagement/createConsentManagement.ts index b46f8048..d58c7877 100644 --- a/src/consentManagement/createConsentManagement.ts +++ b/src/consentManagement/createConsentManagement.ts @@ -9,7 +9,7 @@ import { useRerenderOnChange } from "../tools/StatefulObservable/hooks"; import { createConsentBannerAndConsentManagement } from "./ConsentBannerAndConsentManagement"; import { isBrowser } from "../tools/isBrowser"; -export const localStorageKeyPrefix = "@codegouvfr/react-dsfr finalityConsent"; +export const defaultLocalStorageKeyPrefix = "@codegouvfr/react-dsfr finalityConsent"; export function createConsentManagement< FinalityDescription extends Record< @@ -21,10 +21,16 @@ export function createConsentManagement< consentCallback?: ConsentCallback>; /** Optional: If you have a dedicated page that provides comprehensive information about your website's GDPR policies. */ personalDataPolicyLinkProps?: RegisteredLinkProps; + localStorageKeyPrefix?: string; }) { type Finality = ExtractFinalityFromFinalityDescription; - const { finalityDescription, personalDataPolicyLinkProps, consentCallback } = params; + const { + finalityDescription, + personalDataPolicyLinkProps, + consentCallback, + localStorageKeyPrefix = defaultLocalStorageKeyPrefix + } = params; const finalities = getFinalitiesFromFinalityDescription({ "finalityDescription": diff --git a/stories/ConsentManagement.stories.tsx b/stories/ConsentManagement.stories.tsx index a122e7cd..87800d3a 100644 --- a/stories/ConsentManagement.stories.tsx +++ b/stories/ConsentManagement.stories.tsx @@ -2,7 +2,7 @@ import React from "react"; import { sectionName } from "./sectionName"; import { getStoryFactory } from "./getStory"; import { createConsentManagement } from "../dist/consentManagement"; -import { localStorageKeyPrefix } from "../dist/consentManagement/createConsentManagement"; +import { defaultLocalStorageKeyPrefix } from "../dist/consentManagement/createConsentManagement"; import { Placeholder } from "../dist/consentManagement/Placeholder"; import { Footer } from "../dist/Footer"; import { Button } from "../dist/Button"; @@ -284,7 +284,7 @@ function Story() {