### Install Dependencies and Serve Web Example Source: https://github.com/getsentry/sentry-dart/blob/main/packages/dart/example_web/README.md Run these commands to get the project dependencies and then serve the web application in release mode. Refer to Dart webdev documentation for more serving options. ```sh dart pub get ``` ```sh dart run webdev serve --release ``` -------------------------------- ### Install Executable Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/linux/CMakeLists.txt Installs the main executable target to the root of the installation prefix. This makes the application's executable available in the bundle. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Set Installation Prefix Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/linux/CMakeLists.txt Configures the installation prefix to be the build bundle directory. This ensures that the 'install' command creates a relocatable bundle. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() ``` -------------------------------- ### Install Flutter Library Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/linux/CMakeLists.txt Installs the main Flutter library file into the installation bundle's library directory. This is a core component required for the Flutter application to run. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install AOT Library Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/linux/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library into the installation bundle's library directory. This is conditionally performed only on non-Debug builds to optimize performance. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install fvm and melos Source: https://github.com/getsentry/sentry-dart/blob/main/CONTRIBUTING.md Installs the Flutter version management tool (fvm) and the monorepo management tool (melos) globally. ```bash dart pub global activate fvm dart pub global activate melos ``` -------------------------------- ### Install Bundled Libraries Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/linux/CMakeLists.txt Installs bundled libraries, including plugin-specific libraries, into the installation bundle's library directory. This ensures all necessary dynamic libraries are available at runtime. ```cmake set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) ``` -------------------------------- ### Install Flutter SDK via fvm Source: https://github.com/getsentry/sentry-dart/blob/main/CONTRIBUTING.md Uses fvm to install and set the stable version of the Flutter SDK. This command reads the .fvmrc file to determine the version to install. ```bash fvm use stable ``` -------------------------------- ### Example of version.dart usage in Hub Source: https://github.com/getsentry/sentry-dart/blob/main/docs/new-package-release-checklist.md Illustrates how the version.dart file is used to set the version and package in the Hub. This is a common pattern for managing package versions. ```dart class SentryDatabase { /// Creates a new instance of SentryDatabase. SentryDatabase({ required Hub hub, required Database database, }) : _hub = hub, _database = database { // This is a placeholder for where the version would be set. // In a real scenario, this would dynamically read from version.dart. // For example: // final package = SentryPackage(name: 'sqflite', version: '1.0.0'); // _hub.configureScope((scope) { // scope.addEventProcessor(SentryPackageEventProcessor(package)); // }); } final Hub _hub; final Database _database; } ``` -------------------------------- ### Install Application Bundle Data Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/linux/CMakeLists.txt Installs the application's data directory, including Flutter assets, into the installation bundle. It ensures the assets directory is clean before copying new files. ```cmake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### CMake Installation Rules for Windows Executable Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/example/windows/CMakeLists.txt Configures installation rules for the application executable and its associated files on Windows. It sets up the installation directory to be adjacent to the executable for in-place execution and ensures the 'install' step is default in Visual Studio builds. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installation Rules for Executable and Assets Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/windows/CMakeLists.txt Configures the installation process for the built executable, libraries, and assets. It sets the installation prefix relative to the executable's directory, ensuring that support files are placed correctly for in-place execution. This includes installing the main executable, ICU data, Flutter library, bundled plugin libraries, native assets, and Flutter assets. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Install Native Assets Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/linux/CMakeLists.txt Copies native assets provided by build.dart from all packages into the installation bundle's library directory. This ensures that any platform-specific assets are correctly placed. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Initialize Sentry SDK in Flutter Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/README.md Demonstrates how to initialize the Sentry SDK using the SentryFlutter.init method. This setup ensures that errors are automatically captured and the application is wrapped correctly. ```dart import 'package:flutter/widgets.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; Future main() async { await SentryFlutter.init( (options) { options.dsn = 'https://example@sentry.io/add-your-dsn-here'; }, // Init your App. appRunner: () => runApp(MyApp()), ); } ``` -------------------------------- ### Install Flutter ICU Data Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/linux/CMakeLists.txt Installs the Flutter ICU data file into the data directory of the installation bundle. This file is necessary for internationalization support. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### CMake Installation Rules for Application Bundle Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/example/linux/CMakeLists.txt This section defines the installation rules for creating a relocatable application bundle. It cleans the build directory, installs the executable, Flutter ICU data, the Flutter library, bundled plugin libraries, and the assets directory. It also conditionally installs the AOT library for non-Debug builds. ```cmake # === Installation === # By default, "installing" just makes a relocatable bundle in the build # directory. set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() # Start with a clean build bundle directory every time. install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) # Install the AOT library on non-Debug builds only. if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Clean Build Bundle Directory Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/linux/CMakeLists.txt Removes the build bundle directory before installation to ensure a clean state. This is executed as part of the installation process. ```cmake install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) ``` -------------------------------- ### Initialize Sentry SDK and Dio Integration in Dart Source: https://github.com/getsentry/sentry-dart/blob/main/packages/dio/README.md This snippet demonstrates how to initialize the Sentry SDK with your DSN and then add the Sentry integration to your Dio client. It's crucial that `dio.addSentry()` is called as the last step in Dio setup to prevent configuration overwrites. This setup enables performance tracing, HTTP breadcrumbs, and automatic capture of exceptions. ```dart import 'package:sentry/sentry.dart'; import 'package:sentry_dio/sentry_dio.dart'; import 'package:dio/dio.dart'; Future main() async { await Sentry.init( (options) { options.dsn = 'https://example@sentry.io/example'; }, appRunner: initDio, // Init your App. ); } void initDio() { final dio = Dio(); /// This *must* be the last initialization step of the Dio setup, otherwise /// your configuration of Dio might overwrite the Sentry configuration. dio.addSentry(); } ``` -------------------------------- ### Initialize Sentry with Drift Database Interceptor Source: https://github.com/getsentry/sentry-dart/blob/main/packages/drift/README.md Demonstrates how to initialize the Sentry SDK and configure a Drift NativeDatabase with a SentryQueryInterceptor. This setup enables automatic tracking of database transactions and operations. ```dart import 'package:drift/drift.dart'; import 'package:drift/native.dart'; import 'package:sentry/sentry.dart'; import 'package:sentry_drift/sentry_drift.dart'; import 'your_database.dart'; Future main() async { const dsn = 'https://e85b375ffb9f43cf8bdf9787768149e0@o447951.ingest.sentry.io/5428562'; await Sentry.init( (options) { options.dsn = dsn; options.tracesSampleRate = 1.0; options.debug = true; }, appRunner: runApp, ); } Future runApp() async { final tr = Sentry.startTransaction('drift', 'op', bindToScope: true); final executor = NativeDatabase.memory().interceptWith( SentryQueryInterceptor(databaseName: 'my_db_name'), ); final db = AppDatabase(executor); await db.into(db.todoItems).insert( TodoItemsCompanion.insert( title: 'This is a test thing', content: 'test', ), ); final items = await db.select(db.todoItems).get(); print(items); await db.close(); await tr.finish(status: const SpanStatus.ok()); } ``` -------------------------------- ### Set Minimum CMake Version Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/linux/CMakeLists.txt Ensures that CMake version 3.10 or later is installed. Do not increase this version to avoid compilation issues. ```cmake cmake_minimum_required(VERSION 3.10) ``` -------------------------------- ### CMake Plugin and Asset Installation Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/example/windows/CMakeLists.txt Installs bundled plugin libraries and native assets provided by build.dart. It ensures that all necessary runtime components and assets are correctly placed for the application to function. ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Initialize Sentry and Isar with Sentry Integration (Dart/Flutter) Source: https://github.com/getsentry/sentry-dart/blob/main/packages/isar/README.md Initializes the Sentry SDK with a provided DSN and then opens an Isar database instance integrated with Sentry. This setup captures database operations and errors for monitoring. Requires 'sentry_flutter' and 'sentry_isar' packages. ```dart import 'package:path_provider/path_provider.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:sentry_isar/sentry_isar.dart'; import 'user.dart'; Future main() async { await SentryFlutter.init( (options) { options.dsn = 'https://example@sentry.io/add-your-dsn-here'; options.tracesSampleRate = 1.0; }, // Init your App. appRunner: () => runApp(MyApp()), ); } Future runApp() async { final tr = Sentry.startTransaction( 'isarTest', 'db', bindToScope: true, ); final dir = await getApplicationDocumentsDirectory(); final isar = await SentryIsar.open( [UserSchema], directory: dir.path, ); final newUser = User() ..name = 'Joe Dirt' ..age = 36; await isar.writeTxn(() async { await isar.users.put(newUser); // insert & update }); final existingUser = await isar.users.get(newUser.id); // get await isar.writeTxn(() async { await isar.users.delete(existingUser!.id); // delete }); await tr.finish(status: const SpanStatus.ok()); } ``` -------------------------------- ### CMake Project Setup and Configuration Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/example/windows/CMakeLists.txt Initializes the CMake project, sets the minimum version, defines the project name, and configures executable names. It also includes modern CMake policies and handles multi-configuration generator settings. ```cmake cmake_minimum_required(VERSION 3.14) project(sentry_flutter_example LANGUAGES CXX) set(BINARY_NAME "sentry_flutter_example") cmake_policy(VERSION 3.14...3.25) ``` -------------------------------- ### CMake AOT Library Installation Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/example/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library for non-Debug builds (Profile and Release). This optimizes application startup time and runtime performance. ```cmake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Trace Serialization/Parsing with DioLink and Sentry (Dart) Source: https://github.com/getsentry/sentry-dart/blob/main/packages/link/README.md Demonstrates performance tracing for serialization and parsing when using `DioLink` with Sentry integrations. This example utilizes `sentry_link` and the `sentry_dio` package for detailed request monitoring. ```dart import 'package:sentry_link/sentry_link.dart'; import 'package:sentry_dio/sentry_dio.dart'; import 'package:dio/dio.dart'; import 'package:gql_link/gql_link.dart'; final link = Link.from([ AuthLink(getToken: () async => 'Bearer $personalAccessToken'), SentryGql.link( shouldStartTransaction: true, graphQlErrorsMarkTransactionAsFailed: true, ), DioLink( 'https://api.github.com/graphql', client: Dio()..addSentry(), serializer: SentryRequestSerializer(), parser: SentryResponseParser(), ), ]); ``` -------------------------------- ### CMake Project Setup and Build Configuration Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/example/linux/CMakeLists.txt This snippet configures the basic CMake project settings, including the minimum version, project name, binary name, and application ID. It also handles setting the build type (Debug, Profile, Release) if not already defined, ensuring consistent build configurations. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "sentry_flutter_example") set(APPLICATION_ID "io.sentry.flutter.sentry_flutter") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") # Configure build options. if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() ``` -------------------------------- ### CMake Flutter Assets Directory Installation Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/example/windows/CMakeLists.txt Handles the installation of the Flutter assets directory. It ensures the directory is completely re-copied on each build to prevent stale files and maintains the integrity of application assets. ```cmake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Initialize Sentry and Configure Sqflite Database Factory Source: https://github.com/getsentry/sentry-dart/blob/main/packages/sqflite/README.md This snippet demonstrates how to initialize the Sentry Flutter SDK with a DSN and configure the sqflite database factory to use SentrySqfliteDatabaseFactory. This setup enables automatic tracking of database queries and transactions. ```dart import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:sqflite/sqflite.dart'; import 'package:sentry_sqflite/sentry_sqflite.dart'; Future main() async { await SentryFlutter.init( (options) { options.dsn = 'https://example@sentry.io/add-your-dsn-here'; options.tracesSampleRate = 1.0; }, // Init your App. appRunner: () => runApp(MyApp()), ); } Future insertProducts() async { databaseFactory = SentrySqfliteDatabaseFactory(); final db = await openDatabase(inMemoryDatabasePath); await db.execute(''' CREATE TABLE Product ( id INTEGER PRIMARY KEY, title TEXT ) '''); await db.insert('Product', {'title': 'Product 1'}); await db.insert('Product', {'title': 'Product 2'}); final result = await db.query('Product'); print(result); await db.close(); } ``` -------------------------------- ### Set Flutter Library Paths Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/windows/flutter/CMakeLists.txt Configures the path to the Flutter library and its associated header files. Ensures the Flutter library and ICU data file are available in the parent scope for installation. ```cmake set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) ``` -------------------------------- ### Trace Serialization/Parsing with HttpLink and Sentry (Dart) Source: https://github.com/getsentry/sentry-dart/blob/main/packages/link/README.md Illustrates performance tracing for serialization and parsing when using `HttpLink` with Sentry integrations. This example combines `sentry_link` with the `http` integration for comprehensive request monitoring. ```dart import 'package:sentry/sentry.dart'; import 'package:sentry_link/sentry_link.dart'; import 'package:gql_http_link/gql_http_link.dart'; import 'package:gql_link/gql_link.dart'; final link = Link.from([ AuthLink(getToken: () async => 'Bearer $personalAccessToken'), SentryGql.link( shouldStartTransaction: true, graphQlErrorsMarkTransactionAsFailed: true, ), HttpLink( 'https://api.github.com/graphql', httpClient: SentryHttpClient(), serializer: SentryRequestSerializer(), parser: SentryResponseParser(), ), ]); ``` -------------------------------- ### Initialize Sentry with LoggingIntegration in Dart Source: https://github.com/getsentry/sentry-dart/blob/main/packages/logging/README.md Configures the Sentry SDK by providing a DSN and adding the LoggingIntegration to the options. This setup ensures that logs generated by the application are automatically forwarded to Sentry. ```dart import 'package:sentry/sentry.dart'; import 'package:sentry_logging/sentry_logging.dart'; Future main() async { await Sentry.init( (options) { options.dsn = 'https://example@sentry.io/example'; options.addIntegration(LoggingIntegration()); }, appRunner: initApp, // Init your App. ); } void initApp() { // your app code } ``` -------------------------------- ### Bootstrap the project Source: https://github.com/getsentry/sentry-dart/blob/main/CONTRIBUTING.md Initializes the project by resolving all package dependencies and setting up git hooks for pre-commit checks. ```bash melos bootstrap ``` -------------------------------- ### Cross-Building System Root Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/linux/CMakeLists.txt Sets up the system root and find paths for cross-building. This is used when building for a different platform than the host system. ```cmake if(FLUTTER_TARGET_PLATFORM_SYSROOT) set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) endif() ``` -------------------------------- ### Project Configuration Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/linux/CMakeLists.txt Sets up the minimum CMake version, project name, and executable name. It also defines the application identifier and opts into modern CMake behaviors. ```cmake cmake_minimum_required(VERSION 3.13) project(runner LANGUAGES CXX) set(BINARY_NAME "microbenchmarks") set(APPLICATION_ID "com.example.microbenchmarks") cmake_policy(SET CMP0063 NEW) ``` -------------------------------- ### Initialize Sentry SDK in Dart Source: https://github.com/getsentry/sentry-dart/blob/main/packages/dart/README.md Demonstrates how to initialize the Sentry SDK using a DSN. It includes both the standard appRunner approach and the runZonedGuarded approach for capturing unhandled exceptions. ```dart import 'package:sentry/sentry.dart'; Future main() async { await Sentry.init( (options) { options.dsn = 'https://example@sentry.io/example'; }, appRunner: initApp, // Init your App. ); } void initApp() { // your app code } ``` ```dart import 'dart:async'; import 'package:sentry/sentry.dart'; Future main() async { runZonedGuarded(() async { await Sentry.init( (options) { options.dsn = 'https://example@sentry.io/example'; }, ); // Init your App. initApp(); }, (exception, stackTrace) async { await Sentry.captureException(exception, stackTrace: stackTrace); }); } void initApp() { // your app code } ``` -------------------------------- ### Find PkgConfig and GTK Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/linux/CMakeLists.txt Finds the PkgConfig tool and checks for the GTK+ 3.0 library. This is a system-level dependency required for the application. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) ``` -------------------------------- ### Initialize Sentry and Hive Integration in Dart Source: https://github.com/getsentry/sentry-dart/blob/main/packages/hive/README.md Initializes the Sentry SDK with a DSN and then sets up the SentryHive integration. This involves initializing Sentry, configuring options like DSN and sampling rate, and then initializing SentryHive with the application directory path and registering necessary adapters. It demonstrates opening a Hive box through SentryHive and performing basic put/get operations. ```dart import 'package:sentry/sentry.dart'; import 'package:hive/hive.dart'; import 'package:sentry_hive/sentry_hive.dart'; import 'package:path_provider/path_provider.dart'; Future main() async { await SentryFlutter.init( (options) { options.dsn = 'https://example@sentry.io/add-your-dsn-here'; options.tracesSampleRate = 1.0; }, appRunner: () => runApp(YourApp()), ); } Future insertUser() async { // Use [SentryHive] where you would use [Hive] final appDir = await getApplicationDocumentsDirectory(); SentryHive ..init(appDir.path) ..registerAdapter(PersonAdapter()); var box = await SentryHive.openBox('testBox'); var person = Person( name: 'Dave', age: 22, ); await box.put('dave', person); print(box.get('dave')); // Dave: 22 } @HiveType(typeId: 1) class Person { Person({required this.name, required this.age}); @HiveField(0) String name; @HiveField(1) int age; @override String toString() { return '$name: $age'; } } ``` -------------------------------- ### Initialize Sentry with runZonedGuarded Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/README.md Shows how to initialize Sentry within a runZonedGuarded block for legacy Flutter versions (pre-3.3) to manually capture exceptions in a custom error zone. ```dart import 'dart:async'; import 'package:flutter/widgets.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; Future main() async { runZonedGuarded(() async { await SentryFlutter.init( (options) { options.dsn = 'https://example@sentry.io/add-your-dsn-here'; }, ); runApp(MyApp()); }, (exception, stackTrace) async { await Sentry.captureException(exception, stackTrace: stackTrace); }); } ``` -------------------------------- ### Run Microbenchmarks in Release Mode Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/README.md Execute microbenchmarks on a connected device using the Flutter release mode. Ensure a device is connected. ```bash flutter run --release -d ``` -------------------------------- ### Configure Sentry Backend Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/linux/CMakeLists.txt Sets the Sentry backend to 'crashpad' for reporting crashes. This setting is cached and forced. ```cmake set(SENTRY_BACKEND "crashpad" CACHE STRING "The sentry backend responsible for reporting crashes" FORCE) ``` -------------------------------- ### Initialize Sentry SDK and Instrument File Operations in Dart Source: https://github.com/getsentry/sentry-dart/blob/main/packages/file/README.md This snippet demonstrates how to initialize the Sentry SDK with a DSN and sample rate, and then use the `sentry_file` package to wrap `dart.io.File` objects. It shows how to perform file operations like create, write, read, and delete while automatically tracing them within Sentry transactions. ```dart import 'package:sentry/sentry.dart'; import 'package:sentry_file/sentry_file.dart'; import 'dart:io'; Future main() async { // or SentryFlutter.init await Sentry.init( (options) { options.dsn = 'https://example@sentry.io/example'; // To set a uniform sample rate options.tracesSampleRate = 1.0; }, appRunner: runApp, // Init your App. ); } Future runApp() async { final file = File('my_file.txt'); // Call the Sentry extension method to wrap up the File final sentryFile = file.sentryTrace(); // Start a transaction if there's no active transaction final transaction = Sentry.startTransaction( 'MyFileExample', 'file', bindToScope: true, ); // create the File await sentryFile.create(); // Write some content await sentryFile.writeAsString('Hello World'); // Read the content final text = await sentryFile.readAsString(); print(text); // Delete the file await sentryFile.delete(); // Finish the transaction await transaction.finish(status: SpanStatus.ok()); await Sentry.close(); } ``` -------------------------------- ### Initialize Sentry with Firebase Remote Config Integration Source: https://github.com/getsentry/sentry-dart/blob/main/packages/firebase_remote_config/README.md Demonstrates how to initialize the Sentry Flutter SDK while including the SentryFirebaseRemoteConfigIntegration. This setup requires a valid Sentry DSN and an initialized Firebase Remote Config instance. ```dart import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_remote_config_example/home_page.dart'; import 'package:flutter/material.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:sentry_firebase_remote_config/sentry_firebase_remote_config.dart'; import 'firebase_options.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform, ); final remoteConfig = FirebaseRemoteConfig.instance; await remoteConfig.setConfigSettings(RemoteConfigSettings( fetchTimeout: const Duration(minutes: 1), minimumFetchInterval: const Duration(hours: 1), )); await SentryFlutter.init( (options) { options.dsn = 'https://example@sentry.io/add-your-dsn-here'; final sentryFirebaseRemoteConfigIntegration = SentryFirebaseRemoteConfigIntegration( firebaseRemoteConfig: remoteConfig, activateOnConfigUpdated: false, ); options.addIntegration(sentryFirebaseRemoteConfigIntegration); }, ); runApp(const RemoteConfigApp()); } class RemoteConfigApp extends StatelessWidget { const RemoteConfigApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( title: 'Remote Config Example', home: const HomePage(), theme: ThemeData( useMaterial3: true, primarySwatch: Colors.blue, ), ); } } ``` -------------------------------- ### Configure C++ Wrapper for Plugins Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/windows/flutter/CMakeLists.txt Builds a static C++ wrapper library for Flutter plugins. It includes core and plugin-specific sources, applies standard build settings, and links against the Flutter library. Ensures position-independent code and hidden visibility. ```cmake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") # Wrapper sources needed for a plugin. add_library(flutter_wrapper_plugin STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ) apply_standard_settings(flutter_wrapper_plugin) set_target_properties(flutter_wrapper_plugin PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(flutter_wrapper_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden) target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) target_include_directories(flutter_wrapper_plugin PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_plugin flutter_assemble) ``` -------------------------------- ### Run Microbenchmarks in Profile Mode Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/README.md Execute microbenchmarks on a connected device using the Flutter profile mode. Ensure a device is connected. ```bash flutter run --profile -d ``` -------------------------------- ### Enable Performance Monitoring with SentryHttpClient Source: https://github.com/getsentry/sentry-dart/blob/main/packages/dart/README.md Demonstrates how to wrap HTTP requests with SentryHttpClient to track spans. It requires binding a transaction to the scope to ensure requests are associated with the correct performance trace. ```dart import 'package:sentry/sentry.dart'; final transaction = Sentry.startTransaction( 'webrequest', 'request', bindToScope: true, ); var client = SentryHttpClient(); try { var uriResponse = await client.post('https://example.com/whatsit/create', body: {'name': 'doodle', 'color': 'blue'}); print(await client.get(uriResponse.bodyFields['uri'])); } finally { client.close(); } await transaction.finish(status: SpanStatus.ok()); ``` -------------------------------- ### Apply Standard Build Settings (CMake) Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/windows/runner/CMakeLists.txt Applies a standard set of build settings to the defined executable target. This is a common practice for ensuring consistent build configurations across different parts of the project. ```cmake apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Set Runtime Path Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/linux/CMakeLists.txt Configures the runtime search path for libraries to include the 'lib' directory relative to the executable. This is crucial for loading bundled libraries correctly. ```cmake set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Configure Native Sample Build with CMake Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/example/android/app/CMakeLists.txt This CMake script sets up the build environment for the native sample library. It includes the sentry-native integration and links necessary libraries. Dependencies include CMake version 3.6 or higher and the sentry-native module. ```cmake cmake_minimum_required(VERSION 3.6) project(sentry-sample LANGUAGES C CXX) include("${CMAKE_CURRENT_SOURCE_DIR}/../../../sentry-native/sentry-native.cmake") add_library(native-sample SHARED src/main/cpp/native-sample.cpp) find_library(LOG_LIB log) target_link_libraries( native-sample PRIVATE ${LOG_LIB} sentry_flutter_plugin # Use the alias defined in sentry-native.cmake ) ``` -------------------------------- ### Enable Performance Tracing for AssetBundles Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/README.md Wraps the application root with SentryAssetBundle to enable performance tracing for all AssetBundle operations, including image loading. ```dart runApp( DefaultAssetBundle( bundle: SentryAssetBundle(), child: MyApp(), ), ); ``` -------------------------------- ### Apply Standard Compilation Settings Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/linux/CMakeLists.txt Applies standard compilation features and options to a target. It sets the C++ standard to C++14, enables all warnings, and applies optimization and NDEBUG definitions based on the build configuration. ```cmake function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_14) target_compile_options(${TARGET} PRIVATE -Wall -Werror) target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") endfunction() ``` -------------------------------- ### Configure Flutter Linux Build Environment with CMake Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/example/linux/flutter/CMakeLists.txt This script initializes the CMake environment for a Flutter Linux project. It defines helper functions for list manipulation, locates system dependencies via PkgConfig, and establishes the build targets for the Flutter engine. ```cmake cmake_minimum_required(VERSION 3.10) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") include(${EPHEMERAL_DIR}/generated_config.cmake) function(list_prepend LIST_NAME PREFIX) set(NEW_LIST "") foreach(element ${${LIST_NAME}}) list(APPEND NEW_LIST "${PREFIX}${element}") endforeach(element) set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) endfunction() find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### Configure C++ Wrapper for Runner Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/windows/flutter/CMakeLists.txt Builds a static C++ wrapper library for the Flutter runner application. It includes core and application-specific sources, applies standard build settings, and links against the Flutter library. ```cmake list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") # Wrapper sources needed for the runner. add_library(flutter_wrapper_app STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_APP} ) apply_standard_settings(flutter_wrapper_app) target_link_libraries(flutter_wrapper_app PUBLIC flutter) target_include_directories(flutter_wrapper_app PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_app flutter_assemble) ``` -------------------------------- ### Set Build Configuration Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/linux/CMakeLists.txt Configures the build type (Debug, Profile, Release) if not already set. This ensures a consistent build mode is used for the project. ```cmake if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() ``` -------------------------------- ### Include Generated Plugins Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/linux/CMakeLists.txt Includes the CMake file that manages the build rules for generated plugins. This integrates plugin compilation into the main build process. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Determine Native Backend Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/windows/CMakeLists.txt Selects the native crash reporting backend (breakpad or crashpad) based on the Flutter target platform. ```cmake if(FLUTTER_TARGET_PLATFORM EQUAL "windows-arm64") set(native_backend "breakpad") else() set(native_backend "crashpad") endif() ``` -------------------------------- ### Set Runtime Output Directory Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/linux/CMakeLists.txt Configures the runtime output directory for the main executable. Placing it in 'intermediates_do_not_run' prevents accidental execution of unbundled copies. ```cmake set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Set Target Include Directories for Sentry Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/linux/CMakeLists.txt Configures the include directories for the Sentry target, accommodating Flutter tooling requirements. ```cmake target_include_directories(sentry INTERFACE ${CMAKE_CURRENT_LIST_DIR}) ``` -------------------------------- ### Define Executable Target and Source Files (CMake) Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/windows/runner/CMakeLists.txt Defines the main executable target for the application and lists all the source files required for compilation. This includes C++ source files, generated Flutter files, and resource files. ```cmake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) add_executable(${BINARY_NAME} WIN32 "flutter_window.cpp" "main.cpp" "utils.cpp" "win32_window.cpp" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" "Runner.rc" "runner.exe.manifest" ) ``` -------------------------------- ### Flutter Tool Backend Custom Command Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/windows/flutter/CMakeLists.txt Defines a custom command to execute the Flutter tool backend script. This command generates necessary build artifacts like the Flutter library and headers. It uses a phony target to ensure execution on every build. ```cmake # _phony_ is a non-existent file to force this command to run every time, since currently there's no way to get a full input/output list from the flutter tool. set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ${PHONY_OUTPUT} COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" ${FLUTTER_TARGET_PLATFORM} $ VERBATIM ) ``` -------------------------------- ### Link Libraries and Include Directories (CMake) Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/windows/runner/CMakeLists.txt Specifies the libraries and include directories that the application target depends on. This includes Flutter-specific libraries, wrapper libraries, and system libraries like dwmapi.lib. ```cmake target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Initialize SentrySupabaseClient in Dart Source: https://github.com/getsentry/sentry-dart/blob/main/packages/supabase/README.md This code snippet demonstrates how to initialize the SentrySupabaseClient and use it with Supabase.initialize. This ensures that all Supabase operations are automatically instrumented with Sentry. ```dart import 'package:supabase_flutter/supabase_flutter.dart'; import 'package:sentry_supabase/sentry_supabase.dart'; // Create a [SentrySupabaseClient] and pass it to Supabase during initialization. final sentrySupabaseClient = SentrySupabaseClient(); await Supabase.initialize( url: '', anonKey: '', httpClient: sentrySupabaseClient, ); // Now all [Supabase] operations and queries will // be instrumented with Sentry breadcrumbs, traces and errors. final issues = await Supabase.instance.client .from('issues') .select(); ``` -------------------------------- ### Import _sentry_testing in tests Source: https://github.com/getsentry/sentry-dart/blob/main/packages/_sentry_testing/README.md Import the package in your test files to access its utilities. ```dart import 'package:_sentry_testing/_sentry_testing.dart'; ``` -------------------------------- ### CMake Project and Build Configuration Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/windows/CMakeLists.txt Initializes the CMake project, sets the binary name, and configures build types (Debug, Profile, Release) based on whether the generator is multi-config. It also sets up specific linker and compiler flags for the Profile build mode. ```cmake cmake_minimum_required(VERSION 3.14) project(microbenchmarks LANGUAGES CXX) set(BINARY_NAME "microbenchmarks") cmake_policy(VERSION 3.14...3.25) get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) else() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() endif() set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") ``` -------------------------------- ### Define Executable Target in CMake Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/example/windows/runner/CMakeLists.txt Defines the main executable target for the application. Ensure BINARY_NAME is consistent with the top-level CMakeLists.txt for `flutter run` compatibility. Add any new source files to this list. ```cmake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) # Define the application target. To change its name, change BINARY_NAME in the # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer # work. # # Any new source files that you add to the application should be added here. add_executable(${BINARY_NAME} WIN32 "flutter_window.cpp" "main.cpp" "utils.cpp" "win32_window.cpp" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" "Runner.rc" "runner.exe.manifest" ) # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) # Add preprocessor definitions for the build version. target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") # Disable Windows macros that collide with C++ standard library functions. target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") # Add dependency libraries and include directories. Add any application-specific # dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Add _sentry_testing as a dev dependency Source: https://github.com/getsentry/sentry-dart/blob/main/packages/_sentry_testing/README.md To use the internal testing utilities, add this package to your integration package's `dev_dependencies` in `pubspec.yaml`. ```yaml dev_dependencies: _sentry_testing: path: ../_sentry_testing ``` -------------------------------- ### Add Build Version Preprocessor Definitions (CMake) Source: https://github.com/getsentry/sentry-dart/blob/main/packages/flutter/microbenchmarks/windows/runner/CMakeLists.txt Adds preprocessor definitions to the compile command for the application target, embedding version information directly into the build. This allows the application to access version details at compile time. ```cmake target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"" target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") ``` -------------------------------- ### Improve Exception Reports for LinkExceptions (Dart) Source: https://github.com/getsentry/sentry-dart/blob/main/packages/link/README.md Shows how to enhance Sentry's exception reporting for `LinkException` and its subclasses by adding custom GQL extractors. This requires initializing Sentry with `addGqlExtractors()`. ```dart import 'package:sentry/sentry.dart'; Sentry.init((options) { options.addGqlExtractors(); }); ```