Skip to content

Commit

Permalink
feat: adds Angular 13 support, closes #18
Browse files Browse the repository at this point in the history
BREAKING CHANGE: the minimum Angular version is 13
  • Loading branch information
IKatsuba committed Jun 9, 2022
1 parent 64fccf6 commit 768aca0
Show file tree
Hide file tree
Showing 34 changed files with 4,030 additions and 6,178 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
!.vscode/extensions.json

# misc
/.angular/cache
/.sass-cache
/connect.lock
/coverage
Expand Down
12 changes: 8 additions & 4 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@
"parallel": false
}
}
}
},
"tags": []
},
"browser": {
"projectType": "library",
Expand Down Expand Up @@ -133,7 +134,8 @@
"parallel": false
}
}
}
},
"tags": []
},
"core": {
"projectType": "library",
Expand Down Expand Up @@ -200,7 +202,8 @@
"parallel": false
}
}
}
},
"tags": []
},
"docs": {
"projectType": "application",
Expand Down Expand Up @@ -342,7 +345,8 @@
"production": {}
}
}
}
},
"tags": []
}
}
}
5 changes: 4 additions & 1 deletion apps/docs/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ module.exports = {
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
transform: { '^.+\\.(ts|js|html)$': 'jest-preset-angular' },
transform: {
'^.+.(ts|mjs|js|html)$': 'jest-preset-angular',
},
transformIgnorePatterns: ['node_modules/(?!.*.mjs$)'],
};
10 changes: 0 additions & 10 deletions apps/docs/src/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@
* BROWSER POLYFILLS
*/

/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js'; // Run `npm install --save classlist.js`.

/**
* Web Animations `@angular/platform-browser/animations`
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
*/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.

/**
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
Expand Down
13 changes: 13 additions & 0 deletions apps/docs/src/test-setup.ts
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
import 'jest-preset-angular/setup-jest';

import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting,
} from '@angular/platform-browser-dynamic/testing';

getTestBed().resetTestEnvironment();
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(),
{ teardown: { destroyAfterEach: false } }
);
1 change: 0 additions & 1 deletion apps/docs/tsconfig.server.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.app.json",
"compilerOptions": {
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"types": ["jest", "node"]
},
"files": ["src/test-setup.ts"],
"include": ["**/*.spec.ts", "**/*.d.ts"]
"include": ["**/*.spec.ts", "**/*.test.ts", "**/*.d.ts"]
}
5 changes: 4 additions & 1 deletion libs/angular/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ module.exports = {
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
transform: { '^.+\\.(ts|js|html)$': 'jest-preset-angular' },
transform: {
'^.+.(ts|mjs|js|html)$': 'jest-preset-angular',
},
transformIgnorePatterns: ['node_modules/(?!.*.mjs$)'],
};
2 changes: 1 addition & 1 deletion libs/angular/ng-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"lib": {
"entryFile": "src/index.ts"
},
"whitelistedNonPeerDependencies": ["@micro-sentry/browser"]
"allowedNonPeerDependencies": ["@micro-sentry/browser"]
}
4 changes: 2 additions & 2 deletions libs/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@micro-sentry/angular",
"version": "0.0.0-development",
"peerDependencies": {
"@angular/common": "^12.0.0",
"@angular/core": "^12.0.0",
"@angular/common": "^13.0.0",
"@angular/core": "^13.0.0",
"@ng-web-apis/common": "^1.12.0"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { MICRO_SENTRY_ERRORS_THROTTLE } from '../tokens/errors-throttle';

@Injectable()
export class MicroSentryErrorBusService
implements NextObserver<any>, OnDestroy {
implements NextObserver<any>, OnDestroy
{
private _errors$ = new Subject<any>();
errors$: Observable<any>;

Expand Down
4 changes: 2 additions & 2 deletions libs/angular/src/lib/services/micro-sentry.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class MicroSentryService
this.http = new HttpClient(httpBackend);
}

createRequest(body: SentryRequestBody) {
override createRequest(body: SentryRequestBody) {
this.http
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
.post(this.apiUrl!, body, {
Expand All @@ -35,7 +35,7 @@ export class MicroSentryService
.subscribe();
}

protected getRequestBlank(): SentryRequestBody {
protected override getRequestBlank(): SentryRequestBody {
return {
...super.getRequestBlank(),
sdk: {
Expand Down
13 changes: 13 additions & 0 deletions libs/angular/src/test-setup.ts
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
import 'jest-preset-angular/setup-jest';

import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting,
} from '@angular/platform-browser-dynamic/testing';

getTestBed().resetTestEnvironment();
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(),
{ teardown: { destroyAfterEach: false } }
);
2 changes: 1 addition & 1 deletion libs/angular/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"strictMetadataEmit": true,
"enableResourceInlining": true
},
"exclude": ["src/test-setup.ts", "**/*.spec.ts"],
"exclude": ["src/test-setup.ts", "**/*.spec.ts", "**/*.test.ts"],
"include": ["**/*.ts"]
}
3 changes: 1 addition & 2 deletions libs/angular/tsconfig.lib.prod.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.lib.json",
"compilerOptions": {
"declarationMap": false
},
"angularCompilerOptions": {
"enableIvy": false
"compilationMode": "partial"
}
}
2 changes: 1 addition & 1 deletion libs/angular/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"types": ["jest", "node"]
},
"files": ["src/test-setup.ts"],
"include": ["**/*.spec.ts", "**/*.d.ts"]
"include": ["**/*.spec.ts", "**/*.test.ts", "**/*.d.ts"]
}
5 changes: 4 additions & 1 deletion libs/browser/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ module.exports = {
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
transform: { '^.+\\.(ts|js|html)$': 'jest-preset-angular' },
transform: {
'^.+.(ts|mjs|js|html)$': 'jest-preset-angular',
},
transformIgnorePatterns: ['node_modules/(?!.*.mjs$)'],
};
2 changes: 1 addition & 1 deletion libs/browser/ng-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"lib": {
"entryFile": "src/index.ts"
},
"whitelistedNonPeerDependencies": ["@micro-sentry/core"]
"allowedNonPeerDependencies": ["@micro-sentry/core"]
}
13 changes: 4 additions & 9 deletions libs/browser/src/lib/plugins/breadcrumb-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export class BreadcrumbPlugin implements MicroSentryPlugin {
try {
target = event.target
? htmlTreeAsString(event.target as Node)
: htmlTreeAsString((event as unknown) as Node);
: htmlTreeAsString(event as unknown as Node);
} catch (e) {
target = '<unknown>';
}
Expand Down Expand Up @@ -305,14 +305,9 @@ export class BreadcrumbPlugin implements MicroSentryPlugin {
}

private initConsole() {
([
'debug',
'info',
'warn',
'error',
'log',
'assert',
] as (keyof Console)[]).forEach((level) => {
(
['debug', 'info', 'warn', 'error', 'log', 'assert'] as (keyof Console)[]
).forEach((level) => {
if (!(level in window.console)) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions libs/browser/src/lib/services/browser-micro-sentry-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class BrowserMicroSentryClient extends MicroSentryClient {
);
}

protected getRequestBlank(): SentryRequestBody {
protected override getRequestBlank(): SentryRequestBody {
return {
request: {
url: this.window.location.toString(),
Expand All @@ -178,7 +178,7 @@ export class BrowserMicroSentryClient extends MicroSentryClient {
};
}

protected send(request: SentryRequestBody) {
protected override send(request: SentryRequestBody) {
if (
this.destroyed ||
this.isDeniedUrl(request) ||
Expand Down
4 changes: 1 addition & 3 deletions libs/browser/src/lib/utils/parse-url.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export function parseUrl(
url: string
): {
export function parseUrl(url: string): {
host?: string;
path?: string;
protocol?: string;
Expand Down
13 changes: 13 additions & 0 deletions libs/browser/src/test-setup.ts
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
import 'jest-preset-angular/setup-jest';

import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting,
} from '@angular/platform-browser-dynamic/testing';

getTestBed().resetTestEnvironment();
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(),
{ teardown: { destroyAfterEach: false } }
);
2 changes: 1 addition & 1 deletion libs/browser/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"strictMetadataEmit": true,
"enableResourceInlining": true
},
"exclude": ["src/test-setup.ts", "**/*.spec.ts"],
"exclude": ["src/test-setup.ts", "**/*.spec.ts", "**/*.test.ts"],
"include": ["**/*.ts"]
}
3 changes: 1 addition & 2 deletions libs/browser/tsconfig.lib.prod.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.lib.json",
"compilerOptions": {
"declarationMap": false
},
"angularCompilerOptions": {
"enableIvy": false
"compilationMode": "partial"
}
}
2 changes: 1 addition & 1 deletion libs/browser/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"types": ["jest", "node"]
},
"files": ["src/test-setup.ts"],
"include": ["**/*.spec.ts", "**/*.d.ts"]
"include": ["**/*.spec.ts", "**/*.test.ts", "**/*.d.ts"]
}
5 changes: 4 additions & 1 deletion libs/core/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ module.exports = {
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
transform: { '^.+\\.(ts|js|html)$': 'jest-preset-angular' },
transform: {
'^.+.(ts|mjs|js|html)$': 'jest-preset-angular',
},
transformIgnorePatterns: ['node_modules/(?!.*.mjs$)'],
};
12 changes: 8 additions & 4 deletions libs/core/src/lib/consts/consts.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
// @for-internal-use
// Chromium based browsers: Chrome, Brave, new Opera, new Edge
export const CHROME_REGEXP = /^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
export const CHROME_REGEXP =
/^\s*at (?:(.*?) ?\()?((?:file|https?|blob|chrome-extension|address|native|eval|webpack|<anonymous>|[-a-z]+:|.*bundle|\/).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
// gecko regex: `(?:bundle|\d+\.js)`: `bundle` is for react native, `\d+\.js` also but specifically for ram bundles because it
// generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js
// We need this specific case for now because we want no other regex to match.
export const GECKO_REGEXP = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js))(?::(\d+))?(?::(\d+))?\s*$/i;
export const WINJS_REGEXP = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
export const GECKO_REGEXP =
/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js))(?::(\d+))?(?::(\d+))?\s*$/i;
export const WINJS_REGEXP =
/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;

export const UNKNOWN_FUNCTION = '?';
export const AUTH_HEADER = 'X-Sentry-Auth';

// |protocol |public |secret |host |port |projectId
// | | | | | |
export const DSN_REGEXP = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/;
export const DSN_REGEXP =
/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/;
13 changes: 13 additions & 0 deletions libs/core/src/test-setup.ts
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
import 'jest-preset-angular/setup-jest';

import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting,
} from '@angular/platform-browser-dynamic/testing';

getTestBed().resetTestEnvironment();
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting(),
{ teardown: { destroyAfterEach: false } }
);
2 changes: 1 addition & 1 deletion libs/core/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"strictMetadataEmit": true,
"enableResourceInlining": true
},
"exclude": ["src/test-setup.ts", "**/*.spec.ts"],
"exclude": ["src/test-setup.ts", "**/*.spec.ts", "**/*.test.ts"],
"include": ["**/*.ts"]
}
3 changes: 1 addition & 2 deletions libs/core/tsconfig.lib.prod.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.lib.json",
"compilerOptions": {
"declarationMap": false
},
"angularCompilerOptions": {
"enableIvy": false
"compilationMode": "partial"
}
}
2 changes: 1 addition & 1 deletion libs/core/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"types": ["jest", "node"]
},
"files": ["src/test-setup.ts"],
"include": ["**/*.spec.ts", "**/*.d.ts"]
"include": ["**/*.spec.ts", "**/*.test.ts", "**/*.d.ts"]
}
Loading

0 comments on commit 768aca0

Please sign in to comment.