Skip to content

Commit

Permalink
feat(analytics): Bunch of ScreenTrackingService improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesdaniels committed Nov 14, 2020
1 parent d71b59f commit 5bc159a
Show file tree
Hide file tree
Showing 19 changed files with 304 additions and 153 deletions.
18 changes: 16 additions & 2 deletions sample/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home/home.component';

import { ProtectedComponent } from './protected/protected.component';
import { AngularFireAuthGuard } from '@angular/fire/auth-guard';
import { SecondaryComponent } from './secondary/secondary.component';

const routes: Routes = [
{ path: '', component: HomeComponent, pathMatch: 'full' }
{ path: '', component: HomeComponent, outlet: 'primary' },
{ path: '', component: SecondaryComponent, outlet: 'secondary' },
{ path: '', component: SecondaryComponent, outlet: 'tertiary' },
{ path: 'protected', component: ProtectedComponent, canActivate: [AngularFireAuthGuard] },
{ path: 'protected-lazy',
loadChildren: () => import('./protected-lazy/protected-lazy.module').then(m => m.ProtectedLazyModule),
canActivate: [AngularFireAuthGuard] },
{ path: 'protected', component: ProtectedComponent, canActivate: [AngularFireAuthGuard], outlet: 'secondary' },
{ path: 'protected', component: ProtectedComponent, canActivate: [AngularFireAuthGuard], outlet: 'tertiary' },
{ path: 'protected-lazy',
loadChildren: () => import('./protected-lazy/protected-lazy.module').then(m => m.ProtectedLazyModule),
canActivate: [AngularFireAuthGuard],
outlet: 'secondary' },
];

@NgModule({
Expand Down
8 changes: 8 additions & 0 deletions sample/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import { ApplicationRef, Component } from '@angular/core';
import { FirebaseApp } from '@angular/fire';
import { ActivatedRoute, ActivationEnd, NavigationEnd, Router } from '@angular/router';
import { of, zip } from 'rxjs';
import { filter, groupBy, mergeMap, switchMap } from 'rxjs/operators';

@Component({
selector: 'app-root',
template: `
<a [routerLink]="[{ outlets: { primary: [] }}]">Home</a> | <a [routerLink]="[{ outlets: { primary: ['protected'] }}]">Protected</a> | <a [routerLink]="[{ outlets: { primary: ['protected-lazy'] }}]">Protected Lazy</a> | <a [routerLink]="[{ outlets: { primary: ['protected-lazy', 'asdf'] }}]">Protected Lazy Deep</a> | <a [routerLink]="[{ outlets: { primary: ['protected-lazy', '1', 'bob'] }}]">Protected Lazy Deep</a>
<router-outlet></router-outlet>
<a [routerLink]="[{ outlets: { secondary: [] }}]">Home</a> | <a [routerLink]="[{ outlets: { secondary: ['protected'] }}]">Protected</a> | <a [routerLink]="[{ outlets: { secondary: ['protected-lazy'] }}]">Protected Lazy</a>
<router-outlet name="secondary"></router-outlet>
<a [routerLink]="[{ outlets: { tertiary: [] }}]">Home</a> | <a [routerLink]="[{ outlets: { tertiary: ['protected'] }}]">Protected</a>
<router-outlet name="tertiary"></router-outlet>
`,
styles: [``]
})
Expand Down
27 changes: 14 additions & 13 deletions sample/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ import { AngularFireModule } from '@angular/fire';

import {
AngularFireAnalyticsModule,
APP_NAME,
APP_VERSION,
DEBUG_MODE as ANALYTICS_DEBUG_MODE,
ScreenTrackingService,
UserTrackingService
UserTrackingService,
COLLECTION_ENABLED
} from '@angular/fire/analytics';

import { FirestoreComponent } from './firestore/firestore.component';
Expand Down Expand Up @@ -55,24 +58,20 @@ import { FunctionsComponent } from './functions/functions.component';
AngularFireDatabaseModule,
AngularFirestoreModule.enablePersistence({ synchronizeTabs: true }),
AngularFireAuthModule,
AngularFireAuthGuardModule,
AngularFireRemoteConfigModule,
AngularFireMessagingModule,
// AngularFireAnalyticsModule, // TODO having trouble getting this to work in IE
AngularFireAnalyticsModule,
AngularFireFunctionsModule,
// AngularFirePerformanceModule, // TODO having trouble getting this to work in IE
AngularFirePerformanceModule,
AngularFireAuthGuardModule
],
providers: [
/*
TODO Analytics and Performance monitoring aren't working in IE, sort this out
UserTrackingService,
ScreenTrackingService,
PerformanceMonitoringService,
{
provide: ANALYTICS_DEBUG_MODE,
useFactory: () => isDevMode()
},
*/
UserTrackingService,
ScreenTrackingService,
PerformanceMonitoringService,
{ provide: ANALYTICS_DEBUG_MODE, useValue: false },
{ provide: COLLECTION_ENABLED, useValue: true },
{ provide: USE_AUTH_EMULATOR, useValue: environment.useEmulators ? ['localhost', 9099] : undefined },
{ provide: USE_DATABASE_EMULATOR, useValue: environment.useEmulators ? ['localhost', 9000] : undefined },
{ provide: USE_FIRESTORE_EMULATOR, useValue: environment.useEmulators ? ['localhost', 8080] : undefined },
Expand All @@ -84,6 +83,8 @@ import { FunctionsComponent } from './functions/functions.component';
{ provide: USE_DEVICE_LANGUAGE, useValue: true },
{ provide: VAPID_KEY, useValue: environment.vapidKey },
{ provide: SERVICE_WORKER, useFactory: () => navigator?.serviceWorker?.getRegistration() ?? undefined },
{ provide: APP_VERSION, useValue: '0.0.0' },
{ provide: APP_NAME, useValue: 'Angular' }
],
bootstrap: [AppComponent]
})
Expand Down
16 changes: 16 additions & 0 deletions sample/src/app/protected-lazy/protected-lazy-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { ProtectedLazyComponent } from './protected-lazy.component';

const routes: Routes = [
{ path: '', component: ProtectedLazyComponent },
{ path: 'asdf', component: ProtectedLazyComponent },
{ path: ':id/bob', component: ProtectedLazyComponent }
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class ProtectedLazyRoutingModule { }
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>protected-lazy works!</p>
25 changes: 25 additions & 0 deletions sample/src/app/protected-lazy/protected-lazy.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ProtectedLazyComponent } from './protected-lazy.component';

describe('ProtectedLazyComponent', () => {
let component: ProtectedLazyComponent;
let fixture: ComponentFixture<ProtectedLazyComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ProtectedLazyComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(ProtectedLazyComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions sample/src/app/protected-lazy/protected-lazy.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-protected-lazy',
templateUrl: './protected-lazy.component.html',
styleUrls: ['./protected-lazy.component.css']
})
export class ProtectedLazyComponent implements OnInit {

constructor() { }

ngOnInit(): void {
}

}
15 changes: 15 additions & 0 deletions sample/src/app/protected-lazy/protected-lazy.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { ProtectedLazyRoutingModule } from './protected-lazy-routing.module';
import { ProtectedLazyComponent } from './protected-lazy.component';


@NgModule({
declarations: [ProtectedLazyComponent],
imports: [
CommonModule,
ProtectedLazyRoutingModule
]
})
export class ProtectedLazyModule { }
Empty file.
1 change: 1 addition & 0 deletions sample/src/app/protected/protected.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>protected works!</p>
25 changes: 25 additions & 0 deletions sample/src/app/protected/protected.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ProtectedComponent } from './protected.component';

describe('ProtectedComponent', () => {
let component: ProtectedComponent;
let fixture: ComponentFixture<ProtectedComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ProtectedComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(ProtectedComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions sample/src/app/protected/protected.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-protected',
templateUrl: './protected.component.html',
styleUrls: ['./protected.component.css']
})
export class ProtectedComponent implements OnInit {

constructor() { }

ngOnInit(): void {
}

}
Empty file.
1 change: 1 addition & 0 deletions sample/src/app/secondary/secondary.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>secondary works!</p>
25 changes: 25 additions & 0 deletions sample/src/app/secondary/secondary.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { SecondaryComponent } from './secondary.component';

describe('SecondaryComponent', () => {
let component: SecondaryComponent;
let fixture: ComponentFixture<SecondaryComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ SecondaryComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(SecondaryComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions sample/src/app/secondary/secondary.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-secondary',
templateUrl: './secondary.component.html',
styleUrls: ['./secondary.component.css']
})
export class SecondaryComponent implements OnInit {

constructor() { }

ngOnInit(): void {
}

}
Loading

0 comments on commit 5bc159a

Please sign in to comment.