Promote tracker patterns to org third parties via worker
Manual moves of a non-extension TrackerPattern lacking a ThirdPartyID now request mapping, which the tracker-mapping worker resolves with a four-stage pipeline: exact common_third_party_id link, heuristic ranking, agent disambiguation, and finally CreateFromCommon. Existing fuzzy-matched org rows are tagged with common_third_party_id so the next promotion takes the O(1) exact-link path. The matching primitives live in pkg/thirdparty (RankCandidates, LinkToCommon, CreateFromCommon, ScoredCandidate, threshold constants) so the disambiguation agent and the heuristic share one candidate type. Cookiebanner orchestrates them; cookie-banner-specific concerns (pattern -> common-pattern -> common-party navigation, the EXTENSION gate, and structured logs) stay in the worker. Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -2628,6 +2628,20 @@ func (s *Service) MoveTrackerPatternToCategory(
|
||||
return fmt.Errorf("cannot update tracker pattern: %w", err)
|
||||
}
|
||||
|
||||
// A manual move is the user's signal that this is a
|
||||
// real tracker. Enqueue the tracker-mapping worker so
|
||||
// it can promote the pattern to an org ThirdParty (or
|
||||
// link an existing one) — never EXTENSION-sourced
|
||||
// patterns, and never patterns we already promoted.
|
||||
// SetMappingRequested is idempotent: it short-circuits
|
||||
// when mapping_requested_at is already non-NULL.
|
||||
if pattern.ThirdPartyID == nil &&
|
||||
(pattern.Source == nil || *pattern.Source != coredata.CookieSourceExtension) {
|
||||
if err := pattern.SetMappingRequested(ctx, tx); err != nil {
|
||||
return fmt.Errorf("cannot enqueue tracker mapping after move: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
var banner coredata.CookieBanner
|
||||
if err := banner.LoadByID(ctx, tx, scope, pattern.CookieBannerID); err != nil {
|
||||
return fmt.Errorf("cannot load cookie banner: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user