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
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.
Dependency upgrades
Section titled Dependency upgradesReplace the Heap Classic SDK dependencies by the CSQ SDK dependency.
-
In your XCode project >
Package Dependencies, update the repository location:https://github.com/heap/heap-ios-sdk.githttps://github.com/ContentSquare/apple-sdk.git -
Set the Dependency Rule to
Exact Version1.10.0. -
To ensure the library can start properly, add
-ObjCas a linker flag underBuild Settings>Linking - General>Other Linker Flags.
-
Update your pods:
Podfile pod 'Heap', '~> 9.1.0'pod 'ContentsquareSDK', '1.10.0' -
Run
pod installwithin your project directory. -
Build your app target.
Library imports
Section titled Library importsReplace the Heap Classic SDK import with a unified CSQ SDK import.
import Heapimport HeapIOSAutocaptureimport HeapNotificationAutocaptureimport ContentsquareSDKSDK start
Section titled SDK startFollow these steps to start the CSQ SDK with your current configuration.
- Delete
Heap.init()and migrate configuration to the unifiedCSQ.start()method.- Standalone
- Unified CSQ
Onboard to Unified CSQ, our latest, all-in-one platform offering.
Reach out to your Customer Success Manager for more information.
Heap.init("YOUR_ENVIRONMENT_ID", with: [// ...options])CSQ.start(environmentID: "YOUR_ENVIRONMENT_ID",options: [// ...options])Heap.init("YOUR_ENVIRONMENT_ID", with: [// ...options])CSQ.start(dataSourceID: "YOUR_DATASOURCE_ID",options: [// ...options]) Recommended for UIKit Enable Autocapture with
.enableNativeAutocapture: trueand remove the call toHeap.iOSAutocaptureSource.register()- Standalone
- Unified CSQ
Onboard to Unified CSQ, our latest, all-in-one platform offering.
Reach out to your Customer Success Manager for more information.
CSQ.start(environmentID: "YOUR_ENVIRONMENT_ID",options: [// ...options.enableNativeAutocapture: true])Heap.iOSAutocaptureSource.register(isDefault: true)CSQ.start(dataSourceID: "YOUR_DATASOURCE_ID",options: [// ...options.enableNativeAutocapture: true])Heap.iOSAutocaptureSource.register(isDefault: true)- (Optional) To start HeapNotification, add
.enablePushNotificationAutocapture: trueand remove the call toHeap.NotificationAutocaptureSource.register().- Standalone
- Unified CSQ
Onboard to Unified CSQ, our latest, all-in-one platform offering.
Reach out to your Customer Success Manager for more information.
CSQ.start(environmentID: "YOUR_ENVIRONMENT_ID",options: [// ...options.enablePushNotificationAutocapture: true])Heap.NotificationAutocaptureSource.register()CSQ.start(dataSourceID: "YOUR_DATASOURCE_ID",options: [// ...options.enablePushNotificationAutocapture: true])Heap.NotificationAutocaptureSource.register() - (Optional) Configure HeapNotification using
.enablePushNotificationTitleAutocaptureand.enablePushNotificationBodyAutocaptureand remove the call toHeap.NotificationAutocaptureSource.register().- Standalone
- Unified CSQ
Onboard to Unified CSQ, our latest, all-in-one platform offering.
Reach out to your Customer Success Manager for more information.
CSQ.start(environmentID: "YOUR_ENVIRONMENT_ID",options: [// ...options.enablePushNotificationAutocapture: true,.enablePushNotificationTitleAutocapture: true,.enablePushNotificationBodyAutocapture: true])Heap.NotificationAutocaptureSource.register(captureTitle: true|false, captureBody: true|false)CSQ.start(dataSourceID: "YOUR_DATASOURCE_ID",options: [// ...options.enablePushNotificationAutocapture: true,.enablePushNotificationTitleAutocapture: true,.enablePushNotificationBodyAutocapture: true])Heap.NotificationAutocaptureSource.register(captureTitle: true|false, captureBody: true|false)
Get user consent
Section titled Get user consentImplement the optIn() API to forward user consent to the SDK, generate a user ID, and initiate tracking.
- Standalone
- Unified CSQ
Onboard to Unified CSQ, our latest, all-in-one platform offering.
Reach out to your Customer Success Manager for more information.
import UIKitimport ContentsquareSDK
// In viewDidLoad()optinButton.addTarget(self, action: #selector(optInButtonTapped), for: .touchUpInside)
@objc func optInButtonTapped(_ sender: UIButton) { CSQ.start(environmentID: "YOUR_ENVIRONMENT_ID") CSQ.optIn() // Continue with post-consent navigation or UI update}import UIKitimport ContentsquareSDK
// In viewDidLoad()optinButton.addTarget(self, action: #selector(optInButtonTapped), for: .touchUpInside)
@objc func optInButtonTapped(_ sender: UIButton) { CSQ.start(dataSourceID: "YOUR_DATASOURCE_ID") CSQ.optIn() // Continue with post-consent navigation or UI update}Once tracking has started, you're able to take full advantage of the CSQ SDK API to identify users, track custom events, and more.
Contentsquare's Product Analytics module will also automatically start tracking a wide range of user interactions, view controller changes, and app version changes without any additional code.
Update APIs
Section titled Update APIsSearch 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.
Heap.init("YOUR_ENVIRONMENT_ID")CSQ.start(environmentID: "YOUR_ENVIRONMENT_ID")For more information on SDK methods, see the SDK API reference.
GDPR / Identification
| Heap Classic SDK | CSQ SDK |
|---|---|
Heap.shared.identify(string) | CSQ.identify(String) |
Heap.shared.resetIdentity() | CSQ.resetIdentity() |
Heap.shared.userId | CSQ.metadata.userID |
Heap.shared.sessionId | CSQ.metadata.sessionID |
Heap.shared.getEnvironmentId | CSQ.metadata.environmentID |
Heap.shared.identity | CSQ.metadata.identity |
Logging
| Heap Classic SDK | CSQ 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 SDK | CSQ 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 SDK | CSQ SDK |
|---|---|
Heap.shared.track() | CSQ.trackEvent(name: String, properties: [String, PropertyValue]?) |
Personal Data Handling and Masking
| Heap Classic SDK | CSQ SDK |
|---|---|
View.heapIgnoreInteractions | CSQ.ignoreInteractions(View) / CSQ.ignoreInteractions(UIView) / UIView.csqIgnoreInteractions (UIKit) / View.csqIgnoreInteractions(shouldIgnore:Boolean)(SwiftUI) |
View.heapRedactText / View.heapRedactAccessibilityLabel | CSQ.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 disableInteractionAccessibilityLabelCapture | CSQ.maskTexts(mask: Boolean) |
UIView.heapIgnoreInteractionsDefault | csqIgnoreInteractionsDefault |
UIView.heapIgnoreInnerHierarchy | csqIgnoreInnerHierarchy |
UIView.heapIgnoreInnerHierarchyDefault | csqIgnoreInnerHierarchyDefault |
SDK initialization and manipulation
| Heap Classic SDK | CSQ SDK |
|---|---|
| Heap SDK initialization options | CSQ.start(environmentID: "YOUR_ENVIRONMENT_ID", options: AnalyticsOptions(...))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() |
Checklist
Section titled ChecklistCongratulations! 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.