From Heap Core SDK to CSQ SDK

This guide provides a step-by-step upgrade process from your current installation of Heap Mobile to the latest version of the CSQ SDK.
Heap Core SDK

Heap Core SDK

CSQ SDK

CSQ SDK

The latest version of our SDK provides a unified set of APIs for Product Analytics, Experience Analytics, and Experience Monitoring, eliminating redundant APIs that perform the same actions.

Upgrading to the latest version ensures you benefit from all our newest features and product enhancements.

Upgrade your dependency based on your current SDK.

CSQ SDK (com.contentsquare.android:sdk < 1.0)

Upgrade to the latest CSQ SDK version:

build.gradle.kts
implementation("com.contentsquare.android:sdk:0.7.1")
implementation("com.contentsquare.android:sdk-compose:0.7.1")
implementation("com.contentsquare.android:sdk:1.0.0")
implementation("com.contentsquare.android:sdk-compose:1.0.0")

Heap Core SDK (io.heap.core:heap-android-core)

Replace Heap SDK dependencies with the CSQ SDK:

build.gradle.kts
implementation("io.heap.core:heap-android-core:0.8.+")
implementation("io.heap.core.web:webview-heapjs:0.8.+")
implementation("io.heap.core.identifier:ad-id-google:0.8.+")
implementation("io.heap.core.identifier:vendor-id-google:0.8.+")
implementation("io.heap.autocapture:heap-autocapture-view:0.8.+")
implementation("io.heap.autocapture:heap-autocapture-notification:0.8.+")
implementation("io.heap.autocapture:heap-autocapture-compose:0.8.+")
implementation("com.contentsquare.android:sdk:1.0.0")
implementation("com.contentsquare.android:sdk-compose:1.0.0")

Replace Heap Core and Autocapture SDK imports with a unified CSQ SDK import.

import io.heap.core.Heap
import io.heap.autocapture.ViewAutocaptureSDK
import io.heap.autocapture.notification.NotificationAutocaptureSDK
import com.contentsquare.CSQ

Follow these steps to start the CSQ SDK with your current configuration.

  1. Migrate your app ID and the config options from Heap.startRecording() to CSQ.configureProductAnalytics().

    MyApplication.kt
    import android.app.Application
    import com.contentsquare.CSQ
    class MyApplication : Application() {
    override fun onCreate() {
    super.onCreate()
    Heap.startRecording(this, "YOUR_ENVIRONMENT_ID")
    CSQ.configureProductAnalytics(
    context = this,
    envId = "YOUR_ENVIRONMENT_ID"
    )
    }
    }
  2. For Autocapture, replace ViewAutocaptureSDK.register() with enableViewAutocapture = true option:

    MyApplication.kt
    import android.app.Application
    import com.contentsquare.CSQ
    class MyApplication : Application() {
    override fun onCreate() {
    super.onCreate()
    ViewAutocaptureSDK.register()
    CSQ.configureProductAnalytics(
    context = this,
    envId = "YOUR_ENVIRONMENT_ID",
    options = ProductAnalyticsOptions(
    enableViewAutocapture = true
    )
    )
    }
    }
  3. Add a call to CSQ.start(this) after the configuration call.

    MyApplication.kt
    import android.app.Application
    import com.contentsquare.CSQ
    class MyApplication : Application() {
    override fun onCreate() {
    super.onCreate()
    CSQ.configureProductAnalytics(
    context = this,
    envId = "YOUR_ENVIRONMENT_ID",
    options = ProductAnalyticsOptions(
    enableViewAutocapture = true
    )
    )
    CSQ.start(this)
    }
    }

The CSQ SDK treats users as opted-out by default.

import android.app.Application
import com.contentsquare.CSQ
// ...
CSQ.start(context)
// ...
val optinButton: Button = ...
optinButton.setOnClickListener {
CSQ.optIn(it.context)
// Then finish initialization and move to the next screen...
}

Implement the optIn() API to forward user consent to the SDK and generate a user ID.

Search and replace all legacy SDK API calls in your app to the latest CSQ APIs using the following mappings. Updating your API calls ensures continued functionality without disruption.

In most cases, this process consists in updating the namespace and method names, with no changes to parameters.

Heap.track("some_event", mapOf("prop1" to "value1"))
CSQ.trackEvent("some_event", mapOf("prop1" to "value1"))

For more information on SDK methods, see the SDK API reference.

GDPR / Identification

Heap Core SDKCSQ SDK
Heap.identify(string)CSQ.identify(String)
Heap.resetIdentity()CSQ.resetIdentity()
Heap.getUserId()CSQ.metadata.userId
Heap.getSessionId()CSQ.metadata.sessionId
Heap.getEnvironmentId()CSQ.metadata.environmentId
Heap.getIdentity()CSQ.metadata.identity

Logging

Heap Core SDKCSQ SDK
import io.heap.core.logs.LogLevelimport com.contentsquare.api.contract.LogLevel
Heap.setLogLevel()CSQ.debug.logLevel = LogLevel.{LEVEL}

Possible values:

  • LogLevel.NONE
  • LogLevel.TRACE
  • LogLevel.DEBUG
  • LogLevel.INFO
  • LogLevel.WARN
  • LogLevel.ERROR
  • LogLevel.IMPORTANT
import io.heap.core.logs.LogChannelimport com.contentsquare.api.contract.LogChannel
Heap.setLogChannel()CSQ.debug.setLogChannel()

Property tracking

Heap Core SDKCSQ SDK
Heap.addUserProperties(properties: Map<String, Any>)CSQ.addUserProperties(properties: Map<String, Any>)
Heap.addEventProperties(properties: Map<String, Any>)CSQ.addEventProperties(properties: Map<String, Any>)
Heap.removeEventProperty(name: String)CSQ.removeEventProperty(name: String)
Heap.clearEventProperties()CSQ.clearEventProperties()
import io.heap.core.api.contract.HeapPropertyimport com.contentsquare.api.contract.Property

Event tracking

Heap Core SDKCSQ SDK
Heap.trackPageview()CSQ.trackScreenview(name: String, cvars: List<CustomVar>)
Heap.track()CSQ.trackEvent(name: String, properties: Map<String, PropertyValue>?)

Personal Data Handling and Masking

Heap Core SDKCSQ SDK
ViewAutocaptureSDK.ignoreInteractions(view: View)CSQ.ignoreInteractions(view: View)
ViewAutocaptureSDK.redactText(view: View)CSQ.mask(view: View)
view.setTag(R.id.heapRedactText, false)CSQ.unmask(View)
Initialization options disableInteractionTextCapture and disableInteractionAccessibilityLabelCaptureCSQ.maskTexts(mask: Boolean)
Jetpack compose
Heap Core SDKCSQ SDK
@Composable
HeapRedact(redact: Boolean)
@Composable
CsqMask(enable: Boolean)
@Composable
HeapIgnore(ignore: Boolean)
@Composable
CsqIgnoreInteraction(ignore: Boolean)

SDK initialization and manipulation

Heap Core SDKCSQ SDK
import io.heap.core.Optionsimport com.contentsquare.api.model.ProductAnalyticsOptions
Heap SDK initialization optionsCSQ.configureProductAnalytics(Context, String, ProductAnalyticOptions)

See supported options for more information.
Heap.startRecording(Context, String, Options)CSQ.start(Context)
Heap.startRecording(Context, String, Options) with resumePreviousSession = trueCSQ.resumeTracking()
Heap.stopRecording()CSQ.stop() or CSQ.pauseTracking()
Heap.stopRecording(deleteUser = true)CSQ.stop() + CSQ.optOut()

Heap ViewAutocaptureSDK API

ViewAutocaptureSDK.register()
CSQ.configureProductAnalytics(
context = this,
envId = "YOUR_ENVIRONMENT_ID",
options = ProductAnalyticsOptions(
enableViewAutocapture = true
)
)
ViewAutocaptureSDK.deregister()
CSQ.configureProductAnalytics(
context = this,
envId = "YOUR_ENVIRONMENT_ID",
options = ProductAnalyticsOptions(
enableViewAutocapture = false
)
)

Heap NotificationAutocaptureSDK API

NotificationAutocaptureSDK.register(
captureTitleText = true,
captureBodyText = true
)
CSQ.configureProductAnalytics(
context = this,
envId = "YOUR_ENVIRONMENT_ID",
options = ProductAnalyticsOptions(
enablePushNotificationAutocapture = true,
enablePushNotificationTitleAutocapture = true,
enablePushNotificationBodyAutocapture = true
)
)

Congratulations! You’re all set. Use this checklist to ensure everything is correctly updated.

Ensure that your build files no longer reference com.contentsquare.android:library, io.heap.core:heap-android-core, or io.heap.autocapture:heap-autocapture-view.

Your io.heap.* import declarations have been updated to import com.contentsquare.CSQ.

You no longer have references to Heap. methods in your codebase.

All calls to the CSQ SDK use the CSQ.namespace.