Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
log(logLevel: LogLevel, message: string | Error, logInfo?: LogInfo): void {
if (!this._analytics || logLevel === LogLevel.None) {
return;
}
// tslint:disable-next-line: no-any
const properties: { [key: string]: any } = logInfo && logInfo.properties ? { ...logInfo.properties } : {};
if (this._userInfo.userId) {
properties.user_id = this._userInfo.userId;
}
if (this._userInfo.accountId) {
properties.account_id = this._userInfo.accountId;
}
if (logLevel === LogLevel.Error || logLevel === LogLevel.Critical) {
properties.description = typeof message === 'string' ? message : `${message}`;
log(logLevel: LogLevel, message: string | Error, logInfo?: LogInfo): void {
if (!this._analytics$ || logLevel === LogLevel.None) {
return;
}
// tslint:disable-next-line: no-any
const properties: { [key: string]: any } = logInfo && logInfo.properties ? { ...logInfo.properties } : {};
if (logLevel === LogLevel.Error || logLevel === LogLevel.Critical) {
properties.description = typeof message === 'string' ? message : `${message}`;
properties.fatal = logLevel === LogLevel.Critical;
this._analytics$.pipe(
tap((analyticsService) => {
analyticsService.logEvent('exception', properties);
}),
runOutsideAngular(this._zone)
).subscribe();