Skip to content

Data Hygiene

B2B SaaSE-commerceMobile apps

Keep staging and localhost traffic out of production

Use one Apex workspace key across localhost, preview deploys, TestFlight, and production while Apex auto-classifies Production, Beta, and Dev so labeled test events stay out of live numbers.

One workspace key across localhost, Beta previews, TestFlight, and Production.

5 min read5 min setupUpdated
Software engineer in an olive overshirt holding a closed kraft folder beside tall sunlit loft windows speaking with a smiling teammate in a denim shirt.
One workspace key across localhost, staging previews, TestFlight, and production, cleanly separated on ingest.

Interactive environment classification inspector

See how Production, Beta, Dev, and Unclassified events separate on ingest

Toggle the x-apex-environment server header and dashboard filter to see what stays out of live revenue and ad sends, and confirm what still counts on the Events meter.

Illustrative workspace · 1 key across all environments
ApexSettings -> Workspace -> Environments

Staging backend sends x-apex-environment: beta

Turn off to simulate an unlabeled staging server sending 185 test purchases.

Include "testMode": true dry-run payloads (320 events)

Stored under their environment, never create people, still bill as events.

Visible on dashboard

18,420

Filtered to Production

Counted in live revenue

$42,600

Clean: staging orders excluded

Billable Events meter

22,435

Every environment bills equally

BucketEventsCounts in live revenue & ads?Bills on Events meter?
Production18,420YesYes
Beta (preview / TestFlight)2,325NoYes
Dev (localhost / Xcode debug)1,690NoYes
Unclassified (no label)0None presentYes
Server Events API response preview
POST /api/v1/events
x-apex-environment: beta

{
  "data": {
    "received": 185,
    "duplicates": 0,
    "outsideProduction": 185,
    "errors": []
  }
}

Accepted values: production, beta (aliases staging, preview), and dev (aliases test, development, localhost). A misspelled value returns 400 invalid_environment and never silently counts as Production.

Dev, Beta, Unclassified, and testMode: true events are kept out of production reports (except unlabeled Unclassified server events, which still count as revenue and can fire ad sends), and every ingested environment counts toward your Events meter.
Environment does not change price

The complete playbook

Step-by-step setup, worked math, and real limits.

Steps, technical details, and live pricing.

How it works without Apex

Use the same Apex workspace key across localhost, staging previews, TestFlight builds, and production instead of creating a second workspace. Name live domains and Beta preview hosts (and set Shopify store environments) under Settings -> Workspace -> Environments, and send x-apex-environment (or event-level environment) on Server Events API calls so labeled test traffic stays out of live revenue and ad sends.

How Apex does it for you

Apex inspects incoming web hostnames and mobile build signatures automatically, tags events as Production, Beta, Dev, or Unclassified, keeps Beta and Dev traffic out of production analytics, revenue, and ad-platform sends, and still meters every ingested environment transparently.

How to set this up in 5 steps

  1. Keep one Apex workspace key across dev, staging, and production

    Do not create a second workspace just to keep test clicks out. Using one key everywhere preserves identical event schemas, Key Events, and journeys across every stage.

  2. Name live and Beta hosts and Shopify stores in Workspace -> Environments

    Open Settings -> Workspace -> Environments to name your Production and Beta hosts and set Shopify store environments. localhost is detected as Dev automatically, and Apex never guesses staging or qa subdomains.

  3. Verify automatic mobile build detection on iOS and Android

    Apex Mobile SDK automatically classifies App Store and Google Play production builds as Production, TestFlight and Play internal tracks as Beta, and Xcode debug or sideloaded builds as Dev.

  4. Pass x-apex-environment on every Server Events API deployment

    Because server-to-server calls have no browser hostname, set the x-apex-environment header (production, beta, or dev; aliases staging, preview, test, development, localhost) or event-level environment, which wins over the header. Unlabeled server events land in Unclassified and still count as revenue.

  5. Use testMode: true strictly for dry-run payloads, not free Dev volume

    Events with testMode: true are stored under their environment, never create a person, skip live-activity flashes and default journeys, and still bill on the Events meter.

Why one key beats two workspaces

In older analytics tools, engineering teams create a separate "Staging" project and swap keys in environment variables. That creates two recurring headaches: every new Key Event, Segment, or Experiment has to be recreated twice, and one bad .env deployment accidentally points production at the staging key (or vice versa).

Apex uses one workspace key everywhere (localhost, Vercel/Netlify preview URLs, TestFlight builds, dev Shopify stores, and production). Instead of splitting workspaces, Apex separates traffic at ingest into four explicit environments: Production, Beta, Dev, and Unclassified.

Mobile developer holding two matte test smartphones side by side near a bright concrete studio window sill.
Apex Mobile SDK automatically classifies App Store builds as Production, TestFlight as Beta, and Xcode debug builds as Dev.

How Production, Beta & Dev classify

SurfaceProductionBetaDev
Web (`apex-js`)Hosts you name as ProductionVendor previews (*.vercel.app, *.netlify.app) + hosts you name as Betalocalhost, 127.0.0.1, *.local, *.test (automatic)
iOS & Android (`apex-mobile`)App Store & Google Play production buildsTestFlight & Google Play internal tracksXcode debug & sideloaded dev builds
Shopify storesLive store configured in SettingsStaging store configured in SettingsDev store configured in Settings

Hosts you list under Settings -> Workspace -> Environments land in Production or Beta, and you configure Shopify stores in that same screen (localhost is automatic Dev; Apex never guesses staging or qa subdomains).

Billing transparency: Dev and Beta events are stored under their environment and kept out of production analytics, revenue, and ad-platform sends, and they still count toward the Events meter. Environment does not change the price, and Unclassified events bill too.

Engineering manager smiling in a bright glass conference room doorway while talking with her team.
Keep one workspace key everywhere and pass x-apex-environment on server events so QA traffic stays out of live dashboards.

Server events: label every deployment

Browser snippets and mobile SDKs automatically supply hostnames and build signatures. Backend workers calling the Server Events API do not have a browser URL, so label every deployment explicitly:

  • Per deployment (`x-apex-environment` header): Pass production, beta (aliases staging, preview), or dev (aliases test, development, localhost).
  • Per event (`environment` field): Overrides the header when set on an individual event.
  • Typo safety: A misspelled environment value returns 400 invalid_environment (or comes back in data.errors) and never silently counts as Production.
  • Do not omit the label on staging backends: An unlabeled server event lands in Unclassified (hidden when the dashboard is filtered to Production), yet it still counts as revenue and can be sent to your ad platforms. Always set x-apex-environment: beta or dev on non-production servers so staging purchases stay out of live revenue.
  • The `"testMode": true` rule: "testMode": true is a dry-run flag for practice payloads. Those events are stored under their environment, never create a person, skip live-activity flashes and default journeys, and still bill as events (it is not a free Dev or Beta bucket).

What this costs on Apex

Live Apex pricing · Pay-as-you-go

Estimated Apex cost for Engineering team running 25,000 monthly events across localhost, preview, and production

$0 / month

Covered by monthly free allowances.

Apex meter / scheduleScenario volumeFree allowance / basisRateApex cost
Events
Ingested web, mobile, and server events (all environments) (Dev, Beta, Unclassified, and Production events all count toward the Events meter)
25,000 / mo1M / month$5 per 100K events$0
Attribution
Attributed mobile conversions (Attributed conversions from ads, tagged campaigns, and Apex Links; untagged organic counts as events)
1,000 / mo1.5K / month$0.05 per attributed conversion$0

Dev and Beta events are stored under their environment and kept out of production analytics, revenue, and ad-platform sends. Every ingested environment still counts toward the Events meter. History: 13 months no card, 3 years with card, 7 years once you've paid an invoice. Live pricing.

Third-party and campaign costs (not paid to Apex)

ExpenseTypical rangeNotes
Second staging analytics workspace$0/moNo duplicate workspace subscription or schema syncing required

Launch with your AI agent

Inspect and configure workspace environment hosts via MCP

Ask your coding agent to register your Production and Beta hostnames in Apex (localhost is detected as Dev automatically) and add the x-apex-environment header to backend event helpers.

1Add Apex to your editor

Install in Grok Build

Opens Grok Build and adds Apex. Nothing to configure.

2Tell your agent

Prompt for your AI editor

In my Apex workspace, call list_workspace_environments, then set_workspace_environments with production_hosts and beta_hosts for our live domain and staging hosts. localhost is detected as Dev automatically. Then make sure our server-side event helper passes x-apex-environment cleanly.

The first time your agent calls Apex, it gives you a link to approve in the browser. There is no key to paste. In Grok Build you can also run /setup-apex.

See how editor setup works step by step

web-platform · Grok BuildWaiting for approval
Agent
You

Set up Apex in this repo.

Set up Apex · 0 of 4
  • Signed in
  • Workspace named
  • Events arriving
  • Conversion picked
  • Stripe

Your move

Label every environment so QA builds stay out of production attribution.

Classify your domains once under Workspace -> Environments and keep one clean workspace key from localhost to live traffic.