Observer Mode

Learn how to use Adapty React Native SDK in the Observer mode along with an existing purchase infrastructure

If you have a functioning subscription system and you want to give Adapty SDK a quick try, you can use an Observer mode. With just one line of code you can:

Adapty SDK will automatically collect all transactions and send subscription events. To turn on Observer mode, just set observerMode to true when activating Adapty:

import { activateAdapty } from 'react-native-adapty';

const App: React.FC = () => {
  ...
  useEffect(() => {
    activateAdapty({ 
      sdkKey: 'PUBLIC_SDK_KEY', 
            customerUserId: "YOUR_USER_ID", 
      observerMode: true 
    });
  },[]);
  ...
}

🚧

When running in Observer mode, Adapty SDK won't close any transactions, so make sure you're handling it

A/B tests analytics

In an Observer mode, Adapty SDK doesn't know, where purchases was made from. If you display products using our Paywalls or A/B Tests, you can manually assign variation to the purchase. After doing this, you'll be able to see metrics in an Adapty Dashboard

const transactionId = transaction.transactionIdentifier;
const variationId = paywall.variationId;

try {
    await adapty.purchases.setVariationId(variationId, transactionId);
} catch (error: AdaptyError) {}

Request parameters:

  • variationId (required): a string identifier of variation. You can get it using variationId property of AdaptyPaywall
  • transactionId (required): a string identifier of your purchased transaction SKPaymentTransaction

Did this page help you?