-
-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Prepare for Android alpha + refactor the SDK to be used in conjunction with @sentry/angular #35
feat: Prepare for Android alpha + refactor the SDK to be used in conjunction with @sentry/angular #35
Changes from 10 commits
340729f
e36d1c5
d83d0a0
9d1cd1b
a34f025
3d5e98f
e713696
6848f2d
817bb22
0e2e69e
e5b3252
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"editor.formatOnType": true, | ||
"editor.formatOnPaste": false, | ||
"editor.formatOnSave": true, | ||
"editor.rulers": [ | ||
120 | ||
], | ||
"editor.tabSize": 2, | ||
"files.autoSave": "onWindowChange", | ||
"files.trimTrailingWhitespace": true, | ||
"files.insertFinalNewline": true, | ||
"search.exclude": { | ||
"**/node_modules/": true, | ||
"**/build/": true, | ||
"**/dist/": true | ||
}, | ||
"typescript.tsdk": "./node_modules/typescript/lib", | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll": true | ||
}, | ||
"[json]": { | ||
"editor.formatOnType": false, | ||
"editor.formatOnPaste": false, | ||
"editor.formatOnSave": false | ||
}, | ||
"react-native-tools.projectRoot": "./sample" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,14 +62,15 @@ public void startWithOptions(final PluginCall capOptions) { | |
SentryAndroid.init( | ||
this.getContext(), | ||
options -> { | ||
if (capOptions.getData().has("debug") && capOptions.getBoolean("debug")) { | ||
options.setDebug(true); | ||
logger.setLevel(Level.INFO); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We usually have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logger.setLevel(Level.INFO); is only within the |
||
} | ||
|
||
String dsn = capOptions.getString("dsn") != null ? capOptions.getString("dsn") : ""; | ||
logger.info(String.format("Starting with DSN: '%s'", dsn)); | ||
options.setDsn(dsn); | ||
|
||
if (capOptions.getData().has("debug")) { | ||
options.setDebug(capOptions.getBoolean("debug")); | ||
} | ||
|
||
if (capOptions.getData().has("environment") && capOptions.getString("environment") != null) { | ||
options.setEnvironment(capOptions.getString("environment")); | ||
} | ||
|
@@ -145,29 +146,6 @@ public void startWithOptions(final PluginCall capOptions) { | |
capOptions.resolve(resp); | ||
} | ||
|
||
@PluginMethod | ||
public void setLogLevel(PluginCall call) { | ||
int level = call.getInt("level", 2); | ||
try { | ||
logger.setLevel(this.logLevel(level)); | ||
} catch (Exception ex) { | ||
ex.printStackTrace(); | ||
} | ||
} | ||
|
||
private Level logLevel(int level) { | ||
switch (level) { | ||
case 1: | ||
return Level.SEVERE; | ||
case 2: | ||
return Level.INFO; | ||
case 3: | ||
return Level.ALL; | ||
default: | ||
return Level.OFF; | ||
} | ||
} | ||
|
||
@PluginMethod | ||
public void setUser(PluginCall call) { | ||
Sentry.configureScope(scope -> { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,9 @@ | |
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
android:theme="@style/AppTheme" | ||
android:usesCleartextTraffic="true"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its a sample so it does not matter but are we calling an HTTP endpoint instead of HTTPS? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I had to add this to get the capacitor dev server to work |
||
|
||
|
||
<activity | ||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { NgModule, ErrorHandler } from '@angular/core'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { RouteReuseStrategy } from '@angular/router'; | ||
|
||
|
@@ -7,30 +7,54 @@ import { SplashScreen } from '@ionic-native/splash-screen/ngx'; | |
import { StatusBar } from '@ionic-native/status-bar/ngx'; | ||
|
||
import * as Sentry from '@sentry/capacitor'; | ||
import { init as sentryAngularInit, createErrorHandler } from '@sentry/angular'; | ||
import { Integrations } from '@sentry/tracing'; | ||
|
||
import { AppRoutingModule } from './app-routing.module'; | ||
import { AppComponent } from './app.component'; | ||
|
||
// ATTENTION: Change the DSN below with your own to see the events in Sentry. Get one at sentry.io | ||
Sentry.init({ | ||
dsn: | ||
'https://[email protected]/5522756', | ||
// An array of strings or regexps that'll be used to ignore specific errors based on their type/message | ||
ignoreErrors: [/MiddleEarth_\d\d/, 'RangeError'], | ||
// Debug mode with valuable initialization/lifecycle information | ||
debug: true, | ||
// Whether SDK should be enabled or not | ||
enabled: true, | ||
integrations: [new Integrations.BrowserTracing()], | ||
// A release identifier | ||
release: '1537345109360', | ||
// An environment identifier | ||
environment: 'staging', | ||
// We recommend adjusting this value in production, or using tracesSampler | ||
// for finer control | ||
tracesSampleRate: 1.0, | ||
}); | ||
Sentry.init( | ||
{ | ||
dsn: | ||
'https://[email protected]/5522756', | ||
// An array of strings or regexps that'll be used to ignore specific errors based on their type/message | ||
ignoreErrors: [/MiddleEarth_\d\d/, 'RangeError'], | ||
// Debug mode with valuable initialization/lifecycle information | ||
debug: true, | ||
// Whether SDK should be enabled or not | ||
enabled: true, | ||
integrations: [new Integrations.BrowserTracing()], | ||
// A release identifier | ||
release: '1.0.0', | ||
dist: "1.0.0.1", | ||
// An environment identifier | ||
environment: 'staging', | ||
// We recommend adjusting this value in production, or using tracesSampler | ||
// for finer control | ||
tracesSampleRate: 1.0, | ||
}, | ||
sentryAngularInit, | ||
); | ||
|
||
// /** | ||
// * Wrap the ionic error handler with this method so Sentry catches unhandled errors on ionic. | ||
// * See the documentation for more details. | ||
// */ | ||
// const withSentryIonicErrorHandler = <C extends new (...args: any[]) => any>( | ||
// IonicErrorHandler: C, | ||
// ): C => { | ||
// class SentryIonicErrorHandler extends IonicErrorHandler { | ||
// handleError(error: any) { | ||
// super.handleError(error); | ||
// Sentry.captureException(error.originalError ?? error); | ||
// } | ||
// } | ||
|
||
// return SentryIonicErrorHandler; | ||
// }; | ||
|
||
// const SentryIonicErrorHandler = withSentryIonicErrorHandler(ErrorHandler); | ||
jennmueng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
@NgModule({ | ||
declarations: [AppComponent], | ||
|
@@ -39,8 +63,12 @@ Sentry.init({ | |
providers: [ | ||
StatusBar, | ||
SplashScreen, | ||
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy } | ||
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }, | ||
{ | ||
provide: ErrorHandler, | ||
useValue: createErrorHandler(), | ||
}, | ||
], | ||
bootstrap: [AppComponent] | ||
bootstrap: [AppComponent], | ||
}) | ||
export class AppModule {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
<ion-header [translucent]="true"> | ||
<ion-toolbar> | ||
<ion-title> | ||
Tab 3 | ||
</ion-title> | ||
<ion-title> Crashes </ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
|
||
<ion-content [fullscreen]="true"> | ||
<ion-header collapse="condense"> | ||
<ion-toolbar> | ||
<ion-title size="large">Tab 3</ion-title> | ||
<ion-title size="large">Crashes</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
|
||
<section class="button-container"> | ||
<label> | ||
Native Crash | ||
<ion-button (click)="nativeCrash()" | ||
>Crash</ion-button | ||
> | ||
</label> | ||
|
||
</section> | ||
</ion-content> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
import * as Sentry from '@sentry/capacitor'; | ||
|
||
@Component({ | ||
selector: 'app-tab3', | ||
templateUrl: 'tab3.page.html', | ||
styleUrls: ['tab3.page.scss'] | ||
styleUrls: ['tab3.page.scss'], | ||
}) | ||
export class Tab3Page { | ||
|
||
constructor() {} | ||
|
||
public nativeCrash(): void { | ||
Sentry.nativeCrash(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
side note: bump the Android SDK to the latest GA, 5.0.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, after this PR I'll make one to bump Android and another to bump JS