---
title: From Heap Core SDK to CSQ SDK - Flutter
description: Steps to migrate from a Heap Core install to the CSQ SDK
source_url:
  html: https://docs.contentsquare.com/en/csq-sdk-flutter/product-analytics/upgrade-from-heap-core-sdk/
  md: https://docs.contentsquare.com/en/csq-sdk-flutter/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 Flutter app from the Heap Core SDK to the CSQ SDK.
   ```

Prefer to install our skill manually or need custom prompts? See [AI setup for Flutter](https://docs.contentsquare.com/csq-sdk-flutter/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

Increment the Contentsquare SDK in `pubspec.yaml` to the latest version.

```diff
dependencies:
  heap_flutter_bridge: ^0.4.0
  heap_flutter_autocapture: ^0.6.0
  contentsquare: ^4.0.0
```

Sync your dependencies by running `flutter pub get`.

### Imports updates

Replace the Contentsquare SDK import with a CSQ SDK import.

```diff
import 'package:heap_flutter_bridge/heap_flutter_bridge.dart';
import 'package:heap_flutter_autocapture/heap_flutter_autocapture.dart';
import 'package:contentsquare/csq.dart';
```

> **Warning**
>
> After updating the import, some APIs used in your development environment may show errors. The next steps in this guide will help you update them to the latest versions.

### SDK start

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

   * Product Analytics

     **main.dart**

     ```dart
     import 'package:contentsquare/csq.dart';

     void main() async {
       await Heap().startRecording('YOUR_ENVIRONMENT_ID', {
         // ...options
       });
       await CSQ().start(
         startConfig: StartConfig.withEnvironmentId(
           id: 'YOUR_ENVIRONMENT_ID',
           options: AnalyticsOptions(
             // ...options
           ),
         ),
       );
     }
     ```

   * Experience Platform

     **main.dart**

     ```dart
     import 'package:contentsquare/csq.dart';

     void main() async {
       await Heap().startRecording('YOUR_ENVIRONMENT_ID', {
         // ...options
       });
       await CSQ().start(
         startConfig: StartConfig.withDatasourceId(
           id: 'YOUR_DATASOURCE_ID',
           options: AnalyticsOptions(
             // ...options
           ),
         ),
       );
     }
     ```

2. Remove `HeapAutocapture` registration:

   ```dart
   await HeapAutocapture.register();
   ```

3. Recommended To enable automatic capture of user interactions, add the option `enableInteractionsAutocapture: true` to your `AnalyticsOptions` configuration:

   * Product Analytics

     **main.dart**

     ```dart
     import 'package:contentsquare/csq.dart';

     void main() async {
       await CSQ().start(
         startConfig: StartConfig.withEnvironmentId(
           id: 'YOUR_ENVIRONMENT_ID',
           options: AnalyticsOptions(
             enableInteractionsAutocapture: true,
           ),
         ),
       );
     }
     ```

   * Experience Platform

     **main.dart**

     ```dart
     import 'package:contentsquare/csq.dart';

     void main() async {
       await CSQ().start(
         startConfig: StartConfig.withDatasourceId(
           id: 'YOUR_DATASOURCE_ID',
           options: AnalyticsOptions(
             enableInteractionsAutocapture: true,
           ),
         ),
       );
     }
     ```

4. Recommended To capture screen views automatically, add the `CSQNavigatorObserver` to your app's navigator observers:

   **main.dart**

   ```dart
   import 'package:contentsquare/csq.dart';

   MaterialApp(
     navigatorObservers: [
       CSQNavigatorObserver(),
     ],
     home: MyHomePage(),
   )
   ```

   More details in [Track screens](https://docs.contentsquare.com/en/csq-sdk-flutter/experience-analytics/track-screens/).

### Get user consent

Implement the [`optIn()`](https://docs.contentsquare.com/en/csq-sdk-flutter/product-analytics/command-reference/#csqoptin) API to forward user consent to the SDK and generate a user ID.

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

It can be done immediately after `start` is called:

**main.dart**

```dart
void main() async {
  // ...
  await CSQ().start();
  await CSQ().optIn();
  // ...
}
```

Alternatively, you can call `optIn()` in response to a user action, such as tapping an "I agree" button:

```dart
class UserConsentScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('User Consent'),
      ),
      body: Center(
        child: ElevatedButton(
          onPressed: () async {
            await CSQ().optIn();
          },
          child: Text('Agree with Terms and Conditions'),
        ),
      ),
    );
  }
}
```

### 4.2.0 breaking changes

> **Breaking changes in 4.2.0**
>
> The following `AnalyticsOptions` options were removed in version 4.2.0. Remove them from your `CSQ().start()` call if present:
>
> * `disableScreenviewForwardToDXA`
> * `disableScreenviewForwardToPA`
> * `resumePreviousSession`
> * `uploadInterval`
> * `captureVendorId`
> * `captureAdvertiserId`
> * `clearEventPropertiesOnNewUser`
> * `messageBatchMessageLimit`
> * `pruningLookBackWindow`
> * `maximumDatabaseSize`
> * `maximumBatchCountPerUpload`

### 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.

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

```diff
Heap().startRecording('YOUR_ENVIRONMENT_ID')
CSQ().start(startConfig: StartConfig.withEnvironmentId(id: 'YOUR_ENVIRONMENT_ID'))
```

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

#### GDPR / Identification

| Heap SDK | CSQ SDK |
| - | - |
| `Heap().identify(string)` | `CSQ().identify(userIdentifier: 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 SDK | CSQ SDK |
| - | - |
| `Heap().setLogLevel(LogLevel)` | `CSQ().debug.logLevel { get set }` |

#### Property tracking

| Heap SDK | CSQ SDK |
| - | - |
| `Heap().addUserProperties(Map<String, dynamic>)` | `CSQ().addUserProperties(properties: Map<String, dynamic>)` |
| `Heap().addEventProperties(Map<String, dynamic>)` | `CSQ().addEventProperties(properties: Map<String, dynamic>)` |
| `Heap().removeEventProperty(name: String)` | `CSQ().removeEventProperty(name: String)` |
| `Heap().clearEventProperties()` | `CSQ().clearEventProperties()` |

#### Event tracking

| Heap SDK | CSQ SDK |
| - | - |
| `Heap().track(String, [Map<String, dynamic>])` | `CSQ().trackEvent(eventName: String, properties: Map<String, dynamic>?)` |

#### Personal Data Handling and Masking

| Heap SDK | CSQ SDK |
| - | - |
| `HeapRedact(redact: bool)` | `CSQMask(config: CSQMaskingConfig(maskTexts: true))` |
| `HeapIgnore(ignore: bool)` | `CSQMask(config: CSQMaskingConfig(maskInteractions: true))` |

#### SDK initialization and manipulation

| Heap SDK | CSQ SDK |
| - | - |
| `Heap().startRecording(id, options)` | `CSQ().start(startConfig: StartConfig.withEnvironmentId(id: String, options: AnalyticsOptions))` |
| `Heap().stopRecording(deleteUser = true)` | `CSQ().stop()` |
| `Heap().stopRecording(deleteUser = false)` | `CSQ().pauseTracking()` |

Deprecated

**CSQ().configureProductAnalytics()**

Deprecated in 4.2.0. Use `CSQ().start(startConfig: StartConfig.withEnvironmentId(...))` instead. Will be removed in August 2026. See [`CSQ().configureProductAnalytics()`](https://docs.contentsquare.com/en/csq-sdk-flutter/product-analytics/command-reference/#csqconfigureproductanalytics) in the command reference.


```json
{"@context":"https://schema.org","@type":"TechArticle","headline":"From Heap Core SDK to CSQ SDK","description":"Steps to migrate from a Heap Core install to the CSQ SDK","url":"https://docs.contentsquare.com/en/csq-sdk-flutter/product-analytics/upgrade-from-heap-core-sdk/","inLanguage":"en","dateModified":"2026-10-22T13:00:49+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/"}}
```