Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

ScreenTrackingService and UserTrackingService not triggering events in Angular 19

Offen
#3,633 5 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Muss geklärt werden
Aktivitätsstatus
Veraltet
Tech-Stack
angular, firebase, typescript

Rechercherichtung

Beginne mit app.config.ts sowie den Einstiegspunkten ScreenTrackingService und UserTrackingService und bilde anschließend die Navigation aus app.routes.ts sowie die Authentifizierungsänderungen mit signInWithPopup nach. Prüfe, warum die Service-Konstruktoren und ɵscreenViewEvent nicht erreicht werden. Als erledigt gilt die Aufgabe, wenn Routenänderungen und Anmelden/Abmelden die erwarteten Ereignisse in Firebase DebugView erzeugen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Overview of the Issue

Using Angular 19 and AngularFire 19, the ScreenTrackingService and UserTrackingService do not trigger events.

Angular Version

Here is a section of my package.json:

"dependencies": {
    "@angular/animations": "^19.0.0",
    "@angular/cdk": "^19.1.2",
    "@angular/common": "^19.0.0",
    "@angular/compiler": "^19.0.0",
    "@angular/core": "^19.0.0",
    "@angular/fire": "^19.0.0",
    "@angular/forms": "^19.0.0",
    "@angular/platform-browser": "^19.0.0",
    "@angular/platform-browser-dynamic": "^19.0.0",
    "@angular/router": "^19.0.0",
    "@ngrx/signals": "^19.0.0",
    "@ngrx/store": "^19.0.0",
    "@ngrx/store-devtools": "^19.0.0",
    "@ngx-translate/core": "^16.0.4",
    "@ngx-translate/http-loader": "^16.0.1",
    "@tailwindcss/postcss": "^4.0.0",
    "lodash": "^4.17.21",
    "postcss": "^8.5.1",
    "rxjs": "~7.8.0",
    "tailwindcss": "^4.0.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.15.0"
  },
Motivation for or Use Case

These services are supposed to automatically log router and firebase authentication events. When I use the logEvent function from the analytics package, events are logged, but I do not see any events logged from ScreenTrackingService and UserTrackingService

Browsers and Operating System

I am using Chrome Version 133.0.6943.142 (Official Build) (64-bit) on Windows 10

Reproduce the Error

On the DebugView in the Firebase Console, I can see the page_view event for the initial page load.

When I click links to routes around my app, or when I login and logout, I do not see any events.

Here is a component where I am manually triggering an event, and I can see the event in the DebugView:

@Component({
  selector: 'app-home',
  imports: [CommonModule, SharedModule, TranslateModule, RouterModule],
  templateUrl: './home.component.html',
  styleUrl: './home.component.css'
})
export class HomeComponent {
  readonly analytics = inject(Analytics);

  chooseSample(sample: { name: string, words: string[] }) {
    logEvent(this.analytics, 'select_item', {
      items: [{ item_name: sample.name }],
      item_list_name: 'Samples',
      item_list_id: 'samples'
    });
  }
}

Here is my app.routes.ts file:

export const routes: Routes = [
  {
    path: '',
    loadComponent: () => import('./home/home.component').then(c => c.HomeComponent)
  },
  {
    path: 'samples',
    loadChildren: () => import('./samples/sample.module').then(c => c.SampleModule)
  },
];

Here is the sample.module file:

@NgModule({
  imports: [
    CommonModule,
    SampleRoutingModule
  ]
})
export class SampleModule { }

Here is the SampleRoutingModule:

const routes: Routes = [
  {
    path: '',
    component: ListComponent
  },
  {
    path: 'create',
    component: CreateComponent
  },
  {
    path: 'view/:id',
    component: ViewComponent
  },
  {
    path: 'edit/:id',
    component: EditComponent
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class SampleRoutingModule { }

On the HomeComponent, I link to the various pages in the SampleModule like this:

<a routerLink="samples">{{ 'samples' | translate }}</a>
<a routerLink="/samples/create">{{ 'create a sample' | translate }}</a>

Here is my app.config.ts file:

export const appConfig: ApplicationConfig = {
  providers: [
    provideZoneChangeDetection({ eventCoalescing: true }),
    provideHttpClient(),
    importProvidersFrom([TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: httpLoaderFactory,
        deps: [HttpClient],
      },
    })]),
    provideRouter(routes, withInMemoryScrolling({ anchorScrolling: 'enabled'})),
    provideStore({}),
    provideStoreDevtools({ maxAge: 25, logOnly: environment.production, trace: true, traceLimit: 50 }),
    provideFirebaseApp(() => initializeApp(environment.firebase)),
    provideAuth(() => {
      const auth = getAuth();
      if (!environment.production) {
        connectAuthEmulator(auth, 'http://192.168.1.104:9099', { disableWarnings: true });
      }
      return auth;
    }),
    provideAnalytics(() => getAnalytics()),
    ScreenTrackingService,
    UserTrackingService,
    provideAppCheck(() => {
      if (!environment.production) {
        self.FIREBASE_APPCHECK_DEBUG_TOKEN = true;
      }
      const provider = new ReCaptchaEnterpriseProvider(environment.reCaptchaSiteKey);
      return initializeAppCheck(undefined, { provider, isTokenAutoRefreshEnabled: true });
    }),
    provideFirestore(() => {
      const firestore = getFirestore();
      if (!environment.production) {
        connectFirestoreEmulator(firestore, '192.168.1.104', 8080);
      }
      return firestore;
    }),
    provideFunctions(() => {
      const functions = getFunctions();
      if (!environment.production) {
        connectFunctionsEmulator(functions, '192.168.1.104', 5001);
      }
      return functions;
    })
  ]
};

I also tried these configs in the app config and the result was the same:

    { provide: ScreenTrackingService },
    { provide: UserTrackingService },
    { provide: ScreenTrackingService, useClass: ScreenTrackingService },
    { provide: UserTrackingService, useClass: UserTrackingService },
    { provide: ScreenTrackingService, useExisting: ScreenTrackingService },
    { provide: UserTrackingService, useExisting: UserTrackingService },
Suggest a Fix

When I run the Google Analytics Debugger, I can see events logging in the console from the logEvent function call in the HomeComponent. When I click various router links, I do not see any logs in the console. When I log in and out (using firebase auth signInWithPopup), I don't see any logs.

I added some debugger breakpoints in the ScreenTrackingService and UserTrackingService. The breakpoints at the top of the file are hit, so the file is loading. But the breakpoints in the constructors and ɵscreenViewEvent function are not hit at all.

It seems like the ScreenTrackingService and UserTrackingService are not getting constructed, called, or instantiated.

Vorherrschende Sprache
TypeScript
Sterne
7.8k
Forks
2.2k
Ø Merge
3 T. 6 Std.
Gemergte PRs (30 T.)
5

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus angular/angularfire

Alle Issues in angular/angularfire

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.