Skip to content

Commit 0df3981

Browse files
authored
fix: Allow for empty DSN/disabling with AngularJS integration (#2842)
1 parent 8f07fb7 commit 0df3981

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

packages/integrations/src/angular.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ export class Angular implements Integration {
3131
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3232
private readonly _angular: any;
3333

34+
/**
35+
* ngSentry module instance
36+
*/
37+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
38+
private readonly _module: any;
39+
3440
/**
3541
* Returns current hub.
3642
*/
@@ -43,21 +49,28 @@ export class Angular implements Integration {
4349
public constructor(options: { angular?: any } = {}) {
4450
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
4551
this._angular = options.angular || getGlobalObject<any>().angular;
52+
53+
if (!this._angular) {
54+
logger.error('AngularIntegration is missing an Angular instance');
55+
return;
56+
}
57+
58+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
59+
this._module = this._angular.module(Angular.moduleName, []);
4660
}
4761

4862
/**
4963
* @inheritDoc
5064
*/
5165
public setupOnce(_: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void {
52-
if (!this._angular) {
53-
logger.error('AngularIntegration is missing an Angular instance');
66+
if (!this._module) {
5467
return;
5568
}
5669

5770
this._getCurrentHub = getCurrentHub;
5871

5972
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
60-
this._angular.module(Angular.moduleName, []).config([
73+
this._module.config([
6174
'$provide',
6275
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6376
($provide: any): void => {

0 commit comments

Comments
 (0)