---
title: From Heap Core SDK to CSQ SDK - Android
description: Learn how to migrate from the Heap Core SDK to the CSQ SDK
source_url:
  html: https://docs.contentsquare.com/en/csq-sdk-android/product-analytics/upgrade-from-heap-core-sdk/
  md: https://docs.contentsquare.com/en/csq-sdk-android/product-analytics/upgrade-from-heap-core-sdk/index.md
---

> ## Documentation index
> Fetch the complete documentation index at: https://docs.contentsquare.com/llms.txt
> Use this file to discover all available pages before exploring further.

This guide provides a step-by-step upgrade process from your current installation of Heap Mobile to the latest version of the 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 with agents

1. Run the wizard in your project directory:

   ```shell
   npx @contentsquare/wizard install
   ```

2. Paste this prompt into your AI coding assistant:

   ```text
   Upgrade my Android app from the Heap Core SDK to the CSQ SDK.
   ```

Prefer to install our skill manually or need custom prompts? See [AI setup for Android](https://docs.contentsquare.com/csq-sdk-android/product-analytics/ai-setup/).

## Manual upgrade

Once you've completed these steps, your app will be fully migrated to the CSQ SDK — with no impact on your existing data collection.

### Dependency upgrades

Replace Heap SDK dependencies with the CSQ SDK:

* Kotlin

  **build.gradle.kts**

  ```diff
  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.13.0")
  implementation("com.contentsquare.android:sdk-compose:1.13.0")
  ```

* Groovy

  **build.gradle**

  ```diff
  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.13.0'
  implementation 'com.contentsquare.android:sdk-compose:1.13.0'
  ```

> **Replace the autocapture plugin**
>
> If you use autocapture, replace `io.heap.gradle` with `com.contentsquare.gradle` in your application module. Do not apply both plugins.
>
> * Kotlin
>
>   **build.gradle.kts**
>
>   ```kotlin
>   plugins {
>     id("com.contentsquare.gradle") version "1.1.1"
>     // ...
>   }
>   ```
>
> * Groovy
>
>   **build.gradle**
>
>   ```groovy
>   plugins {
>     id 'com.contentsquare.gradle' version "1.1.1"
>     // ...
>   }
>   ```

### Library imports

Replace Heap Core and Autocapture SDK imports with the CSQ SDK import.

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

### SDK start

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

The CSQ SDK captures screenviews per screen (Fragment, Compose destination, or custom screen). Review the [screenview options](https://docs.contentsquare.com/en/csq-sdk-android/product-analytics/track-screenviews/#screenview-options) before replacing existing tracking calls.

1. Delete `Heap.startRecording()` and migrate configuration options to `CSQ.start()`.

   * Product Analytics

     **MyApplication.kt**

     ```kotlin
     import android.app.Application
     import com.contentsquare.CSQ

     class MyApplication : Application() {
     override fun onCreate() {
       super.onCreate()

       Heap.startRecording(
         context = this,
         "YOUR_ENVIRONMENT_ID",
         Options(
           // ...options
         )
       )

       CSQ.start(
         context = this,
         StartConfig.withEnvironmentId(
           id = "YOUR_ENVIRONMENT_ID",
           options = AnalyticsOptions(
             // ...options
           )
         )
       )
     }
     }
     ```

   * Experience Platform

     **MyApplication.kt**

     ```kotlin
     import android.app.Application
     import com.contentsquare.CSQ

     class MyApplication : Application() {
     override fun onCreate() {
       super.onCreate()

       Heap.startRecording(
         context = this,
         "YOUR_ENVIRONMENT_ID",
         Options(
           // ...options
         )
       )

       CSQ.start(
         context = this,
         StartConfig.withDataSourceId(
           id = "YOUR_DATASOURCE_ID",
           options = AnalyticsOptions(
             // ...options
           )
         )
       )
     }
     }
     ```

   > **Deprecated configuration options**
   >
   > The following Heap SDK configuration options are not supported in the CSQ SDK:
   >
   > * `startSessionImmediately`
   > * `disableInteractionTextCapture`
   > * `disableInteractionAccessibilityLabelCapture`
   > * `captureVendorId`
   > * `captureAdvertiserId`
   > * `clearEventPropertiesOnNewUser`
   > * `messageBatchMessageLimit`
   > * `resumePreviousSession`
   > * `pruningLookBackWindow`
   > * `maximumDatabaseSize`
   > * `maximumBatchCountPerUpload`
   > * `disableUploadsInBackground`
   >
   > See [supported options](https://docs.contentsquare.com/en/csq-sdk-android/product-analytics/command-reference/#sdk-configuration-options) for more information.

2. Enable Autocapture with `enableViewAutocapture = true` and remove the call to `ViewAutocaptureSDK.register()`.

   * Product Analytics

     **MyApplication.kt**

     ```kotlin
     import android.app.Application
     import com.contentsquare.CSQ

     class MyApplication : Application() {
     override fun onCreate() {
       super.onCreate()

       ViewAutocaptureSDK.register()

       CSQ.start(
         context = this,
         StartConfig.withEnvironmentId(
           id = "YOUR_ENVIRONMENT_ID",
           options = AnalyticsOptions(
             // ...options
             enableViewAutocapture = true
           )
         )
       )
     }
     }
     ```

   * Experience Platform

     **MyApplication.kt**

     ```kotlin
     import android.app.Application
     import com.contentsquare.CSQ

     class MyApplication : Application() {
     override fun onCreate() {
       super.onCreate()

       ViewAutocaptureSDK.register()

       CSQ.start(
         context = this,
         StartConfig.withDataSourceId(
           id = "YOUR_DATASOURCE_ID",
           options = AnalyticsOptions(
             // ...options
             enableViewAutocapture = true
           )
         )
       )
     }
     }
     ```

   > **Autocapture and screenviews**
   >
   > With `enableViewAutocapture` set to `true`, `CSQ.start()` registers both Views and Jetpack Compose autocapture.
   >
   > The SDK also reports each Fragment, Jetpack Compose destination, or custom screen as its own screenview.
   >
   > For more information, see [Track screenviews](https://docs.contentsquare.com/en/csq-sdk-android/product-analytics/track-screenviews/#set-up-screens-for-your-navigation).

3. If your app uses Jetpack Compose, remove the old `ComposeAutocaptureSDK` import and registration call. Compose autocapture no longer needs a separate registration.

   * Product Analytics

     **MyApplication.kt**

     ```kotlin
     import android.app.Application
     import com.contentsquare.CSQ
     import com.contentsquare.StartConfig
     import com.contentsquare.api.model.AnalyticsOptions
     import io.heap.autocapture.compose.ComposeAutocaptureSDK

     class MyApplication : Application() {
       override fun onCreate() {
         super.onCreate()

         ComposeAutocaptureSDK.register()

         CSQ.start(
           context = this,
           StartConfig.withEnvironmentId(
             id = "YOUR_ENVIRONMENT_ID",
             options = AnalyticsOptions(
               // ...options
               enableViewAutocapture = true
             )
           )
         )
       }
     }
     ```

   * Experience Platform

     **MyApplication.kt**

     ```kotlin
     import android.app.Application
     import com.contentsquare.CSQ
     import com.contentsquare.StartConfig
     import com.contentsquare.api.model.AnalyticsOptions
     import io.heap.autocapture.compose.ComposeAutocaptureSDK

     class MyApplication : Application() {
       override fun onCreate() {
         super.onCreate()

         ComposeAutocaptureSDK.register()

         CSQ.start(
           context = this,
           StartConfig.withDataSourceId(
             id = "YOUR_DATASOURCE_ID",
             options = AnalyticsOptions(
               // ...options
               enableViewAutocapture = true
             )
           )
         )
       }
     }
     ```

### Get user consent

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

* Product Analytics

  ```kotlin
  import android.app.Application
  import com.contentsquare.CSQ

  class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        CSQ.start(this, StartConfig.withEnvironmentId("YOUR_ENVIRONMENT_ID"))
    }
  }

  // ConsentActivity
  val optinButton: Button = findViewById(R.id.btn_accept_tracking)

  optinButton.setOnClickListener {
    CSQ.optIn()
    startActivity(Intent(this, MainActivity::class.java))
  }
  ```

* Experience Platform

  ```kotlin
  import android.app.Application
  import com.contentsquare.CSQ

  class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        CSQ.start(this, StartConfig.withDataSourceId("YOUR_DATASOURCE_ID"))
    }
  }

  // ConsentActivity
  val optinButton: Button = findViewById(R.id.btn_accept_tracking)

  optinButton.setOnClickListener {
    CSQ.optIn()
    startActivity(Intent(this, MainActivity::class.java))
  }
  ```

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

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.

```diff
Heap.startRecording("YOUR_ENVIRONMENT_ID")
CSQ.start(this, StartConfig.withEnvironmentId("YOUR_ENVIRONMENT_ID"))
```

For more information on SDK methods, see the [SDK API reference](https://docs.contentsquare.com/en/csq-sdk-android/product-analytics/command-reference/).

#### GDPR / Identification

| Heap Core SDK | CSQ SDK |
| - | - |
| `Heap.identify(identity: String)` | `CSQ.identify(identity: 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: - `LogLevel.NONE`
- `LogLevel.TRACE`
- `LogLevel.DEBUG`
- `LogLevel.INFO`
- `LogLevel.WARN`
- `LogLevel.ERROR` |
| `import io.heap.core.logs.LogChannel` | `import com.contentsquare.api.contract.LogChannel` |
| `Heap.setLogChannel(logChannel: LogChannel)` | `interface LogChannel` `CSQ.debug.logChannel = LogChannel()` |

#### 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, customVars: 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, includeSubtree: Boolean)` |
| `ViewAutocaptureSDK.redactText(view: View)` | `CSQ.mask(view: View)` |
| `view.setTag(R.id.heapRedactText, false)` | `CSQ.unmask(view: View)` |
| Initialization options `disableInteractionTextCapture` and `disableInteractionAccessibilityLabelCapture` | `CSQ.maskTexts(mask: Boolean)` |

> **Kotlin extension functions**
>
> If you use Kotlin, the CSQ SDK comes with Extension functions for:
>
> * `CSQ.ignoreInteractions(view: View, includeSubtree: Boolean)` -> `View.csqIgnoreInteractions(includeSubtree: Boolean)`
> * `CSQ.unmask(view: View)` -> `View.csqMaskContents(true)`
> * `CSQ.unmask(view: View)` -> `View.csqMaskContents(false)`

#### Jetpack compose

| Heap Core SDK | CSQ SDK |
| - | - |
| ```
@Composable
HeapRedact(redact: Boolean)
``` | ```
@Composable
CsqMask(enable: Boolean)
``` |
| ```
@Composable
HeapIgnore(ignore: Boolean)
``` | ```
@Composable
CsqIgnoreInteraction(ignore: Boolean)
``` |

#### SDK initialization and manipulation

| Heap Core SDK | CSQ SDK |
| - | - |
| `import io.heap.core.Options` | `import com.contentsquare.api.model.AnalyticsOptions` |
| Heap SDK initialization options | `CSQ.start(context, StartConfig.withEnvironmentId(id = "envId", options = AnalyticsOptions()))` See [supported options](https://docs.contentsquare.com/en/csq-sdk-android/product-analytics/command-reference/#sdk-configuration-options) for more information. |
| `Heap.startRecording(context: Context, envId: String, options: Options)` | `CSQ.start(context, StartConfig.withEnvironmentId(id = "envId", options = AnalyticsOptions()))` |
| `Heap.startRecording(context: Context, envId: String, options: Options)` with `resumePreviousSession = true` | `CSQ.resumeTracking()` |
| `Heap.stopRecording()` | `CSQ.stop()` or `CSQ.pauseTracking()` |
| `Heap.stopRecording(deleteUser = true)` | `CSQ.stop()` + `CSQ.optOut()` |

## Checklist

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.


```json
{"@context":"https://schema.org","@type":"TechArticle","headline":"From Heap Core SDK to CSQ SDK","description":"Learn how to migrate from the Heap Core SDK to the CSQ SDK","url":"https://docs.contentsquare.com/en/csq-sdk-android/product-analytics/upgrade-from-heap-core-sdk/","inLanguage":"en","dateModified":"2026-10-20T16:57:11+02:00","publisher":{"@type":"Organization","name":"Contentsquare","url":"https://www.contentsquare.com/"},"isPartOf":{"@type":"WebSite","@id":"https://docs.contentsquare.com/#website","name":"Contentsquare Technical Documentation","url":"https://docs.contentsquare.com/"}}
```