React Native Survicate Plugin
Survicate is an all-in-one customer feedback platform that helps you collect and act on feedback from your customers. It helps you understand your customers and improve their experience with your product or service.
Install the @survicate/analytics-react-native-survicate and @survicate/react-native-survicate packages.
Using npm:
npm install --save @survicate/analytics-react-native-survicate @survicate/react-native-survicate
Using yarn:
yarn add @survicate/analytics-react-native-survicate @survicate/react-native-survicate
- Add your Survicate workspace key to
Info.plist.
1<key>Survicate</key>2<dict>3<key>WorkspaceKey</key>4<string>*WORKSPACE_KEY*</string>5</dict>
- Run
pod installin theiosdirectory.
- Add the Maven repository to your project
build.gradlelocated underandroiddirectory.
1allprojects {2repositories {3// ...4maven { url 'https://repo.survicate.com' }5}6}
- Add your Survicate workspace key to
AndroidManifest.xml.
1<application2android:name=".MyApp"3>4<!-- ... -->5<meta-data android:name="com.survicate.surveys.workspaceKey" android:value="*WORKSPACE_KEY*"/>6</application>
Follow the instructions for adding plugins on the main Analytics client:
In the file where you initialize the Analytics client, call .add(plugin) with a SurvicatePlugin instance:
1import { createClient } from '@segment/analytics-react-native';23import { SurvicatePlugin } from '@segment/analytics-react-native-plugin-survicate';45const segmentClient = createClient({6writeKey: 'SEGMENT_KEY'7});89segmentClient.add({ plugin: new SurvicatePlugin() });
The SurvicateDestination plugin maps Segment Identify events to Survicate's setUserTrait method. Inside the plugin's Identify function, the code extracts the traits object and userId from the incoming Identify payload and forwards them to Survicate. For each key–value pair in traits, the function calls setUserTrait(key,value). It also sends the userId as a trait by calling setUserTrait('userId',userId).
The SurvicateDestination plugin maps Segment Track events to the Survicate invokeEvent method. This means when you track an event in Segment, it will be invoked in Survicate.
The SurvicateDestination plugin maps the Segment Screen method to the Survicate enterScreen method. This means when you track a screen in Segment, it will be entered in Survicate.
The SurvicateDestination plugin maps the Segment Reset method to the Survicate reset method. This means when you reset the Segment client, the Survicate client will also be reset.