diff --git a/src/hooks/use-users.ts b/src/hooks/use-users.ts index 515263db..0ce89e46 100644 --- a/src/hooks/use-users.ts +++ b/src/hooks/use-users.ts @@ -14,6 +14,7 @@ import { } from "@/queries/index" import logAction from "@/utils/log-action" import { getSession } from "next-auth/react" +import logger from "@/utils/logger" interface UserMapping { name: string @@ -116,11 +117,15 @@ export const mergeUsers = async ( userToDrop: User ): Promise => { const session = await getSession() - logAction({ - action: "merge", - user: session?.user.login, - parameters: JSON.stringify({ userToKeep, userToDrop }), - }) + try { + await logAction({ + action: "merge", + user: session?.user.login, + parameters: JSON.stringify({ userToKeep, userToDrop }), + }) + } catch (e) { + logger.error({ e }, "error inserting log") + } await graphQLFetcher({ query: mergeUsersQuery, diff --git a/src/utils/graphql-fetcher.ts b/src/utils/graphql-fetcher.ts index ed1f0a2e..1539b61f 100644 --- a/src/utils/graphql-fetcher.ts +++ b/src/utils/graphql-fetcher.ts @@ -1,5 +1,6 @@ import { GraphQLClient } from "graphql-request" import { NEXT_PUBLIC_HASURA_URL } from "./env" +import logger from "./logger" export interface GraphQLFetcherParams { query: string @@ -31,7 +32,9 @@ const graphQLFetcher = ({ } } - const client = new GraphQLClient(url || NEXT_PUBLIC_HASURA_URL, options) + const using_url = url || NEXT_PUBLIC_HASURA_URL + const client = new GraphQLClient(using_url, options) + logger.info({ using_url }) return client.request(query, parameters) } diff --git a/src/utils/log-action.ts b/src/utils/log-action.ts index f148d469..24289733 100644 --- a/src/utils/log-action.ts +++ b/src/utils/log-action.ts @@ -15,7 +15,7 @@ const logAction = ({ parameters, token, }: LogActionParameters) => { - graphQLServiceFetcher({ + return graphQLServiceFetcher({ query: insertLog, ...(token && { token, includeCookie: false }), ...(!token && { includeCookie: true }),