Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix miro log #87

Merged
merged 4 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/cuddly-lobsters-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@dandori/libs": patch
"@dandori/ui": patch
---

fix miro log
2 changes: 1 addition & 1 deletion packages/libs/src/checkApiKey.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export function checkApiKey(
keyName: string,
targetKey?: string,
alternativeKey?: string,
alternativeKey?: string | undefined | null,
): string {
if (targetKey) {
return targetKey;
Expand Down
2 changes: 1 addition & 1 deletion packages/libs/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const setLogger = (newLogger: Logger): void => {
logger = newLogger;
};

type LogLevel = "debug" | "info" | "warn" | "error";
export type LogLevel = typeof process.env.LOG_LEVEL;

export const getLogLevel = (): LogLevel => {
return process.env.LOG_LEVEL ?? "info";
Expand Down
9 changes: 7 additions & 2 deletions packages/ui/src/miro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
export type GenerateDandoriMiroCardsOptions = {
boardId: Parameters<MiroApi["getBoard"]>[0];
isAppCard?: boolean;
apiKey?: string;
apiKey?: Parameters<typeof checkApiKey>[2];
};

// miro settings
Expand Down Expand Up @@ -66,7 +66,12 @@ export async function generateDandoriMiroCards(
);
const logger = getLogger();
const miroApi = new MiroApi(key, undefined, (...thing) => {
logger[getLogLevel()](thing);
// miro api sdk has no log level setting, so dandori only log debug level.
// https://github.com/miroapp/api-clients/blob/main/packages/miro-api/api/apis.ts#L4905-L4926
const logLevel = getLogLevel();
if (logLevel === "debug") {
logger[logLevel](thing);
}
});
const miroBoard = await miroApi.getBoard(options.boardId);
const taskFlat: (DandoriTask & { [taskParentPropName]?: string })[] = tasks
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/notion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export type DatabasePropertiesMap =
export type GenerateDandoriNotionPagesOptions = {
databaseId: string;
databasePropertiesMap?: DatabasePropertiesMap;
apiKey?: string;
apiKey?: Parameters<typeof checkApiKey>[2];
};

const hasStatusProperty = (
Expand Down