APP.COMPONENT.TS : Agregue registro.registrar(this.constructor.name);
import { Component, Renderer2, Inject } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { Router, ActivatedRoute, NavigationEnd } from '@angular/router';
import { RoutePartsService } from './core/services/router-parts.service';
import { LayoutService } from './system/frame/services/layout.service';
import { filter } from 'rxjs/operators';
import { RegistrarVisitaService } from './services/registrar-visita.service';
import { DOCUMENT } from '@angular/common';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
appTitle = 'MIS';
pageTitle = '';
constructor(
public title: Title,
private router: Router,
private activeRoute: ActivatedRoute,
private routePartsService: RoutePartsService,
private layout: LayoutService,
private renderer: Renderer2,
private registro: RegistrarVisitaService
) {
registro.registrar(this.constructor.name);
// registro.registrar('Modulo/NombreDelComponente');
}
Cree un servicio llamado: RegistrarVisitaService
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { UserService } from '../core/services/user.service';
@Injectable({
providedIn: 'root'
})
export class RegistrarVisitaService {
constructor(private http: HttpClient, private userService: UserService) { }
registrar(componente : string){
console.log(componente);
this.http.post('url para enviar los datos',
{
componente : componente,
usuario: this.obtenerUsuario()
}).subscribe(r => {
});
}
private obtenerUsuario(){
// obtener el usuario logueado
console.log(this.userService.getEmail())
return this.userService.getEmail();//'usuarioFalso';
}
}