Guides
Environments
One project per environment, so staging and CI never touch production data.
One project per environment#
Tughas no separate test mode. Create one project per environment instead, for example "Shipcart", "Shipcart (staging)" and "Shipcart (development)".
Each project has its own public key, events, cohorts, approvals and stats. Staging traffic and CI runs never land in production data or skew production cohorts.
TypeScript
// Same code everywhere; the key decides the project.
const tug = new TugClient({ publicKey: process.env.TUG_PUBLIC_KEY });Set-up checklist#
- Label each project Production, Staging or Development on its project page. The label shows next to the key and in the project list, and
GET /projectsreturns it asenvironment. - Keep keys in environment config, not in code: for example
TUG_PUBLIC_KEYset per environment in your hosting provider. - Give each environment its own server API key, named after it. Keys cover the whole workspace, so separate keys let you revoke one without touching the others.
- Set Allowed origin on the production project to your production site. Leave development projects open for
localhost. - Use mock mode in CI and Storybook (
mock: true). It makes no network calls. See Mock mode.