Skip to content

fix: Allow for empty DSN/disabling with AngularJS integration #2842

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

Merged
merged 1 commit into from
Aug 24, 2020
Merged
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
19 changes: 16 additions & 3 deletions packages/integrations/src/angular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ export class Angular implements Integration {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private readonly _angular: any;

/**
* ngSentry module instance
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private readonly _module: any;

/**
* Returns current hub.
*/
Expand All @@ -43,21 +49,28 @@ export class Angular implements Integration {
public constructor(options: { angular?: any } = {}) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
this._angular = options.angular || getGlobalObject<any>().angular;

if (!this._angular) {
logger.error('AngularIntegration is missing an Angular instance');
return;
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
this._module = this._angular.module(Angular.moduleName, []);
}

/**
* @inheritDoc
*/
public setupOnce(_: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void {
if (!this._angular) {
logger.error('AngularIntegration is missing an Angular instance');
if (!this._module) {
return;
}

this._getCurrentHub = getCurrentHub;

// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
this._angular.module(Angular.moduleName, []).config([
this._module.config([
'$provide',
// eslint-disable-next-line @typescript-eslint/no-explicit-any
($provide: any): void => {
Expand Down