From f4d4ea3ac68dbbb1dadd3640ae1fc5cbaa0b2508 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois?= <francois.mockers@vleue.com>
Date: Fri, 26 Apr 2024 02:35:36 +0200
Subject: [PATCH] setup sentry in Bevy by default

---
 .github/workflows/workflow-native.yml |  8 ++++++++
 add_sentry.patch                      | 16 ++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 add_sentry.patch

diff --git a/.github/workflows/workflow-native.yml b/.github/workflows/workflow-native.yml
index 00086f82..3d8a3c3d 100644
--- a/.github/workflows/workflow-native.yml
+++ b/.github/workflows/workflow-native.yml
@@ -25,6 +25,8 @@ jobs:
   split-pages:
     name: Prepare pages
     runs-on: ubuntu-latest
+    env:
+      SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
     outputs:
       pages: ${{ steps.env.outputs.pages }}
     steps:
@@ -74,6 +76,12 @@ jobs:
       - name: Setup Rust
         uses: dtolnay/rust-toolchain@stable
 
+      - name: Setup Sentry Reporting
+        shell: pwsh
+        run: |
+          cargo add vleue_sentry --git https://github.com/vleue/vleue_sentry -p bevy_internal
+          git apply --ignore-whitespace add_sentry.patch
+
       - name: Install Bevy dependencies
         if: runner.os == 'linux'
         run: |
diff --git a/add_sentry.patch b/add_sentry.patch
new file mode 100644
index 00000000..144d625f
--- /dev/null
+++ b/add_sentry.patch
@@ -0,0 +1,16 @@
+diff --git a/crates/bevy_internal/src/default_plugins.rs b/crates/bevy_internal/src/default_plugins.rs
+index acfa89d0b6..516a16ca9c 100644
+--- a/crates/bevy_internal/src/default_plugins.rs
++++ b/crates/bevy_internal/src/default_plugins.rs
+@@ -44,7 +44,10 @@ impl PluginGroup for DefaultPlugins {
+         let mut group = PluginGroupBuilder::start::<Self>();
+         group = group
+             .add(bevy_app::PanicHandlerPlugin)
+-            .add(bevy_log::LogPlugin::default())
++            .add(bevy_log::LogPlugin {
++                update_subscriber: Some(vleue_sentry::sentry_error_reporter),
++                ..Default::default()
++            })
+             .add(bevy_core::TaskPoolPlugin::default())
+             .add(bevy_core::TypeRegistrationPlugin)
+             .add(bevy_core::FrameCountPlugin)