Skip to content

Deno test #8780

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

Closed
wants to merge 6 commits into from
Closed
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"packages/browser",
"packages/browser-integration-tests",
"packages/core",
"packages/deno",
"packages/e2e-tests",
"packages/ember",
"packages/eslint-config-sdk",
Expand Down
3 changes: 3 additions & 0 deletions packages/deno/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['../../.eslintrc.js'],
};
14 changes: 14 additions & 0 deletions packages/deno/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Copyright (c) 2019 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.
57 changes: 57 additions & 0 deletions packages/deno/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "@sentry/deno",
"version": "7.61.1",
"description": "Official Sentry SDK for Deno",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/react",
"author": "Sentry",
"license": "MIT",
"engines": {
"node": ">=8"
},
"main": "build/cjs/index.js",
"module": "build/esm/index.js",
"types": "build/types/index.d.ts",
"typesVersions": {
"<4.9": {
"build/types/index.d.ts": [
"build/types-ts3.8/index.d.ts"
]
}
},
"publishConfig": {
"access": "public"
},
"devDependencies": {
"rollup-plugin-dts": "^5.3.1"
},
"scripts": {
"build": "run-p build:transpile build:types",
"build:dev": "yarn build",
"build:transpile": "rollup -c rollup.config.js",
"build:types": "run-s build:types:core build:types:bundle build:types:downlevel",
"build:types:bundle": "rollup -c rollup.types.config.js",
"build:types:core": "tsc -p tsconfig.types.json",
"build:types:downlevel": "yarn downlevel-dts build build --to ts3.8",
"build:watch": "run-p build:transpile:watch build:types:watch",
"build:dev:watch": "yarn build:watch",
"build:transpile:watch": "rollup -c rollup.npm.config.js --watch",
"build:types:watch": "tsc -p tsconfig.types.json --watch",
"build:tarball": "npm pack ./build",
"circularDepCheck": "madge --circular src/index.ts",
"clean": "rimraf build coverage sentry-react-*.tgz",
"fix": "run-s fix:eslint fix:prettier",
"fix:eslint": "eslint . --format stylish --fix",
"fix:prettier": "prettier --write \"{src,test,scripts}/**/**.ts\"",
"lint": "run-s lint:prettier lint:eslint",
"lint:eslint": "eslint . --format stylish",
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"test": "jest",
"test:watch": "jest --watch",
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
},
"volta": {
"extends": "../../package.json"
},
"sideEffects": false
}
34 changes: 34 additions & 0 deletions packages/deno/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import nodeResolve from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
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'],
}),
replace({
preventAssignment: true,
values: {
__DEBUG_BUILD__: false,
__SENTRY_DEBUG__: false,
__SENTRY_BROWSER_BUNDLE__: false,
__SENTRY_SDK_SOURCE__: JSON.stringify('denoland'),
},
}),
sucrase({
transforms: ['typescript', 'jsx'],
}),
],
};
34 changes: 34 additions & 0 deletions packages/deno/rollup.types.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import nodeResolve from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import sucrase from '@rollup/plugin-sucrase';

export default {
input: ['types/index.d.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'],
}),
replace({
preventAssignment: true,
values: {
__DEBUG_BUILD__: false,
__SENTRY_DEBUG__: false,
__SENTRY_BROWSER_BUNDLE__: false,
__SENTRY_SDK_SOURCE__: JSON.stringify('denoland'),
},
}),
sucrase({
transforms: ['typescript', 'jsx'],
}),
],
};
54 changes: 54 additions & 0 deletions packages/deno/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { BaseClient, createTransport, getCurrentHub, initAndBind } from '@sentry/core';

import { ClientOptions, Event, SeverityLevel } from '@sentry/types';

function makeDenoTransport(options: any) {
function makeRequest(request: any) {
const req = {
body: request.body,
method: 'POST',
referrerPolicy: 'origin',
headers: options.headers,
...options.fetchOptions,
};

console.log(req);

return fetch(options.url, req).then(response => ({
statusCode: response.status,
}));
}

return createTransport(options, makeRequest);
}

interface DenoClientOptions extends ClientOptions {}

class DenoClient extends BaseClient<DenoClientOptions> {
public eventFromException(exception: any): PromiseLike<Event> {
const event: Event = {
exception: {
values: [
{
type: exception.name,
value: exception.message,
},
],
},
};

return Promise.resolve(event);
}

public eventFromMessage(message: string, level: SeverityLevel = 'info'): PromiseLike<Event> {
return Promise.resolve({ message, level });
}
}

export { DenoClient, getCurrentHub, initAndBind, makeDenoTransport };
export type { DenoClientOptions };

export interface State<in out T> {
get: () => T;
set: (value: T) => void;
}
16 changes: 16 additions & 0 deletions packages/deno/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { DenoClient, getCurrentHub, initAndBind, makeDenoTransport } from './build/index.js';

initAndBind(DenoClient, {
dsn: 'https://[email protected]/4505391490007040',
transport: makeDenoTransport,
integrations: [],
beforeSend(event, hint) {
console.log(event);
return event;
},
});

const hub = getCurrentHub();
const client = hub.getClient();

client?.captureException(new Error('Hello from Deno!'));
11 changes: 11 additions & 0 deletions packages/deno/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.json",

"include": ["src/**/*"],

"compilerOptions": {
// package-specific options
"esModuleInterop": true,
"jsx": "react"
}
}
10 changes: 10 additions & 0 deletions packages/deno/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",

"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "types"
}
}
40 changes: 39 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,14 @@
dependencies:
"@babel/highlight" "^7.18.6"

"@babel/code-frame@^7.22.5":
version "7.22.10"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.22.10.tgz#1c20e612b768fefa75f6e90d6ecb86329247f0a3"
integrity sha512-/KKIMG4UEL35WmI9OlvMhurwtytjvXoFcGNrOvyG9zIzA8YmPjVtIZUf7b05+TPO7G7/GEmLHDaoCgACHl9hhA==
dependencies:
"@babel/highlight" "^7.22.10"
chalk "^2.4.2"

"@babel/compat-data@^7.11.0", "@babel/compat-data@^7.13.0", "@babel/compat-data@^7.17.7", "@babel/compat-data@^7.19.4", "@babel/compat-data@^7.20.0":
version "7.20.1"
resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.20.1.tgz#f2e6ef7790d8c8dbf03d379502dcc246dcce0b30"
Expand Down Expand Up @@ -980,6 +988,11 @@
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz#7eea834cf32901ffdc1a7ee555e2f9c27e249ca2"
integrity sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==

"@babel/helper-validator-identifier@^7.22.5":
version "7.22.5"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz#9544ef6a33999343c8740fa51350f30eeaaaf193"
integrity sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==

"@babel/helper-validator-option@^7.14.5", "@babel/helper-validator-option@^7.16.7", "@babel/helper-validator-option@^7.18.6":
version "7.18.6"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.18.6.tgz#bf0d2b5a509b1f336099e4ff36e1a63aa5db4db8"
Expand Down Expand Up @@ -1022,6 +1035,15 @@
chalk "^2.0.0"
js-tokens "^4.0.0"

"@babel/highlight@^7.22.10":
version "7.22.10"
resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.22.10.tgz#02a3f6d8c1cb4521b2fd0ab0da8f4739936137d7"
integrity sha512-78aUtVcT7MUscr0K5mIEnkwxPE0MaxkR5RxRwuHaQ+JuU5AmTPhY+do2mdzVTnIJJpyBglql2pehuBIWHug+WQ==
dependencies:
"@babel/helper-validator-identifier" "^7.22.5"
chalk "^2.4.2"
js-tokens "^4.0.0"

"@babel/parser@^7.0.0", "@babel/parser@^7.1.0", "@babel/parser@^7.10.4", "@babel/parser@^7.11.1", "@babel/parser@^7.14.7", "@babel/parser@^7.16.4", "@babel/parser@^7.18.10", "@babel/parser@^7.20.1", "@babel/parser@^7.20.2", "@babel/parser@^7.4.5", "@babel/parser@^7.7.0":
version "7.20.3"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.20.3.tgz#5358cf62e380cf69efcb87a7bb922ff88bfac6e2"
Expand Down Expand Up @@ -3171,7 +3193,7 @@
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24"
integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==

"@jridgewell/sourcemap-codec@^1.4.14":
"@jridgewell/sourcemap-codec@^1.4.14", "@jridgewell/sourcemap-codec@^1.4.15":
version "1.4.15"
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32"
integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==
Expand Down Expand Up @@ -18684,6 +18706,13 @@ magic-string@^0.30.0:
dependencies:
"@jridgewell/sourcemap-codec" "^1.4.13"

magic-string@^0.30.2:
version "0.30.2"
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.2.tgz#dcf04aad3d0d1314bc743d076c50feb29b3c7aca"
integrity sha512-lNZdu7pewtq/ZvWUp9Wpf/x7WzMTsR26TWV03BRZrXFsv+BI6dy8RAiKgm1uM/kyR0rCfUcqvOlXKG66KhIGug==
dependencies:
"@jridgewell/sourcemap-codec" "^1.4.15"

[email protected]:
version "0.2.8"
resolved "https://registry.yarnpkg.com/magicast/-/magicast-0.2.8.tgz#02b298c65fbc5b7d1fce52ef779c59caf68cc9cf"
Expand Down Expand Up @@ -24394,6 +24423,15 @@ [email protected]:
js-cleanup "^1.2.0"
rollup-pluginutils "^2.8.2"

rollup-plugin-dts@^5.3.1:
version "5.3.1"
resolved "https://registry.yarnpkg.com/rollup-plugin-dts/-/rollup-plugin-dts-5.3.1.tgz#c2841269a3a5cb986b7791b0328e6a178eba108f"
integrity sha512-gusMi+Z4gY/JaEQeXnB0RUdU82h1kF0WYzCWgVmV4p3hWXqelaKuCvcJawfeg+EKn2T1Ie+YWF2OiN1/L8bTVg==
dependencies:
magic-string "^0.30.2"
optionalDependencies:
"@babel/code-frame" "^7.22.5"

rollup-plugin-license@^2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/rollup-plugin-license/-/rollup-plugin-license-2.6.1.tgz#20f15cc37950f362f8eefdc6e3a2e659d0cad9eb"
Expand Down