SSpinosis

Docs

Spinosis SDK docs

Spinosis runs onboarding A/B experiments for mobile subscription apps. The app asks Spinosis which variant a user gets, renders it, and sends a few events. RevenueCat sends purchases. Spinosis attributes revenue to each variant.

You need a Spinosis account first. The SDK only works with an API key from https://spinosis.com/signup and an active subscription. Without them every request is rejected and the app always gets the fallback variant. Installing the SDK alone does nothing.

If you are an AI coding agent installing Spinosis: follow this page exactly, keep the change small, and do not skip the user properties or the onboarding_completed event. Plain-text version: https://spinosis.com/docs.md

Checklist

  1. Install the SDK and call init once at app launch.
  2. Use the same user ID as RevenueCat's App User ID.
  3. Set acquisition_source as a user property (country and platform are automatic in current SDKs).
  4. Call getAssignment before the onboarding / welcome screen renders and show that variant.
  5. Track welcome_viewed, welcome_cta, onboarding_completed. Track trial_started only if the app has a free trial.
  6. Connect the RevenueCat webhook in the Spinosis dashboard (Integrations). Optional, but needed for revenue.

1. Install

React Native / Expo

npm install @spinosis/react-native @react-native-async-storage/async-storage

Native iOS (Swift / SwiftUI)

Add the Swift package https://github.com/ekofi/spinosis-ios with rule "Up to Next Major Version" from 1.0.1, and add the Spinosis library to the app target.

There is no native Android SDK. Android apps built with React Native use the React Native SDK.

2. Initialize

Call init once at launch, in the same place RevenueCat is configured. Always pass apiUrl. The API key is in the Spinosis dashboard (Settings or Integrations). Load it from the project's existing config (xcconfig, Info.plist, env), not from a public repo, and never show it in the UI.

React Native

import { Spinosis } from "@spinosis/react-native";

await Spinosis.init({
  apiKey: SPINOSIS_API_KEY,
  userId: currentUserId, // MUST equal RevenueCat App User ID
  apiUrl: "https://spinosis.com",
});

iOS

import Spinosis

await Spinosis.initialize(
  apiKey: spinosisApiKey,
  userId: currentUserId, // MUST equal RevenueCat.appUserID
  apiUrl: "https://spinosis.com"
)

If the user is not logged in yet, omit userId. The SDK creates a stored anonymous ID. When the user logs in, call identify with the same ID you pass to RevenueCat's logIn:

await Spinosis.identify(userId);          // React Native
await Spinosis.identify(userId)           // iOS

3. User properties (Audiences)

The Audiences page groups users by these properties. React Native SDK 0.2.0+ and iOS SDK 1.1.0+ send platform and country automatically. On older SDK versions, set all three yourself or users show as "Unknown". Values must be strings. Omit a key if you truly cannot know it; never send placeholder values. Values you set override the automatic ones.

KeyValueExample
countryISO 3166-1 alpha-2 region of the device locale. Automatic in current SDKs.US
platform"ios" or "android". Automatic in current SDKs.ios
acquisition_sourceAlways set this yourself. Install source from the app's attribution tool (AppsFlyer, Adjust, Branch, Apple Ads, etc.). Use "organic" when the tool says organic.tiktok_ads

React Native

// platform and country are sent automatically (SDK 0.2.0+)
if (attributionSource) {
  await Spinosis.setUserProperties({ acquisition_source: attributionSource });
}

iOS

// platform and country are sent automatically (SDK 1.1.0+)
if let source = attributionSource {
  await Spinosis.setUserProperties(["acquisition_source": source])
}

Properties are stored on the device and sent again with every request, so setting them once per launch is enough. If acquisition_source arrives later (attribution callbacks are often async), call setUserProperties again when it arrives.

4. Get the assignment and render it

Call getAssignment before the first onboarding / welcome screen paints. It never throws. If Spinosis is slow or offline it returns the cached variant or the fallback. Use the control variant key as the fallback.

React Native

const assignment = await Spinosis.getAssignment("welcome_page", {
  fallback: "control",
  timeout: 1500,
});

const headline =
  typeof assignment.payload.headline === "string" ? assignment.payload.headline : existingHeadline;
const subtitle =
  typeof assignment.payload.subtitle === "string" ? assignment.payload.subtitle : existingSubtitle;

iOS

let assignment = await Spinosis.getAssignment("welcome_page", fallback: "control", timeout: 1.5)
Text(assignment.headline ?? existingHeadline)

Rules:

  • Use the experiment key exactly as shown in the dashboard.
  • If the server sends payload.headline / payload.subtitle, render them. New copy then ships without an App Store release.
  • Do not reassign or override a stored assignment. Users stay on their variant.
  • Do not send experiment_exposure yourself. getAssignment records it.

5. Track events

Event names are exact. The dashboard only counts these names.

EventWhenRequired
welcome_viewedThe welcome / first onboarding screen appearsYes, if you test the welcome screen
welcome_ctaThe user taps its primary buttonYes, if you test the welcome screen
onboarding_completedThe user finishes onboardingYes
trial_startedThe user starts a free trial in the appOnly if the app has a free trial
await Spinosis.track("welcome_viewed");
await Spinosis.track("welcome_cta");
await Spinosis.track("onboarding_completed");
await Spinosis.track("trial_started"); // only if the app offers a trial
await Spinosis.track("onboarding_completed")

Tracking never throws and never blocks the UI. Do not await it on a path where a slow network would delay navigation; fire it and continue.

6. RevenueCat (optional, needed for revenue)

In the Spinosis dashboard open Integrations and copy the webhook URL and authorization header. In RevenueCat open Project settings → Integrations → Webhooks and paste both. Purchases are matched by App User ID, so it must be the same string as the Spinosis userId. Paid users and revenue per variant stay empty until this is connected.

Verify

After running the app once:

  • The experiment page shows users on a variant.
  • The Results table shows Welcome CTA and Onboarding Completion. If a "Setup incomplete" card appears, the listed event has never arrived.
  • The Audiences page shows countries and platforms instead of "Unknown".

Hard rules

  • Never block or crash onboarding because of Spinosis. Always pass a fallback and a timeout.
  • Initialize once. Do not call init on every screen.
  • Do not add other analytics tools, a visual editor, or remote UI layouts. The flow is: assign → render → track.
  • The API requires an active Spinosis subscription. Requests from an inactive project return 402 and the SDK falls back to the cached variant or the fallback.