Skip to content

Sentry Angular 8: Can't use without @angular/router #12524

@hheexx

Description

@hheexx

Is there an existing issue for this?

How do you use Sentry?

Self-hosted/on-premise

Which SDK are you using?

@sentry/angular

SDK Version

8.9.2

Framework Version

Angular 18

Link to Sentry event

No response

SDK Setup

No response

Steps to Reproduce

Sentry can't be used without angular router.
We have a project that uses alternative router.
As soon as I import * as Sentry from "@sentry/angular";
I get error:

X [ERROR] Could not resolve "@angular/router"

node_modules/@sentry/angular/fesm2020/sentry-angular.mjs:9:20:
  9 │ import * as i1 from '@angular/router';
    ╵                     ~~~~~~~~~~~~~~~~~

You can mark the path "@angular/router" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.

X [ERROR] TS2307: Cannot find module '@angular/router' or its corresponding type declarations. [plugin angular-compiler]

node_modules/@sentry/angular/tracing.d.ts:2:51:
  2 │ import type { ActivatedRouteSnapshot, Event } from '@angular/router';
    ╵                                                    ~~~~~~~~~~~~~~~~~

X [ERROR] TS2307: Cannot find module '@angular/router' or its corresponding type declarations. [plugin angular-compiler]

node_modules/@sentry/angular/tracing.d.ts:3:23:
  3 │ import { Router } from '@angular/router';

Expected Result

work

Actual Result

!work

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions