set_intervention
TRIGGER: Call WITHOUT asking whenever the user applies or ships a fix. 'Fix' covers any shipped change — SEO/copy/ads/UX/ops, AND code/schema/connector changes. Distinct from save_insights (which captures observations) — this is for tracking actions: 'I changed X, hypothesised Y, will measure at dates [a,b,c]'. Auto-captures the most recent matching snapshots as baseline (for each {store, metric} in trackedMetrics), so you don't have to manually record baselines first. Use complete_intervention later to capture the post-fix snapshots and compute deltas. INPUT-MINIMAL EXAMPLE: set_intervention({store: 'acme-store-us', type: 'technical_seo', description: 'Applied hreflang fix to product pages', trackedMetrics: ['organic_clicks', 'organic_ctr'], checkDates: ['2026-06-07','2026-07-07','2026-08-07']}). For code/connector fixes use type: 'connector_fix' or similar. Pass linkedInsightIds when this intervention closes the loop on existing insights. After saving, tell the user in one line what you logged.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | Yes | Category of intervention. | |
| notes | No | Free-text context (excluded scope, caveats, etc.). | |
| store | No | The store/region this fix applies to. Either short ('acme-store-us') or full ('acme-store-us.myshopify.com') — both normalize. | |
| watch | No | Optional threshold watch evaluated on every get_briefing, so a breach SURFACES rather than being recomputed by hand each time. Shape: {metric:'orders'|'revenue', windowDays: 1-90, op:'lt'|'lte'|'gt'|'gte', threshold: number, note?: string}, e.g. {metric:'orders', windowDays:3, op:'lt', threshold:55}. Windows cover COMPLETE days only; an unsupported metric is rejected here rather than silently never firing. | |
| _offset | No | Pagination offset. If a response includes _pagination.hasMore=true, use _offset to fetch the next page. | |
| appliedAt | No | ISO date (YYYY-MM-DD) the fix was ACTUALLY applied, for logging it retroactively (default: now). The baseline auto-lookup only considers snapshots within 60 days BEFORE this date — pass the real date so a retroactive log can still find an older-but-correct baseline instead of one anchored to today. Also anchors the auto-assigned checkDates horizon when checkDates isn't given. Must not be in the future. | |
| checkDates | No | ISO dates (YYYY-MM-DD) for planned check-ins, e.g. ['2026-06-07','2026-07-07','2026-08-07']. Stored for the dashboard / reminders; not enforced by the system. | |
| hypothesis | No | Why you think it'll work (e.g. 'US property losing clicks to UK; hreflang should restore correct routing'). | |
| description | Yes | What was actually changed (e.g. 'Added hreflang tags to all PDPs to fix country-mismatch issue'). | |
| trackedMetrics | No | Metrics to track for before/after comparison. Each entry is either a canonical metric key string (e.g. 'organic_clicks') OR an object {metric, segment?, source?} for dimensional pinning. Use the object form when a (metric, store) pair has snapshots across multiple segments or sources — otherwise the auto-baseline lookup is ambiguous and the call rejects with a list of candidates. Examples: ['cvr','aov'] (works when each metric has only one snapshot per store), [{metric:'organic_clicks',segment:'non_branded',source:'search-console'},{metric:'cvr',source:'ga4'}] (explicit dimensions per metric). | |
| expectedMetrics | No | Optional. Per-metric expectation, e.g. {organic_clicks: {deltaPercent: 15, direction: 'up'}}. Used at completion time to flag whether outcomes met expectations. | |
| linkedInsightIds | No | Insights this intervention is acting on (the original finding(s) that prompted it). Captured for traceability — they're not modified. |