Skip to content

feat(types): Introduce @sentry/types package #1332

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 2 commits into from
May 17, 2018
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
3 changes: 2 additions & 1 deletion packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
},
"dependencies": {
"@sentry/core": "0.5.4",
"@sentry/shim": "0.5.4"
"@sentry/shim": "0.5.4",
"@sentry/types": "0.5.4"
},
"devDependencies": {
"chai": "^4.1.2",
Expand Down
8 changes: 2 additions & 6 deletions packages/browser/src/backend.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { Backend, Options, SentryError } from '@sentry/core';
import {
addBreadcrumb,
captureEvent,
SentryEvent,
SentryException,
} from '@sentry/shim';
import { addBreadcrumb, captureEvent } from '@sentry/shim';
import { SentryEvent, SentryException } from '@sentry/types';
import { Raven, SendMethod } from './raven';

/** Original raven send function. */
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseClient } from '@sentry/core';
import { SdkInfo } from '@sentry/shim';
import { SdkInfo } from '@sentry/types';
import { BrowserBackend, BrowserOptions } from './backend';
import { Raven } from './raven';

Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export {
Stacktrace,
Thread,
User,
} from '@sentry/shim';
} from '@sentry/types';

export {
addBreadcrumb,
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/raven.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Breadcrumb, SentryEvent } from '@sentry/shim';
import { Breadcrumb, SentryEvent } from '@sentry/types';
// tslint:disable-next-line:no-implicit-dependencies
import * as RavenJS from 'raven-js';

Expand Down
3 changes: 2 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"access": "public"
},
"dependencies": {
"@sentry/shim": "0.5.4"
"@sentry/shim": "0.5.4",
"@sentry/types": "0.5.4"
},
"devDependencies": {
"chai": "^4.1.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Breadcrumb, Context, SdkInfo, SentryEvent } from '@sentry/shim';
import { Breadcrumb, Context, SdkInfo, SentryEvent } from '@sentry/types';
import { DSN } from './dsn';
import { Backend, Client, Options, Scope } from './interfaces';
import { SendStatus } from './status';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Breadcrumb, Context, SentryEvent } from '@sentry/shim';
import { Breadcrumb, Context, SentryEvent } from '@sentry/types';
import { DSN } from './dsn';
import { SendStatus } from './status';

Expand Down
9 changes: 6 additions & 3 deletions packages/core/src/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import * as Shim from '@sentry/shim';
import {
bindClient as shimBindClient,
getCurrentClient as shimGetCurrentClient,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, alright then :)

} from '@sentry/shim';
import { Client, Options } from './interfaces';

export {
Expand Down Expand Up @@ -28,11 +31,11 @@ export function initAndBind<F extends Client, O extends Options>(
clientClass: ClientClass<F, O>,
options: O,
): void {
if (Shim.getCurrentClient()) {
if (shimGetCurrentClient()) {
return;
}

const client = new clientClass(options);
client.install();
Shim.bindClient(client);
shimBindClient(client);
}
1 change: 1 addition & 0 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"dependencies": {
"@sentry/core": "0.5.4",
"@sentry/shim": "0.5.4",
"@sentry/types": "0.5.4",
"raven": "^2.6.0"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion packages/node/src/backend.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Backend, DSN, Options, SentryError } from '@sentry/core';
import { addBreadcrumb, captureEvent, SentryEvent } from '@sentry/shim';
import { addBreadcrumb, captureEvent } from '@sentry/shim';
import { SentryEvent } from '@sentry/types';
import {
HTTPSTransport,
HTTPTransport,
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseClient } from '@sentry/core';
import { SdkInfo } from '@sentry/shim';
import { SdkInfo } from '@sentry/types';
import { NodeBackend, NodeOptions } from './backend';
import { Raven } from './raven';

Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export {
Stacktrace,
Thread,
User,
} from '@sentry/shim';
} from '@sentry/types';

export {
addBreadcrumb,
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/raven.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Breadcrumb, SentryEvent } from '@sentry/shim';
import { Breadcrumb, SentryEvent } from '@sentry/types';
import * as RavenNode from 'raven';

export type SendMethod = (event: SentryEvent, cb?: (err: any) => void) => void;
Expand Down
3 changes: 3 additions & 0 deletions packages/shim/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"publishConfig": {
"access": "public"
},
"dependencies": {
"@sentry/types": "0.5.4"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going forward, we should probably also provide a rollup build without that dependency for our CDN, just like the @sentry/browser package. This would allow users to include a single javascript file to shim sentry instead of having to install multiple packages for use cases without sophisticated bundlers.

},
"devDependencies": {
"chai": "^4.1.2",
"jest": "^22.4.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/shim/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export {
Stacktrace,
Thread,
User,
} from './models';
} from '@sentry/types';
export {
_callOnClient,
addBreadcrumb,
Expand Down
2 changes: 1 addition & 1 deletion packages/shim/src/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Breadcrumb, SentryEvent, User } from '@sentry/types';
import { getGlobalRegistry } from './global';
import { Breadcrumb, SentryEvent, User } from './models';
import { API_VERSION, Shim } from './shim';

/** Default callback used for catching async errors. */
Expand Down
2 changes: 2 additions & 0 deletions packages/types/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!/dist/**/*
27 changes: 27 additions & 0 deletions packages/types/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2018 Sentry (https://sentry.io) and individual contributors.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Neither the name of the Sentry nor the names of its contributors may be
used to endorse or promote products derived from this software without specific
prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 changes: 14 additions & 0 deletions packages/types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<p align="center">
<a href="https://sentry.io" target="_blank" align="center">
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280">
</a>
<br />
</p>

# Sentry JavaScript SDK Types

[![npm version](https://img.shields.io/npm/v/@sentry/types.svg)](https://www.npmjs.com/package/@sentry/types)
[![npm dm](https://img.shields.io/npm/dm/@sentry/types.svg)](https://www.npmjs.com/package/@sentry/types)
[![npm dt](https://img.shields.io/npm/dt/@sentry/types.svg)](https://www.npmjs.com/package/@sentry/types)

Common types used by the Sentry JavaScript SDKs.
33 changes: 33 additions & 0 deletions packages/types/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@sentry/types",
"version": "0.5.4",
"description": "Types for all Sentry JavaScript SDKs",
"repository": "git://github.com/getsentry/raven-js.git",
"homepage": "https://github.com/getsentry/raven-js/tree/next/packages/types",
"author": "Sentry",
"license": "BSD-3-Clause",
"engines": {
"node": ">=6"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"publishConfig": {
"access": "public"
},
"devDependencies": {
"npm-run-all": "^4.1.2",
"prettier": "^1.12.1",
"prettier-check": "^2.0.0",
"tslint": "^5.9.1",
"typescript": "^2.8.3"
},
"scripts": {
"build": "tsc -p tsconfig.build.json",
"lint": "run-s lint:prettier lint:tslint",
"lint:prettier": "prettier-check '{src,test}/**/*.ts'",
"lint:tslint": "tslint -t stylish -p .",
"fix": "run-s fix:tslint fix:prettier",
"fix:prettier": "prettier --write '{src,test}/**/*.ts'",
"fix:tslint": "tslint --fix -t stylish -p ."
}
}
File renamed without changes.
9 changes: 9 additions & 0 deletions packages/types/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"outDir": "dist",
"rootDir": "src"
},
"include": ["src/**/*.ts"]
}
10 changes: 10 additions & 0 deletions packages/types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.build.json",
"include": ["src/**/*.ts"],
"exclude": ["dist"],
"compilerOptions": {
"rootDir": ".",
"types": ["node"],
"plugins": [{ "name": "tslint-language-service" }]
}
}
3 changes: 3 additions & 0 deletions packages/types/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@sentry/typescript/tslint"
}
3 changes: 3 additions & 0 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"publishConfig": {
"access": "public"
},
"dependencies": {
"@sentry/types": "0.5.4"
},
"devDependencies": {
"chai": "^4.1.2",
"jest": "^22.4.3",
Expand Down