From ab4065cd0dc34f65937a6c0c9023b3c3f52182fb Mon Sep 17 00:00:00 2001 From: LucasZF Date: Mon, 30 May 2022 15:46:24 -0300 Subject: [PATCH 1/9] Update Ionic Wizard --- src/wizard/ionic/index.md | 48 +++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/src/wizard/ionic/index.md b/src/wizard/ionic/index.md index 703ceb6266037..5dce064c8d724 100644 --- a/src/wizard/ionic/index.md +++ b/src/wizard/ionic/index.md @@ -36,9 +36,13 @@ public class MainActivity extends BridgeActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Initializes the Bridge - this.init(savedInstanceState, new ArrayList>() {{ - add(SentryCapacitor.class); - }}); + // Capacitor 3 + registerPlugin(SentryCapacitor.class); + + // Capacitor 2 + // this.init(savedInstanceState, new ArrayList>() {{ + // add(SentryCapacitor.class); + // }}); } } ``` @@ -52,13 +56,17 @@ import com.getcapacitor.Plugin import io.sentry.capacitor.SentryCapacitor class MainActivity : BridgeActivity() { - fun onCreate(savedInstanceState: Bundle?) { + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // Initializes the Bridge - this.init( - savedInstanceState, - listOf>(SentryCapacitor::class.java) - ) + // Capacitor 3 + registerPlugin(SentryCapacitor::class.java) + + // Capacitor 2 + // this.init( + // savedInstanceState, + // listOf>(SentryCapacitor::class.java) + // ) } } ``` @@ -68,24 +76,24 @@ class MainActivity : BridgeActivity() { You must initialize the Sentry SDK as early as you can: ```javascript -import * as Sentry from "@sentry/capacitor"; -// The example is using Angular, Import "@sentry/vue" or "@sentry/react" when using a Sibling different than Angular. -import * as SentrySibling from "@sentry/angular"; +import * as Sentry from '@sentry/capacitor'; +// The example is using Angular, Import '@sentry/vue' or '@sentry/react' when using a Sibling different than Angular. +import * as SentrySibling from '@sentry/angular'; // For automatic instrumentation (highly recommended) -import { BrowserTracing } from "@sentry/tracing"; +import { BrowserTracing } from '@sentry/tracing'; Sentry.init( { - dsn: "___PUBLIC_DSN___", + dsn: '___PUBLIC_DSN___', // To set your release and dist versions - release: "my-project-name@" + process.env.npm_package_version, - dist: "1", + release: 'my-project-name@' + process.env.npm_package_version, + dist: '1', // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. // We recommend adjusting this value in production. tracesSampleRate: 1.0, integrations: [ new BrowserTracing({ - tracingOrigins: ["localhost", "https://yourserver.io/api"], + tracingOrigins: ['localhost', 'https://yourserver.io/api'], }), ] }, @@ -113,22 +121,22 @@ Additionally for Angular, you will also need to alter NgModule (same code doesn' This snippet includes an intentional error, so you can test that everything is working as soon as you set it up: ```javascript -import * as Sentry from "@sentry/capacitor"; +import * as Sentry from '@sentry/capacitor'; -Sentry.captureException("Test Captured Exception"); +Sentry.captureException('Test Captured Exception'); ``` You can also throw an error anywhere in your application: ```javascript // Must be thrown after Sentry.init is called to be captured. -throw new Error(`Test Thrown Error`); +throw new Error('Test Thrown Error'); ``` Or trigger a native crash: ```javascript -import * as Sentry from "@sentry/capacitor"; +import * as Sentry from '@sentry/capacitor'; Sentry.nativeCrash(); ``` From 2eb162a3c76efe08aa3fc4a5eb18f03c11631294 Mon Sep 17 00:00:00 2001 From: LucasZF Date: Mon, 30 May 2022 15:47:09 -0300 Subject: [PATCH 2/9] Update Capacitor Wizard --- src/wizard/capacitor/index.md | 56 ++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/src/wizard/capacitor/index.md b/src/wizard/capacitor/index.md index f7303b7aae39c..646992d9eff27 100644 --- a/src/wizard/capacitor/index.md +++ b/src/wizard/capacitor/index.md @@ -43,9 +43,13 @@ public class MainActivity extends BridgeActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Initializes the Bridge - this.init(savedInstanceState, new ArrayList>() {{ - add(SentryCapacitor.class); - }}); + // Capacitor 3 + registerPlugin(SentryCapacitor.class); + + // Capacitor 2 + // this.init(savedInstanceState, new ArrayList>() {{ + // add(SentryCapacitor.class); + // }}); } } ``` @@ -59,13 +63,17 @@ import com.getcapacitor.Plugin import io.sentry.capacitor.SentryCapacitor class MainActivity : BridgeActivity() { - fun onCreate(savedInstanceState: Bundle?) { + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // Initializes the Bridge - this.init( - savedInstanceState, - listOf>(SentryCapacitor::class.java) - ) + // Capacitor 3 + registerPlugin(SentryCapacitor::class.java) + + // Capacitor 2 + // this.init( + // savedInstanceState, + // listOf>(SentryCapacitor::class.java) + // ) } } ``` @@ -78,26 +86,26 @@ With Ionic/Angular: ```typescript // app.module.ts -import * as Sentry from "@sentry/capacitor"; -import * as SentryAngular from "@sentry/angular"; +import * as Sentry from '@sentry/capacitor'; +import * as SentryAngular from '@sentry/angular'; // If taking advantage of automatic instrumentation (highly recommended) -import { BrowserTracing } from "@sentry/tracing"; +import { BrowserTracing } from '@sentry/tracing'; // Or, if only manually tracing // import "@sentry/tracing"; // Note: You MUST import the package in some way for tracing to work Sentry.init( { - dsn: "___PUBLIC_DSN___", + dsn: '___PUBLIC_DSN___', // To set your release and dist versions - release: "my-project-name@" + process.env.npm_package_version, - dist: "1", + release: 'my-project-name@' + process.env.npm_package_version, + dist: '1', // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. // We recommend adjusting this value in production. tracesSampleRate: 1.0, integrations: [ new BrowserTracing({ - tracingOrigins: ["localhost", "https://yourserver.io/api"], + tracingOrigins: ['localhost', 'https://yourserver.io/api'], }), ] }, @@ -120,15 +128,15 @@ Standalone: ```javascript // App.js -import * as Sentry from "@sentry/capacitor"; +import * as Sentry from '@sentry/capacitor'; Sentry.init({ - dsn: "___PUBLIC_DSN___", + dsn: '___PUBLIC_DSN___', - // Set your release version, such as "getsentry@1.0.0" - release: "my-project-name@", + // Set your release version, such as 'getsentry@1.0.0' + release: 'my-project-name@', // Set your dist version, such as "1" - dist: "", + dist: '', }); ``` @@ -137,22 +145,22 @@ Sentry.init({ This snippet includes an intentional error, so you can test that everything is working as soon as you set it up: ```javascript -import * as Sentry from "@sentry/capacitor"; +import * as Sentry from '@sentry/capacitor'; -Sentry.captureException("Test Captured Exception"); +Sentry.captureException('Test Captured Exception'); ``` You can also throw an error anywhere in your application: ```javascript // Must be thrown after Sentry.init is called to be captured. -throw new Error(`Test Thrown Error`); +throw new Error('Test Thrown Error'); ``` Or trigger a native crash: ```javascript -import * as Sentry from "@sentry/capacitor"; +import * as Sentry from '@sentry/capacitor'; Sentry.nativeCrash(); ``` From 262acde220e8459daa6e22d88c24ce9ef2c75cea Mon Sep 17 00:00:00 2001 From: LucasZF Date: Mon, 30 May 2022 15:47:38 -0300 Subject: [PATCH 3/9] Update Cordova Wizard --- src/wizard/cordova/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wizard/cordova/index.md b/src/wizard/cordova/index.md index 5878620fa5ecc..62a41938feed7 100644 --- a/src/wizard/cordova/index.md +++ b/src/wizard/cordova/index.md @@ -15,7 +15,7 @@ You should `init` the SDK in the `deviceReady` function, to make sure the native ```javascript onDeviceReady: function() { - var Sentry = cordova.require("sentry-cordova.Sentry"); + var Sentry = cordova.require('sentry-cordova.Sentry'); Sentry.init({ dsn: '___PUBLIC_DSN___' }); } ``` From e4aec17f98a681d30a00950d4c0b8fe0cbf2c529 Mon Sep 17 00:00:00 2001 From: LucasZF Date: Wed, 1 Jun 2022 11:56:41 -0300 Subject: [PATCH 4/9] update capacitor wizard --- src/wizard/capacitor/index.md | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/wizard/capacitor/index.md b/src/wizard/capacitor/index.md index 646992d9eff27..0d0fb77bbf589 100644 --- a/src/wizard/capacitor/index.md +++ b/src/wizard/capacitor/index.md @@ -25,7 +25,11 @@ npm install --save @sentry/capacitor @sentry/tracing yarn add @sentry/capacitor ``` -## Android Installation +## Capacitor 2 - Android Installation + + + This step is not needed if you are using Capacitor 3 + Then, add the `SentryCapacitor` plugin class inside the `onCreate` method of your `MainActivity` file. @@ -43,13 +47,9 @@ public class MainActivity extends BridgeActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Initializes the Bridge - // Capacitor 3 - registerPlugin(SentryCapacitor.class); - - // Capacitor 2 - // this.init(savedInstanceState, new ArrayList>() {{ - // add(SentryCapacitor.class); - // }}); + this.init(savedInstanceState, new ArrayList>() {{ + add(SentryCapacitor.class); + }}); } } ``` @@ -66,14 +66,10 @@ class MainActivity : BridgeActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // Initializes the Bridge - // Capacitor 3 - registerPlugin(SentryCapacitor::class.java) - - // Capacitor 2 - // this.init( - // savedInstanceState, - // listOf>(SentryCapacitor::class.java) - // ) + this.init( + savedInstanceState, + listOf>(SentryCapacitor::class.java) + ) } } ``` From dddc0639d7288420a695d53c24fe7bb301a4f8c9 Mon Sep 17 00:00:00 2001 From: LucasZF Date: Wed, 1 Jun 2022 11:57:26 -0300 Subject: [PATCH 5/9] Update ionic wizard --- src/wizard/ionic/index.md | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/wizard/ionic/index.md b/src/wizard/ionic/index.md index 5dce064c8d724..bcd1ecfcc0ffe 100644 --- a/src/wizard/ionic/index.md +++ b/src/wizard/ionic/index.md @@ -18,7 +18,11 @@ yarn add @sentry/capacitor @sentry/angular ``` The same installation process applies to the other siblings, all you need to do is to replace `@sentry/angular` by the desired sibling. -## Android Installation +## Capacitor 2 - Android Installation + + + This step is not needed if you are using Capacitor 3 + Then, add the `SentryCapacitor` plugin class inside the `onCreate` method of your `MainActivity` file. @@ -36,13 +40,9 @@ public class MainActivity extends BridgeActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Initializes the Bridge - // Capacitor 3 - registerPlugin(SentryCapacitor.class); - - // Capacitor 2 - // this.init(savedInstanceState, new ArrayList>() {{ - // add(SentryCapacitor.class); - // }}); + this.init(savedInstanceState, new ArrayList>() {{ + add(SentryCapacitor.class); + }}); } } ``` @@ -59,14 +59,10 @@ class MainActivity : BridgeActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // Initializes the Bridge - // Capacitor 3 - registerPlugin(SentryCapacitor::class.java) - - // Capacitor 2 - // this.init( - // savedInstanceState, - // listOf>(SentryCapacitor::class.java) - // ) + this.init( + savedInstanceState, + listOf>(SentryCapacitor::class.java) + ) } } ``` From d8513f28c476923078ec4bc76701229f08371851 Mon Sep 17 00:00:00 2001 From: LucasZF Date: Wed, 1 Jun 2022 11:58:23 -0300 Subject: [PATCH 6/9] update install steps on capacitor --- .../getting-started-install/javascript.capacitor.mdx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/includes/getting-started-install/javascript.capacitor.mdx b/src/includes/getting-started-install/javascript.capacitor.mdx index 68bf195f9f4f0..41a8c2d2edff5 100644 --- a/src/includes/getting-started-install/javascript.capacitor.mdx +++ b/src/includes/getting-started-install/javascript.capacitor.mdx @@ -16,7 +16,11 @@ npm install --save @sentry/capacitor yarn add @sentry/capacitor ``` -### Android Specifics +### Capacitor 2 - Android Specifics + + + This step is not needed if you are using Capacitor 3 + Add the plugin declaration to your `MainActivity.java` file From dc04e625db87fcbdab9923d46c729c641cdaedba Mon Sep 17 00:00:00 2001 From: LucasZF Date: Wed, 1 Jun 2022 11:59:19 -0300 Subject: [PATCH 7/9] Update troubleshooting.mdx --- .../guides/capacitor/troubleshooting.mdx | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/platforms/javascript/guides/capacitor/troubleshooting.mdx b/src/platforms/javascript/guides/capacitor/troubleshooting.mdx index ade71a82d6730..fdb2fef4854aa 100644 --- a/src/platforms/javascript/guides/capacitor/troubleshooting.mdx +++ b/src/platforms/javascript/guides/capacitor/troubleshooting.mdx @@ -27,3 +27,28 @@ Then update your iOS settings: ```bash npx cap sync ``` + +## Capacitor on Android + +### No events sent + +Check if you added SentryCapacitor to the bridge, this step is required for Capacitor 2 and optional on Capacitor 3 (It's only required if you are initializing other plugins using the old method, if so, prefer to use registerPlugin instead of the deprecated code for initializing plugins.) + +```Java +import io.sentry.capacitor.SentryCapacitor; + +public class MainActivity extends BridgeActivity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Capacitor 3 + registerPlugin(SentryCapacitor.class); + + // Capacitor 2 + this.init(savedInstanceState, new ArrayList>() {{ + add(SentryCapacitor.class); + }}); + } +} +``` From 54d9ea8230b57b35f5a46ae0714779f30c7a6530 Mon Sep 17 00:00:00 2001 From: LucasZF Date: Thu, 2 Jun 2022 11:03:32 -0300 Subject: [PATCH 8/9] Apply suggestions from code review Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com> --- src/includes/getting-started-install/javascript.capacitor.mdx | 2 ++ src/platforms/javascript/guides/capacitor/troubleshooting.mdx | 2 +- src/wizard/capacitor/index.md | 2 ++ src/wizard/ionic/index.md | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/includes/getting-started-install/javascript.capacitor.mdx b/src/includes/getting-started-install/javascript.capacitor.mdx index 41a8c2d2edff5..f7ab6c7a657ee 100644 --- a/src/includes/getting-started-install/javascript.capacitor.mdx +++ b/src/includes/getting-started-install/javascript.capacitor.mdx @@ -19,7 +19,9 @@ yarn add @sentry/capacitor ### Capacitor 2 - Android Specifics + This step is not needed if you are using Capacitor 3 + Add the plugin declaration to your `MainActivity.java` file diff --git a/src/platforms/javascript/guides/capacitor/troubleshooting.mdx b/src/platforms/javascript/guides/capacitor/troubleshooting.mdx index fdb2fef4854aa..e480cc3cb0c85 100644 --- a/src/platforms/javascript/guides/capacitor/troubleshooting.mdx +++ b/src/platforms/javascript/guides/capacitor/troubleshooting.mdx @@ -32,7 +32,7 @@ npx cap sync ### No events sent -Check if you added SentryCapacitor to the bridge, this step is required for Capacitor 2 and optional on Capacitor 3 (It's only required if you are initializing other plugins using the old method, if so, prefer to use registerPlugin instead of the deprecated code for initializing plugins.) +Check if you added `SentryCapacitor` to the bridge. This step is required for Capacitor 2 and optional on Capacitor 3. (It's only required if you are initializing other plugins using the old method. If so, we recommend you use `registerPlugin` instead of the deprecated code for initializing plugins.) ```Java import io.sentry.capacitor.SentryCapacitor; diff --git a/src/wizard/capacitor/index.md b/src/wizard/capacitor/index.md index 0d0fb77bbf589..fecad1119c19f 100644 --- a/src/wizard/capacitor/index.md +++ b/src/wizard/capacitor/index.md @@ -28,7 +28,9 @@ yarn add @sentry/capacitor ## Capacitor 2 - Android Installation + This step is not needed if you are using Capacitor 3 + Then, add the `SentryCapacitor` plugin class inside the `onCreate` method of your `MainActivity` file. diff --git a/src/wizard/ionic/index.md b/src/wizard/ionic/index.md index bcd1ecfcc0ffe..552147335ad0b 100644 --- a/src/wizard/ionic/index.md +++ b/src/wizard/ionic/index.md @@ -21,7 +21,9 @@ The same installation process applies to the other siblings, all you need to do ## Capacitor 2 - Android Installation + This step is not needed if you are using Capacitor 3 + Then, add the `SentryCapacitor` plugin class inside the `onCreate` method of your `MainActivity` file. From f5b98fc7fa0d292bed605d8f48da9dbc3ed98caf Mon Sep 17 00:00:00 2001 From: LucasZF Date: Thu, 2 Jun 2022 12:26:50 -0300 Subject: [PATCH 9/9] Update src/platforms/javascript/guides/capacitor/troubleshooting.mdx --- src/platforms/javascript/guides/capacitor/troubleshooting.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/javascript/guides/capacitor/troubleshooting.mdx b/src/platforms/javascript/guides/capacitor/troubleshooting.mdx index e480cc3cb0c85..719af06a14059 100644 --- a/src/platforms/javascript/guides/capacitor/troubleshooting.mdx +++ b/src/platforms/javascript/guides/capacitor/troubleshooting.mdx @@ -34,7 +34,7 @@ npx cap sync Check if you added `SentryCapacitor` to the bridge. This step is required for Capacitor 2 and optional on Capacitor 3. (It's only required if you are initializing other plugins using the old method. If so, we recommend you use `registerPlugin` instead of the deprecated code for initializing plugins.) -```Java +```java import io.sentry.capacitor.SentryCapacitor; public class MainActivity extends BridgeActivity {