Skip to content

Commit e0b7be2

Browse files
committed
Added Telemtry to guest login API
1 parent f8ec7c0 commit e0b7be2

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/api/api.controller.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ export class ApiController {
430430
@Headers('authorization') authHeader,
431431
@Headers('ADMIN-API-KEY') adminApiKey,
432432
): Promise<any> {
433+
const startTime = Date.now();
433434
if (adminApiKey != this.configService.get('ADMIN_API_KEY')) {
434435
const response: SignupResponse = new SignupResponse().init(uuidv4());
435436
response.responseCode = ResponseCode.FAILURE;
@@ -438,7 +439,25 @@ export class ApiController {
438439
response.params.status = ResponseStatus.failure;
439440
return response;
440441
}
441-
return await this.apiService.loginWithUniqueId(user, authHeader);
442+
let response = await this.apiService.loginWithUniqueId(user, authHeader);
443+
if (this.configService.get('TELEMETRY_INTERNAL_BASE_URL')) {
444+
this.telemetryService.sendEvent(
445+
{
446+
botId: user.botId,
447+
orgId: null,
448+
timeTaken: Date.now() - startTime,
449+
createdAt: Math.floor(new Date().getTime() / 1000),
450+
userId: response.result.data.user.id,
451+
eventLog: `Status from Fusionauth - ${response.responseCode}`,
452+
fingerPrint: user.loginId
453+
},
454+
'E119',
455+
'Guest Login',
456+
'GuestLogin',
457+
'PWA'
458+
);
459+
}
460+
return response;
442461
}
443462

444463
@Post('jwt/verify')

src/api/dto/login.dto.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ export class LoginWithUniqueIdDto {
3232
@IsUUID()
3333
@IsNotEmpty()
3434
applicationId: string;
35+
36+
@IsOptional()
37+
@IsUUID()
38+
botId: string;
3539
}

0 commit comments

Comments
 (0)