Youbora

The Youbora plugin integrates PRESTOplay for React Native with NPAW’s Youbora analytics service. It’s a plugin, so you install and enable it separately.

Setup

First, install the @castlabs/react-native-prestoplay-youbora package:

npm install @castlabs/react-native-prestoplay-youbora

Once the plugin is installed, set its configuration and enable it when initializing the SDK, by passing the YouboraPlugin class. For example:

import { Sdk } from "@castlabs/react-native-prestoplay";
import { YouboraPlugin } from '@castlabs/react-native-prestoplay-youbora';

YouboraPlugin.setConfiguration({
  accountCode: 'youbora-account-code',
  logLevel: LogLevel.Error,
  //deviceId: 'device-id-1', // Optionally override automatic device id generation
  //deviceIsAnonymous: true, // If true device id won't be reported
})

Sdk.initialize({
  licenseKey: /* Valid license here */,
  plugins: [YouboraPlugin],
});

Then you can configure additional options in the player instance setting PlayerConfiguration.youbora field with YouboraMetadata type. Example:

export default function App() {
  const playerConfig: PlayerConfiguration = {
    autoPlay: true,
    source: {
      url: "https://demo.cf.castlabs.com/media/prestohls/master.m3u8",
      type: ContentType.Hls,
    },
    userId: getUserId(),
    metadata: {
      title: "Demo",
      channelDescription: "CastlabsChannel",
      artist: "castlabs",
    }
  };

  const youboraMetadata: YouboraMetadata = {
    live: false,
    assetId: "castlabs-demo-asset",
    analyticsOptions: {
      userName: playerConfig?.userId,
      appName: "prestoplay-rn",
      contentTitle: playerConfig?.metaData?.title,
      contentChannel: playerConfig?.metaData?.channelDescription,
      contentMetadata: {
        artist: playerConfig?.metaData?.artist,
      },
      customDimensionValue1: "value-1",
    },
  };

  playerConfig.youbora = youboraMetadata;

  return (
    <SafeAreaView>
      <PlayerProvider playerConfig={playerConfig}>
        <PlayerView />
      </PlayerProvider>
    </SafeAreaView>
  );
}

Android

Add NPAW repository to the application build.gradle file:

repositories {
...
    // NPAW (Youbora) Dependencies
    maven {
        url "https://artifact.plugin.npaw.com/artifactory/plugins/android/"
        content { includeGroup "com.npaw.plugin" }
    }
...
}

iOS

Add NPAW repository to the application Podfile file:

# NPAW repository
source 'https://bitbucket.org/npaw/plugin-ios-cocoapods.git'
Next topic: Known issues
Previous topic: Broadpeak