Test and Live Keys
WhiskrKit has two kinds of API keys. Use a test key while you build and test your integration, and a live key in the version of your app you release. Both keys show the same surveys. Only the data they send is kept apart, so the responses from your simulator never end up next to the responses from your users.
What’s different
Section titled “What’s different”| Live key | Test key | |
|---|---|---|
| Starts with | wk_live_ | wk_test_ |
| Use it in | The version you release in the App Store or Play Store | Debug builds, simulators and CI |
| Responses are kept | Yes | For 14 days |
| Counts toward your plan | Yes | No |
| Requests per hour | 1,000 | 100 |
| In the weekly summary email | Yes | No |
| In the dashboard | Under Live, the default | Under Test, see Seeing test data |
Surveys, targeting and survey priority are shared between the two. When you change a survey, you change it for your live app as well. To try a new survey before your users see it, give it a minimum app version rule for a version you haven’t released yet.
Creating a key
Section titled “Creating a key”- Go to Settings → API keys. Only admins and owners see this tab
- Choose Live key or Test key. There is no default, so you always pick on purpose
- Give the key a name, for example “Debug builds” or “Release”, and click Create key
- Copy the key straight away. You won’t be able to see it again
The key belongs to the app selected in the app switcher. Each app can have two active live keys and two active test keys, so you can replace a key without downtime: create a new one, ship it, then revoke the old one.
Using the right key in each build
Section titled “Using the right key in each build”Let your build configuration pick the key, so a debug build always uses the test key and a release build always uses the live key.
#if DEBUGlet whiskrKitKey = "wk_test_your_test_key"#elselet whiskrKitKey = "wk_live_your_live_key"#endif
WhiskrKit.shared.initialize(apiKey: whiskrKitKey)val whiskrKitKey = if (BuildConfig.DEBUG) "wk_test_your_test_key" else "wk_live_your_live_key"
WhiskrKit.initialize(context = this, apiKey = whiskrKitKey)BuildConfig needs buildFeatures { buildConfig = true } in your module’s build.gradle.kts.
initialize(__DEV__ ? 'wk_test_your_test_key' : 'wk_live_your_live_key');import 'package:flutter/foundation.dart';
await whiskrkit.initialize(kDebugMode ? 'wk_test_your_test_key' : 'wk_live_your_live_key');Keep your API keys private. Do not commit them to source control.
Seeing test data
Section titled “Seeing test data”As soon as an app has a test key, a Live / Test switch appears below the app switcher. On a phone it sits at the top of the screen.
- Live is the default. You see only the data from live keys.
- Test shows only the data from test keys. Every page follows it: the dashboard, the survey list, responses, charts, filters and exports. An exported file gets
-testin its name.
While you look at test data, a banner at the top of each page reminds you. Click Back to live data in the banner, or use the switch, to go back.
Test data is deleted automatically after 14 days. To start fresh sooner, admins and owners can click Clear test data in the banner. That deletes every test response and test impression of the selected app. It doesn’t touch your live data, your surveys or your keys, and it can’t be undone.
Keys made before test keys existed
Section titled “Keys made before test keys existed”Before WhiskrKit had test and live keys, every key started with wk_test_. Those keys are live keys: their responses count as live data, and nothing changes for apps you have already released. The API keys page lists them under Live keys with a short note.
You don’t need to do anything. If you prefer a key that starts with wk_live_, create a new live key, release your app with it, and then revoke the old one.