Skip to content

earlsprig/analytics-swift-sprig

 
 

Repository files navigation

Analytics-Swift Sprig

Add Sprig device-mode support to your application via this plugin

Adding the dependency

via Xcode

In the Xcode File menu, click Add Packages. You'll see a dialog where you can search for Swift packages.

image

In the search field, enter the URL to this repo.

https://github.com/UserLeap/analytics-swift-sprig

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.

image

via Package.swift

Open your Package.swift file and add the following do your the dependencies section:

.package(
            name: "Segment",
            url: "https://github.com/UserLeap/analytics-swift-sprig.git",
            from: "1.1.3"
        ),

Note the Sprig library itself will be installed as an additional dependency.

Using the Plugin in your App

Select your iOS Source from My Sources dashboard on segment, and get the value for Write Key from Settings -> API Keys

Open the file where you setup and configure the Analytics-Swift library. Add this plugin to the list of imports. Replace the write key value.

import Segment
import SegmentSprig // <-- Add this line

Just under your Analytics-Swift library setup, call analytics.add(plugin: ...) to add an instance of the plugin to the Analytics timeline.

let analytics = Analytics(configuration: Configuration(writeKey: "<YOUR WRITE KEY>")
                    .flushAt(3)
                    .trackApplicationLifecycleEvents(true))
analytics.add(plugin: SprigDestination())

Your events will now begin to flow to Sprig in device mode. When you track an event and receives a survey, the survey will show on the top view controller. To record attributes, you can make use of the traits parameter when you call identify function. Download Basic Example app for reference.

Support

Please use Github issues, Pull Requests, or feel free to reach out to our support team.

About

The Sprig analytics-swift integration.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 81.3%
  • Shell 18.7%