From c853d59fe5e89d11e07f83120946ef28e6004e61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Tue, 5 May 2026 15:54:42 +0400 Subject: [PATCH] Add trackerType to GraphQL schema and detection UI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add TrackerType enum to GraphQL schema with all 6 values - Add trackerType field to CookiePattern type (nullable source) - Add optional trackerType to CreateCookiePatternInput - Add Type column to detection page table - Add NewTrackerPattern helper in types package - Regenerate gqlgen + Relay artifacts Signed-off-by: Émile Ré --- .../detection/CookieBannerDetectionPage.tsx | 1 + .../_components/DetectionPatternRow.tsx | 26 +++++++++++++-- .../console/v1/graphql/cookie_banner.graphql | 32 ++++++++++++++++++- .../api/console/v1/types/cookie_pattern.go | 26 ++++++++++++++- 4 files changed, 81 insertions(+), 4 deletions(-) diff --git a/apps/console/src/pages/organizations/cookie-banners/configuration/detection/CookieBannerDetectionPage.tsx b/apps/console/src/pages/organizations/cookie-banners/configuration/detection/CookieBannerDetectionPage.tsx index 64a89aeeb..7d3dfbffc 100644 --- a/apps/console/src/pages/organizations/cookie-banners/configuration/detection/CookieBannerDetectionPage.tsx +++ b/apps/console/src/pages/organizations/cookie-banners/configuration/detection/CookieBannerDetectionPage.tsx @@ -178,6 +178,7 @@ export default function CookieBannerDetectionPage({ {__("Name")} + {__("Type")} {__("Source")} {__("Last Matched")} {__("Updated")} diff --git a/apps/console/src/pages/organizations/cookie-banners/configuration/detection/_components/DetectionPatternRow.tsx b/apps/console/src/pages/organizations/cookie-banners/configuration/detection/_components/DetectionPatternRow.tsx index 81ccc331b..2a6310c05 100644 --- a/apps/console/src/pages/organizations/cookie-banners/configuration/detection/_components/DetectionPatternRow.tsx +++ b/apps/console/src/pages/organizations/cookie-banners/configuration/detection/_components/DetectionPatternRow.tsx @@ -46,6 +46,7 @@ import { const detectionPatternFragment = graphql` fragment DetectionPatternRowFragment on CookiePattern { id + trackerType displayName source description @@ -123,6 +124,18 @@ const updatePatternMutation = graphql` } `; +function trackerTypeLabel(type: string, __: (s: string) => string): string { + switch (type) { + case "COOKIE": return __("Cookie"); + case "LOCAL_STORAGE": return __("localStorage"); + case "SESSION_STORAGE": return __("sessionStorage"); + case "INDEXED_DB": return __("IndexedDB"); + case "SCRIPT": return __("Script"); + case "IFRAME": return __("Iframe"); + default: return type; + } +} + interface DetectionPatternRowProps { patternKey: DetectionPatternRowFragment$key; connectionId: string; @@ -288,10 +301,19 @@ export function DetectionPatternRow({ patternKey, connectionId }: DetectionPatte - - {pattern.source === "SCRIPT" ? __("Script") : __("Pre-existing")} + + {trackerTypeLabel(pattern.trackerType, __)} + + {pattern.source + ? ( + + {pattern.source === "SCRIPT" ? __("Script") : __("Pre-existing")} + + ) + : -} + {pattern.lastMatchedAt ? ( diff --git a/pkg/server/api/console/v1/graphql/cookie_banner.graphql b/pkg/server/api/console/v1/graphql/cookie_banner.graphql index 9f986a777..34fc9e4da 100644 --- a/pkg/server/api/console/v1/graphql/cookie_banner.graphql +++ b/pkg/server/api/console/v1/graphql/cookie_banner.graphql @@ -34,6 +34,34 @@ enum CookieSource ) } +enum TrackerType + @goModel(model: "go.probo.inc/probo/pkg/coredata.TrackerType") { + COOKIE + @goEnum( + value: "go.probo.inc/probo/pkg/coredata.TrackerTypeCookie" + ) + LOCAL_STORAGE + @goEnum( + value: "go.probo.inc/probo/pkg/coredata.TrackerTypeLocalStorage" + ) + SESSION_STORAGE + @goEnum( + value: "go.probo.inc/probo/pkg/coredata.TrackerTypeSessionStorage" + ) + INDEXED_DB + @goEnum( + value: "go.probo.inc/probo/pkg/coredata.TrackerTypeIndexedDB" + ) + SCRIPT + @goEnum( + value: "go.probo.inc/probo/pkg/coredata.TrackerTypeScript" + ) + IFRAME + @goEnum( + value: "go.probo.inc/probo/pkg/coredata.TrackerTypeIframe" + ) +} + enum CookieBannerOrderField @goModel( model: "go.probo.inc/probo/pkg/coredata.CookieBannerOrderField" @@ -227,12 +255,13 @@ input CookiePatternFilter { type CookiePattern implements Node { id: ID! cookieCategory: CookieCategory @goField(forceResolver: true) + trackerType: TrackerType! pattern: String! matchType: CookiePatternMatchType! displayName: String! maxAgeSeconds: Int description: String! - source: CookieSource! + source: CookieSource excluded: Boolean! cookieCount: Int! @goField(forceResolver: true) lastMatchedAt: Datetime @@ -463,6 +492,7 @@ type ReorderCookieCategoryPayload { input CreateCookiePatternInput { cookieCategoryId: ID! + trackerType: TrackerType pattern: String! matchType: CookiePatternMatchType! displayName: String! diff --git a/pkg/server/api/console/v1/types/cookie_pattern.go b/pkg/server/api/console/v1/types/cookie_pattern.go index 033ccae99..caace87ae 100644 --- a/pkg/server/api/console/v1/types/cookie_pattern.go +++ b/pkg/server/api/console/v1/types/cookie_pattern.go @@ -81,15 +81,39 @@ func NewCookiePattern(cp *coredata.CookiePattern) *CookiePattern { ID: cp.CookieBannerID, }, }, + TrackerType: coredata.TrackerTypeCookie, Pattern: cp.Pattern, MatchType: cp.MatchType, DisplayName: cp.DisplayName, MaxAgeSeconds: cp.MaxAgeSeconds, Description: cp.Description, - Source: cp.Source, + Source: &cp.Source, Excluded: cp.Excluded, LastMatchedAt: cp.LastMatchedAt, CreatedAt: cp.CreatedAt, UpdatedAt: cp.UpdatedAt, } } + +func NewTrackerPattern(tp *coredata.TrackerPattern) *CookiePattern { + return &CookiePattern{ + ID: tp.ID, + CookieCategory: &CookieCategory{ + ID: tp.CookieCategoryID, + CookieBanner: &CookieBanner{ + ID: tp.CookieBannerID, + }, + }, + TrackerType: tp.TrackerType, + Pattern: tp.Pattern, + MatchType: tp.MatchType, + DisplayName: tp.DisplayName, + MaxAgeSeconds: tp.MaxAgeSeconds, + Description: tp.Description, + Source: tp.Source, + Excluded: tp.Excluded, + LastMatchedAt: tp.LastMatchedAt, + CreatedAt: tp.CreatedAt, + UpdatedAt: tp.UpdatedAt, + } +}