coredata: split SCRIPT/IFRAME into tracker_resources table

Move resource tracking (scripts, iframes) out of the pattern-based
tracker_patterns/detected_trackers machinery into its own
tracker_resources table keyed by (banner, type, origin, path).

- Add migration that creates the tracker_resource_type enum, the
  tracker_resources table with a unique index, drops existing
  SCRIPT/IFRAME rows (not yet in production), and recreates the
  tracker_type enum without those values.
- Add TrackerResource coredata model with full CRUD, Upsert (bumps
  last_detected_at on conflict), list/count/move operations, filter,
  and order field support.
- Register TrackerResourceEntityType (91) in the entity type registry.
- Drop TrackerTypeScript/TrackerTypeIframe from TrackerType enum.
- Update handler to use TrackerResourceType for resource detection.
- Temporarily stub out resource ingestion in ReportDetectedTrackers
  pending the service-layer wiring in the next commit.
- Drop SCRIPT/IFRAME from the GraphQL TrackerType enum.

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-05-08 18:36:07 +04:00
parent 923488b2b0
commit 93407f6431
10 changed files with 1015 additions and 40 deletions

View File

@@ -127,7 +127,7 @@ type (
DetectedResourceItem struct {
URL uri.URI
ResourceType coredata.TrackerType
ResourceType coredata.TrackerResourceType
}
ReportDetectedTrackersRequest struct {
@@ -1999,23 +1999,10 @@ func (s *Service) ReportDetectedTrackers(
}
}
for _, dr := range req.Resources {
if err := s.reportDetectedTracker(
ctx,
tx,
scope,
&banner,
uncategorised.ID,
now,
detectedTrackerInfo{
TrackerType: dr.ResourceType,
Identifier: dr.URL.String(),
},
&inserted,
); err != nil {
return err
}
}
// Resources (SCRIPT/IFRAME) are now stored in their own
// tracker_resources table; ingestion will be wired in a
// follow-up commit alongside the new service surface.
_ = req.Resources
if inserted > 0 {
if err := banner.SetPatternAnalysisRequested(ctx, tx); err != nil {