How do I keep staging traffic out of production data?
We are a fintech and our QA team runs regression suites against staging every night. Those sessions are showing up in our production audiences and analytics, which is skewing an experiment we care about.
What I tried so far:
- Filtering QA IP ranges in the audience conditions. Works but fragile, and it does not stop the events from being recorded.
- Pointing staging at a separate slot. Wrong tool for the job obviously.
- Looked for an "exclude internal traffic" toggle and did not find one
What is the intended setup here? I assume there is a proper way to isolate non-production traffic entirely.
1 answer
The intended setup is environments. Croct supports multiple environments per workspace, typically dev and prod, and each environment has its own application ID. Point staging at the dev application ID and its traffic lands in a completely separate bucket: separate profiles, separate events, separate analytics. Your production audiences never see it.
If you use the CLI, this is exactly what croct.json5 is for. The config maps applications per environment, so the right application ID gets used depending on where the code runs. No conditionals in your own code.
For the automated test suites specifically there is an even stricter option: set NEXT_PUBLIC_CROCT_TEST and the SDK uses a mock event transport, so the tests send no events at all. That is what we do for CI, dev environment for humans poking at staging, test mode for the machines.
Your IP-filter approach was fighting the symptom; with the environment split the data never mixes in the first place.
Set up the dev environment yesterday and enabled the test flag in CI. Overnight run came through clean, nothing in production analytics. Exactly what I was looking for, thanks.