From Heap Classic 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 Classic SDK

Heap Classic 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.

Replace the Heap Classic SDK dependencies by the CSQ SDK dependency.

Heap Classic SDK (https://͏github.com/heap/heap-ios-sdk.git)

  1. In your XCode project > Package Dependencies, update the repository location:

    https://github.com/heap/heap-ios-sdk.git
    https://github.com/ContentSquare/apple-sdk-prereleases.git
  2. Set the Dependency Rule to Exact Version 1.1.0-rc.1.

  3. To ensure the library can start properly, add -ObjC as a linker flag under Build Settings > Linking - General > Other Linker Flags.

Replace the Heap Classic SDK import with a unified CSQ SDK import.

import Heap
import HeapIOSAutocapture
import HeapNotificationAutocapture
import ContentsquareSDK

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

  1. Migrate configuration options from Heap.init() to CSQ.configureProductAnalytics().
    Heap.init("YOUR_ENVIRONMENT_ID",
    CSQ.configureProductAnalytics(
    environmentID: "YOUR_ENVIRONMENT_ID",
    additionalOptions: [
    .uploadInterval: 5,
    .baseUrl: "https://example.com/",
    .captureVendorId: true,
    .disablePageviewTitleCapture: true
    ]
    )
  2. Recommended for UIKit Enable Autocapture with .enableUIKitAutocapture: true and remove the call to Heap.iOSAutocaptureSource.register()

    CSQ.configureProductAnalytics(
    environmentID: "YOUR_ENVIRONMENT_ID",
    additionalOptions: [
    .enableUIKitAutocapture: true
    ]
    )
    Heap.iOSAutocaptureSource.register(isDefault: true)
  3. Add a call to CSQ.start(this) after the configuration call.

    CSQ.configureProductAnalytics(
    environmentID: "YOUR_ENVIRONMENT_ID",
    additionalOptions: [
    .enableUIKitAutocapture: true
    ]
    )
    CSQ.start(this)
  4. (Optional) To start HeapNotification, add .enablePushNotificationAutocapture: true and remove the call to Heap.NotificationAutocaptureSource.register().
    CSQ.configureProductAnalytics(
    environmentID: "YOUR_ENVIRONMENT_ID",
    additionalOptions: [
    .uploadInterval: 5,
    .baseUrl: "https://example.com/",
    .captureVendorId: true,
    .disablePageviewTitleCapture: true,
    .enablePushNotificationAutocapture: true
    ]
    )
    Heap.NotificationAutocaptureSource.register()
  5. (Optional) Configure HeapNotification using .enablePushNotificationTitleAutocapture and .enablePushNotificationBodyAutocapture and remove the call to Heap.NotificationAutocaptureSource.register().
    CSQ.configureProductAnalytics(
    environmentID: "YOUR_ENVIRONMENT_ID",
    additionalOptions: [
    .enablePushNotificationAutocapture: true,
    .enablePushNotificationTitleAutocapture: true|false,
    .enablePushNotificationBodyAutocapture: true|false
    ]
    )
    Heap.NotificationAutocaptureSource.register(captureTitle: true|false, captureBody: true|false)

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

import UIKit
import ContentsquareSDK
optinButton.addTarget(self, action: #selector(optInButtonTapped), for: .touchUpInside)
@objc func optInButtonTapped(_ sender: UIButton) {
CSQ.start()
CSQ.optIn()
...
}

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.init()
CSQ.start()

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

GDPR / Identification

Heap Classic SDKCSQ SDK
Heap.shared.identify(string)CSQ.identify(String)
Heap.shared.resetIdentity()CSQ.resetIdentity()
Heap.shared.userIdCSQ.metadata.userID
Heap.shared.sessionIdCSQ.metadata.sessionID
Heap.shared.getEnvironmentIdCSQ.metadata.environmentID
Heap.shared.identityCSQ.metadata.identity

Logging

Heap Classic SDKCSQ SDK
Heap.shared.logLevel { get set }CSQ.debug.logLevel { get set }
Heap.shared.logChannel { get set }CSQ.debug.logChannel(LogChannel)
Heap.shared.printLog()LogChannel.printLog()

Property tracking

Heap Classic SDKCSQ SDK
Heap.shared.addUserProperties(properties: [String: HeapPropertyValue])CSQ.addUserProperties([Property])
Heap.shared.addEventProperties(properties: [String: HeapPropertyValue])CSQ.addEventProperties([Property])
Heap.shared.removeEventProperty(name: String)CSQ.removeEventProperty(name: String)
Heap.shared.clearEventProperties()CSQ.clearEventProperties()

Event tracking

Heap Classic SDKCSQ SDK
Heap.shared.track()CSQ.trackEvent(name: String, properties: [String, PropertyValue]?)

Personal Data Handling and Masking

Heap Classic SDKCSQ SDK
View.heapIgnoreInteractionsCSQ.ignoreInteractions(View) / CSQ.ignoreInteractions(UIView) / UIView.csqIgnoreInteractions (UIKit) / View.csqIgnoreInteractions(shouldIgnore:Boolean)(SwiftUI)
View.heapRedactText / View.heapRedactAccessibilityLabelCSQ.mask(UIView) / UIView.csqMaskContents (UIKit)/ View.csqMaskContents(enable: boolean) (SwiftUI)
view.setTag(R.id.heapRedactText, false)CSQ.unmask(UIView) / UIView.csqMaskContents (UIKit) / View.csqMaskContents(enable: Boolean) (SwiftUI)
Initialization options disableInteractionTextCapture and disableInteractionAccessibilityLabelCaptureCSQ.maskTexts(mask: Boolean)
UIView.heapIgnoreInteractionsDefaultcsqIgnoreInteractionsDefault
UIView.heapIgnoreInnerHierarchycsqIgnoreInnerHierarchy
UIView.heapIgnoreInnerHierarchyDefaultcsqIgnoreInnerHierarchyDefault

SDK initialization and manipulation

Heap Classic SDKCSQ SDK
import io.heap.core.Optionsimport com.contentsquare.api.model.ProductAnalyticsOptions
Heap SDK initialization optionsCSQ.configureProductAnalytics(environmentID: "YOUR_ENVIRONMENT_ID", additionalOptions: [ options ])

See supported options for more information.
Heap.shared.init(context, id)CSQ.start()
Heap.shared.stopRecording(deleteUser = true)CSQ.stop()
Heap.shared.stopRecording(deleteUser = false)CSQ.pauseTracking()

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

Ensure that your build files no longer reference https://github.com/heap/heap-ios-sdk.git.

Your import Heap declarations have been updated to import ContentsquareSDK.

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

All calls to the CSQ SDK use the CSQ.namespace. */}