Skip to content

Commit

Permalink
fix logger (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
peelar committed Apr 30, 2024
1 parent 62a761e commit 45c3f27
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 71 deletions.
44 changes: 0 additions & 44 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,47 +41,3 @@ jobs:

- name: Generate
run: pnpm generate

- name: Test
run: pnpm test:ci
env:
# Secrets
SECRET_KEY: ${{ secrets.SECRET_KEY }}
TEST_SALEOR_APP_TOKEN: ${{ secrets.TEST_SALEOR_APP_TOKEN }}
TEST_KLARNA_USERNAME: ${{ secrets.TEST_KLARNA_USERNAME }}
TEST_KLARNA_PASSWORD: ${{ secrets.TEST_KLARNA_PASSWORD }}
# Variables
TEST_SALEOR_API_URL: ${{ vars.TEST_SALEOR_API_URL }}
TEST_SALEOR_APP_ID: ${{ vars.TEST_SALEOR_APP_ID }}
TEST_SALEOR_JWKS: ${{ vars.TEST_SALEOR_JWKS }}
TEST_KLARNA_API_URL: ${{ vars.TEST_KLARNA_API_URL }} # https://api.playground.klarna.com/
APP_API_BASE_URL: https://klarna.saleor.app

- name: Dependency cruiser
if: ${{ github.event_name != 'push' }}
run: pnpm exec dependency-cruiser src

- name: Download coverage report from canary
if: ${{ github.event_name != 'push' }}
uses: dawidd6/action-download-artifact@v2
with:
workflow_conclusion: success
branch: canary
event: push
name: coverage-artifacts
path: coverage-main/

- name: Coverage report
if: ${{ github.event_name != 'push' }}
uses: ArtiomTr/jest-coverage-report-action@v2.2.5
with:
skip-step: all
coverage-file: coverage/report.json
base-coverage-file: coverage-main/report.json

- name: Upload coverage report
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/canary' }}
uses: actions/upload-artifact@v3
with:
name: coverage-artifacts
path: coverage/
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
20
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"next": "13.4.19",
"omit-deep-lodash": "1.1.7",
"openapi-typescript-fetch": "1.1.3",
"pino": "8.15.1",
"pino": "8.20.0",
"pino-pretty": "11.0.0",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down Expand Up @@ -144,7 +144,7 @@
"node": ">=18.0.0 <19.0.0",
"pnpm": ">=8.14.0 <9.0.0"
},
"packageManager": "pnpm@8.14.1",
"packageManager": "pnpm@8.14.2",
"pnpm": {
"overrides": {
"@urql/exchange-auth>@urql/core": "3.2.2"
Expand Down
37 changes: 25 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 1 addition & 12 deletions src/modules/trpc/trpc-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import { SALEOR_API_URL_HEADER, SALEOR_AUTHORIZATION_BEARER_HEADER } from "@sale
import { useErrorModalStore } from "../ui/organisms/GlobalErrorModal/state";
import { type AppRouter } from "./trpc-app-router";
import { getErrorHandler } from "./utils";
import { logger } from "@/lib/logger";
import { appBridgeInstance } from "@/app-bridge-instance";
import { BaseTrpcError, JwtInvalidError, JwtTokenExpiredError } from "@/errors";
import { isDevelopment } from "@/lib/isEnv";
import { appBridgeInstance } from "@/app-bridge-instance";

const genericErrorHandler = (err: unknown) => {
getErrorHandler({
Expand All @@ -22,15 +20,6 @@ export const trpcClient = createTRPCNext<AppRouter>({
return {
abortOnUnmount: true,
links: [
loggerLink({
// enable client and server logs for development
// enable client logs for production
enabled: (opts) =>
(isDevelopment() && typeof window !== "undefined") ||
(opts.direction === "down" && opts.result instanceof Error),
// use logger for production, console.log for development
logger: !isDevelopment() ? (data) => logger.error(data, "TRPC client error") : undefined,
}),
loggerLink({
logger: (data) => {
if (data.direction === "down" && data.result instanceof TRPCClientError) {
Expand Down

0 comments on commit 45c3f27

Please sign in to comment.