GoogleChromeLabs / bubblewrap

Bubblewrap is a Command Line Interface (CLI) that helps developers to create a Project for an Android application that launches an existing Progressive Web App (PWAs) using a Trusted Web Activity.
Apache License 2.0
2.33k stars 160 forks source link

Sentry integration #634

Open hadifarnoud opened 2 years ago

hadifarnoud commented 2 years ago

Is there a way to integrate Sentry into the TWA app generated?

sometimes the web app fails to load and I'd like to know why from browser side of TWA. I already have Sentry on my web app

PEConn commented 2 years ago

The app will mostly be running in the user's browser, and I don't think you can set up Sentry to get crash/debug info for the user's browser.

If there's something going wrong before the browser is launched, then you should be able to do that. We don't have a plugin for this, but you may be able to get it to work by modifying the generated project.

hadifarnoud commented 2 years ago

the app will have its own Sentry integration, the issue is every time I regenerate the app, the changes will be written over. If it's not that difficult, why not add Sentry to bubblewrap?

there are lots of issues that cannot be logged if there is no Sentry. Like ssl issue for example or anything that prevents the browser loading the app. I can't see what went wrong.

I did add sentry manually but the data I get is limited

PEConn commented 2 years ago

To be clear, I don't know how difficult this is going to be, I've never used Sentry. Could you share the changes you've been making manually to the app?

"I did add Sentry manually but the data I get is limited" - are you implying that if Sentry is added into bubblewrap (as opposed to being added manually after the project is generated) that you'll get better data?

hadifarnoud commented 2 years ago

Sorry I thought we did have it but it was our custom app that had Sentry. We have not managed to do this for Bubblewrap

6a616e commented 2 years ago

Adding sentry is pretty simple (https://docs.sentry.io/platforms/android/):

# app/build.gradle
repositories {
+    mavenCentral()
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.3.0'
+    implementation 'io.sentry:sentry-android:5.2.3'
}
# app\src\main\AndroidManifest.xml
<manifest>
    <application>
+      <meta-data
+          android:name="io.sentry.dsn"
+          android:value="YOUR_SENTRY_DSN" 
+      />
    </application>
</manifest>

This will log all erros that happen directly in the application. I don't know if it will log errors in the browser, probably it won't. I don't think the data will be better when added somewhere deeper.

hadifarnoud commented 2 years ago

Thank you.

This will log all erros that happen directly in the application. I don't know if it will log errors in the browser, probably it won't. I don't think the data will be better when added somewhere deeper.

I'm hoping to get connection errors in Sentry. if for any reason browser can't connect to the webapp, I can't get errors from sentry I put in my webapp. I thought I should explain why it is needed