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 12 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
35 changes: 34 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# Changelog

## Unreleased
// MEMO: enableOutOfMemoryTracking removed and replaced by enableWatchdogTerminationTracking

> [!IMPORTANT]
> If you are upgrading to the `1.x` versions of the SDK from `0.x` or below, make sure you follow our
> [migration guide](https://docs.sentry.io/platforms/javascript/migration/v7-to-v8/#migration-codemod) first.

### Features

- Support for Angular 18 ([#675](https://github.com/getsentry/sentry-capacitor/pull/675))
- Add close function on `@sentry/capacitor` ([#664](https://github.com/getsentry/sentry-capacitor/pull/664))
- Expose `getClient` on `@sentry/capacitor` ([#664](https://github.com/getsentry/sentry-capacitor/pull/664))
- Add the following functions to `@sentry/capacitor` ([#666](https://github.com/getsentry/sentry-capacitor/pull/666))
Expand All @@ -15,6 +18,36 @@

- Accept undefined as value for tags ([#656](https://github.com/getsentry/sentry-capacitor/pull/656))

### Dependencies

- Bump JavaScript SDK from v7.114.0 to v8.9.2 ([#675](https://github.com/getsentry/sentry-capacitor/pull/675))
- [changelog](https://github.com/getsentry/sentry-javascript/blob/8.9.2/CHANGELOG.md)
- [diff](https://github.com/getsentry/sentry-javascript/compare/7.114.0...8.9.2)


### How to Upgrade to Version 1:

- Angular minimum supported version changed to version 14, upgrade to Angular 14 or higher for using the latest SDK.

- When using the package `@sentry/angular-ivy`, you will need to replace it by `@sentry/angular`.

- enableOutOfMemoryTracking was removed and replaced by enableWatchdogTerminationTracking.

- We recommend reading the
[migration guide docs](https://docs.sentry.io/platforms/javascript/migration/v7-to-v8/#migration-codemod) to find out
how to address any breaking changes in your code for your specific platform or framework.

To automate upgrading to v8 as much as possible, use our migration codemod `@sentry/migr8`:

```sh
npx @sentry/migr8@latest
```

All deprecations from the v7 cycle, with the exception of `getCurrentHub()`, have been removed and can no longer be used
in v8. If you have an advanced Sentry SDK setup, we additionally recommend reading the
[in-depth migration guide](https://github.com/getsentry/sentry-javascript/blob/develop/MIGRATION.md#upgrading-from-7x-to-8x) in our repo which highlights all changes with additional details and
information.

## 0.18.0

### Features
Expand Down
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 { }
14 changes: 4 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,14 @@ 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?

}

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