From Heap Core SDK + Contentsquare SDK to CSQ SDK

Heap Core SDK

Contentsquare 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 upgradesUpgrade your dependency based on your current SDK.
CSQ SDK (com.contentsquare.android:sdk
< 1.0)
Upgrade to the latest CSQ SDK version:
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")
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 and Contentsquare SDKs (io.heap.core:heap-android-core
, com.contentsquare.android:sdk
)
Replace Heap SDK dependencies by the CSQ SDK:
implementation("io.heap.core:heap-android-core:0.8.+")implementation("io.heap.contentsquare.csbridge:contentsquare-bridge:0.8.+)implementation("io.heap.autocapture:heap-autocapture-view:0.8.+")implementation("io.heap.autocapture:heap-autocapture-compose:0.8.+")implementation("com.contentsquare.android:library:4.39.1")implementation("com.contentsquare.android:sdk-compose:4.39.1")implementation("com.contentsquare.android:sdk:1.0.0")implementation("com.contentsquare.android:sdk-compose:1.0.0")
implementation 'io.heap.core:heap-android-core:0.8.+'implementation 'io.heap.contentsquare.csbridge:contentsquare-bridge:0.8.+'implementation 'io.heap.autocapture:heap-autocapture-view:0.8.+'implementation 'io.heap.autocapture:heap-autocapture-compose:0.8.+'implementation 'com.contentsquare.android:library:4.39.1'implementation 'com.contentsquare.android:sdk-compose:4.39.1'implementation 'com.contentsquare.android:sdk:1.0.0'implementation 'com.contentsquare.android:sdk-compose:1.0.0'
Library imports
Section titled Library importsReplace the Heap and Contentsquare dependency imports with a CSQ SDK import.
import io.heap.core.Heapimport io.heap.autocapture.ViewAutocaptureSDKimport io.heap.contentsquare.csbridge.HeapContentsquareIntegrationimport com.contentsquare.android.Contentsquareimport com.contentsquare.CSQ
import io.heap.core.Heap;import io.heap.autocapture.ViewAutocaptureSDK;import io.heap.contentsquare.csbridge.HeapContentsquareIntegration;import com.contentsquare.android.Contentsquare;import com.contentsquare.CSQ;
SDK start
Section titled SDK startFollow these steps to start the CSQ SDK with your current configuration.
Migrate your app ID and the config options from
Heap.startRecording()
toCSQ.configureProductAnalytics()
.MyApplication.kt import android.app.Applicationimport com.contentsquare.CSQclass MyApplication : Application() {override fun onCreate() {super.onCreate()Heap.startRecording(this, "YOUR_ENVIRONMENT_ID")CSQ.configureProductAnalytics(context = this,envId = "YOUR_ENVIRONMENT_ID")}}MyApplication.java import android.app.Application;import com.contentsquare.CSQ;public class MyApplication extends Application {@Overridepublic void onCreate() {super.onCreate();Heap.startRecording(this, "YOUR_ENVIRONMENT_ID");CSQ.configureProductAnalytics(this,"YOUR_ENVIRONMENT_ID");}}For Autocapture, replace
ViewAutocaptureSDK.register()
withenableViewAutocapture = true
option:MyApplication.kt import android.app.Applicationimport com.contentsquare.CSQclass MyApplication : Application() {override fun onCreate() {super.onCreate()ViewAutocaptureSDK.register()CSQ.configureProductAnalytics(context = this,envId = "YOUR_ENVIRONMENT_ID",options = ProductAnalyticsOptions(enableViewAutocapture = true))}}MyApplication.java import android.app.Application;import com.contentsquare.CSQ;public class MyApplication extends Application {@Overridepublic void onCreate() {super.onCreate();ViewAutocaptureSDK.register();ProductAnalyticsOptions options = new ProductAnalyticsOptions.Builder().enableViewAutocapture(true).build();CSQ.configureProductAnalytics(this, "YOUR_ENVIRONMENT_ID", options);}}Add a call to
CSQ.start(this)
after the configuration call.MyApplication.kt import android.app.Applicationimport com.contentsquare.CSQclass MyApplication : Application() {override fun onCreate() {super.onCreate()CSQ.configureProductAnalytics(context = this,envId = "YOUR_ENVIRONMENT_ID",options = ProductAnalyticsOptions(enableViewAutocapture = true))CSQ.start(this)}}MyApplication.java import android.app.Application;import com.contentsquare.CSQ;public class MyApplication extends Application {@Overridepublic void onCreate() {super.onCreate();ProductAnalyticsOptions options = new ProductAnalyticsOptions.Builder().enableViewAutocapture(true).build();CSQ.configureProductAnalytics(this, "YOUR_ENVIRONMENT_ID", options);CSQ.start(this);}}- Replace
HeapContentsquareIntegration.bind()
by configuration options. Note the change in boolean flags controlling data forwarding.Sending Heap pageviews to Contentsquare:
MyApplication.kt HeapContentsquareIntegration.bind(applicationContext,sendHeapPageviewsToContentsquare = true,sendContentsquareScreenviewsToHeap = false)CSQ.configureProductAnalytics(context = this,envId = "YOUR_ENVIRONMENT_ID",options = ProductAnalyticsOptions(disableScreenviewForwardToDXA = false,disableScreenviewForwardToPA = true))MyApplication.java HeapContentsquareIntegration.bind(applicationContext,true, // sendHeapPageviewsToContentsquarefalse // sendContentsquareScreenviewsToHeap);ProductAnalyticsOptions options = new ProductAnalyticsOptions.Builder().disableScreenviewForwardToDXA(false).disableScreenviewForwardToPA(true).build();CSQ.configureProductAnalytics(this, "YOUR_ENVIRONMENT_ID", options);Sending Contentsquare screenviews to Heap:
MyApplication.kt HeapContentsquareIntegration.bind(applicationContext,sendHeapPageviewsToContentsquare = false,sendContentsquareScreenviewsToHeap = true)CSQ.configureProductAnalytics(context = this,envId = "YOUR_ENVIRONMENT_ID",options = ProductAnalyticsOptions(disableScreenviewForwardToDXA = true,disableScreenviewForwardToPA = false))MyApplication.java HeapContentsquareIntegration.bind(applicationContext,false, // sendHeapPageviewsToContentsquaretrue // sendContentsquareScreenviewsToHeap);ProductAnalyticsOptions options = new ProductAnalyticsOptions.Builder().disableScreenviewForwardToDXA(true).disableScreenviewForwardToPA(false).build();CSQ.configureProductAnalytics(this, "YOUR_ENVIRONMENT_ID", options); (Optional) If you were relying on the Contentsquare SDK autostart, remove the
CSDisableAutostart
property and calls toContentsquare.start()
.AndroidManifest.xml <application>...<meta-dataandroid:name="com.contentsquare.android.autostart"android:value="false"/>...</application>MyApplication.kt Contentsquare.start()AndroidManifest.xml <application>...<meta-dataandroid:name="com.contentsquare.android.autostart"android:value="false"/>...</application>MyApplication.java Contentsquare.start();
Get user consent
Section titled Get user consentThe CSQ SDK treats users as opted-out by default.
import android.app.Applicationimport com.contentsquare.CSQ
// ...CSQ.start(context)// ...
val optinButton: Button = ...optinButton.setOnClickListener { CSQ.optIn(it.context) // Then finish initialization and move to the next screen...}
import android.app.Application;import com.contentsquare.CSQ;
// ...CSQ.start(context);// ...
Button optinButton = ...optinButton.setOnClickListener(view -> { CSQ.optIn(view.getContext()); // 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.
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.
In most cases, this process consists in updating the namespace and method names, with no changes to parameters.
Contentsquare.start(this)CSQ.start(this)
For more information on SDK methods, see the SDK API reference.
Product Analytics
Section titled Product AnalyticsGDPR / Identification
Heap Core SDK | CSQ 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 SDK | CSQ SDK |
---|---|
import io.heap.core.logs.LogLevel | import com.contentsquare.api.contract.LogLevel |
Heap.setLogLevel() | CSQ.debug.logLevel = LogLevel.{LEVEL} Possible values:
|
import io.heap.core.logs.LogChannel | import com.contentsquare.api.contract.LogChannel |
Heap.setLogChannel() | CSQ.debug.setLogChannel() |
Property tracking
Heap Core SDK | CSQ 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.HeapProperty | import com.contentsquare.api.contract.Property |
Event tracking
Heap Core SDK | CSQ 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 SDK | CSQ 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 disableInteractionAccessibilityLabelCapture | CSQ.maskTexts(mask: Boolean) |
Heap Core SDK | CSQ SDK |
---|---|
@Composable | @Composable |
@Composable | @Composable |
SDK initialization and manipulation
Heap Core SDK | CSQ SDK |
---|---|
import io.heap.core.Options | import com.contentsquare.api.model.ProductAnalyticsOptions |
Heap SDK initialization options | CSQ.configureProductAnalytics(Context, String, ProductAnalyticsOptions) See supported options for more information. |
Heap.startRecording(Context, String, Options) | CSQ.start(Context) |
Heap.startRecording(context, String, Options) with resumePreviousSession = true | CSQ.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 ))
Experience Analytics
Section titled Experience AnalyticsGDPR / Identification
Contentsquare SDK | CSQ SDK |
---|---|
Contentsquare.optIn(Context) | CSQ.optIn(Context) |
Contentsquare.optOut(Context) | CSQ.optOut() |
Contentsquare.getUserId() | CSQ.metadata.userId |
Contentsquare.getProjectId() | CSQ.metadata.projectId |
Contentsquare.getSessionNumber() | CSQ.metadata.sessionId |
Property tracking
Contentsquare SDK | CSQ SDK |
---|---|
Contentsquare.send(String key, long value) Contentsquare.send(String key, string value) | CSQ.addDynamicVar(String, Any) |
View tracking
Contentsquare SDK | CSQ SDK |
---|---|
Contentsquare.excludeFromExposureMetric(View) | CSQ.excludeFromExposureMetric(View) |
Interoperability
Contentsquare SDK | CSQ SDK |
---|---|
Contentsquare.onSessionReplayLinkChange(callback) | CSQ.metadata.onChanged(Metadata) |
CsWebViewManager.injectEventTrackingInterface(webView: WebView) | CSQ.registerWebView(WebView webView) |
CsWebViewManager.removeEventTrackingInterface(webView: WebView) | CSQ.unregisterWebView(WebView) |
Event tracking
Contentsquare SDK | CSQ SDK |
---|---|
Contentsquare.send(Transaction transaction) | CSQ.trackTransaction(Transaction) |
Contentsquare.send(string) / Contentsquare.send(String screenName, CustomVar[] customVars) | CSQ.trackScreenview(name:String, cvars: List<CustomVar>) |
Contentsquare.consumeEvent(motionEvent) | CSQ.trackMotionEvent(motionEvent: MotionEvent) |
Contentsquare SDK | CSQ SDK |
---|---|
import com.contentsquare.android.compose.analytics.TriggeredOnResume TriggeredOnResume(block: () -> Unit) | import com.contentsquare.api.compose.TriggeredOnResume TriggeredOnResume(block: () -> Unit) |
Error tracking
Contentsquare SDK | CSQ SDK |
---|---|
ErrorAnalysis.setUrlMaskingPatterns(List<String>) | CSQ.setUrlMaskingPatterns(List<String>) |
import com.contentsquare.android.error.analysis.ErrorAnalysis | import com.contentsquare.api.model.NetworkMetric |
ErrorAnalysis.getInstance().newNetworkMetric(url, ErrorAnalysis.HttpMethod.GET) | NetworkMetric(url, HttpMethod.GET) |
networkMetric.stop() | CSQ.trackNetworkMetric(NetworkMetric) |
Personal Data Handling and Masking
Contentsquare SDK | CSQ SDK |
---|---|
Contentsquare.doNotTrack(Class<? extends Activity>... activitiesClasses) | CSQ.ignoreInteractions(view: View) |
Contentsquare.setDefaultMasking(boolean masked) | CSQ.setDefaultMasking(masked: Boolean) |
Contentsquare.mask(View view) | CSQ.mask(View) |
Contentsquare.mask(Class<?> type) | CSQ.mask(Class<?> type) |
Contentsquare.unMask(View view) | CSQ.unmask(View) |
Contentsquare.unmask(Class<?> type) | CSQ.unmask(Class<?> type) |
Contentsquare SDK | CSQ SDK |
---|---|
Modifier.sessionReplayMask(enableMasking: Boolean) | @Composable |
Modifier.excludeFromGestureRecognition() | @Composable |
SDK initialization and manipulation
Contentsquare SDK | CSQ SDK |
---|---|
Contentsquare.start(Context) | CSQ.start(Context) |
Contentsquare.stopTracking() | CSQ.pauseTracking() |
Contentsquare.resumeTracking() | CSQ.resumeTracking() |
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
io.heap.core:heap-android-core
, io.heap.autocapture:heap-autocapture-view
, com.contentsquare.android:library
, or
com.contentsquare.android:sdk-compose
.
Your import io.heap.core.Heap
,
import io.heap.autocapture.ViewAutocaptureSDK
, and
com.contentsquare.android.Contentsquare;
declarations have been updated to
import com.contentsquare.CSQ
.
You no longer have references to Heap.
(except if you are using
webviews), HeapContentsquareIntegration.
, or Contentsquare.
methods in your codebase.
All calls to the CSQ SDK use the CSQ.
namespace.