Phase 2 part 7: the end of the funnel

Posts can be written for a buying signal: the prompt gets its hypothesis
and angle, and links carry its campaign tag. Plausible (Stats API v2) is
read once a day for visitors on tagged links, recorded per signal as
Visited. Stripe (restricted key) is read every hour: $0 checkouts are
Signed up, paid invoices and one-time payments are Paid with their value,
tied to a signal by the checkout's utm_campaign metadata or the payer's
email. The Core's Cal.com has no API, so booking emails from Cal.com in
the outreach mailbox count as Booked. New Settings → Website & sales;
the signal page lists its posts and tagged links. Schema 11.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 06:42:03 -07:00
co-authored by Claude Opus 5.5
parent 90d73cf907
commit d23d5e2a87
32 changed files with 1775 additions and 26 deletions
+31
View File
@@ -14,6 +14,7 @@ import (
"supermarket/internal/inventory"
"supermarket/internal/models"
"supermarket/internal/profile"
"supermarket/internal/signals"
"supermarket/internal/utm"
)
@@ -335,3 +336,33 @@ func TestScheduleAndDue(t *testing.T) {
t.Errorf("unscheduled: %+v", got)
}
}
func TestDraftsForSignal(t *testing.T) {
d := openDB(t)
sig := &signals.Signal{Name: "Leaving M365", Slug: "leaving-m365", Angle: "A flat price"}
if err := signals.Save(d, sig); err != nil {
t.Fatal(err)
}
if _, err := CreateDrafts(d, []Draft{{InventoryName: "Rival", Kind: "competitor", Channel: ChannelX, Content: "Hi", SignalID: sig.ID},
{InventoryName: "Rival", Kind: "competitor", Channel: ChannelLinkedIn, Content: "Plain"}}); err != nil {
t.Fatal(err)
}
list, err := ForSignal(d, sig.ID, 10)
if err != nil || len(list) != 1 || list[0].SignalSlug != "leaving-m365" {
t.Fatalf("for signal: %+v %v", list, err)
}
if p := list[0].UTM(); p.Campaign != "leaving-m365" || p.Medium != "social" {
t.Errorf("utm: %+v", p)
}
all, _ := ListDrafts(d, 10, StatusDraft)
for _, dr := range all {
if dr.SignalID == 0 && dr.UTM().Campaign != "competitor" {
t.Errorf("plain draft's campaign: %+v", dr.UTM())
}
}
prompt := userPrompt(Request{Profile: &profile.Profile{Name: "Us"}, Entry: &inventory.Entry{Name: "Rival", Relationship: "competitor"},
Channels: []string{ChannelX}, Signal: sig}, "")
if !strings.Contains(prompt, "Leaving M365") || !strings.Contains(prompt, "A flat price") {
t.Errorf("prompt lacks the signal: %s", prompt)
}
}