kleinere Korrekturen zu #60

This commit is contained in:
2024-09-13 09:45:48 +02:00
parent 7c9a47cf4e
commit d4ec9d067f
5 changed files with 18 additions and 24 deletions

View File

@@ -1,6 +1,6 @@
import { HttpClient } from '@angular/common/http';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { BehaviorSubject, lastValueFrom, Observable } from 'rxjs';
import { lastValueFrom } from 'rxjs';
import { EventTypeEnum, ListingEvent } from '../../../../bizmatch-server/src/models/db.model';
import { LogMessage } from '../../../../bizmatch-server/src/models/main.model';
import { environment } from '../../environments/environment';
@@ -12,21 +12,13 @@ import { GeoService } from './geo.service';
export class AuditService {
private apiBaseUrl = environment.apiBaseUrl;
private apiKey = environment.ipinfo_token;
// private ipifyUrl = 'https://api.ipify.org?format=json';
// private ipInfoUrl = 'https://ipinfo.io';
private ipifyUrl = 'https://api.ipify.org?format=json';
private ipInfoUrl = 'https://ipinfo.io';
// BehaviorSubject to store the geolocation data
private geoLocationSubject = new BehaviorSubject<any>(null);
public geoLocation$: Observable<any> = this.geoLocationSubject.asObservable();
constructor(private http: HttpClient, private geoService: GeoService) {}
async log(message: LogMessage): Promise<void> {
lastValueFrom(this.http.post(`${this.apiBaseUrl}/bizmatch/log`, message));
}
async createEvent(id: string, eventType: EventTypeEnum, userId: string): Promise<void> {
async createEvent(id: string, eventType: EventTypeEnum, userId: string, additionalData?): Promise<void> {
const ipInfo = await this.geoService.getIpInfo();
const [latitude, longitude] = ipInfo.loc ? ipInfo.loc.split(',') : [null, null]; //.map(Number);
const listingEvent: ListingEvent = {
@@ -40,7 +32,9 @@ export class AuditService {
locationCity: ipInfo.city,
locationLat: latitude,
locationLng: longitude,
additionalData,
};
lastValueFrom(this.http.post(`${this.apiBaseUrl}/bizmatch/event`, listingEvent));
let headers = new HttpHeaders().set('X-Hide-Loading', 'true');
lastValueFrom(this.http.post(`${this.apiBaseUrl}/bizmatch/event`, listingEvent, { headers }));
}
}