Sprig Device Mode Integration

Send events to Sprig using RudderStack device mode.

RudderStack lets you send your event data to Sprig in web and mobile device mode, that is, using the native Sprig SDK.

Find the open source code for this integration below:

Add mobile device mode integration

Once you add Sprig as a destination in the RudderStack dashboard, follow these steps to add it to your mobile project depending on your integration platform:

Identify

You can use the identify call to identify a user in Sprig.

A sample identify call is shown:

rudderanalytics.identify('1hKOmRA4GRlm', {
  firstName: 'Alex',
  lastName: 'Keener',
  email: "alex@example.com"
});

Supported mappings

RudderStack maps the following optional user attributes in the identify events to the corresponding Sprig fields:

RudderStack propertySprig property
userIduserId
context.traitsattributes
context.traits.emailemail

Track

The track call lets you record any user actions along with the associated properties.

A sample track call is shown:

rudderanalytics.track('Sample Survey', {
  plan: "Annual",
  accountType: "Pro"
});

If you send a track event called Signed Out, then RudderStack automatically maps it to the logoutUser event before sending it to Sprig. Otherwise, it maps the following event/properties to the corresponding Sprig fields:

RudderStack propertySprig property
event
Required
eventName
userIduserId
propertiesproperties

Sprig expects the event name to be present in the eventName key. Hence, if you send a track event named Product Added, RudderStack maps it to Sprig’s eventName key before sending it across to Sprig.

info

To display the survey, you must pass the ViewController instance for iOS and the FragmentActivity instance for Android, otherwise the survey won’t be displayed.

If you do not want to display the survey, you can skip setting FragmentActivity or ViewController. RudderStack then forwards the call to the Sprig.track API instead of Sprig.trackAndPresent.

Reset

The reset method resets the previously identified user and related information.

A sample reset call is shown:

Logging

Both the Android (Kotlin) and iOS (Swift) SDK integrations forward the Sprig SDK’s internal log messages to the RudderStack logger, so they appear alongside the rest of your SDK output.

Android (Kotlin)

The Sprig Android SDK emits log messages with a severity (DEBUG, INFO, WARNING, ERROR, CRITICAL). The integration forwards each message to the RudderStack logger at the mapped severity, so Sprig output honours the log level you configure on the SDK.

Set the log level in Configuration when you initialize the SDK:

import com.rudderstack.sdk.kotlin.android.Configuration
import com.rudderstack.sdk.kotlin.core.internals.logger.Logger

val config = Configuration(
    writeKey = "<WRITE_KEY>",
    dataPlaneUrl = "<DATA_PLANE_URL>",
    logLevel = Logger.LogLevel.VERBOSE,
)

When the log level is Logger.LogLevel.NONE, the integration skips listener registration entirely and no Sprig output is forwarded.

iOS (Swift)

The Sprig iOS SDK emits log messages without a severity (its loggingEvent callback only carries a message string), so the integration forwards every Sprig message at the verbose level.

To see Sprig output, set the RudderStack log level to anything other than .none:

LoggerAnalytics.logLevel = .verbose

When the log level is set to .none, the integration skips listener registration entirely and no Sprig output is forwarded.


Questions? We're here to help.

Join the RudderStack Slack community or email us for support