diff --git a/pkg/coredata/detected_tracker.go b/pkg/coredata/detected_tracker.go index 92f79fea1..2c3cbf016 100644 --- a/pkg/coredata/detected_tracker.go +++ b/pkg/coredata/detected_tracker.go @@ -36,6 +36,7 @@ type ( Source *CookieSource `db:"source"` ValueSize *int `db:"value_size"` InitiatorURL *string `db:"initiator_url"` + InitiatorDomain *string `db:"initiator_domain"` LastDetectedAt time.Time `db:"last_detected_at"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` @@ -61,6 +62,7 @@ INSERT INTO detected_trackers ( source, value_size, initiator_url, + initiator_domain, last_detected_at, created_at, updated_at @@ -75,6 +77,7 @@ INSERT INTO detected_trackers ( @source, @value_size, @initiator_url, + @initiator_domain, @last_detected_at, @created_at, @updated_at @@ -87,6 +90,7 @@ ON CONFLICT (cookie_banner_id, tracker_type, identifier) DO UPDATE ELSE detected_trackers.source END, initiator_url = COALESCE(EXCLUDED.initiator_url, detected_trackers.initiator_url), + initiator_domain = COALESCE(EXCLUDED.initiator_domain, detected_trackers.initiator_domain), updated_at = EXCLUDED.updated_at ` @@ -102,6 +106,7 @@ ON CONFLICT (cookie_banner_id, tracker_type, identifier) DO UPDATE "source_script": CookieSourceScript, "value_size": dt.ValueSize, "initiator_url": dt.InitiatorURL, + "initiator_domain": dt.InitiatorDomain, "last_detected_at": dt.LastDetectedAt, "created_at": dt.CreatedAt, "updated_at": dt.UpdatedAt, diff --git a/pkg/coredata/entity_type_reg.go b/pkg/coredata/entity_type_reg.go index 3ea38c146..ab8c71f53 100644 --- a/pkg/coredata/entity_type_reg.go +++ b/pkg/coredata/entity_type_reg.go @@ -116,6 +116,8 @@ const ( DetectedTrackerEntityType uint16 = 90 TrackerResourceEntityType uint16 = 91 CommonThirdPartyEntityType uint16 = 92 + CommonThirdPartyDomainEntityType uint16 = 93 + CommonTrackerPatternEntityType uint16 = 94 ) func NewEntityFromID(id gid.GID) (any, bool) { @@ -290,6 +292,10 @@ func NewEntityFromID(id gid.GID) (any, bool) { return &TrackerResource{ID: id}, true case CommonThirdPartyEntityType: return &CommonThirdParty{ID: id}, true + case CommonThirdPartyDomainEntityType: + return &CommonThirdPartyDomain{ID: id}, true + case CommonTrackerPatternEntityType: + return &CommonTrackerPattern{ID: id}, true default: return nil, false } diff --git a/pkg/coredata/third_party.go b/pkg/coredata/third_party.go index b86f6dd01..7e28e070a 100644 --- a/pkg/coredata/third_party.go +++ b/pkg/coredata/third_party.go @@ -139,6 +139,7 @@ type ( ID gid.GID `db:"id"` TenantID gid.TenantID `db:"tenant_id"` OrganizationID gid.GID `db:"organization_id"` + CommonThirdPartyID *gid.GID `db:"common_third_party_id"` Name string `db:"name"` Description *string `db:"description"` Category ThirdPartyCategory `db:"category"` @@ -204,6 +205,7 @@ SELECT id, tenant_id, organization_id, + common_third_party_id, name, description, category, @@ -270,6 +272,7 @@ SELECT id, tenant_id, organization_id, + common_third_party_id, name, description, category, @@ -330,6 +333,7 @@ INSERT INTO tenant_id, id, organization_id, + common_third_party_id, name, description, category, @@ -357,6 +361,7 @@ VALUES ( @tenant_id, @third_party_id, @organization_id, + @common_third_party_id, @name, @description, @category, @@ -386,6 +391,7 @@ VALUES ( "tenant_id": scope.GetTenantID(), "third_party_id": v.ID, "organization_id": v.OrganizationID, + "common_third_party_id": v.CommonThirdPartyID, "name": v.Name, "description": v.Description, "category": v.Category, @@ -477,6 +483,7 @@ SELECT id, tenant_id, organization_id, + common_third_party_id, name, description, category, @@ -539,6 +546,7 @@ SELECT id, tenant_id, organization_id, + common_third_party_id, name, description, category, @@ -742,6 +750,7 @@ WITH vend AS ( v.id, v.tenant_id, v.organization_id, + v.common_third_party_id, v.name, v.description, v.category, @@ -775,6 +784,7 @@ SELECT id, tenant_id, organization_id, + common_third_party_id, name, description, category, @@ -874,6 +884,7 @@ WITH vend AS ( v.id, v.tenant_id, v.organization_id, + v.common_third_party_id, v.name, v.description, v.category, @@ -907,6 +918,7 @@ SELECT id, tenant_id, organization_id, + common_third_party_id, name, description, category, @@ -967,6 +979,7 @@ WITH vend AS ( v.id, v.tenant_id, v.organization_id, + v.common_third_party_id, v.name, v.description, v.category, @@ -1000,6 +1013,7 @@ SELECT id, tenant_id, organization_id, + common_third_party_id, name, description, category, @@ -1061,6 +1075,7 @@ WITH vend AS ( v.id, v.tenant_id, v.organization_id, + v.common_third_party_id, v.name, v.description, v.category, @@ -1094,6 +1109,7 @@ SELECT id, tenant_id, organization_id, + common_third_party_id, name, description, category, @@ -1218,6 +1234,7 @@ WITH vend AS ( v.id, v.tenant_id, v.organization_id, + v.common_third_party_id, v.name, v.description, v.category, @@ -1251,6 +1268,7 @@ SELECT id, tenant_id, organization_id, + common_third_party_id, name, description, category, diff --git a/pkg/coredata/tracker_pattern.go b/pkg/coredata/tracker_pattern.go index c1662eb40..aae18a56c 100644 --- a/pkg/coredata/tracker_pattern.go +++ b/pkg/coredata/tracker_pattern.go @@ -31,21 +31,23 @@ import ( type ( TrackerPattern struct { - ID gid.GID `db:"id"` - OrganizationID gid.GID `db:"organization_id"` - CookieBannerID gid.GID `db:"cookie_banner_id"` - CookieCategoryID gid.GID `db:"cookie_category_id"` - TrackerType TrackerType `db:"tracker_type"` - Pattern string `db:"pattern"` - MatchType TrackerPatternMatchType `db:"match_type"` - DisplayName string `db:"display_name"` - Description string `db:"description"` - Excluded bool `db:"excluded"` - MaxAgeSeconds *int `db:"max_age_seconds"` - Source *CookieSource `db:"source"` - LastMatchedAt *time.Time `db:"last_matched_at"` - CreatedAt time.Time `db:"created_at"` - UpdatedAt time.Time `db:"updated_at"` + ID gid.GID `db:"id"` + OrganizationID gid.GID `db:"organization_id"` + CookieBannerID gid.GID `db:"cookie_banner_id"` + CookieCategoryID gid.GID `db:"cookie_category_id"` + CommonTrackerPatternID *gid.GID `db:"common_tracker_pattern_id"` + ThirdPartyID *gid.GID `db:"third_party_id"` + TrackerType TrackerType `db:"tracker_type"` + Pattern string `db:"pattern"` + MatchType TrackerPatternMatchType `db:"match_type"` + DisplayName string `db:"display_name"` + Description string `db:"description"` + Excluded bool `db:"excluded"` + MaxAgeSeconds *int `db:"max_age_seconds"` + Source *CookieSource `db:"source"` + LastMatchedAt *time.Time `db:"last_matched_at"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` } TrackerPatterns []*TrackerPattern @@ -101,6 +103,8 @@ SELECT organization_id, cookie_banner_id, cookie_category_id, + common_tracker_pattern_id, + third_party_id, tracker_type, pattern, match_type, @@ -158,6 +162,8 @@ SELECT organization_id, cookie_banner_id, cookie_category_id, + common_tracker_pattern_id, + third_party_id, tracker_type, pattern, match_type, @@ -222,6 +228,8 @@ SELECT organization_id, cookie_banner_id, cookie_category_id, + common_tracker_pattern_id, + third_party_id, tracker_type, pattern, match_type, @@ -296,6 +304,8 @@ INSERT INTO tracker_patterns ( organization_id, cookie_banner_id, cookie_category_id, + common_tracker_pattern_id, + third_party_id, tracker_type, pattern, match_type, @@ -313,6 +323,8 @@ INSERT INTO tracker_patterns ( @organization_id, @cookie_banner_id, @cookie_category_id, + @common_tracker_pattern_id, + @third_party_id, @tracker_type, @pattern, @match_type, @@ -328,22 +340,24 @@ INSERT INTO tracker_patterns ( ` args := pgx.StrictNamedArgs{ - "id": tp.ID, - "tenant_id": scope.GetTenantID(), - "organization_id": tp.OrganizationID, - "cookie_banner_id": tp.CookieBannerID, - "cookie_category_id": tp.CookieCategoryID, - "tracker_type": tp.TrackerType, - "pattern": tp.Pattern, - "match_type": tp.MatchType, - "display_name": tp.DisplayName, - "description": tp.Description, - "excluded": tp.Excluded, - "max_age_seconds": tp.MaxAgeSeconds, - "source": tp.Source, - "last_matched_at": tp.LastMatchedAt, - "created_at": tp.CreatedAt, - "updated_at": tp.UpdatedAt, + "id": tp.ID, + "tenant_id": scope.GetTenantID(), + "organization_id": tp.OrganizationID, + "cookie_banner_id": tp.CookieBannerID, + "cookie_category_id": tp.CookieCategoryID, + "common_tracker_pattern_id": tp.CommonTrackerPatternID, + "third_party_id": tp.ThirdPartyID, + "tracker_type": tp.TrackerType, + "pattern": tp.Pattern, + "match_type": tp.MatchType, + "display_name": tp.DisplayName, + "description": tp.Description, + "excluded": tp.Excluded, + "max_age_seconds": tp.MaxAgeSeconds, + "source": tp.Source, + "last_matched_at": tp.LastMatchedAt, + "created_at": tp.CreatedAt, + "updated_at": tp.UpdatedAt, } _, err := tx.Exec(ctx, q, args) @@ -371,6 +385,8 @@ INSERT INTO tracker_patterns ( organization_id, cookie_banner_id, cookie_category_id, + common_tracker_pattern_id, + third_party_id, tracker_type, pattern, match_type, @@ -388,6 +404,8 @@ INSERT INTO tracker_patterns ( @organization_id, @cookie_banner_id, @cookie_category_id, + @common_tracker_pattern_id, + @third_party_id, @tracker_type, @pattern, @match_type, @@ -404,22 +422,24 @@ ON CONFLICT (cookie_banner_id, tracker_type, pattern, COALESCE(max_age_seconds, ` args := pgx.StrictNamedArgs{ - "id": tp.ID, - "tenant_id": scope.GetTenantID(), - "organization_id": tp.OrganizationID, - "cookie_banner_id": tp.CookieBannerID, - "cookie_category_id": tp.CookieCategoryID, - "tracker_type": tp.TrackerType, - "pattern": tp.Pattern, - "match_type": tp.MatchType, - "display_name": tp.DisplayName, - "description": tp.Description, - "excluded": tp.Excluded, - "max_age_seconds": tp.MaxAgeSeconds, - "source": tp.Source, - "last_matched_at": tp.LastMatchedAt, - "created_at": tp.CreatedAt, - "updated_at": tp.UpdatedAt, + "id": tp.ID, + "tenant_id": scope.GetTenantID(), + "organization_id": tp.OrganizationID, + "cookie_banner_id": tp.CookieBannerID, + "cookie_category_id": tp.CookieCategoryID, + "common_tracker_pattern_id": tp.CommonTrackerPatternID, + "third_party_id": tp.ThirdPartyID, + "tracker_type": tp.TrackerType, + "pattern": tp.Pattern, + "match_type": tp.MatchType, + "display_name": tp.DisplayName, + "description": tp.Description, + "excluded": tp.Excluded, + "max_age_seconds": tp.MaxAgeSeconds, + "source": tp.Source, + "last_matched_at": tp.LastMatchedAt, + "created_at": tp.CreatedAt, + "updated_at": tp.UpdatedAt, } result, err := tx.Exec(ctx, q, args) @@ -525,6 +545,8 @@ SELECT organization_id, cookie_banner_id, cookie_category_id, + common_tracker_pattern_id, + third_party_id, tracker_type, pattern, match_type, @@ -621,6 +643,8 @@ SELECT organization_id, cookie_banner_id, cookie_category_id, + common_tracker_pattern_id, + third_party_id, tracker_type, pattern, match_type, @@ -730,6 +754,8 @@ SELECT organization_id, cookie_banner_id, cookie_category_id, + common_tracker_pattern_id, + third_party_id, tracker_type, pattern, match_type,