Skip to content
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

Adding AngularFireAnalytics, AngularFireRemoteConfig, and refactoring DI Tokens #2187

Merged
merged 41 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
e5be927
Firebase v7, analytics and remote-config
jamesdaniels Oct 2, 2019
1cf961b
Cleaning up the DI tokens
jamesdaniels Oct 2, 2019
f5f67ad
Cleaning things up
jamesdaniels Oct 4, 2019
73413e8
DI and jazz
jamesdaniels Oct 4, 2019
dd0efb1
Bumping the tests
jamesdaniels Nov 8, 2019
dffca53
Adding to the root-spec
jamesdaniels Nov 9, 2019
9731e3c
Spelling is good.
jamesdaniels Nov 9, 2019
7308f9c
Merge branch 'master' into firebase-v7
jamesdaniels Nov 9, 2019
dcdf8bc
Have to include UMDs in the karma.conf
jamesdaniels Nov 9, 2019
6f71d46
Just importing performance is destablizing the app
jamesdaniels Nov 11, 2019
6638b9d
Merge branch 'master' into firebase-v7
jamesdaniels Nov 12, 2019
d7d52c8
Adding the zone arg to the app factory
jamesdaniels Nov 12, 2019
eb4bc00
First pass on the new RC API and the start of the AngularFireLazy effort
jamesdaniels Nov 13, 2019
89344cc
Update src/remote-config/tsconfig-test.json
jamesdaniels Nov 14, 2019
075afe6
Reworking things a bit
jamesdaniels Nov 20, 2019
b8b351a
Router as optional, drop this/private from screen tracking
jamesdaniels Nov 20, 2019
1e39052
Minor changes to RC
jamesdaniels Nov 20, 2019
768c21b
It's firebase_screen_class
jamesdaniels Nov 21, 2019
60c0cad
Reworking analytics
jamesdaniels Nov 22, 2019
9b2e920
current!
jamesdaniels Nov 22, 2019
916e069
Use _loadedConfig if available and scope screen_id on outlet
jamesdaniels Nov 22, 2019
5955925
Fixing the types to handle older Firebase SDKs
jamesdaniels Nov 22, 2019
659165e
SEMVER notes on the DI tokens
jamesdaniels Nov 22, 2019
62d90b9
Starting on the docs
jamesdaniels Nov 22, 2019
1a43ad1
Merge branch 'firebase-v7' of github.com:angular/angularfire2 into fi…
jamesdaniels Nov 22, 2019
67e1b55
Monitoring...
jamesdaniels Dec 9, 2019
91778ff
More work on analytics
jamesdaniels Dec 11, 2019
460170c
more expirimentation
jamesdaniels Dec 12, 2019
3c1ad1f
Flushing out RC more and fixing SSR issues
jamesdaniels Dec 14, 2019
e2d83c8
New RC API
jamesdaniels Dec 16, 2019
4601932
Mapping to objects and templates, budget pipe
jamesdaniels Dec 17, 2019
7fe92ed
More strict types
jamesdaniels Dec 17, 2019
d47dc3f
Fix proxy in Node, get component name for analytics in both JIT and AOT
jamesdaniels Dec 21, 2019
05c840b
Cleaning things up, beyond docs ready for release
jamesdaniels Jan 7, 2020
b46b382
Docs and cleanup
jamesdaniels Jan 7, 2020
ff65db8
Fixing analytics spec
jamesdaniels Jan 7, 2020
baaeccf
Adding more API to the docs
jamesdaniels Jan 7, 2020
04a3bb1
Further simplifications to the DI tokens
jamesdaniels Jan 7, 2020
c37fcb7
Add Analytics and RemoteConfig to install-and-setup
jamesdaniels Jan 7, 2020
6753a67
Merge branch 'master' into firebase-v7
jamesdaniels Jan 7, 2020
6f114c6
Our RC Value implements a Partial, so minors dont break
jamesdaniels Jan 7, 2020
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
Prev Previous commit
Next Next commit
Cleaning up the DI tokens
  • Loading branch information
jamesdaniels committed Oct 2, 2019
commit 1cf961bd2185c988916aa3741d7764a556d3a027
6 changes: 3 additions & 3 deletions src/analytics/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Observable, from, of } from 'rxjs';
import { map, switchMap, tap, filter } from 'rxjs/operators';
import { FirebaseAppConfig, FirebaseOptions, runOutsideAngular } from '@angular/fire';
import { Router, NavigationEnd } from '@angular/router';
import { FirebaseAnalytics, FirebaseOptionsToken, FirebaseNameOrConfigToken, _firebaseAppFactory } from '@angular/fire';
import { FirebaseAnalytics, FIREBASE_OPTIONS, FIREBASE_APP_NAME, _firebaseAppFactory } from '@angular/fire';

export const AUTOMATICALLY_SET_CURRENT_SCREEN = new InjectionToken<boolean>('angularfire2.analytics.setCurrentScreen');
export const ANALYTICS_COLLECTION_ENABLED = new InjectionToken<boolean>('angularfire2.analytics.analyticsCollectionEnabled');
Expand All @@ -18,8 +18,8 @@ export class AngularFireAnalytics {
public readonly analytics: Observable<FirebaseAnalytics>;

constructor(
@Inject(FirebaseOptionsToken) options:FirebaseOptions,
@Optional() @Inject(FirebaseNameOrConfigToken) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Inject(FIREBASE_OPTIONS) options:FirebaseOptions,
@Optional() @Inject(FIREBASE_APP_NAME) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Optional() router:Router,
@Optional() @Inject(AUTOMATICALLY_SET_CURRENT_SCREEN) automaticallySetCurrentScreen:boolean|null,
@Optional() @Inject(ANALYTICS_COLLECTION_ENABLED) analyticsCollectionEnabled:boolean|null,
Expand Down
8 changes: 3 additions & 5 deletions src/auth/auth.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Injectable, Inject, Optional, NgZone, PLATFORM_ID } from '@angular/core';
import { Observable, of, from } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { FirebaseAppConfig, FirebaseOptions } from '@angular/fire';
import { FIREBASE_OPTIONS, FIREBASE_APP_NAME, FirebaseOptions, FirebaseAppConfig, FirebaseAuth, _firebaseAppFactory, FirebaseZoneScheduler } from '@angular/fire';
import { User, auth } from 'firebase/app';

import { FirebaseAuth, FirebaseOptionsToken, FirebaseNameOrConfigToken, _firebaseAppFactory, FirebaseZoneScheduler } from '@angular/fire';

@Injectable()
export class AngularFireAuth {

Expand Down Expand Up @@ -37,8 +35,8 @@ export class AngularFireAuth {
public readonly idTokenResult: Observable<auth.IdTokenResult|null>;

constructor(
@Inject(FirebaseOptionsToken) options:FirebaseOptions,
@Optional() @Inject(FirebaseNameOrConfigToken) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Inject(FIREBASE_OPTIONS) options:FirebaseOptions,
@Optional() @Inject(FIREBASE_APP_NAME) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Inject(PLATFORM_ID) platformId: Object,
private zone: NgZone
) {
Expand Down
1 change: 1 addition & 0 deletions src/core/angularfire2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Observable, Subscription, queueScheduler as queue } from 'rxjs';

// Put in database.ts when we drop database-depreciated
export const RealtimeDatabaseURL = new InjectionToken<string>('angularfire2.realtimeDatabaseURL');
export const DATABASE_URL = RealtimeDatabaseURL;
jamesdaniels marked this conversation as resolved.
Show resolved Hide resolved

export class FirebaseZoneScheduler {
constructor(public zone: NgZone, private platformId: Object) {}
Expand Down
13 changes: 8 additions & 5 deletions src/core/firebase.app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export type FirebaseOptions = {[key:string]: any};
export type FirebaseAppConfig = {[key:string]: any};

export const FirebaseOptionsToken = new InjectionToken<FirebaseOptions>('angularfire2.app.options');
export const FirebaseNameOrConfigToken = new InjectionToken<string|FirebaseAppConfig|undefined>('angularfire2.app.nameOrConfig')
export const FirebaseNameOrConfigToken = new InjectionToken<string|FirebaseAppConfig|undefined>('angularfire2.app.nameOrConfig');

export const FIREBASE_OPTIONS = FirebaseOptionsToken;
export const FIREBASE_APP_NAME = FirebaseNameOrConfigToken;

export type FirebaseDatabase = database.Database;
export type FirebaseAuth = auth.Auth;
Expand Down Expand Up @@ -51,8 +54,8 @@ const FirebaseAppProvider = {
provide: FirebaseApp,
useFactory: _firebaseAppFactory,
deps: [
FirebaseOptionsToken,
[new Optional(), FirebaseNameOrConfigToken]
FIREBASE_OPTIONS,
[new Optional(), FIREBASE_APP_NAME]
]
};

Expand All @@ -64,8 +67,8 @@ export class AngularFireModule {
return {
ngModule: AngularFireModule,
providers: [
{ provide: FirebaseOptionsToken, useValue: options },
{ provide: FirebaseNameOrConfigToken, useValue: nameOrConfig }
{ provide: FIREBASE_OPTIONS, useValue: options },
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }
]
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/database-deprecated/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FirebaseListFactoryOpts, FirebaseObjectFactoryOpts, PathReference } fro
import { FirebaseObjectFactory } from './firebase_object_factory';
import { FirebaseObjectObservable } from './firebase_object_observable';
import * as utils from './utils';
import { FirebaseDatabase, FirebaseOptions, FirebaseAppConfig, FirebaseOptionsToken, FirebaseNameOrConfigToken, RealtimeDatabaseURL, _firebaseAppFactory } from '@angular/fire';
import { FirebaseDatabase, FirebaseOptions, FirebaseAppConfig, RealtimeDatabaseURL, FIREBASE_OPTIONS, FIREBASE_APP_NAME, DATABASE_URL, _firebaseAppFactory } from '@angular/fire';

@Injectable()
export class AngularFireDatabase {
Expand All @@ -16,9 +16,9 @@ export class AngularFireDatabase {
database: FirebaseDatabase;

constructor(
@Inject(FirebaseOptionsToken) options:FirebaseOptions,
@Optional() @Inject(FirebaseNameOrConfigToken) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Optional() @Inject(RealtimeDatabaseURL) databaseURL:string|null,
@Inject(FIREBASE_OPTIONS) options:FirebaseOptions,
@Optional() @Inject(FIREBASE_APP_NAME) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Optional() @Inject(DATABASE_URL) databaseURL:string|null,
zone: NgZone
) {
this.database = zone.runOutsideAngular(() => {
Expand All @@ -39,4 +39,4 @@ export class AngularFireDatabase {

}

export { RealtimeDatabaseURL };
export { DATABASE_URL };
10 changes: 5 additions & 5 deletions src/database/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import { getRef } from './utils';
import { InjectionToken } from '@angular/core';
import { createListReference } from './list/create-reference';
import { createObjectReference } from './object/create-reference';
import { FirebaseDatabase, FirebaseOptions, FirebaseAppConfig, FirebaseOptionsToken, FirebaseNameOrConfigToken, RealtimeDatabaseURL, _firebaseAppFactory, FirebaseZoneScheduler } from '@angular/fire';
import { FirebaseDatabase, FirebaseOptions, FirebaseAppConfig, RealtimeDatabaseURL, FIREBASE_OPTIONS, FIREBASE_APP_NAME, DATABASE_URL, _firebaseAppFactory, FirebaseZoneScheduler } from '@angular/fire';

@Injectable()
export class AngularFireDatabase {
public readonly database: FirebaseDatabase;
public readonly scheduler: FirebaseZoneScheduler;

constructor(
@Inject(FirebaseOptionsToken) options:FirebaseOptions,
@Optional() @Inject(FirebaseNameOrConfigToken) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Optional() @Inject(RealtimeDatabaseURL) databaseURL:string|null,
@Inject(FIREBASE_OPTIONS) options:FirebaseOptions,
@Optional() @Inject(FIREBASE_APP_NAME) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Optional() @Inject(DATABASE_URL) databaseURL:string|null,
@Inject(PLATFORM_ID) platformId: Object,
zone: NgZone
) {
Expand Down Expand Up @@ -58,4 +58,4 @@ export {
SnapshotAction
} from './interfaces';

export { RealtimeDatabaseURL };
export { RealtimeDatabaseURL, DATABASE_URL };
16 changes: 10 additions & 6 deletions src/firestore/firestore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AngularFirestoreDocument } from './document/document';
import { AngularFirestoreCollection } from './collection/collection';
import { AngularFirestoreCollectionGroup } from './collection-group/collection-group';

import { FirebaseFirestore, FirebaseOptions, FirebaseAppConfig, FirebaseOptionsToken, FirebaseNameOrConfigToken, _firebaseAppFactory, FirebaseZoneScheduler } from '@angular/fire';
import { FirebaseFirestore, FirebaseOptions, FirebaseAppConfig, FIREBASE_OPTIONS, FIREBASE_APP_NAME, _firebaseAppFactory, FirebaseZoneScheduler } from '@angular/fire';
import { isPlatformServer } from '@angular/common';

// Workaround for Nodejs build
Expand All @@ -24,6 +24,10 @@ export const EnablePersistenceToken = new InjectionToken<boolean>('angularfire2.
export const PersistenceSettingsToken = new InjectionToken<PersistenceSettings|undefined>('angularfire2.firestore.persistenceSettings');
export const FirestoreSettingsToken = new InjectionToken<Settings>('angularfire2.firestore.settings');

export const ENABLE_PERSISTENCE = EnablePersistenceToken;
export const PERSISTENCE_SETTINGS = PersistenceSettingsToken
export const FIRESTORE_SETTINGS = FirestoreSettingsToken;
jamesdaniels marked this conversation as resolved.
Show resolved Hide resolved

// timestampsInSnapshots was depreciated in 5.8.0
const major = parseInt(firebase.SDK_VERSION.split('.')[0]);
const minor = parseInt(firebase.SDK_VERSION.split('.')[1]);
Expand Down Expand Up @@ -115,13 +119,13 @@ export class AngularFirestore {
* @param app
*/
constructor(
@Inject(FirebaseOptionsToken) options:FirebaseOptions,
@Optional() @Inject(FirebaseNameOrConfigToken) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Optional() @Inject(EnablePersistenceToken) shouldEnablePersistence: boolean|null,
@Optional() @Inject(FirestoreSettingsToken) settings: Settings|null,
@Inject(FIREBASE_OPTIONS) options:FirebaseOptions,
@Optional() @Inject(FIREBASE_APP_NAME) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Optional() @Inject(ENABLE_PERSISTENCE) shouldEnablePersistence: boolean|null,
@Optional() @Inject(FIRESTORE_SETTINGS) settings: Settings|null,
@Inject(PLATFORM_ID) platformId: Object,
zone: NgZone,
@Optional() @Inject(PersistenceSettingsToken) persistenceSettings: PersistenceSettings|null,
@Optional() @Inject(PERSISTENCE_SETTINGS) persistenceSettings: PersistenceSettings|null,
) {
this.scheduler = new FirebaseZoneScheduler(zone, platformId);
this.firestore = zone.runOutsideAngular(() => {
Expand Down
8 changes: 4 additions & 4 deletions src/functions/functions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Injectable, Inject, Optional, NgZone, PLATFORM_ID, InjectionToken } from '@angular/core';
import { Observable, from } from 'rxjs';
import { map } from 'rxjs/operators';
import { FirebaseOptions, FirebaseAppConfig } from '@angular/fire';
import { FirebaseFunctions, FirebaseOptionsToken, FirebaseNameOrConfigToken, _firebaseAppFactory, FirebaseZoneScheduler } from '@angular/fire';
import { FirebaseOptions, FirebaseAppConfig, FIREBASE_APP_NAME } from '@angular/fire';
import { FirebaseFunctions, FIREBASE_OPTIONS, _firebaseAppFactory, FirebaseZoneScheduler } from '@angular/fire';

// SEMVER: @ v6 remove FunctionsRegionToken in favor of FUNCTIONS_REGION
export const FunctionsRegionToken = new InjectionToken<string>('angularfire2.functions.region');
Expand All @@ -20,8 +20,8 @@ export class AngularFireFunctions {
public readonly scheduler: FirebaseZoneScheduler;

constructor(
@Inject(FirebaseOptionsToken) options:FirebaseOptions,
@Optional() @Inject(FirebaseNameOrConfigToken) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Inject(FIREBASE_OPTIONS) options:FirebaseOptions,
@Optional() @Inject(FIREBASE_APP_NAME) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Inject(PLATFORM_ID) platformId: Object,
zone: NgZone,
@Optional() @Inject(FUNCTIONS_REGION) region:string|null,
Expand Down
8 changes: 4 additions & 4 deletions src/messaging/messaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { isPlatformServer } from '@angular/common';
import { messaging } from 'firebase/app';
import { Observable, empty, from, of, throwError } from 'rxjs';
import { mergeMap, catchError, map, switchMap, concat, defaultIfEmpty } from 'rxjs/operators';
import { FirebaseOptions, FirebaseAppConfig, runOutsideAngular } from '@angular/fire';
import { FirebaseOptionsToken, FirebaseNameOrConfigToken, _firebaseAppFactory, FirebaseZoneScheduler } from '@angular/fire';
import { FirebaseOptions, FirebaseAppConfig, runOutsideAngular, FIREBASE_APP_NAME, FIREBASE_OPTIONS } from '@angular/fire';
import { _firebaseAppFactory, FirebaseZoneScheduler } from '@angular/fire';

@Injectable()
export class AngularFireMessaging {
Expand All @@ -17,8 +17,8 @@ export class AngularFireMessaging {
deleteToken: (token: string) => Observable<boolean>;

constructor(
@Inject(FirebaseOptionsToken) options:FirebaseOptions,
@Optional() @Inject(FirebaseNameOrConfigToken) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Inject(FIREBASE_OPTIONS) options:FirebaseOptions,
@Optional() @Inject(FIREBASE_APP_NAME) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Inject(PLATFORM_ID) platformId: Object,
zone: NgZone
) {
Expand Down
12 changes: 6 additions & 6 deletions src/remote-config/remote-config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Injectable, Inject, Optional, NgZone, InjectionToken } from '@angular/core';
import { Observable, from } from 'rxjs';
import { map, switchMap, tap } from 'rxjs/operators';
import { FirebaseAppConfig, FirebaseOptions } from '@angular/fire';
import { FirebaseAppConfig, FirebaseOptions, FIREBASE_OPTIONS, FIREBASE_APP_NAME } from '@angular/fire';
import { remoteConfig } from 'firebase/app';

export interface DefaultConfig {[key:string]: string|number|boolean};

export const SETTINGS = new InjectionToken<remoteConfig.Settings>('angularfire2.remoteConfig.settings');
export const REMOTE_CONFIG_SETTINGS = new InjectionToken<remoteConfig.Settings>('angularfire2.remoteConfig.settings');
export const DEFAULT_CONFIG = new InjectionToken<DefaultConfig>('angularfire2.remoteConfig.defaultConfig');

import { FirebaseRemoteConfig, FirebaseOptionsToken, FirebaseNameOrConfigToken, _firebaseAppFactory, runOutsideAngular } from '@angular/fire';
import { FirebaseRemoteConfig, _firebaseAppFactory, runOutsideAngular } from '@angular/fire';

@Injectable()
export class AngularFireRemoteConfig {
Expand All @@ -24,9 +24,9 @@ export class AngularFireRemoteConfig {
public readonly configuration: Observable<{[key:string]: remoteConfig.Value}>;

constructor(
@Inject(FirebaseOptionsToken) options:FirebaseOptions,
@Optional() @Inject(FirebaseNameOrConfigToken) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Optional() @Inject(SETTINGS) settings:remoteConfig.Settings|null,
@Inject(FIREBASE_OPTIONS) options:FirebaseOptions,
@Optional() @Inject(FIREBASE_APP_NAME) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Optional() @Inject(REMOTE_CONFIG_SETTINGS) settings:remoteConfig.Settings|null,
@Optional() @Inject(DEFAULT_CONFIG) defaultConfig:DefaultConfig|null,
private zone: NgZone
) {
Expand Down
10 changes: 6 additions & 4 deletions src/storage/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { Injectable, Inject, Optional, InjectionToken, NgZone, PLATFORM_ID } fro
import { createStorageRef, AngularFireStorageReference } from './ref';
import { createUploadTask, AngularFireUploadTask } from './task';
import { Observable } from 'rxjs';
import { FirebaseStorage, FirebaseOptions, FirebaseAppConfig, FirebaseOptionsToken, FirebaseNameOrConfigToken, FirebaseZoneScheduler, _firebaseAppFactory } from '@angular/fire';
import { FirebaseStorage, FirebaseOptions, FirebaseAppConfig, FirebaseZoneScheduler, _firebaseAppFactory, FIREBASE_OPTIONS, FIREBASE_APP_NAME } from '@angular/fire';

import { UploadMetadata } from './interfaces';

export const StorageBucket = new InjectionToken<string>('angularfire2.storageBucket');

export const STORAGE_BUCKET = StorageBucket;
jamesdaniels marked this conversation as resolved.
Show resolved Hide resolved

/**
* AngularFireStorage Service
*
Expand All @@ -21,9 +23,9 @@ export class AngularFireStorage {
public readonly scheduler: FirebaseZoneScheduler;

constructor(
@Inject(FirebaseOptionsToken) options:FirebaseOptions,
@Optional() @Inject(FirebaseNameOrConfigToken) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Optional() @Inject(StorageBucket) storageBucket:string|null,
@Inject(FIREBASE_OPTIONS) options:FirebaseOptions,
@Optional() @Inject(FIREBASE_APP_NAME) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Optional() @Inject(STORAGE_BUCKET) storageBucket:string|null,
@Inject(PLATFORM_ID) platformId: Object,
zone: NgZone
) {
Expand Down