From 0d52aac82091557f3c011aa8a6b1a85f520bb73d Mon Sep 17 00:00:00 2001 From: mertmit Date: Fri, 20 Oct 2023 09:39:14 +0000 Subject: [PATCH] chore: at import logging --- .../nocodb/src/controllers/utils.controller.ts | 8 ++++++-- .../jobs/jobs/at-import/at-import.processor.ts | 14 +++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/packages/nocodb/src/controllers/utils.controller.ts b/packages/nocodb/src/controllers/utils.controller.ts index a3e24a5857..7910849c7e 100644 --- a/packages/nocodb/src/controllers/utils.controller.ts +++ b/packages/nocodb/src/controllers/utils.controller.ts @@ -14,12 +14,16 @@ import { UtilsService } from '~/services/utils.service'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { MetaApiLimiterGuard } from '~/guards/meta-api-limiter.guard'; import { PublicApiLimiterGuard } from '~/guards/public-api-limiter.guard'; +import { TelemetryService } from '~/services/telemetry.service'; @Controller() export class UtilsController { private version: string; - constructor(protected readonly utilsService: UtilsService) {} + constructor( + protected readonly utilsService: UtilsService, + protected readonly telemetryService: TelemetryService, + ) {} @UseGuards(PublicApiLimiterGuard) @Get('/api/v1/version') @@ -44,7 +48,7 @@ export class UtilsController { scope: 'org', }) @HttpCode(200) - async testConnection(@Body() body: any) { + async testConnection(@Body() body: any, @Request() _req: any) { body.pool = { min: 0, max: 1, diff --git a/packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts b/packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts index 85f317d02f..3f856b1a0f 100644 --- a/packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts +++ b/packages/nocodb/src/modules/jobs/jobs/at-import/at-import.processor.ts @@ -2,7 +2,6 @@ import moment from 'moment'; import { UITypes } from 'nocodb-sdk'; import Airtable from 'airtable'; import hash from 'object-hash'; -import { T } from 'nc-help'; import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; import tinycolor from 'tinycolor2'; @@ -33,6 +32,7 @@ import { ViewsService } from '~/services/views.service'; import { FormsService } from '~/services/forms.service'; import { JOBS_QUEUE, JobTypes } from '~/interface/Jobs'; import { GridColumnsService } from '~/services/grid-columns.service'; +import { TelemetryService } from '~/services/telemetry.service'; dayjs.extend(utc); @@ -104,6 +104,7 @@ export class AtImportProcessor { private readonly bulkDataAliasService: BulkDataAliasService, private readonly jobsLogService: JobsLogService, private readonly gridColumnService: GridColumnsService, + private readonly telemetryService: TelemetryService, ) {} @Process(JobTypes.AtImport) @@ -1981,8 +1982,10 @@ export class AtImportProcessor { logBasic(`:: Axios fetch count: ${rtc.fetchAt.count}`); logBasic(`:: Axios fetch time: ${rtc.fetchAt.time}`); - T.event({ - event: 'a:airtable-import:success', + this.telemetryService.sendEvent({ + evt_type: 'a:airtable-import:success', + user_id: syncDB.user.id, + email: syncDB.user.email, data: { stats: { migrationTime: duration, @@ -2515,8 +2518,9 @@ export class AtImportProcessor { } } catch (e) { if (e.message) { - T.event({ - event: 'a:airtable-import:error', + this.telemetryService.sendEvent({ + evt_type: 'a:airtable-import:error', + user_id: syncDB.user.id, data: { error: e.message }, }); console.log(e);