I wanted to know if anyone has an agreement with how PostHog.setup works in react native

245 Views Asked by At

PostHog.setup issue only occurs in android studio with xcode. The error it produces is "apiKey must not be null or empty ". In ios it works perfectly which seems strange to me, i'm not sure what i'm doing wrong the function is used as follows

import Posthog from 'posthog-react-native';
import Gleap from 'react-native-gleapsdk'

export default function App() {
  useAutoUpdateAppHandler({
    versionUrl: config.versionUrl,
    versionRelease: config.versionRelease,
    appName: 'UPchieve',
  });

  Posthog.setup(posthogConfig.token, posthogConfig.settings)
  Gleap.initialize(gleapConfig.token)
    
}


this is the config 
const Config = {
    demo: {
        webSocketUrl: 'https:...',
        socketUrl: 'wss://demo....',
        baseUrl: 'https://demo....',
        versionUrl: 'https://cdn....',
        versionRelease: '2.0.0',
    },
    prod: {
        baseUrl: 'https://...',
    },
    posthog: {
        token: '',
        settings: {
            host: 'https://...',
            captureApplicationLifecycleEvents: true,
            captureDeepLinks: true,
            iOS: {
                capturePushNotifications: true,
            }
        }
    },
   
}
1

There are 1 best solutions below

0
On

If your posthog.token is the empty string in the actual config that could be causing the error

In the documentation you can see that the token should be the "Project API key" from the settings page of your PostHog project. https://app.posthog.com/project/settings if you're on PostHog cloud