@angular/fire 16.0.0-canary.5793d6f → 16.0.0-canary.78407bc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +200 -0
- package/analytics/firebase.d.ts +4 -1
- package/app-check/firebase.d.ts +2 -1
- package/auth/firebase.d.ts +3 -1
- package/docs/analytics.md +67 -0
- package/docs/app-check.md +53 -0
- package/docs/auth.md +165 -0
- package/docs/compat/analytics/getting-started.md +137 -0
- package/docs/compat/auth/getting-started.md +162 -0
- package/docs/compat/auth/router-guards.md +104 -0
- package/docs/compat/emulators/emulators.md +134 -0
- package/docs/compat/firestore/collections.md +326 -0
- package/docs/compat/firestore/documents.md +115 -0
- package/docs/compat/firestore/offline-data.md +39 -0
- package/docs/compat/firestore/querying-collections.md +204 -0
- package/docs/compat/functions/functions.md +166 -0
- package/docs/compat/messaging/messaging.md +232 -0
- package/docs/compat/performance/getting-started.md +132 -0
- package/docs/compat/remote-config/getting-started.md +134 -0
- package/docs/compat/rtdb/lists.md +257 -0
- package/docs/compat/rtdb/objects.md +182 -0
- package/docs/compat/rtdb/querying-lists.md +155 -0
- package/docs/compat/storage/storage.md +257 -0
- package/docs/compat.md +70 -0
- package/docs/database.md +175 -0
- package/docs/deploy/getting-started.md +204 -0
- package/docs/firebase.json +16 -0
- package/docs/firestore.md +148 -0
- package/docs/functions.md +52 -0
- package/docs/images/analytics-illo_1x.png +0 -0
- package/docs/images/auth-illo_1x.png +0 -0
- package/docs/images/cloud-messaging-illo_1x.png +0 -0
- package/docs/images/database-illo_1x.png +0 -0
- package/docs/images/firestore-illo_1x.png +0 -0
- package/docs/images/functions-illo_1x.png +0 -0
- package/docs/images/hosting-illo_1x.png +0 -0
- package/docs/images/performance-illo_1x.png +0 -0
- package/docs/images/reCAPTCHA-logo@1x.png +0 -0
- package/docs/images/remote-config-illo_1x.png +0 -0
- package/docs/images/storage-illo_1x.png +0 -0
- package/docs/install-and-setup.md +114 -0
- package/docs/install-angular-cli-windows10.md +82 -0
- package/docs/install-firebase-tools.md +78 -0
- package/docs/messaging.md +25 -0
- package/docs/performance.md +57 -0
- package/docs/remote-config.md +53 -0
- package/docs/storage.md +90 -0
- package/docs/universal/cloud-functions.md +96 -0
- package/docs/universal/getting-started.md +28 -0
- package/docs/universal/prerendering.md +72 -0
- package/docs/version-4-upgrade.md +119 -0
- package/docs/version-5-upgrade.md +82 -0
- package/docs/version-6-upgrade.md +16 -0
- package/docs/version-7-upgrade.md +298 -0
- package/esm2022/analytics/analytics.module.mjs +5 -5
- package/esm2022/analytics/firebase.mjs +5 -2
- package/esm2022/analytics/screen-tracking.service.mjs +4 -4
- package/esm2022/analytics/user-tracking.service.mjs +4 -4
- package/esm2022/app/app.module.mjs +5 -5
- package/esm2022/app-check/app-check.module.mjs +5 -5
- package/esm2022/app-check/firebase.mjs +3 -2
- package/esm2022/auth/auth.module.mjs +5 -5
- package/esm2022/auth/firebase.mjs +4 -2
- package/esm2022/auth-guard/auth-guard.mjs +4 -4
- package/esm2022/auth-guard/auth-guard.module.mjs +5 -5
- package/esm2022/compat/analytics/analytics.mjs +4 -4
- package/esm2022/compat/analytics/analytics.module.mjs +5 -5
- package/esm2022/compat/analytics/screen-tracking.service.mjs +4 -4
- package/esm2022/compat/analytics/user-tracking.service.mjs +4 -4
- package/esm2022/compat/auth/auth.mjs +4 -4
- package/esm2022/compat/auth/auth.module.mjs +5 -5
- package/esm2022/compat/auth-guard/auth-guard.mjs +4 -4
- package/esm2022/compat/auth-guard/auth-guard.module.mjs +5 -5
- package/esm2022/compat/database/database.mjs +4 -4
- package/esm2022/compat/database/database.module.mjs +5 -5
- package/esm2022/compat/firebase.app.module.mjs +5 -5
- package/esm2022/compat/firestore/firestore.mjs +4 -4
- package/esm2022/compat/firestore/firestore.module.mjs +5 -5
- package/esm2022/compat/functions/functions.mjs +4 -4
- package/esm2022/compat/functions/functions.module.mjs +5 -5
- package/esm2022/compat/messaging/messaging.mjs +4 -4
- package/esm2022/compat/messaging/messaging.module.mjs +5 -5
- package/esm2022/compat/performance/performance.mjs +4 -4
- package/esm2022/compat/performance/performance.module.mjs +5 -5
- package/esm2022/compat/performance/performance.service.mjs +4 -4
- package/esm2022/compat/remote-config/remote-config.mjs +4 -4
- package/esm2022/compat/remote-config/remote-config.module.mjs +5 -5
- package/esm2022/compat/storage/pipes/storageUrl.pipe.mjs +8 -8
- package/esm2022/compat/storage/storage.mjs +4 -4
- package/esm2022/compat/storage/storage.module.mjs +5 -5
- package/esm2022/database/database.module.mjs +5 -5
- package/esm2022/firestore/firebase.mjs +22 -3
- package/esm2022/firestore/firestore.module.mjs +5 -5
- package/esm2022/firestore/lite/firebase.mjs +11 -2
- package/esm2022/firestore/lite/lite.module.mjs +5 -5
- package/esm2022/firestore/lite/rxfire.mjs +4 -2
- package/esm2022/firestore/rxfire.mjs +4 -4
- package/esm2022/functions/functions.module.mjs +5 -5
- package/esm2022/messaging/messaging.module.mjs +5 -5
- package/esm2022/performance/performance.module.mjs +5 -5
- package/esm2022/remote-config/remote-config.module.mjs +5 -5
- package/esm2022/storage/storage.module.mjs +5 -5
- package/esm2022/zones.mjs +4 -4
- package/fesm2022/angular-fire-analytics.mjs +15 -12
- package/fesm2022/angular-fire-analytics.mjs.map +1 -1
- package/fesm2022/angular-fire-app-check.mjs +7 -6
- package/fesm2022/angular-fire-app-check.mjs.map +1 -1
- package/fesm2022/angular-fire-app.mjs +4 -4
- package/fesm2022/angular-fire-app.mjs.map +1 -1
- package/fesm2022/angular-fire-auth-guard.mjs +7 -7
- package/fesm2022/angular-fire-auth-guard.mjs.map +1 -1
- package/fesm2022/angular-fire-auth.mjs +8 -6
- package/fesm2022/angular-fire-auth.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-analytics.mjs +13 -13
- package/fesm2022/angular-fire-compat-analytics.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-auth-guard.mjs +7 -7
- package/fesm2022/angular-fire-compat-auth-guard.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-auth.mjs +7 -7
- package/fesm2022/angular-fire-compat-auth.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-database.mjs +7 -7
- package/fesm2022/angular-fire-compat-database.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-firestore.mjs +7 -7
- package/fesm2022/angular-fire-compat-firestore.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-functions.mjs +7 -7
- package/fesm2022/angular-fire-compat-functions.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-messaging.mjs +7 -7
- package/fesm2022/angular-fire-compat-messaging.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-performance.mjs +10 -10
- package/fesm2022/angular-fire-compat-performance.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-remote-config.mjs +7 -7
- package/fesm2022/angular-fire-compat-remote-config.mjs.map +1 -1
- package/fesm2022/angular-fire-compat-storage.mjs +14 -14
- package/fesm2022/angular-fire-compat-storage.mjs.map +1 -1
- package/fesm2022/angular-fire-compat.mjs +4 -4
- package/fesm2022/angular-fire-compat.mjs.map +1 -1
- package/fesm2022/angular-fire-database.mjs +4 -4
- package/fesm2022/angular-fire-database.mjs.map +1 -1
- package/fesm2022/angular-fire-firestore-lite.mjs +18 -7
- package/fesm2022/angular-fire-firestore-lite.mjs.map +1 -1
- package/fesm2022/angular-fire-firestore.mjs +29 -10
- package/fesm2022/angular-fire-firestore.mjs.map +1 -1
- package/fesm2022/angular-fire-functions.mjs +4 -4
- package/fesm2022/angular-fire-functions.mjs.map +1 -1
- package/fesm2022/angular-fire-messaging.mjs +4 -4
- package/fesm2022/angular-fire-messaging.mjs.map +1 -1
- package/fesm2022/angular-fire-performance.mjs +4 -4
- package/fesm2022/angular-fire-performance.mjs.map +1 -1
- package/fesm2022/angular-fire-remote-config.mjs +4 -4
- package/fesm2022/angular-fire-remote-config.mjs.map +1 -1
- package/fesm2022/angular-fire-storage.mjs +4 -4
- package/fesm2022/angular-fire-storage.mjs.map +1 -1
- package/fesm2022/angular-fire.mjs +3 -3
- package/fesm2022/angular-fire.mjs.map +1 -1
- package/firestore/firebase.d.ts +21 -2
- package/firestore/lite/firebase.d.ts +10 -1
- package/firestore/lite/rxfire.d.ts +3 -1
- package/firestore/rxfire.d.ts +3 -3
- package/package.json +12 -12
- package/schematics/add/schema.json +16 -0
- package/schematics/builders.json +10 -0
- package/schematics/collection.json +15 -0
- package/schematics/deploy/schema.json +119 -0
- package/schematics/migration.json +15 -0
- package/schematics/setup/schema.json +16 -0
- package/publish.sh +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
|
|
2
|
+
# AngularFire
|
|
3
|
+
|
|
4
|
+
AngularFire smooths over the rough edges an Angular developer might encounter when implementing the framework-agnostic
|
|
5
|
+
[Firebase JS SDK](https://github.com/firebase/firebase-js-sdk) & aims to provide a more natural developer experience
|
|
6
|
+
by conforming to Angular conventions.
|
|
7
|
+
|
|
8
|
+
<strong><pre>ng add @angular/fire</pre></strong>
|
|
9
|
+
|
|
10
|
+
_Note: If you want to ng add AngularFire and will be using Hosting/Cloud Functions, you need to configure the
|
|
11
|
+
Firebase CLI first so that you are logged in for the schematics that are run as part of `ng add @angular/fire`.
|
|
12
|
+
Follow [this guide](docs/install-firebase-tools.md) to have the Firebase CLI walk you through the setup._
|
|
13
|
+
|
|
14
|
+
- **Dependency injection** - Provide and Inject Firebase services in your components
|
|
15
|
+
- **Zone.js wrappers** - Stable zones allow proper functionality of service workers, forms, SSR, and pre-rendering
|
|
16
|
+
- **Observable based** - Utilize RxJS rather than callbacks for realtime streams
|
|
17
|
+
- **NgRx friendly API** - Integrate with NgRx using AngularFire's action based APIs.
|
|
18
|
+
- **Lazy-loading** - AngularFire dynamically imports much of Firebase, reducing time to load your app
|
|
19
|
+
- **Deploy schematics** - Get your Angular application deployed on Firebase Hosting with a single command
|
|
20
|
+
- **Google Analytics** - Zero-effort Angular Router awareness in Google Analytics
|
|
21
|
+
- **Router Guards** - Guard your Angular routes with built-in Firebase Authentication checks
|
|
22
|
+
|
|
23
|
+
## Example use
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { provideFirebaseApp, getApp, initializeApp } from '@angular/fire/app';
|
|
27
|
+
import { getFirestore, provideFirestore } from '@angular/fire/firestore';
|
|
28
|
+
|
|
29
|
+
@NgModule({
|
|
30
|
+
imports: [
|
|
31
|
+
provideFirebaseApp(() => initializeApp({ ... })),
|
|
32
|
+
provideFirestore(() => getFirestore()),
|
|
33
|
+
],
|
|
34
|
+
...
|
|
35
|
+
})
|
|
36
|
+
export class AppModule { }
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { inject } from '@angular/core';
|
|
41
|
+
import { Firestore, collectionData, collection } from '@angular/fire/firestore';
|
|
42
|
+
import { Observable } from 'rxjs';
|
|
43
|
+
|
|
44
|
+
interface Item {
|
|
45
|
+
name: string,
|
|
46
|
+
...
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
@Component({
|
|
50
|
+
selector: 'app-root',
|
|
51
|
+
template: `
|
|
52
|
+
<ul>
|
|
53
|
+
<li *ngFor="let item of item$ | async">
|
|
54
|
+
{{ item.name }}
|
|
55
|
+
</li>
|
|
56
|
+
</ul>
|
|
57
|
+
`
|
|
58
|
+
})
|
|
59
|
+
export class AppComponent {
|
|
60
|
+
item$: Observable<Item[]>;
|
|
61
|
+
firestore: Firestore = inject(Firestore);
|
|
62
|
+
|
|
63
|
+
constructor() {
|
|
64
|
+
const itemCollection = collection(this.firestore, 'items');
|
|
65
|
+
this.item$ = collectionData(itemCollection);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Polyfills
|
|
71
|
+
|
|
72
|
+
Neither AngularFire or Firebase ship with polyfills. To have compatibility across as wide-range of environments we suggest the following polyfills be added to your application:
|
|
73
|
+
|
|
74
|
+
| API | Environments | Suggested Polyfill | License |
|
|
75
|
+
|-----|--------------|--------------------|---------|
|
|
76
|
+
| Various ES5+ features | Safari < 10 | [`core-js/stable`](https://github.com/zloirock/core-js#readme) | MIT |
|
|
77
|
+
| `globalThis` | [Chrome < 71<br>Safari < 12.1<br>iOS < 12.2<br>Node < 12](https://caniuse.com/mdn-javascript_builtins_globalthis) | [`globalThis`](https://github.com/es-shims/globalThis#readme) | MIT |
|
|
78
|
+
| `Proxy` | [Safari < 10](https://caniuse.com/proxy) | [`proxy-polyfill`](https://github.com/GoogleChrome/proxy-polyfill#readme) | Apache 2.0 |
|
|
79
|
+
| `fetch` | [Safari < 10.1<br>iOS < 10.3](https://caniuse.com/fetch) | [`cross-fetch`](https://github.com/lquixada/cross-fetch#readme) | MIT |
|
|
80
|
+
|
|
81
|
+
## Resources
|
|
82
|
+
|
|
83
|
+
[Quickstart](docs/install-and-setup.md) - Get your first application up and running by following our quickstart guide.
|
|
84
|
+
|
|
85
|
+
[Contributing](CONTRIBUTING.md)
|
|
86
|
+
|
|
87
|
+
[Stackblitz Template](https://stackblitz.com/edit/angular-fire-start) - Remember to set your Firebase configuration in `app/app.module.ts`.
|
|
88
|
+
|
|
89
|
+
[Upgrading to v7.0? Check out our guide.](docs/version-7-upgrade.md)
|
|
90
|
+
|
|
91
|
+
### Sample apps
|
|
92
|
+
|
|
93
|
+
We have three sample apps in this repository:
|
|
94
|
+
|
|
95
|
+
1. [`samples/compat`](samples/compat) a kitchen sink application that demonstrates use of the "compatibility" API
|
|
96
|
+
1. [`samples/modular`](samples/modular) a kitchen sink application that demonstrates the new tree-shakable API
|
|
97
|
+
1. [`samples/advanced`](samples/advanced) the same app as `samples/modular` but demonstrates more advanced concepts such as Angular Universal state-transfer, dynamically importing Firebase feature modules, and Firestore data bundling.
|
|
98
|
+
|
|
99
|
+
### Having troubles?
|
|
100
|
+
|
|
101
|
+
Get help on our [Q&A board](https://github.com/angular/angularfire/discussions?discussions_q=category%3AQ%26A), the official [Firebase Mailing List](https://groups.google.com/forum/#!forum/firebase-talk), the [Firebase Community Slack](https://firebase.community/) (`#angularfire2`), the [Angular Community Discord](http://discord.gg/angular) (`#firebase`), [Gitter](https://gitter.im/angular/angularfire2), the [Firebase subreddit](https://www.reddit.com/r/firebase), or [Stack Overflow](https://stackoverflow.com/questions/tagged/angularfire2).
|
|
102
|
+
|
|
103
|
+
> **NOTE:** AngularFire is maintained by Googlers but is not a supported Firebase product. Questions on the mailing list and issues filed here are answered on a <strong>best-effort basis</strong> by maintainers and other community members. If you are able to reproduce a problem with Firebase <em>outside of AngularFire's implementation</em>, please [file an issue on the Firebase JS SDK](https://github.com/firebase/firebase-js-sdk/issues) or reach out to the personalized [Firebase support channel](https://firebase.google.com/support/).
|
|
104
|
+
|
|
105
|
+
## Developer Guide
|
|
106
|
+
|
|
107
|
+
This developer guide assimes you're using the new tree-shakable AngularFire API, [if you're looking for the compatability API you can find the documentation here](docs/compat.md).
|
|
108
|
+
|
|
109
|
+
[See the v7 upgrade guide for more information on this change.](docs/version-7-upgrade.md).
|
|
110
|
+
|
|
111
|
+
### Firebase product integrations
|
|
112
|
+
|
|
113
|
+
<table>
|
|
114
|
+
<tr>
|
|
115
|
+
<td>
|
|
116
|
+
|
|
117
|
+
#### [Analytics](docs/analytics.md#analytics)
|
|
118
|
+
```ts
|
|
119
|
+
import { } from '@angular/fire/analytics';
|
|
120
|
+
```
|
|
121
|
+
</td>
|
|
122
|
+
<td>
|
|
123
|
+
|
|
124
|
+
#### [Authentication](docs/auth.md#authentication)
|
|
125
|
+
```ts
|
|
126
|
+
import { } from '@angular/fire/auth';
|
|
127
|
+
```
|
|
128
|
+
</td>
|
|
129
|
+
</tr>
|
|
130
|
+
<tr>
|
|
131
|
+
<td>
|
|
132
|
+
|
|
133
|
+
#### [Cloud Firestore](docs/firestore.md#cloud-firestore)
|
|
134
|
+
```ts
|
|
135
|
+
import { } from '@angular/fire/firestore';
|
|
136
|
+
```
|
|
137
|
+
</td>
|
|
138
|
+
<td>
|
|
139
|
+
|
|
140
|
+
#### [Cloud Functions](docs/functions.md#cloud-functions)
|
|
141
|
+
```ts
|
|
142
|
+
import { } from '@angular/fire/functions';
|
|
143
|
+
```
|
|
144
|
+
</td>
|
|
145
|
+
</tr>
|
|
146
|
+
<tr>
|
|
147
|
+
<td>
|
|
148
|
+
|
|
149
|
+
#### [Cloud Messaging](docs/messaging.md#cloud-messaging)
|
|
150
|
+
```ts
|
|
151
|
+
import { } from '@angular/fire/messaging';
|
|
152
|
+
```
|
|
153
|
+
</td>
|
|
154
|
+
<td>
|
|
155
|
+
|
|
156
|
+
#### [Cloud Storage](docs/storage.md#cloud-storage)
|
|
157
|
+
```ts
|
|
158
|
+
import { } from '@angular/fire/storage';
|
|
159
|
+
```
|
|
160
|
+
</td>
|
|
161
|
+
</tr>
|
|
162
|
+
<tr>
|
|
163
|
+
<td>
|
|
164
|
+
|
|
165
|
+
#### [Performance Monitoring](docs/performance.md#performance-monitoring)
|
|
166
|
+
```ts
|
|
167
|
+
import { } from '@angular/fire/performance';
|
|
168
|
+
```
|
|
169
|
+
</td>
|
|
170
|
+
<td>
|
|
171
|
+
|
|
172
|
+
#### [Realtime Database](docs/database.md#realtime-database)
|
|
173
|
+
```ts
|
|
174
|
+
import { } from '@angular/fire/database';
|
|
175
|
+
```
|
|
176
|
+
</td>
|
|
177
|
+
</tr>
|
|
178
|
+
<tr>
|
|
179
|
+
<td>
|
|
180
|
+
|
|
181
|
+
#### [Remote Config](docs/remote-config.md#remote-config)
|
|
182
|
+
```ts
|
|
183
|
+
import { } from '@angular/fire/remote-config';
|
|
184
|
+
```
|
|
185
|
+
</td>
|
|
186
|
+
<td>
|
|
187
|
+
|
|
188
|
+
#### [App Check](docs/app-check.md#app-check)
|
|
189
|
+
```ts
|
|
190
|
+
import { } from '@angular/fire/app-check';
|
|
191
|
+
```
|
|
192
|
+
</td>
|
|
193
|
+
</tr>
|
|
194
|
+
</table>
|
|
195
|
+
|
|
196
|
+
### Deploying your site
|
|
197
|
+
|
|
198
|
+
* Deploy to Firebase Hosting
|
|
199
|
+
* Angular Universal: Deploy to Cloud Functions
|
|
200
|
+
* Angular Universal: Deploy to Cloud Run
|
package/analytics/firebase.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
export * from 'firebase/analytics';
|
|
2
|
-
import { getAnalytics as _getAnalytics, initializeAnalytics as _initializeAnalytics, logEvent as _logEvent, setAnalyticsCollectionEnabled as _setAnalyticsCollectionEnabled, setCurrentScreen as _setCurrentScreen, settings as _settings, setUserId as _setUserId, setUserProperties as _setUserProperties } from 'firebase/analytics';
|
|
2
|
+
import { getAnalytics as _getAnalytics, getGoogleAnalyticsClientId as _getGoogleAnalyticsClientId, initializeAnalytics as _initializeAnalytics, logEvent as _logEvent, setAnalyticsCollectionEnabled as _setAnalyticsCollectionEnabled, setConsent as _setConsent, setCurrentScreen as _setCurrentScreen, setDefaultEventParameters as _setDefaultEventParameters, settings as _settings, setUserId as _setUserId, setUserProperties as _setUserProperties } from 'firebase/analytics';
|
|
3
3
|
export { isSupported } from './overrides';
|
|
4
4
|
export declare const getAnalytics: typeof _getAnalytics;
|
|
5
|
+
export declare const getGoogleAnalyticsClientId: typeof _getGoogleAnalyticsClientId;
|
|
5
6
|
export declare const initializeAnalytics: typeof _initializeAnalytics;
|
|
6
7
|
export declare const logEvent: typeof _logEvent;
|
|
7
8
|
export declare const setAnalyticsCollectionEnabled: typeof _setAnalyticsCollectionEnabled;
|
|
9
|
+
export declare const setConsent: typeof _setConsent;
|
|
8
10
|
export declare const setCurrentScreen: typeof _setCurrentScreen;
|
|
11
|
+
export declare const setDefaultEventParameters: typeof _setDefaultEventParameters;
|
|
9
12
|
export declare const settings: typeof _settings;
|
|
10
13
|
export declare const setUserId: typeof _setUserId;
|
|
11
14
|
export declare const setUserProperties: typeof _setUserProperties;
|
package/app-check/firebase.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from 'firebase/app-check';
|
|
2
|
-
import { getToken as _getToken, initializeAppCheck as _initializeAppCheck, onTokenChanged as _onTokenChanged, setTokenAutoRefreshEnabled as _setTokenAutoRefreshEnabled } from 'firebase/app-check';
|
|
2
|
+
import { getLimitedUseToken as _getLimitedUseToken, getToken as _getToken, initializeAppCheck as _initializeAppCheck, onTokenChanged as _onTokenChanged, setTokenAutoRefreshEnabled as _setTokenAutoRefreshEnabled } from 'firebase/app-check';
|
|
3
|
+
export declare const getLimitedUseToken: typeof _getLimitedUseToken;
|
|
3
4
|
export declare const getToken: typeof _getToken;
|
|
4
5
|
export declare const initializeAppCheck: typeof _initializeAppCheck;
|
|
5
6
|
export declare const onTokenChanged: typeof _onTokenChanged;
|
package/auth/firebase.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from 'firebase/auth';
|
|
2
|
-
import { applyActionCode as _applyActionCode, beforeAuthStateChanged as _beforeAuthStateChanged, checkActionCode as _checkActionCode, confirmPasswordReset as _confirmPasswordReset, connectAuthEmulator as _connectAuthEmulator, createUserWithEmailAndPassword as _createUserWithEmailAndPassword, deleteUser as _deleteUser, fetchSignInMethodsForEmail as _fetchSignInMethodsForEmail, getAdditionalUserInfo as _getAdditionalUserInfo, getAuth as _getAuth, getIdToken as _getIdToken, getIdTokenResult as _getIdTokenResult, getMultiFactorResolver as _getMultiFactorResolver, getRedirectResult as _getRedirectResult, initializeAuth as _initializeAuth, isSignInWithEmailLink as _isSignInWithEmailLink, linkWithCredential as _linkWithCredential, linkWithPhoneNumber as _linkWithPhoneNumber, linkWithPopup as _linkWithPopup, linkWithRedirect as _linkWithRedirect, multiFactor as _multiFactor, onAuthStateChanged as _onAuthStateChanged, onIdTokenChanged as _onIdTokenChanged, parseActionCodeURL as _parseActionCodeURL, reauthenticateWithCredential as _reauthenticateWithCredential, reauthenticateWithPhoneNumber as _reauthenticateWithPhoneNumber, reauthenticateWithPopup as _reauthenticateWithPopup, reauthenticateWithRedirect as _reauthenticateWithRedirect, reload as _reload, sendEmailVerification as _sendEmailVerification, sendPasswordResetEmail as _sendPasswordResetEmail, sendSignInLinkToEmail as _sendSignInLinkToEmail, setPersistence as _setPersistence, signInAnonymously as _signInAnonymously, signInWithCredential as _signInWithCredential, signInWithCustomToken as _signInWithCustomToken, signInWithEmailAndPassword as _signInWithEmailAndPassword, signInWithEmailLink as _signInWithEmailLink, signInWithPhoneNumber as _signInWithPhoneNumber, signInWithPopup as _signInWithPopup, signInWithRedirect as _signInWithRedirect, signOut as _signOut, unlink as _unlink, updateCurrentUser as _updateCurrentUser, updateEmail as _updateEmail, updatePassword as _updatePassword, updatePhoneNumber as _updatePhoneNumber, updateProfile as _updateProfile, useDeviceLanguage as _useDeviceLanguage, verifyBeforeUpdateEmail as _verifyBeforeUpdateEmail, verifyPasswordResetCode as _verifyPasswordResetCode } from 'firebase/auth';
|
|
2
|
+
import { applyActionCode as _applyActionCode, beforeAuthStateChanged as _beforeAuthStateChanged, checkActionCode as _checkActionCode, confirmPasswordReset as _confirmPasswordReset, connectAuthEmulator as _connectAuthEmulator, createUserWithEmailAndPassword as _createUserWithEmailAndPassword, deleteUser as _deleteUser, fetchSignInMethodsForEmail as _fetchSignInMethodsForEmail, getAdditionalUserInfo as _getAdditionalUserInfo, getAuth as _getAuth, getIdToken as _getIdToken, getIdTokenResult as _getIdTokenResult, getMultiFactorResolver as _getMultiFactorResolver, getRedirectResult as _getRedirectResult, initializeAuth as _initializeAuth, initializeRecaptchaConfig as _initializeRecaptchaConfig, isSignInWithEmailLink as _isSignInWithEmailLink, linkWithCredential as _linkWithCredential, linkWithPhoneNumber as _linkWithPhoneNumber, linkWithPopup as _linkWithPopup, linkWithRedirect as _linkWithRedirect, multiFactor as _multiFactor, onAuthStateChanged as _onAuthStateChanged, onIdTokenChanged as _onIdTokenChanged, parseActionCodeURL as _parseActionCodeURL, reauthenticateWithCredential as _reauthenticateWithCredential, reauthenticateWithPhoneNumber as _reauthenticateWithPhoneNumber, reauthenticateWithPopup as _reauthenticateWithPopup, reauthenticateWithRedirect as _reauthenticateWithRedirect, reload as _reload, sendEmailVerification as _sendEmailVerification, sendPasswordResetEmail as _sendPasswordResetEmail, sendSignInLinkToEmail as _sendSignInLinkToEmail, setPersistence as _setPersistence, signInAnonymously as _signInAnonymously, signInWithCredential as _signInWithCredential, signInWithCustomToken as _signInWithCustomToken, signInWithEmailAndPassword as _signInWithEmailAndPassword, signInWithEmailLink as _signInWithEmailLink, signInWithPhoneNumber as _signInWithPhoneNumber, signInWithPopup as _signInWithPopup, signInWithRedirect as _signInWithRedirect, signOut as _signOut, unlink as _unlink, updateCurrentUser as _updateCurrentUser, updateEmail as _updateEmail, updatePassword as _updatePassword, updatePhoneNumber as _updatePhoneNumber, updateProfile as _updateProfile, useDeviceLanguage as _useDeviceLanguage, validatePassword as _validatePassword, verifyBeforeUpdateEmail as _verifyBeforeUpdateEmail, verifyPasswordResetCode as _verifyPasswordResetCode } from 'firebase/auth';
|
|
3
3
|
export declare const applyActionCode: typeof _applyActionCode;
|
|
4
4
|
export declare const beforeAuthStateChanged: typeof _beforeAuthStateChanged;
|
|
5
5
|
export declare const checkActionCode: typeof _checkActionCode;
|
|
@@ -15,6 +15,7 @@ export declare const getIdTokenResult: typeof _getIdTokenResult;
|
|
|
15
15
|
export declare const getMultiFactorResolver: typeof _getMultiFactorResolver;
|
|
16
16
|
export declare const getRedirectResult: typeof _getRedirectResult;
|
|
17
17
|
export declare const initializeAuth: typeof _initializeAuth;
|
|
18
|
+
export declare const initializeRecaptchaConfig: typeof _initializeRecaptchaConfig;
|
|
18
19
|
export declare const isSignInWithEmailLink: typeof _isSignInWithEmailLink;
|
|
19
20
|
export declare const linkWithCredential: typeof _linkWithCredential;
|
|
20
21
|
export declare const linkWithPhoneNumber: typeof _linkWithPhoneNumber;
|
|
@@ -49,5 +50,6 @@ export declare const updatePassword: typeof _updatePassword;
|
|
|
49
50
|
export declare const updatePhoneNumber: typeof _updatePhoneNumber;
|
|
50
51
|
export declare const updateProfile: typeof _updateProfile;
|
|
51
52
|
export declare const useDeviceLanguage: typeof _useDeviceLanguage;
|
|
53
|
+
export declare const validatePassword: typeof _validatePassword;
|
|
52
54
|
export declare const verifyBeforeUpdateEmail: typeof _verifyBeforeUpdateEmail;
|
|
53
55
|
export declare const verifyPasswordResetCode: typeof _verifyPasswordResetCode;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<img align="right" width="30%" src="images/analytics-illo_1x.png">
|
|
2
|
+
|
|
3
|
+
<small>
|
|
4
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Analytics
|
|
5
|
+
</small>
|
|
6
|
+
|
|
7
|
+
# Analytics
|
|
8
|
+
|
|
9
|
+
Google Analytics is an app measurement solution, available at no charge, that provides insight on app usage and user engagement.
|
|
10
|
+
|
|
11
|
+
[Learn more](https://firebase.google.com/docs/analytics)
|
|
12
|
+
## Dependency Injection
|
|
13
|
+
|
|
14
|
+
As a prerequisite, ensure that `AngularFire` has been added to your project via
|
|
15
|
+
```bash
|
|
16
|
+
ng add @angular/fire
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Provide a Google Analytics instance in the application's `NgModule` (`app.module.ts`):
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
@NgModule({
|
|
23
|
+
declarations: [
|
|
24
|
+
...
|
|
25
|
+
],
|
|
26
|
+
imports: [
|
|
27
|
+
...
|
|
28
|
+
// App initialization
|
|
29
|
+
provideFirebaseApp(() => initializeApp(environment.firebase)),
|
|
30
|
+
provideAnalytics(() => getAnalytics())
|
|
31
|
+
],
|
|
32
|
+
providers: [],
|
|
33
|
+
bootstrap: [AppComponent]
|
|
34
|
+
})
|
|
35
|
+
export class AppModule { }
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
In your component class, for example `user-profile.component.ts` import and inject `Firestore`:
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { Component, inject } from '@angular/core';
|
|
42
|
+
import { Analytics } from '@angular/fire/analytics';
|
|
43
|
+
|
|
44
|
+
@Component({
|
|
45
|
+
standalone: true,
|
|
46
|
+
selector: 'app-user-profile',
|
|
47
|
+
...
|
|
48
|
+
})
|
|
49
|
+
export class UserProfileComponent {
|
|
50
|
+
private analytics: Analytics = inject(Analytics);
|
|
51
|
+
...
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Firebase API
|
|
56
|
+
|
|
57
|
+
The [Firebase API for Google Analytics documentation](https://firebase.google.com/docs/reference/js/analytics.md#analytics_package) is available on the Firebase website.
|
|
58
|
+
|
|
59
|
+
## Services
|
|
60
|
+
|
|
61
|
+
### ScreenTrackingService
|
|
62
|
+
|
|
63
|
+
Coming soon, for now [please review the documentation](https://firebase.google.com/docs/analytics/screenviews)
|
|
64
|
+
|
|
65
|
+
### UserTrackingService
|
|
66
|
+
Coming soon
|
|
67
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<small>
|
|
2
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Realtime App Check
|
|
3
|
+
</small>
|
|
4
|
+
|
|
5
|
+
<img align="right" width="30%" src="images/reCAPTCHA-logo@1x.png">
|
|
6
|
+
|
|
7
|
+
# App Check
|
|
8
|
+
|
|
9
|
+
App Check helps protect your API resources from abuse by preventing unauthorized clients from accessing your backend resources. It works with both Firebase services, Google Cloud services, and your own APIs to keep your resources safe.
|
|
10
|
+
|
|
11
|
+
[Learn More](https://firebase.google.com/docs/app-check)
|
|
12
|
+
|
|
13
|
+
## Dependency Injection
|
|
14
|
+
As a prerequisite, ensure that `AngularFire` has been added to your project via
|
|
15
|
+
```bash
|
|
16
|
+
ng add @angular/fire
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Provide an App Check instance and configuration in the application's `NgModule` (`app.module.ts`):
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
23
|
+
import { provideAppCheck } from '@angular/fire/app-check';
|
|
24
|
+
|
|
25
|
+
@NgModule({
|
|
26
|
+
imports: [
|
|
27
|
+
provideFirebaseApp(() => initializeApp(environment.firebase)),
|
|
28
|
+
provideAppCheck(() => initializeAppCheck(getApp(), {
|
|
29
|
+
provider: new ReCaptchaV3Provider(/* configuration */),
|
|
30
|
+
})),
|
|
31
|
+
]
|
|
32
|
+
})
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Next inject it into your component:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { Component, inject} from '@angular/core';
|
|
39
|
+
import { AppCheck } from '@angular/fire/app-check';
|
|
40
|
+
|
|
41
|
+
@Component({ ... })
|
|
42
|
+
export class AppCheckComponent {
|
|
43
|
+
private appCheck: AppCheck = inject(AppCheck);
|
|
44
|
+
...
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Firebase API
|
|
49
|
+
|
|
50
|
+
The [AppCheck documentation](https://firebase.google.com/docs/reference/js/app-check) is available on the Firebase website.
|
|
51
|
+
|
|
52
|
+
## Convenience observables
|
|
53
|
+
Coming soon.
|
package/docs/auth.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
<img align="right" width="30%" src="images/auth-illo_1x.png">
|
|
2
|
+
|
|
3
|
+
<small>
|
|
4
|
+
<a href="https://github.com/angular/angularfire">AngularFire</a> ❱ <a href="../README.md#developer-guide">Developer Guide</a> ❱ Authentication
|
|
5
|
+
</small>
|
|
6
|
+
|
|
7
|
+
# Authentication
|
|
8
|
+
|
|
9
|
+
Most apps need to know the identity of a user. Knowing a user's identity allows an app to securely save user data in the cloud and provide the same personalized experience across all of the user's devices.
|
|
10
|
+
Firebase Authentication provides backend services, easy-to-use SDKs, and ready-made UI libraries to authenticate users to your app. It supports authentication using passwords, phone numbers, popular federated identity providers like Google, Facebook and Twitter, and more.
|
|
11
|
+
|
|
12
|
+
Firebase Authentication integrates tightly with other Firebase services, and it leverages industry standards like OAuth 2.0 and OpenID Connect, so it can be easily integrated with your custom backend.
|
|
13
|
+
|
|
14
|
+
[Learn more about Firebase Authentication](https://firebase.google.com/docs/auth)
|
|
15
|
+
|
|
16
|
+
## Dependency Injection
|
|
17
|
+
|
|
18
|
+
As a prerequisite, ensure that `AngularFire` has been added to your project via
|
|
19
|
+
```bash
|
|
20
|
+
ng add @angular/fire
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Provide an auth instance in the application's `NgModule` (`app.module.ts`):
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
27
|
+
import { getAuth, provideAuth } from '@angular/fire/auth';
|
|
28
|
+
|
|
29
|
+
@NgModule({
|
|
30
|
+
imports: [
|
|
31
|
+
provideFirebaseApp(() => initializeApp(environment.firebase)),
|
|
32
|
+
provideAuth(() => getAuth()),
|
|
33
|
+
]
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Next inject it into your component:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { Component, inject} from '@angular/core';
|
|
41
|
+
import { Auth } from '@angular/fire/auth';
|
|
42
|
+
|
|
43
|
+
@Component({ ... })
|
|
44
|
+
export class LoginComponent {
|
|
45
|
+
private auth: Auth = inject(Auth);
|
|
46
|
+
...
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Firebase API
|
|
51
|
+
|
|
52
|
+
AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.
|
|
53
|
+
|
|
54
|
+
Update the imports from `import { ... } from 'firebase/auth'` to `import { ... } from '@angular/fire/auth'` and follow the offical documentation.
|
|
55
|
+
|
|
56
|
+
[Getting Started](https://firebase.google.com/docs/auth/web/start) | [API Reference](https://firebase.google.com/docs/reference/js/auth)
|
|
57
|
+
|
|
58
|
+
## Convenience observables
|
|
59
|
+
|
|
60
|
+
AngularFire provides observables to allow convenient use of the Firebase Authentication with RXJS.
|
|
61
|
+
|
|
62
|
+
### user
|
|
63
|
+
|
|
64
|
+
The `user` observable streams events triggered by sign-in, sign-out, and token refresh events.
|
|
65
|
+
|
|
66
|
+
Example code:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { Auth, User, user } from '@angular/fire/auth';
|
|
70
|
+
...
|
|
71
|
+
|
|
72
|
+
export class UserComponent implements OnDestroy {
|
|
73
|
+
private auth: Auth = inject(Auth);
|
|
74
|
+
user$ = user(auth);
|
|
75
|
+
userSubscription: Subscription;
|
|
76
|
+
...
|
|
77
|
+
|
|
78
|
+
constructor() {
|
|
79
|
+
this.userSubscription = this.user$.subscribe((aUser: User | null) => {
|
|
80
|
+
//handle user state changes here. Note, that user will be null if there is no currently logged in user.
|
|
81
|
+
console.log(aUser);
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
ngOnDestroy() {
|
|
86
|
+
// when manually subscribing to an observable remember to unsubscribe in ngOnDestroy
|
|
87
|
+
this.userSubscription.unsubscribe();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### authState
|
|
94
|
+
|
|
95
|
+
The `authState` observable streams events triggered by sign-in and sign-out events.
|
|
96
|
+
|
|
97
|
+
Example code:
|
|
98
|
+
```ts
|
|
99
|
+
import { Auth, authState } from '@angular/fire/auth';
|
|
100
|
+
...
|
|
101
|
+
|
|
102
|
+
export class UserComponent implements OnDestroy {
|
|
103
|
+
private auth: Auth = inject(Auth);
|
|
104
|
+
authState$ = authState(auth);
|
|
105
|
+
authStateSubscription: Subscription;
|
|
106
|
+
...
|
|
107
|
+
|
|
108
|
+
constructor() {
|
|
109
|
+
this.authStateSubscription = this.authState$.subscribe((aUser: User | null) => {
|
|
110
|
+
//handle auth state changes here. Note, that user will be null if there is no currently logged in user.
|
|
111
|
+
console.log(aUser);
|
|
112
|
+
})
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
ngOnDestroy() {
|
|
116
|
+
// when manually subscribing to an observable remember to unsubscribe in ngOnDestroy
|
|
117
|
+
this.authStateSubscription.unsubscribe();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### idToken
|
|
123
|
+
|
|
124
|
+
The `idToken` observable streams events triggered by sign-in, sign-out and token refresh events.
|
|
125
|
+
|
|
126
|
+
Example code:
|
|
127
|
+
```ts
|
|
128
|
+
import { Auth, idToken } from '@angular/fire/auth';
|
|
129
|
+
...
|
|
130
|
+
|
|
131
|
+
export class UserComponent implements OnDestroy {
|
|
132
|
+
private auth: Auth = inject(Auth);
|
|
133
|
+
idToken$ = idToken(auth);
|
|
134
|
+
idTokenSubscription: Subscription;
|
|
135
|
+
...
|
|
136
|
+
|
|
137
|
+
constructor() {
|
|
138
|
+
this.idTokenSubscription = this.idToken$.subscribe((token: string | null) => {
|
|
139
|
+
//handle idToken changes here. Note, that user will be null if there is no currently logged in user.
|
|
140
|
+
console.log(string);
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
ngOnDestroy() {
|
|
145
|
+
// when manually subscribing to an observable remember to unsubscribe in ngOnDestroy
|
|
146
|
+
this.idTokenSubscription.unsubscribe();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Connecting the emulator suite
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
import { connectAuthEmulator, getAuth, provideAuth } from '@angular/fire/auth';
|
|
155
|
+
|
|
156
|
+
@NgModule({
|
|
157
|
+
imports: [
|
|
158
|
+
provideAuth(() => {
|
|
159
|
+
const auth = getAuth();
|
|
160
|
+
connectAuthEmulator(auth, 'http://localhost:9099', { disableWarnings: true });
|
|
161
|
+
return auth;
|
|
162
|
+
}),
|
|
163
|
+
]
|
|
164
|
+
})
|
|
165
|
+
```
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Getting started with Google Analytics
|
|
2
|
+
|
|
3
|
+
`AngularFireAnalytics` dynamically imports the `firebase/analytics` library and provides a promisified version of the [Firebase Analytics SDK (`firebase.analytics.Analytics`)](https://firebase.google.com/docs/reference/js/firebase.analytics.Analytics.html).
|
|
4
|
+
|
|
5
|
+
> **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md).
|
|
6
|
+
|
|
7
|
+
### API:
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
class AngularFireAnalytics {
|
|
11
|
+
updateConfig(options: {[key:string]: any}): Promise<void>;
|
|
12
|
+
|
|
13
|
+
// from firebase.analytics() proxy:
|
|
14
|
+
logEvent(eventName: string, eventParams?: {[key: string]: any}, options?: analytics.AnalyticsCallOptions): Promise<void>;
|
|
15
|
+
setCurrentScreen(screenName: string, options?: analytics.AnalyticsCallOptions): Promise<void>;
|
|
16
|
+
setUserId(id: string, options?: analytics.AnalyticsCallOptions): Promise<void>;
|
|
17
|
+
setUserProperties(properties: analytics.CustomParams, options?: analytics.AnalyticsCallOptions): Promise<void>;
|
|
18
|
+
setAnalyticsCollectionEnabled(enabled: boolean): Promise<void>;
|
|
19
|
+
app: Promise<app.App>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
COLLECTION_ENABLED = InjectionToken<boolean>;
|
|
23
|
+
APP_VERSION = InjectionToken<string>;
|
|
24
|
+
APP_NAME = InjectionToken<string>;
|
|
25
|
+
DEBUG_MODE = InjectionToken<boolean>;
|
|
26
|
+
CONFIG = InjectionToken<Config>;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Usage:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { AngularFireAnalyticsModule } from '@angular/fire/compat/analytics';
|
|
33
|
+
|
|
34
|
+
@NgModule({
|
|
35
|
+
imports: [
|
|
36
|
+
AngularFireModule.initializeApp(environment.firebase),
|
|
37
|
+
AngularFireAnalyticsModule
|
|
38
|
+
]
|
|
39
|
+
})
|
|
40
|
+
export class AppModule { }
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`AngularFireAnalyticsModule` will dynamically import and configure `firebase/analytics`. A `page_view` event will automatically be logged (see `CONFIG` below if you wish to disable this behavior.)
|
|
44
|
+
|
|
45
|
+
In your component you can then dependency inject `AngularFireAnalytics` and make calls against the SDK:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { AngularFireAnalytics } from '@angular/fire/compat/analytics';
|
|
49
|
+
|
|
50
|
+
constructor(analytics: AngularFireAnalytics) {
|
|
51
|
+
analytics.logEvent('custom_event', { ... });
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Tracking Screen Views
|
|
56
|
+
|
|
57
|
+
You can log [`screen_view` events](https://firebase.google.com/docs/reference/js/firebase.analytics.Analytics.html#parameters_10) yourself of course, but AngularFire provides the `ScreenTrackingService` which automatically integrates with the Angular Router to provide Firebase with screen view tracking. You simply can integrate like so:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { AngularFireAnalyticsModule, ScreenTrackingService } from '@angular/fire/compat/analytics';
|
|
61
|
+
|
|
62
|
+
@NgModule({
|
|
63
|
+
imports: [
|
|
64
|
+
AngularFireModule.initializeApp(environment.firebase),
|
|
65
|
+
AngularFireAnalyticsModule
|
|
66
|
+
],
|
|
67
|
+
providers: [
|
|
68
|
+
ScreenTrackingService
|
|
69
|
+
]
|
|
70
|
+
})
|
|
71
|
+
export class AppModule { }
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`AngularFireAnalyticsModule` will initialize `ScreenTrackingService` if it is provided.
|
|
75
|
+
|
|
76
|
+
## Tracking User Identifiers
|
|
77
|
+
|
|
78
|
+
To enrich your Analytics data you can track the currently signed in user by setting [`setuserid`](https://firebase.google.com/docs/reference/js/firebase.analytics.Analytics.html#setuserid) and [`setUserProperties`](https://firebase.google.com/docs/reference/js/firebase.analytics.Analytics.html#set-user-properties). AngularFire provides a `UserTrackingService` which will dynamically import `firebase/auth`, monitor for changes in the logged in user, and call `setuserid` for you automatically.
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
import { AngularFireAnalyticsModule, UserTrackingService } from '@angular/fire/compat/analytics';
|
|
83
|
+
|
|
84
|
+
@NgModule({
|
|
85
|
+
imports: [
|
|
86
|
+
AngularFireModule.initializeApp(environment.firebase),
|
|
87
|
+
AngularFireAnalyticsModule
|
|
88
|
+
],
|
|
89
|
+
providers: [
|
|
90
|
+
UserTrackingService
|
|
91
|
+
]
|
|
92
|
+
})
|
|
93
|
+
export class AppModule { }
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`AngularFireAnalyticsModule` will initialize `UserTrackingService` if it is provided.
|
|
97
|
+
|
|
98
|
+
## Configuration with Dependency Injection
|
|
99
|
+
|
|
100
|
+
### Configure Google Analtyics with `CONFIG`
|
|
101
|
+
|
|
102
|
+
Using the `CONFIG` DI Token (*default: {}*) will allow you to configure Google Analytics. E.g, you could skip sending the initial `page_view` event, anonymize IP addresses, and disallow ads personalization signals for all events like so:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
import { AngularFireAnalyticsModule, CONFIG } from '@angular/fire/compat/analytics';
|
|
106
|
+
|
|
107
|
+
@NgModule({
|
|
108
|
+
imports: [
|
|
109
|
+
AngularFireModule.initializeApp(environment.firebase),
|
|
110
|
+
AngularFireAnalyticsModule
|
|
111
|
+
],
|
|
112
|
+
providers: [
|
|
113
|
+
{ provide: CONFIG, useValue: {
|
|
114
|
+
send_page_view: false,
|
|
115
|
+
allow_ad_personalization_signals: false,
|
|
116
|
+
anonymize_ip: true
|
|
117
|
+
} }
|
|
118
|
+
]
|
|
119
|
+
})
|
|
120
|
+
export class AppModule { }
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
See the gtag.js documentation to learn of the different configuration options at your disposal.
|
|
124
|
+
|
|
125
|
+
### Use DebugView `DEBUG_MODE`
|
|
126
|
+
|
|
127
|
+
To use [DebugView in Analytics](https://console.firebase.google.com/project/_/analytics/debugview) set `DEBUG_MODE` to `true` (*default: false*).
|
|
128
|
+
|
|
129
|
+
### Track deployments with `APP_NAME` and `APP_VERSION`
|
|
130
|
+
|
|
131
|
+
If you provide `APP_NAME` and `APP_VERSION` (*default: undefined*) you will be able to [track version adoption](https://console.firebase.google.com/project/_/analytics/latestrelease) of your PWA.
|
|
132
|
+
|
|
133
|
+
### Disable analytics collection via `COLLECTION_ENABLED`
|
|
134
|
+
|
|
135
|
+
If you set `COLLECTION_ENABLED` (*default: true*) to `false` then analytics collection will be disabled for this app on this device. To opt back in to analytics collection you could then call `setAnalyticsCollectionEnabled(true)`.
|
|
136
|
+
|
|
137
|
+
Putting these APIs to use with cookies would allow you to create a flexible analytics collection scheme that would respect your user's desire for privacy.
|