feat: integrate Microsoft Clarity for mobile session recording and heatmaps

This commit is contained in:
pradeepkumar
2026-04-24 23:44:34 +05:30
parent 0f49b21f33
commit f18b35d1a3
7 changed files with 95 additions and 1 deletions

View File

@@ -0,0 +1,14 @@
import 'package:clarity_flutter/clarity_flutter.dart';
/// Microsoft Clarity configuration — separate mobile project so recordings
/// and heatmaps are isolated from web traffic.
class ClarityAnalytics {
ClarityAnalytics._();
static const _projectId = 'wgtcstm336';
static final ClarityConfig config = ClarityConfig(
projectId: _projectId,
logLevel: LogLevel.None,
);
}

View File

@@ -1,8 +1,10 @@
import 'package:clarity_flutter/clarity_flutter.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:real_estate_mobile/config/app_config.dart';
import 'package:real_estate_mobile/config/firebase_config.dart';
import 'package:real_estate_mobile/core/analytics/clarity_analytics.dart';
import 'package:real_estate_mobile/core/theme/app_theme.dart';
import 'package:real_estate_mobile/core/utils/image_url_resolver.dart';
import 'package:real_estate_mobile/routing/app_router.dart';
@@ -20,7 +22,12 @@ Future<void> mainCommon(Flavor flavor) async {
// forces every image to re-download, causing visible delay on all screens.
ImageUrlResolver.instance.clearCache();
runApp(const ProviderScope(child: MyApp()));
runApp(
ClarityWidget(
clarityConfig: ClarityAnalytics.config,
app: const ProviderScope(child: MyApp()),
),
);
}
class MyApp extends ConsumerWidget {

View File

@@ -5,6 +5,7 @@
import FlutterMacOS
import Foundation
import connectivity_plus
import device_info_plus
import emoji_picker_flutter
import facebook_auth_desktop
@@ -23,6 +24,7 @@ import url_launcher_macos
import webview_flutter_wkwebview
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
EmojiPickerFlutterPlugin.register(with: registry.registrar(forPlugin: "EmojiPickerFlutterPlugin"))
FacebookAuthDesktopPlugin.register(with: registry.registrar(forPlugin: "FacebookAuthDesktopPlugin"))

View File

@@ -169,6 +169,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.4"
clarity_flutter:
dependency: "direct main"
description:
name: clarity_flutter
sha256: "06b15ed56b1a738e47d6a6a1fb9d812ac9ffecec6ef8fe4893bbd3149f442084"
url: "https://pub.dev"
source: hosted
version: "1.8.0"
cli_util:
dependency: transitive
description:
@@ -201,6 +209,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.19.1"
connectivity_plus:
dependency: transitive
description:
name: connectivity_plus
sha256: "62ffa266d9a23b79fb3fcbc206afc00bb979417ba57b1324c546b5aab95ba057"
url: "https://pub.dev"
source: hosted
version: "7.1.1"
connectivity_plus_platform_interface:
dependency: transitive
description:
name: connectivity_plus_platform_interface
sha256: "3c09627c536d22fd24691a905cdd8b14520de69da52c7a97499c8be5284a32ed"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
convert:
dependency: transitive
description:
@@ -912,6 +936,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.13.0"
memory_info:
dependency: transitive
description:
name: memory_info
sha256: "2d2150e070e1ceeb44d9ac3edad3d03d19022c4e0a4ddb08a3f8a494fc41d1c4"
url: "https://pub.dev"
source: hosted
version: "0.0.4"
memory_info_platform_interface:
dependency: transitive
description:
name: memory_info_platform_interface
sha256: "07c5ad0625f9810fb378fabd69a38c19a800865e11433e767804ff9bd84796db"
url: "https://pub.dev"
source: hosted
version: "0.0.2"
meta:
dependency: transitive
description:
@@ -928,6 +968,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.0"
nm:
dependency: transitive
description:
name: nm
sha256: "2c9aae4127bdc8993206464fcc063611e0e36e72018696cd9631023a31b24254"
url: "https://pub.dev"
source: hosted
version: "0.5.0"
octo_image:
dependency: transitive
description:
@@ -1072,6 +1120,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.5.0"
protobuf:
dependency: transitive
description:
name: protobuf
sha256: "75ec242d22e950bdcc79ee38dd520ce4ee0bc491d7fadc4ea47694604d22bf06"
url: "https://pub.dev"
source: hosted
version: "6.0.0"
pub_semver:
dependency: transitive
description:
@@ -1621,6 +1677,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.6.1"
xxh3:
dependency: transitive
description:
name: xxh3
sha256: "399a0438f5d426785723c99da6b16e136f4953fb1e9db0bf270bd41dd4619916"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
yaml:
dependency: transitive
description:

View File

@@ -68,6 +68,9 @@ dependencies:
# Analytics (Umami)
flutter_estatisticas: ^0.2.2
# Microsoft Clarity (session recording / heatmaps)
clarity_flutter: ^1.8.0
dev_dependencies:
flutter_test:
sdk: flutter

View File

@@ -6,6 +6,7 @@
#include "generated_plugin_registrant.h"
#include <connectivity_plus/connectivity_plus_windows_plugin.h>
#include <emoji_picker_flutter/emoji_picker_flutter_plugin_c_api.h>
#include <file_selector_windows/file_selector_windows.h>
#include <firebase_core/firebase_core_plugin_c_api.h>
@@ -14,6 +15,8 @@
#include <url_launcher_windows/url_launcher_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
ConnectivityPlusWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
EmojiPickerFlutterPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("EmojiPickerFlutterPluginCApi"));
FileSelectorWindowsRegisterWithRegistrar(

View File

@@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
connectivity_plus
emoji_picker_flutter
file_selector_windows
firebase_core