1- import { InjectionToken , NgModule , Optional , NgZone } from '@angular/core' ;
1+ import { InjectionToken , NgModule , Optional , NgZone , VERSION as NG_VERSION , Version } from '@angular/core' ;
22import { auth , database , messaging , storage , firestore , functions } from 'firebase/app' ;
33// @ts -ignore (https://github.com/firebase/firebase-js-sdk/pull/1206)
44import firebase from 'firebase/app' ; // once fixed can pull in as "default as firebase" above
@@ -42,8 +42,11 @@ export class FirebaseApp {
4242 firestore : ( ) => FirebaseFirestore ;
4343 functions : ( region ?: string ) => FirebaseFunctions ;
4444 remoteConfig : ( ) => FirebaseRemoteConfig ;
45+ registerVersion ?: ( library : string , version : string ) => void ;
4546}
4647
48+ export const VERSION = new Version ( 'ANGULARFIRE2_VERSION' ) ;
49+
4750export function _firebaseAppFactory ( options : FirebaseOptions , zone : NgZone , nameOrConfig ?: string | FirebaseAppConfig | null ) {
4851 const name = typeof nameOrConfig === 'string' && nameOrConfig || '[DEFAULT]' ;
4952 const config = typeof nameOrConfig === 'object' && nameOrConfig || { } ;
@@ -52,7 +55,12 @@ export function _firebaseAppFactory(options: FirebaseOptions, zone: NgZone, name
5255 const existingApp = firebase . apps . filter ( app => app && app . name === config . name ) [ 0 ] as any ;
5356 // We support FirebaseConfig, initializeApp's public type only accepts string; need to cast as any
5457 // Could be solved with https://github.com/firebase/firebase-js-sdk/pull/1206
55- return ( existingApp || zone . runOutsideAngular ( ( ) => firebase . initializeApp ( options , config as any ) ) ) as FirebaseApp ;
58+ const app = ( existingApp || zone . runOutsideAngular ( ( ) => firebase . initializeApp ( options , config as any ) ) ) as FirebaseApp ;
59+ if ( app . registerVersion ) {
60+ app . registerVersion ( 'angularfire' , VERSION . full ) ;
61+ app . registerVersion ( 'angular' , NG_VERSION . full ) ;
62+ }
63+ return app ;
5664}
5765
5866const FirebaseAppProvider = {
0 commit comments