add husky

This commit is contained in:
Peter Maquiran
2024-06-21 14:35:50 +01:00
parent 3b6da3d2c7
commit 4d400e1f8b
7 changed files with 108 additions and 22 deletions
+8 -11
View File
@@ -18,7 +18,7 @@ const metricReader = new PeriodicExportingMetricReader({
// }
}),
exportIntervalMillis: 1000,
})
});
meterProvider.addMetricReader(metricReader);
@@ -27,32 +27,29 @@ const requestCounter = meter.createCounter('post_requests', {
description: 'Example of a Counter',
});
@Injectable()
export class MetricsInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(req).pipe(
tap(event => {
if (event instanceof HttpResponse) {
// Capture the status code
// Capture the status code and check protocol
if (req.method !== 'GET' && !req.urlWithParams.includes('metrics')) {
const path = req.urlWithParams;
const url = new URL(path);
let attributes = { path: url.pathname, method: req.method };
const statusCode = event.status;
const extendedAttributes = { ...attributes, status: statusCode };
requestCounter.add(1, extendedAttributes);
if (!window.location.origin.includes('https:')) {
let attributes = { path: url.pathname, method: req.method };
const statusCode = event.status;
const extendedAttributes = { ...attributes, status: statusCode };
requestCounter.add(1, extendedAttributes);
}
}
}
})
);
}
}
export const metricsInterceptor = {
provide: HTTP_INTERCEPTORS,
useClass: MetricsInterceptor,
@@ -186,6 +186,13 @@ export class AgendaDataRepositoryService {
updateEvent(eventId, eventData, editAllEvent, calendar: TableSharedCalendar) {
let body;
if(typeof eventData?.Body == 'object') {
body = eventData?.Body?.Text
} else {
body = eventData?.Body
}
let eventInput = {
userId: calendar.wxUserId,
ownerType: this.utils.selectedCalendarOwner(calendar.role),