0.2.45 - Advanced analytics, logout old versions

This commit is contained in:
ponzischeme89
2026-08-10 20:24:22 +12:00
parent 63f0768507
commit 56c1167382
32 changed files with 1125 additions and 452 deletions
+38
View File
@@ -0,0 +1,38 @@
package api
import (
"testing"
"time"
)
func TestJourneyEventUsesAuthenticatedUser(t *testing.T) {
now := time.Date(2026, 8, 10, 12, 0, 0, 0, time.UTC)
payload := journeyEventPayload{UserID: "user-1", JourneyID: "journey-1", Sequence: 3,
Category: "navigation", Action: "open", Screen: "home", Feature: "search", Target: "search"}
event, ok := toJourneyEvent(payload, "user-1", now)
if !ok {
t.Fatal("valid event was rejected")
}
if event.UserID != "user-1" || event.Sequence != 3 {
t.Fatalf("unexpected event: %+v", event)
}
if _, ok := toJourneyEvent(payload, "user-2", now); ok {
t.Fatal("an event buffered under another profile was accepted")
}
}
func TestJourneyEventRejectsFreeTextAndUnknownVocabulary(t *testing.T) {
now := time.Now().UTC()
base := journeyEventPayload{UserID: "u1", JourneyID: "j1", Category: "content", Action: "open"}
withTitle := base
withTitle.Feature = "A Film Title"
if _, ok := toJourneyEvent(withTitle, "u1", now); ok {
t.Fatal("free text feature was accepted")
}
unknown := base
unknown.Action = "typed_query"
if _, ok := toJourneyEvent(unknown, "u1", now); ok {
t.Fatal("unknown action was accepted")
}
}