feat(tier2): finish the finish line — Block H follow-ups, Block G geolocation, cross-cutting
Three threads of work land here together to close out Tier 2.
### Block H follow-ups — day-of check-in
- Scanner is now an "open on your phone" magic-link flow. Hosts on
desktop mint a scoped JWT via POST /events/{id}/scanner-ticket and
render its URL into a QR; phone scans it and lands on /scanner with
the ticket as bearer. The ticket carries Audience=scanner so it can
never substitute for a session token.
- Plus-one confirmation at the door: scan → POST /check-in/preview to
fetch guest + expected party size → confirm buttons ("Just them",
"Party of N", custom) → POST /check-in. No more silent arrival_count=1.
- Offline scan queue: failed POSTs go into an IndexedDB store and drain
on the 'online' event with poison-message protection.
- Day-of arrivals headline widget on the event overview, gated to the
host's local calendar date so it doesn't dominate the page weeks out.
- Tab nav restyled with inline heroicons + scrollable segmented control;
Check-in moves to the rightmost slot.
- PWA: manifest + service worker scoped to /scanner, generated 192/512
icons (Go scripted renderer in scripts/gen-scanner-icons.go).
- Confirmation email QR was rendering broken because html/template
rewrites data: URLs to #ZgotmplZ; mark the value as template.URL.
- Email "open your invitation" link 404'd because we had no token to
put after /rsvp/. Threaded AccessLink through the RSVPConfirmed NATS
event from the API at submit time.
### Block G remainder — geolocation + threshold preview
- Pluggable GeoResolver in the fraud engine (NullResolver, IPApiResolver
for the free ip-api.com fallback, MaxMindResolver behind GG_GEOIP_DB_PATH).
Wrapped in a Redis cache (30d TTL). Geo flows through both gRPC and
NATS scoring paths.
- geo_jump scoring feature: >500km in <1h flags ("accessed from Lagos
and Paris within 12 minutes"); >500km in <6h is a softer signal. The
existing single-signal cap keeps a lone geo_jump in MEDIUM.
- FraudScored event carries geo_country/city/lat/lon; ApplyScore uses
COALESCE so a later re-score without geo doesn't wipe earlier data.
- Threshold-slider live preview: GET /events/{id}/security/thresholds/preview
returns band counts the host's existing access events would have
fallen into under the proposed thresholds. Debounced (250ms) widget
under the Advanced sliders so the host gets concrete feedback instead
of guessing.
### Cross-cutting — audit, tier-gating, feature flags
- audit_log table + internal/audit.Recorder (async fire-and-forget on
detached context so an audit blip never fails the real action). Wired
into branding update, thresholds update, allowlist add/remove,
collaborator invite/role-change/remove, message create/send-now/cancel.
- Tier-gating: extended billing.Limits with MaxCollaborators,
CustomBranding, Scanner, Broadcasts. Free = none; Pro = 5 + all;
Business = unlimited. Gates the scanner-ticket, message create,
branding put, and collaborator invite endpoints with 402 +
structured upgrade payload. Auto-reminders, fraud detection, and
analytics deliberately stay on every tier — those are safety + visibility
features, not upsell levers.
- Feature flags: feature_flags table + internal/flags.Store with 30s
in-memory refresh, stable sha256(key + user_id) percent bucketing,
unknown-key-defaults-on. Six Tier 2 flags pre-seeded. Three handlers
(branding, broadcasts, scanner) check the kill switch ahead of the
tier gate so ops can pull a feature back without a redeploy.
### Verified
- go test ./... + fraud-engine pytest (12/12 incl. 3 new geo_jump tests + 5
new flags tests).
- docker compose build + up across api, fraud-engine, notifier, frontend.
- /health endpoints 200; migrations 0014 + 0015 applied; 6 flags
seeded; audit_log table + partial indexes confirmed.
- Fraud-engine logs confirm geo resolver kind=CachedGeoResolver provider=auto.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -95,6 +95,21 @@ const thresholds = ref<Thresholds>({ medium: 30, high: 60, block: 85, defaults:
|
||||
const allowlist = ref<AllowlistEntry[]>([])
|
||||
const feedback = ref<FeedbackEntry[]>([])
|
||||
|
||||
// Threshold-preview state. Live counter under the sliders — given the
|
||||
// host's *proposed* settings, how would the event's past access events
|
||||
// have been classified? Removes the "guess and wait for new scans"
|
||||
// step that used to be the only way to feel confident before saving.
|
||||
interface ThresholdPreview {
|
||||
total: number
|
||||
low: number
|
||||
medium: number
|
||||
high: number
|
||||
block: number
|
||||
}
|
||||
const preview = ref<ThresholdPreview | null>(null)
|
||||
const previewLoading = ref(false)
|
||||
let previewTimer: ReturnType<typeof setTimeout> | null = null
|
||||
|
||||
const showAdvanced = ref(false)
|
||||
const showAddNetwork = ref(false)
|
||||
const newNetworkIP = ref('')
|
||||
@@ -132,6 +147,33 @@ async function refresh() {
|
||||
}
|
||||
onMounted(refresh)
|
||||
|
||||
// Debounced preview fetch. Watching the threshold refs catches both
|
||||
// slider drags and preset clicks; 250ms is short enough to feel
|
||||
// instant while still avoiding a request per pixel of drag.
|
||||
async function fetchPreview() {
|
||||
try {
|
||||
previewLoading.value = true
|
||||
const t = thresholds.value
|
||||
const data = await useApi<ThresholdPreview>(
|
||||
`/events/${props.eventId}/security/thresholds/preview?medium=${t.medium}&high=${t.high}&block=${t.block}`,
|
||||
)
|
||||
preview.value = data
|
||||
} catch {
|
||||
// Network blip / 403 from viewer → just hide the panel until next try.
|
||||
preview.value = null
|
||||
} finally {
|
||||
previewLoading.value = false
|
||||
}
|
||||
}
|
||||
watch(
|
||||
() => [thresholds.value.medium, thresholds.value.high, thresholds.value.block],
|
||||
() => {
|
||||
if (previewTimer) clearTimeout(previewTimer)
|
||||
previewTimer = setTimeout(fetchPreview, 250)
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
// Which preset does the current threshold triple correspond to?
|
||||
// Exact match wins; otherwise "Custom". Selecting a preset writes its
|
||||
// triple over the current values and saves on the next click.
|
||||
@@ -475,6 +517,42 @@ function verdictLabel(v: string) {
|
||||
</p>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- Threshold preview. Concrete counts answer the host's
|
||||
unspoken "is this too strict?" question better than any
|
||||
amount of explainer copy. Empty state when nothing's
|
||||
been scored yet keeps the panel honest. -->
|
||||
<div class="mt-4 rounded-lg border border-zinc-800 bg-zinc-900/50 p-3 text-xs">
|
||||
<div class="mb-2 flex items-center justify-between text-zinc-400">
|
||||
<span>
|
||||
With these settings applied to your last
|
||||
<span class="font-medium text-zinc-200">{{ preview?.total ?? 0 }}</span>
|
||||
{{ (preview?.total ?? 0) === 1 ? 'access event' : 'access events' }}:
|
||||
</span>
|
||||
<span v-if="previewLoading" class="text-zinc-500">refreshing…</span>
|
||||
</div>
|
||||
<div v-if="!preview || preview.total === 0" class="text-zinc-500">
|
||||
No scored access events yet. The preview will fill in as guests start opening invitations.
|
||||
</div>
|
||||
<div v-else class="grid grid-cols-4 gap-2">
|
||||
<div class="rounded-md border border-zinc-800 bg-zinc-950 p-2 text-center">
|
||||
<div class="text-[10px] uppercase tracking-wider text-zinc-500">Quiet</div>
|
||||
<div class="mt-0.5 text-lg font-semibold tabular-nums text-zinc-200">{{ preview.low }}</div>
|
||||
</div>
|
||||
<div class="rounded-md border border-brand-700/40 bg-brand-500/[0.06] p-2 text-center">
|
||||
<div class="text-[10px] uppercase tracking-wider text-brand-400">Watched</div>
|
||||
<div class="mt-0.5 text-lg font-semibold tabular-nums text-brand-200">{{ preview.medium }}</div>
|
||||
</div>
|
||||
<div class="rounded-md border border-amber-800/40 bg-amber-500/[0.06] p-2 text-center">
|
||||
<div class="text-[10px] uppercase tracking-wider text-amber-300">Flagged</div>
|
||||
<div class="mt-0.5 text-lg font-semibold tabular-nums text-amber-200">{{ preview.high }}</div>
|
||||
</div>
|
||||
<div class="rounded-md border border-red-800/40 bg-red-500/[0.06] p-2 text-center">
|
||||
<div class="text-[10px] uppercase tracking-wider text-red-300">Refused</div>
|
||||
<div class="mt-0.5 text-lg font-semibold tabular-nums text-red-200">{{ preview.block }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user