Skip to content

Commit b851ae7

Browse files
committed
feat: @sentry/vue
1 parent d1671b8 commit b851ae7

File tree

18 files changed

+5309
-1
lines changed

18 files changed

+5309
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ package. Please refer to the README and instructions of those SDKs for more deta
4141
including integrations for React, Angular, Ember, Vue and Backbone
4242
- [`@sentry/node`](https://github.com/getsentry/sentry-javascript/tree/master/packages/node): SDK for Node, including
4343
integrations for Express, Koa, Loopback, Sails and Connect
44+
- [`@sentry/angular`](https://github.com/getsentry/sentry-javascript/tree/master/packages/angular): SDK for Angular
45+
- [`@sentry/react`](https://github.com/getsentry/sentry-javascript/tree/master/packages/react): SDK for ReactJS
46+
- [`@sentry/ember`](https://github.com/getsentry/sentry-javascript/tree/master/packages/ember): SDK for Ember
47+
- [`@sentry/vue`](https://github.com/getsentry/sentry-javascript/tree/master/packages/vue): SDK for Vue
48+
- [`@sentry/gatsby`](https://github.com/getsentry/sentry-javascript/tree/master/packages/gatsby): SDK for Gatsby
4449
- [`@sentry/react-native`](https://github.com/getsentry/sentry-react-native): SDK for React Native with support for native crashes
4550
- [`@sentry/integrations`](https://github.com/getsentry/sentry-javascript/tree/master/packages/integrations): Pluggable
4651
integrations that can be used to enhance JS SDKs

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"packages/tracing",
3636
"packages/types",
3737
"packages/typescript",
38-
"packages/utils"
38+
"packages/utils",
39+
"packages/vue"
3940
],
4041
"devDependencies": {
4142
"@google-cloud/storage": "^2.5.0",

packages/integrations/src/angular.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ export class Angular implements Integration {
4747
*/
4848
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4949
public constructor(options: { angular?: any } = {}) {
50+
logger.warn('You are still using the Angular integration, consider moving to @sentry/angular');
51+
5052
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
5153
this._angular = options.angular || getGlobalObject<any>().angular;
5254

packages/integrations/src/vue.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ export class Vue implements Integration {
154154
public constructor(
155155
options: Partial<Omit<IntegrationOptions, 'tracingOptions'> & { tracingOptions: Partial<TracingOptions> }>,
156156
) {
157+
logger.warn('You are still using the Angular integration, consider moving to @sentry/angular');
157158
this._options = {
158159
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
159160
Vue: getGlobalObject<any>().Vue,

packages/vue/.eslintrc.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
es6: true,
5+
browser: true,
6+
},
7+
parserOptions: {
8+
ecmaVersion: 2018,
9+
jsx: true,
10+
},
11+
extends: ['@sentry-internal/sdk'],
12+
ignorePatterns: ['build/**', 'dist/**', 'esm/**', 'examples/**', 'scripts/**'],
13+
overrides: [
14+
{
15+
files: ['*.ts', '*.tsx', '*.d.ts'],
16+
parserOptions: {
17+
project: './tsconfig.json',
18+
},
19+
},
20+
{
21+
files: ['*.tsx'],
22+
rules: {
23+
'jsdoc/require-jsdoc': 'off',
24+
},
25+
},
26+
{
27+
files: ['test/**'],
28+
rules: {
29+
'@typescript-eslint/no-explicit-any': 'off',
30+
},
31+
},
32+
],
33+
rules: {
34+
'react/prop-types': 'off',
35+
'@typescript-eslint/no-unsafe-member-access': 'off',
36+
},
37+
};

packages/vue/.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*
2+
!/dist/**/*
3+
!/esm/**/*
4+
*.tsbuildinfo

packages/vue/LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
MIT License
2+
3+
Copyright (c) 2019, Sentry
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
* Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

packages/vue/README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<p align="center">
2+
<a href="https://sentry.io" target="_blank" align="center">
3+
<img src="https://sentry-brand.storage.googleapis.com/sentry-logo-black.png" width="280">
4+
</a>
5+
<br />
6+
</p>
7+
8+
# Official Sentry SDK for VueJS
9+
10+
## Links
11+
12+
- [Official SDK Docs](https://docs.sentry.io/quickstart/)
13+
- [TypeDoc](http://getsentry.github.io/sentry-javascript/)
14+
15+
## General
16+
17+
This package is a wrapper around `@sentry/browser`, with added functionality related to React. All methods available in
18+
`@sentry/browser` can be imported from `@sentry/react`.
19+
20+
To use this SDK, call `Sentry.init(options)` before you mount your React component.
21+
22+
```javascript
23+
import React from 'react';
24+
import ReactDOM from "react-dom";
25+
import * as Sentry from '@sentry/react';
26+
27+
Sentry.init({
28+
dsn: '__DSN__',
29+
// ...
30+
});
31+
32+
// ...
33+
34+
ReactDOM.render(<App />, rootNode);
35+
36+
// Can also use with React Concurrent Mode
37+
// ReactDOM.createRoot(rootNode).render(<App />);
38+
```
39+
40+
### ErrorBoundary
41+
42+
`@sentry/react` exports an ErrorBoundary component that will automatically send Javascript errors from inside a
43+
component tree to Sentry, and set a fallback UI. Requires React version >= 16.
44+
45+
> app.js
46+
```javascript
47+
import React from 'react';
48+
import * as Sentry from '@sentry/react';
49+
50+
function FallbackComponent() {
51+
return (
52+
<div>An error has occured</div>
53+
)
54+
}
55+
56+
class App extends React.Component {
57+
render() {
58+
return (
59+
<Sentry.ErrorBoundary fallback={FallbackComponent} showDialog>
60+
<OtherComponents />
61+
</Sentry.ErrorBoundary>
62+
)
63+
}
64+
}
65+
66+
export default App;
67+
```
68+
69+
### Profiler
70+
71+
`@sentry/react` exports a Profiler component that leverages the `@sentry/apm` Tracing integration to add React related
72+
spans to transactions. If the Tracing integration is not enabled, the Profiler component will not work. The Profiler
73+
tracks component mount, render duration and updates. Requires React version >= 15.
74+
75+
> app.js
76+
```javascript
77+
import React from 'react';
78+
import * as Sentry from '@sentry/react';
79+
80+
class App extends React.Component {
81+
render() {
82+
return (
83+
<FancyComponent>
84+
<InsideComponent someProp={2} />
85+
<AnotherComponent />
86+
</FancyComponent>
87+
)
88+
}
89+
}
90+
91+
export default Sentry.withProfiler(App);
92+
```

packages/vue/package.json

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"name": "@sentry/vue",
3+
"version": "5.24.2",
4+
"description": "Offical Sentry SDK for Vue.js",
5+
"repository": "git://github.com/getsentry/sentry-javascript.git",
6+
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/react",
7+
"author": "Sentry",
8+
"license": "MIT",
9+
"engines": {
10+
"node": ">=6"
11+
},
12+
"main": "dist/index.js",
13+
"module": "esm/index.js",
14+
"types": "dist/index.d.ts",
15+
"publishConfig": {
16+
"access": "public"
17+
},
18+
"dependencies": {
19+
"@sentry/browser": "5.24.2",
20+
"@sentry/core": "5.24.2",
21+
"@sentry/minimal": "5.24.2",
22+
"@sentry/types": "5.24.2",
23+
"@sentry/utils": "5.24.2",
24+
"tslib": "^1.9.3"
25+
},
26+
"peerDependencies": {
27+
"vue": "2.x"
28+
},
29+
"devDependencies": {
30+
"@sentry-internal/eslint-config-sdk": "5.24.2",
31+
"eslint": "7.6.0",
32+
"jest": "^24.7.1",
33+
"jsdom": "^16.2.2",
34+
"npm-run-all": "^4.1.2",
35+
"prettier": "1.19.0",
36+
"react": "^16.0.0",
37+
"rimraf": "^2.6.3",
38+
"typescript": "3.7.5",
39+
"vue": "^2.6"
40+
},
41+
"scripts": {
42+
"build": "run-p build:es5 build:esm",
43+
"build:es5": "tsc -p tsconfig.build.json",
44+
"build:esm": "tsc -p tsconfig.esm.json",
45+
"build:watch": "run-p build:watch:es5 build:watch:esm",
46+
"build:watch:es5": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
47+
"build:watch:esm": "tsc -p tsconfig.esm.json -w --preserveWatchOutput",
48+
"clean": "rimraf dist coverage build esm",
49+
"link:yarn": "yarn link",
50+
"lint": "run-s lint:prettier lint:eslint",
51+
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
52+
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
53+
"fix": "run-s fix:eslint fix:prettier",
54+
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
55+
"fix:eslint": "eslint . --format stylish --fix",
56+
"test": "jest",
57+
"test:watch": "jest --watch",
58+
"pack": "npm pack"
59+
},
60+
"volta": {
61+
"extends": "../../package.json"
62+
},
63+
"jest": {
64+
"collectCoverage": true,
65+
"transform": {
66+
"^.+\\.ts$": "ts-jest"
67+
},
68+
"moduleFileExtensions": [
69+
"js",
70+
"ts"
71+
],
72+
"testEnvironment": "jsdom",
73+
"testMatch": [
74+
"**/*.test.ts"
75+
],
76+
"globals": {
77+
"ts-jest": {
78+
"tsConfig": "./tsconfig.json",
79+
"diagnostics": false
80+
}
81+
}
82+
},
83+
"sideEffects": [
84+
"./src/index.ts"
85+
]
86+
}

packages/vue/src/index.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { addGlobalEventProcessor, SDK_VERSION } from '@sentry/browser';
2+
3+
/**
4+
* A global side effect that makes sure Sentry events that user
5+
* `@sentry/react` will correctly have Sentry events associated
6+
* with it.
7+
*/
8+
function createVueEventProcessor(): void {
9+
if (addGlobalEventProcessor) {
10+
addGlobalEventProcessor(event => {
11+
event.sdk = {
12+
...event.sdk,
13+
name: 'sentry.javascript.vue',
14+
packages: [
15+
...((event.sdk && event.sdk.packages) || []),
16+
{
17+
name: 'npm:@sentry/vue',
18+
version: SDK_VERSION,
19+
},
20+
],
21+
version: SDK_VERSION,
22+
};
23+
24+
return event;
25+
});
26+
}
27+
}
28+
29+
export {
30+
addGlobalEventProcessor,
31+
addBreadcrumb,
32+
captureException,
33+
captureEvent,
34+
captureMessage,
35+
configureScope,
36+
getHubFromCarrier,
37+
getCurrentHub,
38+
Hub,
39+
Scope,
40+
setContext,
41+
setExtra,
42+
setExtras,
43+
setTag,
44+
setTags,
45+
setUser,
46+
startTransaction,
47+
withScope,
48+
} from '@sentry/browser';
49+
50+
export { init } from './sdk';
51+
52+
createVueEventProcessor();

0 commit comments

Comments
 (0)