@apex-inc/mcp-server 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,77 @@
1
+ ---
2
+ name: apex-spec
3
+ description: The Apex Spec — one event vocabulary for a whole business — and the scan-first wiring method. Use whenever you are instrumenting a merchant's codebase with Apex tracking: audit the code for Spec opportunities FIRST, propose the plan, wire each event where the truth lives, then verify your own work.
4
+ ---
5
+
6
+ # Apex Spec — scan-first instrumentation
7
+
8
+ The Apex Spec is ONE vocabulary for the merchant's whole business.
9
+ `order_placed` is `order_placed` whether it fires from the website,
10
+ the mobile app, or the backend — a data source is WHERE an event
11
+ fires, never a separate plan. Your job when wiring a codebase is to
12
+ find where each business truth already lives and instrument it there.
13
+
14
+ ## The method (always in this order)
15
+
16
+ 1. **Scan before asking.** Never ask the merchant to enumerate their
17
+ events. Audit the codebase for Spec opportunities:
18
+ - auth / signup flows → `apex.identify(email, first_name, last_name)` + `user_signed_up`
19
+ - login flows → `identify` (cross-device stitching)
20
+ - checkout / payment success paths → `purchase` / `checkout_started` / `order_placed` (server)
21
+ - in-app purchase / StoreKit / Play Billing → `in_app_purchase`
22
+ - subscription create / renew / cancel webhooks → `subscription_event`
23
+ - lead/contact forms → `form_submit`
24
+ - cart mutations → `add_to_cart`, `remove_from_cart`
25
+ - search, share, content views → `search`, `share`, `content_view`
26
+ Fetch the authoritative schema with the `get_event_spec` tool (or
27
+ `GET /api/spec/events`) before inventing names.
28
+
29
+ Report your scan in THREE sections — this exact shape, every time:
30
+ - **Already wired** — events the repo already instruments. Brownfield
31
+ repos often have many. Check the SDK is actually configured with a
32
+ workspace key: wired events with no key never reach Apex, and
33
+ fixing the config may be the highest-value change in the plan.
34
+ - **Gaps to wire** — the work you propose, each with the file you'll
35
+ touch.
36
+ - **Won't wire + why** — opportunities you're deliberately skipping
37
+ (a server event with no backend; a form that already fires a
38
+ richer dedicated event and would double-count).
39
+
40
+ 2. **Propose the plan.** Call the `propose_wiring_plan` tool with the
41
+ already-wired events (mark them `wired: true`) AND the gaps (event
42
+ name, surface, where you found it). This populates pending lights on
43
+ the merchant's setup page — they watch your work land in real time;
44
+ already-wired events show as "wired — awaiting first event". If the
45
+ tool is missing (older MCP server), POST the same payload —
46
+ `{ "events": [{ "name", "surface", "note", "wired" }], "summary" }`
47
+ — to `POST /api/workspaces/<workspaceKey>/wiring-plan` with the
48
+ `x-api-key` header. Then ask the merchant to confirm or trim the
49
+ plan before editing.
50
+
51
+ 3. **Wire each event where the truth lives.** Checkout on the site,
52
+ IAP in the app, `order_placed` on the backend. Server truth beats
53
+ client truth when both exist (ad blockers can't touch it). Make the
54
+ smallest change that works; never commit; never enable test mode in
55
+ production paths.
56
+
57
+ 4. **Verify your own work.** Call `get_wiring_status` after wiring and
58
+ iterate until every event you proposed reports `detected`. The
59
+ merchant's page celebrates each first arrival — your verification
60
+ loop is their receipt.
61
+
62
+ ## Surfaces
63
+
64
+ - `web` — apex.js snippet (`apex.track`, `apex.identify`); `page_view` is automatic.
65
+ - `mobile` — Apex SDK (iOS/Android/React Native/Flutter/Capacitor); `app_open` + `screen_view` are automatic. Detect the platform from the repo — never ask.
66
+ - `server` — `POST /api/v1/events` with the workspace's `apex_sk_` key; the ground-truth lane for money events.
67
+
68
+ ## Hard rules
69
+
70
+ - Identifiers: send raw values only into `identify` / event payloads —
71
+ Apex hashes (SHA-256) before any third-party egress. Never log them.
72
+ - Custom events are allowed (`apex.track` accepts any snake_case
73
+ name) but prefer canonical Spec names — they unlock journeys,
74
+ funnels, and metric chips automatically.
75
+ - Revenue events MUST carry `value` + `currency`, and a stable
76
+ external id when one exists (order id, invoice id) — dedupe depends
77
+ on it.