Add trackerType to GraphQL schema and detection UI
- 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é <emile@getprobo.com>
This commit is contained in:
@@ -178,6 +178,7 @@ export default function CookieBannerDetectionPage({
|
||||
<Thead>
|
||||
<Tr>
|
||||
<SortableTh field="NAME">{__("Name")}</SortableTh>
|
||||
<Th>{__("Type")}</Th>
|
||||
<SortableTh field="SOURCE">{__("Source")}</SortableTh>
|
||||
<SortableTh field="LAST_MATCHED_AT">{__("Last Matched")}</SortableTh>
|
||||
<SortableTh field="UPDATED_AT">{__("Updated")}</SortableTh>
|
||||
|
||||
@@ -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
|
||||
</div>
|
||||
</Td>
|
||||
<Td>
|
||||
<Badge variant={pattern.source === "SCRIPT" ? "info" : "neutral"}>
|
||||
{pattern.source === "SCRIPT" ? __("Script") : __("Pre-existing")}
|
||||
<Badge variant="neutral">
|
||||
{trackerTypeLabel(pattern.trackerType, __)}
|
||||
</Badge>
|
||||
</Td>
|
||||
<Td>
|
||||
{pattern.source
|
||||
? (
|
||||
<Badge variant={pattern.source === "SCRIPT" ? "info" : "neutral"}>
|
||||
{pattern.source === "SCRIPT" ? __("Script") : __("Pre-existing")}
|
||||
</Badge>
|
||||
)
|
||||
: <span className="text-txt-tertiary">-</span>}
|
||||
</Td>
|
||||
<Td>
|
||||
{pattern.lastMatchedAt
|
||||
? (
|
||||
|
||||
@@ -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!
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user