Skip to content

Commit

Permalink
feat: integrate sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
inpt333 authored and borgoat committed Jan 1, 2025
1 parent d1cf6d2 commit 1791561
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,9 @@ jobs:
status: completed
mappingFile: build/app/outputs/mapping/release/mapping.txt
debugSymbols: build/app/intermediates/merged_native_libs/release/mergeReleaseNativeLibs/out/lib

- name: Upload to Sentry
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
run: |
dart run sentry_dart_plugin
13 changes: 13 additions & 0 deletions ios/ci_scripts/ci_post_xcodebuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

# Fail this script if any subcommand fails.
set -e

# The default execution directory of this script is the ci_scripts directory.
cd $CI_PRIMARY_REPOSITORY_PATH # change working directory to the root of your cloned repo.

# Run Sentry dart plugin.
dart run sentry_dart_plugin

exit 0

8 changes: 3 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ Future<void> main() async {
yield LicenseEntryWithLineBreaks(['google_fonts'], license);
});

// Initialize analytics
await initAnalytics();
// Initialize PostHog
await initPostHog();

final configService = ConfigService();
await configService.initialize();
Expand All @@ -64,9 +64,7 @@ Future<void> main() async {
.uriLinkStream
.listen((uri) => store.dispatch(HandleDeeplinkAction(uri.path)));

runApp(
ParApp(store: store),
);
initSentry(() => runApp(ParApp(store: store)));
}

Future<Store<AppState>> _initStore(SupabaseClient supabase) async {
Expand Down
16 changes: 15 additions & 1 deletion lib/util/analytics.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'package:posthog_flutter/posthog_flutter.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

/// Initialize PostHog
Future<void> initAnalytics() async {
Future<void> initPostHog() async {
final config =
PostHogConfig('phc_maDGNEUn4Xpo0Nys1jNI2GnZjEQTVD2IIymbcRxBPta');
config.host = 'https://eu.i.posthog.com';
Expand All @@ -10,3 +11,16 @@ Future<void> initAnalytics() async {
final posthog = Posthog();
await posthog.setup(config);
}

/// Initialize Sentry
Future<void> initSentry(AppRunner? appRunner) async {
await SentryFlutter.init(
(options) {
options.dsn =
'https://1b0aa021dcaeef223fe5ee6105969fe4@o4508562988597248.ingest.de.sentry.io/4508562990039120';
options.tracesSampleRate = 0.5;
options.profilesSampleRate = 0.5;
},
appRunner: appRunner,
);
}
4 changes: 4 additions & 0 deletions linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <file_selector_linux/file_selector_plugin.h>
#include <gtk/gtk_plugin.h>
#include <sentry_flutter/sentry_flutter_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>

void fl_register_plugins(FlPluginRegistry* registry) {
Expand All @@ -17,6 +18,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) gtk_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "GtkPlugin");
gtk_plugin_register_with_registrar(gtk_registrar);
g_autoptr(FlPluginRegistrar) sentry_flutter_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "SentryFlutterPlugin");
sentry_flutter_plugin_register_with_registrar(sentry_flutter_registrar);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
Expand Down
1 change: 1 addition & 0 deletions linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
file_selector_linux
gtk
sentry_flutter
url_launcher_linux
)

Expand Down
4 changes: 4 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import Foundation
import app_links
import file_selector_macos
import google_sign_in_ios
import package_info_plus
import path_provider_foundation
import posthog_flutter
import sentry_flutter
import share_plus
import shared_preferences_foundation
import sign_in_with_apple
Expand All @@ -19,8 +21,10 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AppLinksMacosPlugin.register(with: registry.registrar(forPlugin: "AppLinksMacosPlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
FLTGoogleSignInPlugin.register(with: registry.registrar(forPlugin: "FLTGoogleSignInPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
PosthogFlutterPlugin.register(with: registry.registrar(forPlugin: "PosthogFlutterPlugin"))
SentryFlutterPlugin.register(with: registry.registrar(forPlugin: "SentryFlutterPlugin"))
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
SignInWithApplePlugin.register(with: registry.registrar(forPlugin: "SignInWithApplePlugin"))
Expand Down
72 changes: 72 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.2"
globbing:
dependency: transitive
description:
name: globbing
sha256: "4f89cfaf6fa74c9c1740a96259da06bd45411ede56744e28017cc534a12b6e2d"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
go_router:
dependency: "direct main"
description:
Expand Down Expand Up @@ -772,6 +780,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.2.1+1"
injector:
dependency: transitive
description:
name: injector
sha256: ed389bed5b48a699d5b9561c985023d0d5cc88dd5ff2237aadcce5a5ab433e4e
url: "https://pub.dev"
source: hosted
version: "3.0.0"
inspector:
dependency: transitive
description:
Expand Down Expand Up @@ -953,6 +969,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.1"
package_info_plus:
dependency: transitive
description:
name: package_info_plus
sha256: "70c421fe9d9cc1a9a7f3b05ae56befd469fe4f8daa3b484823141a55442d858d"
url: "https://pub.dev"
source: hosted
version: "8.1.2"
package_info_plus_platform_interface:
dependency: transitive
description:
name: package_info_plus_platform_interface
sha256: a5ef9986efc7bf772f2696183a3992615baa76c1ffb1189318dd8803778fb05b
url: "https://pub.dev"
source: hosted
version: "3.0.2"
path:
dependency: transitive
description:
Expand Down Expand Up @@ -1097,6 +1129,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.0.2"
properties:
dependency: transitive
description:
name: properties
sha256: "333f427dd4ed07bdbe8c75b9ff864a1e70b5d7a8426a2e8bdd457b65ae5ac598"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
pub_semver:
dependency: transitive
description:
Expand Down Expand Up @@ -1217,6 +1257,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.27.7"
sentry:
dependency: transitive
description:
name: sentry
sha256: "576ad83415102ba2060142a6701611abc6e67a55af1d7ab339cedd3ba1b0f84c"
url: "https://pub.dev"
source: hosted
version: "8.12.0"
sentry_dart_plugin:
dependency: "direct dev"
description:
name: sentry_dart_plugin
sha256: "14c298de1be3ba3a6a16d9ce0aad8662b14ca6ed85b8ade234f75b2f3c285edf"
url: "https://pub.dev"
source: hosted
version: "2.2.1"
sentry_flutter:
dependency: "direct main"
description:
name: sentry_flutter
sha256: dc3761e8659839cc67a18432d9f12e5531affb7ff68e196dbb56846909b5dfdc
url: "https://pub.dev"
source: hosted
version: "8.12.0"
share_plus:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1487,6 +1551,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.3.0+3"
system_info2:
dependency: transitive
description:
name: system_info2
sha256: "65206bbef475217008b5827374767550a5420ce70a04d2d7e94d1d2253f3efc9"
url: "https://pub.dev"
source: hosted
version: "4.0.0"
term_glyph:
dependency: transitive
description:
Expand Down
16 changes: 14 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ dependencies:
mime: ^1.0.4
memoized: ^2.2.6
posthog_flutter: ^4.9.0
universal_html: ^2.2.4
uuid: ^4.1.0
sentry_flutter: ^8.12.0
share_plus: ^10.1.2
styled_text: ^8.1.0
universal_html: ^2.2.4
uuid: ^4.1.0


dev_dependencies:
Expand Down Expand Up @@ -123,6 +124,7 @@ dev_dependencies:

# Utilities
flutter_launcher_icons: ^0.14.1
sentry_dart_plugin: ^2.2.1

# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
Expand Down Expand Up @@ -183,3 +185,13 @@ flutter:
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages

sentry:
upload_debug_symbols: true
upload_source_maps: true
upload_sources: true
project: flutter
org: sealambda
log_level: error
commits: auto
ignore_missing: true
3 changes: 3 additions & 0 deletions windows/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <app_links/app_links_plugin_c_api.h>
#include <file_selector_windows/file_selector_windows.h>
#include <sentry_flutter/sentry_flutter_plugin.h>
#include <share_plus/share_plus_windows_plugin_c_api.h>
#include <url_launcher_windows/url_launcher_windows.h>

Expand All @@ -16,6 +17,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("AppLinksPluginCApi"));
FileSelectorWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FileSelectorWindows"));
SentryFlutterPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("SentryFlutterPlugin"));
SharePlusWindowsPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi"));
UrlLauncherWindowsRegisterWithRegistrar(
Expand Down
1 change: 1 addition & 0 deletions windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
list(APPEND FLUTTER_PLUGIN_LIST
app_links
file_selector_windows
sentry_flutter
share_plus
url_launcher_windows
)
Expand Down

0 comments on commit 1791561

Please sign in to comment.