Constrain PostHog consent to one normal category per banner
Add a partial unique index ensuring only one category per banner can have posthog_consent enabled. Default it to the analytics category on banner creation, clear the previous mapping before setting a new one, and restrict the toggle to NORMAL categories in both the service layer and the console UI. Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -490,6 +490,7 @@ export function CategorySection({ categoryKey, onDelete }: CategorySectionProps)
|
||||
name={category.name}
|
||||
slug={category.slug}
|
||||
description={category.description}
|
||||
kind={category.kind}
|
||||
gcmConsentTypes={[...category.gcmConsentTypes]}
|
||||
posthogConsent={category.posthogConsent}
|
||||
isUpdating={isUpdating}
|
||||
|
||||
@@ -30,6 +30,7 @@ interface EditCategoryFormProps {
|
||||
name: string;
|
||||
slug: string;
|
||||
description: string;
|
||||
kind: string;
|
||||
gcmConsentTypes: string[];
|
||||
posthogConsent: boolean;
|
||||
isUpdating: boolean;
|
||||
@@ -41,6 +42,7 @@ export function EditCategoryForm({
|
||||
name,
|
||||
slug,
|
||||
description,
|
||||
kind,
|
||||
gcmConsentTypes,
|
||||
posthogConsent,
|
||||
isUpdating,
|
||||
@@ -105,23 +107,25 @@ export function EditCategoryForm({
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label className="text-sm font-medium">
|
||||
{__("PostHog")}
|
||||
</label>
|
||||
<p className="text-xs text-muted-foreground mb-2">
|
||||
{__("Control PostHog tracking consent based on this category.")}
|
||||
</p>
|
||||
<label className="flex items-center gap-1.5 text-xs cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={editPosthogConsent}
|
||||
onChange={() => setEditPosthogConsent(prev => !prev)}
|
||||
className="rounded"
|
||||
/>
|
||||
<span>{__("Opt in/out of PostHog tracking")}</span>
|
||||
</label>
|
||||
</div>
|
||||
{kind === "NORMAL" && (
|
||||
<div>
|
||||
<label className="text-sm font-medium">
|
||||
{__("PostHog")}
|
||||
</label>
|
||||
<p className="text-xs text-muted-foreground mb-2">
|
||||
{__("Control PostHog tracking consent based on this category.")}
|
||||
</p>
|
||||
<label className="flex items-center gap-1.5 text-xs cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={editPosthogConsent}
|
||||
onChange={() => setEditPosthogConsent(prev => !prev)}
|
||||
className="rounded"
|
||||
/>
|
||||
<span>{__("Opt in/out of PostHog tracking")}</span>
|
||||
</label>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
onClick={() => {
|
||||
|
||||
Reference in New Issue
Block a user