Skip to content

Commit

Permalink
fix(logs.v1): remove auth, action, hooks (NangoHQ#2363)
Browse files Browse the repository at this point in the history
## Describe your changes

Contributes to
https://linear.app/nango/issue/NAN-585/stop-writing-from-v1

- Remove activities from Account, Auth, Action and Hooks
Initially wanted less but turns out everything is super tied
(surprising).

- Temporarily allowed activityLogId to be string in the relevant places
  • Loading branch information
bodinsamuel authored Jun 19, 2024
1 parent 3516678 commit 90fae84
Show file tree
Hide file tree
Showing 23 changed files with 48 additions and 353 deletions.
6 changes: 3 additions & 3 deletions packages/orchestrator/lib/clients/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface ActionArgs {
environment_id: number;
connection_id: string;
};
activityLogId: number;
activityLogId: string | number;
input: JsonValue;
}
interface WebhookArgs {
Expand All @@ -39,7 +39,7 @@ interface WebhookArgs {
provider_config_key: string;
environment_id: number;
};
activityLogId: number;
activityLogId: string | number;
input: JsonValue;
}

Expand All @@ -52,7 +52,7 @@ interface PostConnectionArgs {
environment_id: number;
};
fileLocation: string;
activityLogId: number;
activityLogId: string | number;
}
export type SchedulesReturn = Result<OrchestratorSchedule[]>;
export type VoidReturn = Result<void, ClientError>;
Expand Down
6 changes: 3 additions & 3 deletions packages/orchestrator/lib/clients/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ export const syncArgsSchema = z.object({
export const actionArgsSchema = z.object({
type: z.literal('action'),
actionName: z.string().min(1),
activityLogId: z.number().positive(),
activityLogId: z.union([z.number(), z.string()]),
input: jsonSchema,
...commonSchemaArgsFields
});
export const webhookArgsSchema = z.object({
type: z.literal('webhook'),
webhookName: z.string().min(1),
parentSyncName: z.string().min(1),
activityLogId: z.number().positive(),
activityLogId: z.union([z.number(), z.string()]),
input: jsonSchema,
...commonSchemaArgsFields
});
export const postConnectionArgsSchema = z.object({
type: z.literal('post-connection-script'),
postConnectionName: z.string().min(1),
fileLocation: z.string().min(1),
activityLogId: z.number().positive(),
activityLogId: z.union([z.number(), z.string()]),
...commonSchemaArgsFields
});

Expand Down
24 changes: 2 additions & 22 deletions packages/server/lib/controllers/account.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Request, Response, NextFunction } from 'express';
import type { LogLevel } from '@nangohq/shared';
import { isCloud } from '@nangohq/utils';
import { accountService, userService, LogActionEnum, createActivityLogAndLogMessage } from '@nangohq/shared';
import { accountService, userService } from '@nangohq/shared';
import type { LogContext } from '@nangohq/logs';
import { logContextGetter } from '@nangohq/logs';
import type { RequestLocals } from '../utils/express.js';
Expand Down Expand Up @@ -134,27 +133,8 @@ class AccountController {
return;
}

const log = {
level: 'info' as LogLevel,
success: true,
action: LogActionEnum.ACCOUNT,
start: Date.now(),
end: Date.now(),
timestamp: Date.now(),
connection_id: 'n/a',
provider: null,
provider_config_key: '',
environment_id: environment.id
};

const activityLogId = await createActivityLogAndLogMessage(log, {
level: 'info',
environment_id: environment.id,
timestamp: Date.now(),
content: `A Nango admin logged into another account for the following reason: "${login_reason}"`
});
logCtx = await logContextGetter.create(
{ id: String(activityLogId), operation: { type: 'admin', action: 'impersonation' }, message: 'Admin logged into another account' },
{ operation: { type: 'admin', action: 'impersonation' }, message: 'Admin logged into another account' },
{
account,
environment,
Expand Down
Loading

0 comments on commit 90fae84

Please sign in to comment.