Swiftpack.co - UserLeap/analytics-swift-sprig as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by UserLeap.
UserLeap/analytics-swift-sprig v1.2.0
The Sprig analytics-swift integration.
⭐️ 0
🕓 4 weeks ago
iOS watchOS tvOS
.package(url: "https://github.com/UserLeap/analytics-swift-sprig.git", from: "v1.2.0")

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 to the dependencies section:

dependencies: [
    // ... other dependencies
    .package(
            url: "https://github.com/UserLeap/analytics-swift-sprig.git",
            from: "1.2.1"
        ),
]

If you need to depend on a pre-released version of the SDK due to xcode compatibility issues, you should be on at least xcode 13.4 and specify the exact version.

dependencies: [
    // ... other dependencies
    .package(
            url: "https://github.com/UserLeap/analytics-swift-sprig.git",
            exact: Version(1, 2, 1, prereleaseIdentifiers: ["alpha"]) // the version number are in sequence: major, minor, patch, prereleaseIdentifier without '-'.
        ),
]

Then specify the names of the package

targets: [
    .target( 
        name: "YourPackageName",
        dependencies: [
            .product(name: "SegmentSprig", package: "analytics-swift-sprig"),
        ]
    )
]

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.

GitHub

link
Stars: 0
Last commit: Yesterday
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

1.2.1-legacy
Yesterday

Imports UserLeapKit 4.11.1-legacy which supports Xcode 13.x

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics