Add Survicate device mode support to your applications via this plugin for Analytics-Swift
Note: the Survicate library itself will be installed as an additional dependency.
In the Xcode File menu, click Add Packages. You'll see a dialog where you can search for Swift packages. In the search field, enter the URL to this repo.
https://github.com/survicate/analytics-swift-survicate.git
You'll then have the option to pin to a version, or specific branch, as well as which project in your workspace to add it to. Once you've made your selections, click the Add Package button.
Open your Package.swift file and add the following do your the dependencies section:
.package(
name: "SurvicateDestination",
url: "https://github.com/survicate/analytics-swift-survicate.git",
from: "3.0.2"
),import Segment
import SurvicateDestination // <-- Add this lineNote the Survicate library itself will be installed as an additional dependency.
Open the file where you setup and configure the Analytics-Swift library. Add this plugin to the list of imports.
Just under your Analytics-Swift library setup, call analytics.add(plugin: ...) to add an instance of the plugin to the Analytics timeline.
Your events will now begin to flow to Survicate in device mode.
You can optionally enable automatic user login on initialization, which will set the user_id trait based on Segment's userId when the destination initializes:
analytics.add(plugin: SurvicateDestination()
.enableLoginUserOnInitialization(true)
)identify
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 user Id is also set as a user trait with the key "user_id".
track
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. Moreover every String property passed in track properties argument will be passed to Survicate SDK.
screen
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.
reset
The reset method from Segment is used as the reset method in Survicate. This means that when you reset the user in Segment, it will be reset in Survicate.
Got an Issue?
To make things more streamlined, we’ve transitioned our issue reporting to our customer support platform. If you encounter any bugs or have feedback, please reach out to our customer support team. Your insights are invaluable to us, and we’re here to help ensure your experience is top-notch!
Contact us via Intercom in the application, or drop us an email at: [[email protected]]
Thank you for your support and understanding!