Skip to content
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

Prepare Samples for Sentry Javascript V8 #686

Merged
merged 18 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions example/ionic-angular-v3/angular.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"defaultProject": "app",
"newProjectRoot": "projects",
"projects": {
"app": {
Expand Down Expand Up @@ -171,7 +170,10 @@
}
},
"cli": {
"defaultCollection": "@ionic/angular-toolkit"
"schematicCollections": [
"@ionic/angular-toolkit"
],
"analytics": false
},
"schematics": {
"@ionic/angular-toolkit:component": {
Expand Down
12 changes: 0 additions & 12 deletions example/ionic-angular-v3/browserslist

This file was deleted.

24 changes: 12 additions & 12 deletions example/ionic-angular-v3/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"author": "Ionic Framework",
"dependencies": {
"@angular/common": "~13.3.0",
"@angular/core": "~13.3.0",
"@angular/forms": "~13.3.0",
"@angular/platform-browser": "~13.3.0",
"@angular/platform-browser-dynamic": "~13.3.0",
"@angular/router": "~13.3.0",
"@angular/common": "^14.3.0",
"@angular/core": "^14.3.0",
"@angular/forms": "^14.3.0",
"@angular/platform-browser": "^14.3.0",
"@angular/platform-browser-dynamic": "^14.3.0",
"@angular/router": "^14.3.0",
"@capacitor/android": "^3.9.0",
"@capacitor/core": "^3.9.0",
"@capacitor/ios": "^3.9.0",
"@ionic-native/core": "^5.0.0",
"@ionic-native/splash-screen": "^5.0.0",
"@ionic-native/status-bar": "^5.0.0",
"@ionic/angular": "^5.0.0",
"@ionic/angular": "6.7.5",
"@sentry/angular": "8.9.2",
"@sentry/capacitor": "file:.yalc/@sentry/capacitor",
"rxjs": "~6.5.5",
Expand All @@ -22,11 +22,11 @@
},
"description": "An Ionic project",
"devDependencies": {
"@angular-devkit/build-angular": "~13.3.0",
"@angular/cli": "~13.3.0",
"@angular/compiler": "~13.3.0",
"@angular/compiler-cli": "~13.3.0",
"@angular/language-service": "~13.3.0",
"@angular-devkit/build-angular": "^14.2.13",
"@angular/cli": "^14.2.13",
"@angular/compiler": "^14.3.0",
"@angular/compiler-cli": "^14.3.0",
"@angular/language-service": "^14.3.0",
"@capacitor/cli": "^3.9.0",
"@ionic/angular-toolkit": "^2.3.0",
"@ionic/cli": "^6.16.3",
Expand Down
38 changes: 22 additions & 16 deletions example/ionic-angular-v3/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ 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-ivy';
import { init as sentryAngularInit, createErrorHandler } from '@sentry/angular';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
Expand All @@ -24,7 +24,13 @@ Sentry.init(
// Whether SDK should be enabled or not
enabled: true,
// Use the tracing integration to see traces and add performance monitoring
integrations: [new Sentry.BrowserTracing()],
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration({
maskAllText: false,
blockAllMedia: true,
}),
],
// A release identifier
release: '1.0.0',
// A dist identifier
Expand All @@ -39,18 +45,18 @@ Sentry.init(
);

@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
providers: [
StatusBar,
SplashScreen,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
/* Provide the @sentry/angular error handler */
{
provide: ErrorHandler,
useValue: createErrorHandler(),
},
],
bootstrap: [AppComponent]
declarations: [AppComponent],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
providers: [
StatusBar,
SplashScreen,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
/* Provide the @sentry/angular error handler */
{
provide: ErrorHandler,
useValue: createErrorHandler(),
},
],
bootstrap: [AppComponent]
})
export class AppModule {}
export class AppModule { }
16 changes: 6 additions & 10 deletions example/ionic-angular-v3/src/app/tab1/tab1.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { SeverityLevel } from '@sentry/types';
styleUrls: ['tab1.page.scss'],
})
export class Tab1Page {
constructor() {}
constructor() { }

public throwUnhandledException(): void {
// @ts-ignore intentionally calling to demonstrate global error handling
Expand Down Expand Up @@ -126,20 +126,16 @@ export class Tab1Page {
}

public clearUser(): void {
Sentry.configureScope(scope => {
scope.setUser(null);
});
Sentry.setUser(null);
}

public clearBreadcrumbs(): void {
Sentry.configureScope(scope => {
scope.clearBreadcrumbs();
});
Sentry.getGlobalScope().clearBreadcrumbs();
Copy link
Member

@krystofwoldrich krystofwoldrich Jul 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

H: To keep the same behavior as in v7 we need to clear all the scopes. The global Sentry.addBreadcrumb uses isolationScope

Suggested change
Sentry.getGlobalScope().clearBreadcrumbs();
Sentry.getGlobalScope().clearBreadcrumbs();
Sentry.getIsolationScope().clearBreadcrumbs();
Sentry.getCurrentScope().clearBreadcrumbs();

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that was the code generated by the migration tool.
Ideally we should expose clearBreadcrumbs on the SDK and then it clears on all 3 scopes, what do you think?

Sentry.getIsolationScope().clearBreadcrumbs();
Sentry.getCurrentScope().clearBreadcrumbs();
}

public clearTestContext(): void {
Sentry.configureScope(scope => {
scope.setContext('TEST-CONTEXT', null);
});
Sentry.setContext('TEST-CONTEXT', null);
}
}
2 changes: 1 addition & 1 deletion example/ionic-angular-v3/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"target": "es2020",
"lib": [
"es2018",
"dom"
Expand Down
Loading
Loading