Add last_detected_at and last_matched_at tracking
Track when cookies are last detected (last_detected_at on cookies) and when patterns last matched a detected cookie (last_matched_at on cookie_patterns). The cookie timestamp is refreshed on every detection report; the pattern timestamp is computed as MAX(last_detected_at) during pattern analysis. Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -540,6 +540,7 @@ func (s *Service) CreateCookieBanner(
|
||||
Name: "probo_consent",
|
||||
MaxAgeSeconds: &consentMaxAge,
|
||||
Source: coredata.CookieSourceScript,
|
||||
LastDetectedAt: now,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
@@ -2280,6 +2281,7 @@ func (s *Service) ReportDetectedCookies(
|
||||
Name: dc.Name,
|
||||
MaxAgeSeconds: dc.MaxAgeSeconds,
|
||||
Source: dc.Source,
|
||||
LastDetectedAt: now,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
|
||||
@@ -170,6 +170,11 @@ func (h *patternAnalysisHandler) Process(ctx context.Context, banner coredata.Co
|
||||
return fmt.Errorf("cannot adopt uncategorised patterns: %w", err)
|
||||
}
|
||||
|
||||
var patterns coredata.CookiePatterns
|
||||
if err := patterns.RefreshLastMatchedAtByCookieBannerID(ctx, tx, scope, banner.ID); err != nil {
|
||||
return fmt.Errorf("cannot refresh last_matched_at: %w", err)
|
||||
}
|
||||
|
||||
if consentChanged {
|
||||
if _, err := h.svc.ensureDraftVersionForBanner(ctx, tx, scope, banner.ID); err != nil {
|
||||
return fmt.Errorf("cannot ensure draft version: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user