|
| 1 | +--- |
| 2 | +title: Analytics Swift Survicate Plugin |
| 3 | +strat: react-native |
| 4 | +--- |
| 5 | + |
| 6 | +[Survicate](https://survicate.com/){:target="_blank"} 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. |
| 7 | + |
| 8 | +`SurvicatePlugin` for [Survicate](https://survicate.com/). Wraps [`react-native-survicate`](https://github.com/survicate/react-native-survicate). |
| 9 | + |
| 10 | +## Installation |
| 11 | + |
| 12 | +You need to install the `@survicate/analytics-react-native-survicate` and the `@survicate/react-native-survicate` dependency. |
| 13 | + |
| 14 | +Using NPM: |
| 15 | +```bash |
| 16 | +npm install --save @survicate/analytics-react-native-survicate @survicate/react-native-survicate |
| 17 | +``` |
| 18 | + |
| 19 | +Using Yarn: |
| 20 | +```bash |
| 21 | +yarn add @survicate/analytics-react-native-survicate @survicate/react-native-survicate |
| 22 | +``` |
| 23 | + |
| 24 | +### Configuring |
| 25 | +- Add your Survicate workspace key to `Info.plist` |
| 26 | +``` |
| 27 | + <key>Survicate</key> |
| 28 | + <dict> |
| 29 | + <key>WorkspaceKey</key> |
| 30 | + <string>YOUR_WORKSPACE_KEY</string> |
| 31 | + </dict> |
| 32 | +``` |
| 33 | +- run command `pod install` in your `ios` directory |
| 34 | + |
| 35 | +### Configuring Survicate Bindings for Android |
| 36 | + |
| 37 | +- Add maven repository to your project `build.gradle` located under `android` directory |
| 38 | +``` |
| 39 | +allprojects { |
| 40 | + repositories { |
| 41 | + // ... |
| 42 | + maven { url 'https://repo.survicate.com' } |
| 43 | + } |
| 44 | +} |
| 45 | +``` |
| 46 | +- Add your Survicate workspace key to `AndroidManifest.xml` |
| 47 | +```java |
| 48 | +<application |
| 49 | + android:name=".MyApp" |
| 50 | +> |
| 51 | + <!-- ... --> |
| 52 | + <meta-data android:name="com.survicate.surveys.workspaceKey" android:value="YOUR_WORKSPACE_KEY"/> |
| 53 | +</application> |
| 54 | +``` |
| 55 | + |
| 56 | +## Usage |
| 57 | + |
| 58 | +Follow the [instructions for adding plugins](https://github.com/segmentio/analytics-react-native#adding-plugins) on the main Analytics client: |
| 59 | + |
| 60 | +In your code where you initialize the analytics client call the `.add(plugin)` method with an `SurvicatePlugin` instance: |
| 61 | + |
| 62 | +```ts |
| 63 | +import { createClient } from '@segment/analytics-react-native'; |
| 64 | + |
| 65 | +import { SurvicatePlugin } from '@segment/analytics-react-native-plugin-survicate'; |
| 66 | + |
| 67 | +const segmentClient = createClient({ |
| 68 | + writeKey: 'SEGMENT_KEY' |
| 69 | +}); |
| 70 | + |
| 71 | +segmentClient.add({ plugin: new SurvicatePlugin() }); |
| 72 | +``` |
| 73 | + |
| 74 | +### using the Survicate plugin |
| 75 | + |
| 76 | +***identify*** |
| 77 | + |
| 78 | +In the SurvicateDestination plugin, the identify event from Segment is transferred to the setUserTrait method of Survicate. This is achieved within the identify function of the SurvicateDestination class. The traits and userId from the IdentifyEvent are extracted and set as user traits in Survicate using the setUserTrait method. The traits are a dictionary where each key-value pair is set as a user trait. The userId is also set as a user trait with the key "userId". |
| 79 | + |
| 80 | +***track*** |
| 81 | + |
| 82 | +In the SurvicateDestination plugin, the track method from Segment is used as the invokeEvent method in Survicate. This means that when you track an event in Segment, it will be invoked in Survicate. |
| 83 | + |
| 84 | +***screen*** |
| 85 | + |
| 86 | +Similarly, the screen method from Segment is used as the enterScreen method in Survicate. This means that when you track a screen in Segment, it will be entered in Survicate. |
| 87 | + |
| 88 | +***reset*** |
| 89 | + |
| 90 | +The reset method from Segment is used as the reset method in Survicate. This means that when you reset the Segment client, the Survicate client will also be reset. |
0 commit comments