-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: Deno SDK #9206
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
Merged
Merged
feat: Deno SDK #9206
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
895dedd
Deno SDK
timfish c2aab59
Bundle output
timfish d9350d1
move build deps to devDeps
timfish 96c905c
Ensure deno is installed
timfish 2aeac9a
update path
timfish 44ca406
check-in lib.deno.d.ts
timfish 4d6cd25
Merge branch 'develop' into feat/deno
timfish da63122
Seperate tests
timfish 9de20b3
Skip @sentry/deno for Node CI tests
timfish e924b3e
Remove non-functioning fetch tracing
timfish 3881f0c
More minor changes
timfish 8973e91
Basic test working
timfish d50c1ca
oops wrong eslint file
timfish 3213350
Strip the __DEBUG_BUILD__ global from the bundled types
timfish ffb3f9e
move comment
timfish 77228cd
Download lib.deno.d.ts
timfish bbc7ba1
Build with sucrase and tsc
timfish 0a4aa0e
Fix build
timfish e92c01d
pin versions
timfish 9112a8b
Merge branch 'develop' into feat/deno
timfish e494279
linting hell
timfish 143cfb7
Merge branch 'feat/deno' of https://github.com/timfish/sentry-javascr…
timfish a13d286
Update packages/deno/README.md
timfish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -379,7 +379,7 @@ jobs: | |
- name: Set up Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ env.DEFAULT_NODE_VERSION }} | ||
node-version-file: 'package.json' | ||
- name: Restore caches | ||
uses: ./.github/actions/restore-cache | ||
env: | ||
|
@@ -406,7 +406,7 @@ jobs: | |
- name: Set up Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
node-version-file: 'package.json' | ||
- name: Set up Bun | ||
uses: oven-sh/setup-bun@v1 | ||
- name: Restore caches | ||
|
@@ -419,6 +419,38 @@ jobs: | |
- name: Compute test coverage | ||
uses: codecov/codecov-action@v3 | ||
|
||
job_deno_unit_tests: | ||
name: Deno Unit Tests | ||
needs: [job_get_metadata, job_build] | ||
timeout-minutes: 10 | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ env.HEAD_COMMIT }} | ||
- name: Set up Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: 'package.json' | ||
- name: Set up Deno | ||
uses: denoland/[email protected] | ||
with: | ||
deno-version: v1.37.1 | ||
- name: Restore caches | ||
uses: ./.github/actions/restore-cache | ||
env: | ||
DEPENDENCY_CACHE_KEY: ${{ needs.job_build.outputs.dependency_cache_key }} | ||
- name: Run tests | ||
run: | | ||
cd packages/deno | ||
yarn build | ||
yarn test | ||
- name: Compute test coverage | ||
uses: codecov/codecov-action@v3 | ||
|
||
job_node_unit_tests: | ||
name: Node (${{ matrix.node }}) Unit Tests | ||
needs: [job_get_metadata, job_build] | ||
|
@@ -895,6 +927,7 @@ jobs: | |
job_browser_build_tests, | ||
job_browser_unit_tests, | ||
job_bun_unit_tests, | ||
job_deno_unit_tests, | ||
job_node_unit_tests, | ||
job_nextjs_integration_test, | ||
job_node_integration_tests, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,5 +28,6 @@ | |
{ | ||
"mode": "auto" | ||
} | ||
] | ||
], | ||
"deno.enablePaths": ["packages/deno/test"] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
extends: ['../../.eslintrc.js'], | ||
ignorePatterns: ['lib.deno.d.ts', 'scripts/*.mjs'], | ||
rules: { | ||
'@sentry-internal/sdk/no-optional-chaining': 'off', | ||
'@sentry-internal/sdk/no-nullish-coalescing': 'off', | ||
'@sentry-internal/sdk/no-unsupported-es6-methods': 'off', | ||
'@sentry-internal/sdk/no-class-field-initializers': 'off', | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['./test/*.ts'], | ||
rules: { | ||
'import/no-unresolved': 'off', | ||
}, | ||
}, | ||
], | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Copyright (c) 2023 Sentry (https://sentry.io) and individual contributors. All rights reserved. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the | ||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit | ||
persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the | ||
Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<p align="center"> | ||
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank"> | ||
<img src="https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png" alt="Sentry" width="280" height="84"> | ||
</a> | ||
</p> | ||
|
||
# Official Sentry SDK for Deno (Beta) | ||
|
||
[](https://www.npmjs.com/package/@sentry/deno) | ||
[](https://www.npmjs.com/package/@sentry/deno) | ||
[](https://www.npmjs.com/package/@sentry/deno) | ||
|
||
## Links | ||
|
||
- [Official SDK Docs](https://docs.sentry.io/quickstart/) | ||
- [TypeDoc](http://getsentry.github.io/sentry-javascript/) | ||
|
||
The Sentry Deno SDK is in beta. Please help us improve the SDK by [reporting any issues or giving us feedback](https://github.com/getsentry/sentry-javascript/issues). | ||
|
||
## Usage | ||
|
||
To use this SDK, call `Sentry.init(options)` as early as possible in the main entry module. This will initialize the SDK and | ||
hook into the environment. Note that you can turn off almost all side effects using the respective options. | ||
|
||
```javascript | ||
import * as Sentry from 'npm:@sentry/deno'; | ||
|
||
Sentry.init({ | ||
dsn: '__DSN__', | ||
// ... | ||
}); | ||
``` | ||
|
||
To set context information or send manual events, use the exported functions of `@sentry/deno`. Note that these | ||
functions will not perform any action before you have called `init()`: | ||
|
||
```javascript | ||
// Set user information, as well as tags and further extras | ||
Sentry.configureScope(scope => { | ||
scope.setExtra('battery', 0.7); | ||
scope.setTag('user_mode', 'admin'); | ||
scope.setUser({ id: '4711' }); | ||
// scope.clear(); | ||
}); | ||
|
||
// Add a breadcrumb for future events | ||
Sentry.addBreadcrumb({ | ||
message: 'My Breadcrumb', | ||
// ... | ||
}); | ||
|
||
// Capture exceptions, messages or manual events | ||
Sentry.captureMessage('Hello, world!'); | ||
Sentry.captureException(new Error('Good bye')); | ||
Sentry.captureEvent({ | ||
message: 'Manual', | ||
stacktrace: [ | ||
// ... | ||
], | ||
}); | ||
``` | ||
|
||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('../../jest/jest.config.js'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{ | ||
"name": "@sentry/deno", | ||
"version": "7.73.0", | ||
"description": "Official Sentry SDK for Deno", | ||
"repository": "git://github.com/getsentry/sentry-javascript.git", | ||
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/deno", | ||
"author": "Sentry", | ||
"license": "MIT", | ||
"main": "build/index.js", | ||
"module": "build/index.js", | ||
"types": "build/index.d.ts", | ||
"private": true, | ||
"dependencies": { | ||
"@sentry/core": "7.73.0", | ||
"@sentry/browser": "7.73.0", | ||
"@sentry/types": "7.73.0", | ||
"@sentry/utils": "7.73.0", | ||
"lru_map": "^0.3.3" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "20.8.2", | ||
"@rollup/plugin-commonjs": "^25.0.5", | ||
"@rollup/plugin-typescript": "^11.1.5", | ||
"rollup-plugin-dts": "^6.1.0" | ||
}, | ||
"scripts": { | ||
"deno-types": "node ./scripts/download-deno-types.mjs", | ||
"build": "run-s build:transpile build:types", | ||
"build:dev": "yarn build", | ||
"build:transpile": "yarn deno-types && rollup -c rollup.config.js", | ||
"build:types": "run-s deno-types build:types:tsc build:types:bundle", | ||
"build:types:tsc": "tsc -p tsconfig.types.json", | ||
"build:types:bundle": "rollup -c rollup.types.config.js", | ||
"circularDepCheck": "madge --circular src/index.ts", | ||
"clean": "rimraf build coverage", | ||
"prefix": "yarn deno-types", | ||
"fix": "run-s fix:eslint fix:prettier", | ||
"fix:eslint": "eslint . --format stylish --fix", | ||
"fix:prettier": "prettier --write \"{src,test,scripts}/**/**.ts\"", | ||
"prelint": "yarn deno-types", | ||
"lint": "run-s lint:prettier lint:eslint", | ||
"lint:eslint": "eslint . --format stylish", | ||
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"", | ||
"install:deno": "node ./scripts/install-deno.mjs", | ||
"test": "run-s deno-types install:deno test:types test:unit", | ||
"test:types": "deno check ./build/index.js", | ||
"test:unit": "deno test --allow-read --allow-run", | ||
"test:unit:update": "deno test --allow-read --allow-write --allow-run -- --update" | ||
}, | ||
"volta": { | ||
"extends": "../../package.json" | ||
}, | ||
"sideEffects": false, | ||
"madge": { | ||
"detectiveOptions": { | ||
"ts": { | ||
"skipTypeImports": true | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import nodeResolve from '@rollup/plugin-node-resolve'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import sucrase from '@rollup/plugin-sucrase'; | ||
|
||
export default { | ||
input: ['src/index.ts'], | ||
output: { | ||
dir: 'build', | ||
sourcemap: true, | ||
preserveModules: false, | ||
strict: false, | ||
freeze: false, | ||
interop: 'auto', | ||
format: 'esm', | ||
banner: '/// <reference types="./index.d.ts" />', | ||
}, | ||
plugins: [ | ||
nodeResolve({ | ||
extensions: ['.mjs', '.js', '.json', '.node', '.ts', '.tsx'], | ||
}), | ||
commonjs(), | ||
sucrase({ transforms: ['typescript'] }), | ||
], | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import dts from 'rollup-plugin-dts'; | ||
|
||
export default { | ||
input: './build/index.d.ts', | ||
output: [{ file: 'build/index.d.ts', format: 'es' }], | ||
plugins: [ | ||
dts({ respectExternal: true }), | ||
// The bundled types contain a declaration for the __DEBUG_BUILD__ global | ||
// This can result in errors about duplicate global declarations so we strip it out! | ||
{ | ||
name: 'strip-global', | ||
renderChunk(code) { | ||
return { code: code.replace(/declare global \{\s*const __DEBUG_BUILD__: boolean;\s*\}/g, '') }; | ||
}, | ||
}, | ||
], | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { writeFileSync, existsSync } from 'fs'; | ||
import { download } from './download.mjs'; | ||
|
||
if (!existsSync('lib.deno.d.ts')) { | ||
const code = await download('https://github.com/denoland/deno/releases/download/v1.37.1/lib.deno.d.ts'); | ||
writeFileSync('lib.deno.d.ts', code); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** Download a url to a string */ | ||
export async function download(url) { | ||
try { | ||
return await fetch(url).then(res => res.text()); | ||
} catch (e) { | ||
// eslint-disable-next-line no-console | ||
console.error('Failed to download', url, e); | ||
process.exit(1); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { execSync } from 'child_process'; | ||
|
||
import { download } from './download.mjs'; | ||
|
||
try { | ||
execSync('deno --version', { stdio: 'inherit' }); | ||
} catch (_) { | ||
// eslint-disable-next-line no-console | ||
console.error('Deno is not installed. Installing...'); | ||
if (process.platform === 'win32') { | ||
// TODO | ||
// eslint-disable-next-line no-console | ||
console.error('Please install Deno manually: https://docs.deno.com/runtime/manual/getting_started/installation'); | ||
process.exit(1); | ||
} else { | ||
const script = await download('https://deno.land/x/install/install.sh'); | ||
|
||
try { | ||
execSync(script, { stdio: 'inherit' }); | ||
} catch (e) { | ||
// eslint-disable-next-line no-console | ||
console.error('Failed to install Deno', e); | ||
process.exit(1); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we get rid of all the
npm:
prefixes we can probably enable this rule again.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything in
/test/*
is Deno typescript.Some imports use denos URL imports which eslint doesn't understand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checks out!