Skip to content

Commit

Permalink
feat(access-api): add logtail
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias committed Aug 26, 2022
1 parent eec90dc commit 1246ab0
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 36 deletions.
1 change: 1 addition & 0 deletions .env.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
PRIVATE_KEY=MgCYWjE6vp0cn3amPan2xPO+f6EZ3I+KwuN1w2vx57vpJ9O0Bn4ci4jn8itwc121ujm7lDHkCW24LuKfZwIdmsifVysY=
POSTMARK_TOKEN=secret
SENTRY_DSN=https://[email protected]/00000
#LOGTAIL_TOKEN=secret

# CI secrets
SENTRY_TOKEN=secret
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/access.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ on:
- 'packages/access/**'
- '.github/workflows/access.yml'
- 'pnpm-lock.yaml'
- '.env.tpl'
pull_request:
paths:
- 'packages/access/**'
- '.github/workflows/access.yml'
- 'pnpm-lock.yaml'
- '.env.tpl'
jobs:
test:
runs-on: ubuntu-latest
Expand All @@ -32,36 +30,3 @@ jobs:
- run: pnpm install
- run: pnpm -r --filter @web3-storage/access run lint
- run: pnpm -r --filter @web3-storage/access run test
# release:
# needs: test
# runs-on: ubuntu-latest
# if: github.event_name == 'push' && github.ref == 'refs/heads/master'
# outputs:
# releases_created: ${{ steps.release.outputs.releases_created }}
# steps:
# - uses: GoogleCloudPlatform/release-please-action@v3
# id: release
# with:
# path: packages/access
# release-type: node
# monorepo-tags: true
# package-name: '@web3-storage/access'
# publish:
# needs: release
# if: github.event_name == 'push' && github.ref == 'refs/heads/master' && needs.release.outputs.releases_created
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: pnpm/[email protected]
# with:
# version: 7
# - uses: actions/setup-node@v2
# with:
# node-version: 18
# registry-url: 'https://registry.npmjs.org'
# cache: 'pnpm'
# - run: pnpm install
# - run: pnpm -r --filter @web3-storage/access exec tsc
# - run: pnpm -r --filter @web3-storage/access publish --tag next --access public
# env:
# NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
4 changes: 4 additions & 0 deletions .github/workflows/reuse-deploy-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ on:
required: true
SENTRY_TOKEN:
required: true
LOGTAIL_TOKEN:
required: true

jobs:
deploy-api:
Expand All @@ -43,9 +45,11 @@ jobs:
POSTMARK_TOKEN
PRIVATE_KEY
SENTRY_DSN
LOGTAIL_TOKEN
env:
POSTMARK_TOKEN: ${{ secrets.POSTMARK_TOKEN }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SENTRY_UPLOAD: ${{ secrets.SENTRY_UPLOAD }}
SENTRY_TOKEN: ${{ secrets.SENTRY_TOKEN }}
LOGTAIL_TOKEN: ${{ secrets.LOGTAIL_TOKEN }}
2 changes: 2 additions & 0 deletions packages/access-api/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function loadConfigVariables() {
'PRIVATE_KEY',
'SENTRY_DSN',
'POSTMARK_TOKEN',
'LOGTAIL_TOKEN',
]

for (const name of required) {
Expand All @@ -38,6 +39,7 @@ export function loadConfigVariables() {
PRIVATE_KEY: vars.PRIVATE_KEY,
POSTMARK_TOKEN: vars.POSTMARK_TOKEN,
SENTRY_DSN: vars.SENTRY_DSN,
LOGTAIL_TOKEN: vars.LOGTAIL_TOKEN,

// These are injected in esbuild
// @ts-ignore
Expand Down
2 changes: 1 addition & 1 deletion packages/access-api/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ addEventListener('fetch', (event) => {
return env.log.end(corsHeaders(event.request, rsp))
})
.catch((error) => {
return errorHandler(error, env.log)
return env.log.end(errorHandler(error, env.log))
})
)
})
1 change: 1 addition & 0 deletions packages/access-api/src/utils/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export function getContext(event, params) {
waitUntil: event.waitUntil.bind(event),
},
{
token: config.LOGTAIL_TOKEN,
debug: config.DEBUG,
sentry: ['test', 'dev'].includes(config.ENV) ? undefined : sentry,
branch: config.BRANCH,
Expand Down

0 comments on commit 1246ab0

Please sign in to comment.