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>
|
<Thead>
|
||||||
<Tr>
|
<Tr>
|
||||||
<SortableTh field="NAME">{__("Name")}</SortableTh>
|
<SortableTh field="NAME">{__("Name")}</SortableTh>
|
||||||
|
<Th>{__("Type")}</Th>
|
||||||
<SortableTh field="SOURCE">{__("Source")}</SortableTh>
|
<SortableTh field="SOURCE">{__("Source")}</SortableTh>
|
||||||
<SortableTh field="LAST_MATCHED_AT">{__("Last Matched")}</SortableTh>
|
<SortableTh field="LAST_MATCHED_AT">{__("Last Matched")}</SortableTh>
|
||||||
<SortableTh field="UPDATED_AT">{__("Updated")}</SortableTh>
|
<SortableTh field="UPDATED_AT">{__("Updated")}</SortableTh>
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ import {
|
|||||||
const detectionPatternFragment = graphql`
|
const detectionPatternFragment = graphql`
|
||||||
fragment DetectionPatternRowFragment on CookiePattern {
|
fragment DetectionPatternRowFragment on CookiePattern {
|
||||||
id
|
id
|
||||||
|
trackerType
|
||||||
displayName
|
displayName
|
||||||
source
|
source
|
||||||
description
|
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 {
|
interface DetectionPatternRowProps {
|
||||||
patternKey: DetectionPatternRowFragment$key;
|
patternKey: DetectionPatternRowFragment$key;
|
||||||
connectionId: string;
|
connectionId: string;
|
||||||
@@ -288,10 +301,19 @@ export function DetectionPatternRow({ patternKey, connectionId }: DetectionPatte
|
|||||||
</div>
|
</div>
|
||||||
</Td>
|
</Td>
|
||||||
<Td>
|
<Td>
|
||||||
<Badge variant={pattern.source === "SCRIPT" ? "info" : "neutral"}>
|
<Badge variant="neutral">
|
||||||
{pattern.source === "SCRIPT" ? __("Script") : __("Pre-existing")}
|
{trackerTypeLabel(pattern.trackerType, __)}
|
||||||
</Badge>
|
</Badge>
|
||||||
</Td>
|
</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>
|
<Td>
|
||||||
{pattern.lastMatchedAt
|
{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
|
enum CookieBannerOrderField
|
||||||
@goModel(
|
@goModel(
|
||||||
model: "go.probo.inc/probo/pkg/coredata.CookieBannerOrderField"
|
model: "go.probo.inc/probo/pkg/coredata.CookieBannerOrderField"
|
||||||
@@ -227,12 +255,13 @@ input CookiePatternFilter {
|
|||||||
type CookiePattern implements Node {
|
type CookiePattern implements Node {
|
||||||
id: ID!
|
id: ID!
|
||||||
cookieCategory: CookieCategory @goField(forceResolver: true)
|
cookieCategory: CookieCategory @goField(forceResolver: true)
|
||||||
|
trackerType: TrackerType!
|
||||||
pattern: String!
|
pattern: String!
|
||||||
matchType: CookiePatternMatchType!
|
matchType: CookiePatternMatchType!
|
||||||
displayName: String!
|
displayName: String!
|
||||||
maxAgeSeconds: Int
|
maxAgeSeconds: Int
|
||||||
description: String!
|
description: String!
|
||||||
source: CookieSource!
|
source: CookieSource
|
||||||
excluded: Boolean!
|
excluded: Boolean!
|
||||||
cookieCount: Int! @goField(forceResolver: true)
|
cookieCount: Int! @goField(forceResolver: true)
|
||||||
lastMatchedAt: Datetime
|
lastMatchedAt: Datetime
|
||||||
@@ -463,6 +492,7 @@ type ReorderCookieCategoryPayload {
|
|||||||
|
|
||||||
input CreateCookiePatternInput {
|
input CreateCookiePatternInput {
|
||||||
cookieCategoryId: ID!
|
cookieCategoryId: ID!
|
||||||
|
trackerType: TrackerType
|
||||||
pattern: String!
|
pattern: String!
|
||||||
matchType: CookiePatternMatchType!
|
matchType: CookiePatternMatchType!
|
||||||
displayName: String!
|
displayName: String!
|
||||||
|
|||||||
@@ -81,15 +81,39 @@ func NewCookiePattern(cp *coredata.CookiePattern) *CookiePattern {
|
|||||||
ID: cp.CookieBannerID,
|
ID: cp.CookieBannerID,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
TrackerType: coredata.TrackerTypeCookie,
|
||||||
Pattern: cp.Pattern,
|
Pattern: cp.Pattern,
|
||||||
MatchType: cp.MatchType,
|
MatchType: cp.MatchType,
|
||||||
DisplayName: cp.DisplayName,
|
DisplayName: cp.DisplayName,
|
||||||
MaxAgeSeconds: cp.MaxAgeSeconds,
|
MaxAgeSeconds: cp.MaxAgeSeconds,
|
||||||
Description: cp.Description,
|
Description: cp.Description,
|
||||||
Source: cp.Source,
|
Source: &cp.Source,
|
||||||
Excluded: cp.Excluded,
|
Excluded: cp.Excluded,
|
||||||
LastMatchedAt: cp.LastMatchedAt,
|
LastMatchedAt: cp.LastMatchedAt,
|
||||||
CreatedAt: cp.CreatedAt,
|
CreatedAt: cp.CreatedAt,
|
||||||
UpdatedAt: cp.UpdatedAt,
|
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