Contentsquare CLI

A Dart plugin that offers a command-line interface for users of the Contentsquare package.

Add contentsquare_cli as a dev dependency.

Terminal window
flutter pub add -d contentsquare_cli
pubspec.yaml
dev_dependencies:
contentsquare_cli: ^1.0.0

then run

Terminal window
dart run contentsquare_cli

This command enables you to upload debug files generated by the flutter build command to Contentsquare. This allows you to read the Flutter errors generated in an obfuscated or de-symbolized app.

To use the command, provide the following identification elements. These can be passed directly as arguments each time you run the command or set up in a configuration file within your project for a more streamlined command usage.

The required information includes:

  • The targeted platform

    ios or android, corresponding to the flutter build command.

  • The project ID

    1. Login to the Contentsquare platform on https://app.contentsquare.com
    2. Make sure to be on the right project
    3. The project ID can be found in the URL query parameter project: https://app.contentsquare.com/#/{MODULE_NAME}?project={PROJECT_ID}&hash={HASH}]
  • Valid API credentials

    Follow the dedicated documentation from the Help Center to get the client ID and client Secret: How to create API credentials.

  • The debug info directory

    Provided to the --split-debug-info option during build command

  • The obfuscation map path (optional)

    If you use the --obfuscate option during the build process, you can specify the path for the obfuscation map by adding the build option --extra-gen-snapshot-options=--save-obfuscation-map=[YOUR DESIRED FILE PATH].

Using the YAML configuration file
Section titled Using the YAML configuration file

You can supply this information by adding a contentsquare_cli.yaml file to the root of your project.

contentsquare_cli.yaml
contentsquare_cli:
android:
client_id: "[ANDROID CLIENT ID]"
client_secret: "[ANDROID CLIENT SECRET]"
project_id: "[ANDROID PROJECT ID]"
debug_info_dir: "[PATH PROVIDED TO THE --split-debug-info option]"
obfuscation_mapping_file: "[PATH TO THE OBFUSCATION MAP]"
ios:
client_id: "[IOS CLIENT ID]"
client_secret: "[IOS CLIENT SECRET]"
project_id: "[IOS PROJECT ID]"
debug_info_dir: "[PATH PROVIDED TO THE --split-debug-info option]"
obfuscation_mapping_file: "[PATH TO THE OBFUSCATION MAP]"
Using the command line arguments
Section titled Using the command line arguments

Alternatively, this information can be provided directly as arguments on the command line.

OptionDescription
—platformThe target platform for which the debug files are uploaded
—client-idThe client ID of API credentials
—client-secretThe client SECRET of API credentials
—project-idThe contentsquare project ID
—debug-info-dirThe path from --split-debug-info option
—obfuscation-mapping-fileThe generated obfuscation map path

Let’s take the case of debug files generated by this flutter build command:

Terminal window
flutter build apk --release --split-debug-info=myDebugInfoDir --obfuscate --extra-gen-snapshot-options=--save-obfuscation-map=app.android.map.json

Using this configuration file:

contentsquare_cli.yaml
contentsquare_cli:
android:
client_id: "my-client-id-android"
client_secret: "myClientSecretAndroid"
project_id: "00000"
debug_info_dir: "myDebugInfoDir"
obfuscation_mapping_file: "app.android.map.json"
ios:
client_id: "my-client-id-ios"
client_secret: "myClientSecretIos"
project_id: "00001"
debug_info_dir: "myDebugInfoDir"
obfuscation_mapping_file: "app.ios.map.json"

You can invoke the upload-debug-files command as follows:

Terminal window
dart run contentsquare_cli upload-debug-files --platform=android

If you prefer using the command line only:

Terminal window
dart run contentsquare_cli upload-debug-files --platform=android --client-id=my-client-id-android --client-secret="myClientSecretAndroid" --project-id=00000 --debug-info-dir=./myDebugInfoDir --obfuscation-mapping-file=./app.android.map.json
  • Introduce the upload-debug-files command