Skip to content

Test mode in your web app

Your app’s test app has its own key (app_test_…), contacts and data (Test mode); your team sets it up under Testing › Test mode › Set up test mode. Nothing in your code changes for it: a staging build sends the test app’s key, against the same address.

src/crm.ts
export const crm = new Crm({
config: {
apiBase: "https://app.purrcrm.com",
appKey: import.meta.env.VITE_CRM_APP_KEY, // app_... in production, app_test_... in staging
appVersion: "2.4.0",
releaseBuild: import.meta.env.PROD,
},
auth: CrmAuth.tokens(tokens),
});

Find both keys on the App key card of Settings › your app › Developers › Install: switch Live | Test to see the test app’s.

The test app keeps its own Web origins: switch to Test on Settings › your app › Developers › Install and name your staging site there (Install). A staging site named only in Live gets nothing back from the test app, and every call fails as no connection.

The test app checks tokens with its own sign-in. Your staging backend signs with the test app’s identity secret (crm_is_test_…, on Settings › your app › Developers › Sign-in in Test). A staging token sent with the live key, or a live token with the test key, is refused for good: the SDK writes PurrCRM‘s sentence saying which to the logger, once, and does not keep asking for new tokens.

Pushes go through the test app’s own Firebase key (your staging Firebase project), to the browsers your staging build registered. Emails go only to addresses on the test app’s allow-list; the rest wait in the Test outbox.

  • crm.isTestMode says whether the build is in test mode: from the app’s public face once PurrCRM has answered, and from the key’s prefix until then. isTestAppKey(key) reads a key’s prefix alone.
  • The SDK draws nothing for it. Draw your own sign, such as a small “TEST” ribbon in a corner, from crm.isTestMode, in builds that are not releaseBuild.
  • The SDK cannot tell a production bundle by itself: set releaseBuild from your bundler. A release build with a test key writes a warning to the console once as it starts, and carries on: a staging key in what your users get would put all of them in the test app. A release build with debug on warns too (Setup check).
  • The setup check’s App key and mode row says the key, its mode and the app’s name.