Skip to content

Commit

Permalink
Added Google Analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
Varshithvhegde committed Oct 24, 2023
1 parent 7181091 commit 9579140
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, Inject } from '@angular/core';
import { Component, Inject, inject } from '@angular/core';
import { Analytics, logEvent } from '@angular/fire/analytics';
import { Database, onValue, ref } from '@angular/fire/database';
import { Observable } from 'rxjs';
@Component({
Expand All @@ -11,8 +12,12 @@ export class AppComponent {
// console.log('Hello world');
// Get a data with key "hello" from firebase realtime database
itemValue = '';
private analytics: Analytics = inject(Analytics);
// items: Observable<any[]>;
constructor(public database: Database) {}
constructor(public database: Database) {
// log event to firebase analytics
logEvent(this.analytics, 'app_component_loaded');
}
getData() {
// Get a data with key "hello" from firebase realtime database
// this.database.app.name = "hello";
Expand Down
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { MatTooltipModule } from '@angular/material/tooltip';
import { PasswordInputDialogComponent } from './password-input-dialog/password-input-dialog.component';
import {MatDialogModule} from '@angular/material/dialog';
import { PasswordInputComponent } from './password-input/password-input.component';
import { getAuth, provideAuth } from '@angular/fire/auth';

@NgModule({
declarations: [
Expand Down Expand Up @@ -63,8 +64,9 @@ import { PasswordInputComponent } from './password-input/password-input.componen
measurementId: environment.FIREBASE_MEASUREMENT_ID,
})
),
// provideAnalytics(() => getAnalytics()),
provideAuth(() => getAuth()),
provideDatabase(() => getDatabase()),
provideAnalytics(() => getAnalytics()),
BrowserAnimationsModule,
// provideFunctions(() => getFunctions())
],
Expand Down
2 changes: 2 additions & 0 deletions src/app/navigation/navigation.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class NavigationComponent {
});
this.passwordService.unlockRequest$.subscribe(() => {
// make locked false and password empty
this.datalocked = false;
this.locked = false;
this.password = '';
// add this to the database
Expand Down Expand Up @@ -115,6 +116,7 @@ export class NavigationComponent {
});
}
updatePassword(newPassword: string) {
this.datalocked = true;
console.log('Updating password to: ' + newPassword);
// Get the route ID
const routeID = this.routeId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export class PasswordInputDialogComponent {
this.locked = data.locked;
this.password = data.password;
}

togglePasswordVisibility() {
this.passwordFieldType = this.passwordFieldType === 'password' ? 'text' : 'password';
this.showPasswordIcon = this.showPasswordIcon === 'visibility' ? 'visibility_off' : 'visibility';
Expand Down

0 comments on commit 9579140

Please sign in to comment.