Skip to content

Commit

Permalink
Add Rollbar
Browse files Browse the repository at this point in the history
  • Loading branch information
giorgiogross committed Mar 9, 2023
1 parent 8d6960c commit 607b7ab
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
MB_API_KEY=
MB_API_KEY=
ROLLBAR_ACCESS_TOKEN=
ROLLBAR_POST_CLIENT_ITEM_ACCESS_TOKEN=
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:react/recommended"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
"jsx": true,
"tsx": true
},
"ecmaVersion": 6,
"sourceType": "module"
Expand All @@ -16,6 +17,7 @@
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
"@preact/signals-core": "^1.2.2",
"@preact/signals-react": "^1.2.1",
"@primer/octicons-react": "^17.9.0",
"@rollbar/react": "^0.11.1",
"@stitches/react": "^1.2.8",
"@vscode/webview-ui-toolkit": "^1.1.0",
"dotenv": "^16.0.3",
Expand All @@ -139,6 +140,7 @@
"pluralize": "^8.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rollbar": "^2.26.1",
"stream-http": "^3.2.0",
"url": "^0.11.0",
"use-async-effect": "^2.2.7",
Expand Down
2 changes: 1 addition & 1 deletion src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const magicbell = new MagicBell({
userHmac: config.get('userHmac'),
appInfo: {
name: 'ping-vscode',
version: process.env.npm_package_version ?? '0.0.0',
version: process.env.PING_VERSION,
},
});

Expand Down
4 changes: 4 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import * as context from './context';
import { commands } from './lib/commands';
import { register } from './lib/webview';

import rollbar from './lib/rollbar';

export function activate(ctx: vscode.ExtensionContext) {
// record a generic message and send it to Rollbar
rollbar.log('Activated');
const listView = register(ListView, ctx);

ctx.subscriptions.push(listView);
Expand Down
23 changes: 22 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ import { useWebView } from './lib/hooks';
import { globalStyles } from './ui/stitches';
import { List } from './views/list';

import { Provider, ErrorBoundary } from '@rollbar/react';
const rollbarConfig = {
accessToken: process.env.ROLLBAR_POST_CLIENT_ITEM_ACCESS_TOKEN,
environment: process.env.NODE_ENV,
code_version: process.env.PING_VERSION,
};

globalStyles();

const views = {
Expand All @@ -23,5 +30,19 @@ function Index() {
return <View viewType={viewType} data={data} />;
}

const ErrorDisplay = () => (
<div style={{ padding: '24px'}}>
<p>We caught an error in Pings UI root zone. You can help make Ping better if you send a message to [email protected]</p>
</div>
);

const root = createRoot(document.getElementById('root') as HTMLElement);
root.render(<Index />);
root.render(
<Provider config={rollbarConfig}>
{/*
// @ts-ignore */}
<ErrorBoundary fallbackUI={ErrorDisplay}>
<Index />
</ErrorBoundary>
</Provider>
);
8 changes: 8 additions & 0 deletions src/lib/rollbar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Rollbar from 'rollbar';
const rollbar = new Rollbar({
accessToken: process.env.ROLLBAR_ACCESS_TOKEN,
captureUncaught: true,
captureUnhandledRejections: true,
});

export default rollbar;
2 changes: 1 addition & 1 deletion src/lib/webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function getHTML(context: WebViewContext): string {
<meta name="theme-color" content="#000000">
<title>${context.title}</title>
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src vscode-resource: vscode-webview: https:; script-src 'nonce-${nonce}';style-src vscode-resource: 'unsafe-inline' http: https: data:;">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; connect-src https://api.rollbar.com/; img-src vscode-resource: vscode-webview: https:; script-src 'nonce-${nonce}';style-src vscode-resource: 'unsafe-inline' http: https: data:;">
</head>
<body data-view-type="${context.viewType}">
Expand Down
7 changes: 7 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

const dotenv = require('dotenv');

var PACKAGE = require('./package.json');
var pingVersion = PACKAGE.version;

const path = require('path');
const webpack = require('webpack');

Expand All @@ -17,7 +20,11 @@ module.exports = (env, argv) => {
const baseConfig = {
plugins: [
new webpack.DefinePlugin({
'process.env.PING_VERSION': JSON.stringify(pingVersion),
'process.env.NODE_ENV': JSON.stringify(argv.mode),
'process.env.MB_API_KEY': JSON.stringify(process.env.MB_API_KEY),
'process.env.ROLLBAR_ACCESS_TOKEN': JSON.stringify(process.env.ROLLBAR_ACCESS_TOKEN),
'process.env.ROLLBAR_POST_CLIENT_ITEM_ACCESS_TOKEN': JSON.stringify(process.env.ROLLBAR_POST_CLIENT_ITEM_ACCESS_TOKEN),
}),
],
}
Expand Down
95 changes: 95 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@
resolved "https://registry.npmjs.org/@primer/octicons-react/-/octicons-react-17.12.0.tgz"
integrity sha512-GUjV6IT1Ck2lu2GVu1loR0e2dcX2e9aIVmX5rBdR7HJnRdYKY7XH+FnYj7y9sEmzUdNEDswxkefiQlfGrBXlzA==

"@rollbar/react@^0.11.1":
version "0.11.1"
resolved "https://registry.yarnpkg.com/@rollbar/react/-/react-0.11.1.tgz#91cfa39fe54f4c1939233c1f63e27d2f89abb20e"
integrity sha512-QwI8wPjX1xc/AuX39TSJx/tEtjmf8macRqYgX+R/uRh7Y3+4ilZX9OMwLg/4Je8+NN+9y7PFNKkQa9adn58d/g==
dependencies:
tiny-invariant "^1.1.0"

"@stitches/react@^1.2.8":
version "1.2.8"
resolved "https://registry.npmjs.org/@stitches/react/-/react-1.2.8.tgz"
Expand Down Expand Up @@ -630,6 +637,11 @@ array.prototype.tosorted@^1.1.1:
es-shim-unscopables "^1.0.0"
get-intrinsic "^1.1.3"

async@~3.2.3:
version "3.2.4"
resolved "https://registry.yarnpkg.com/async/-/async-3.2.4.tgz#2d22e00f8cddeb5fde5dd33522b56d1cf569a81c"
integrity sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ==

asynckit@^0.4.0:
version "0.4.0"
resolved "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz"
Expand Down Expand Up @@ -944,6 +956,11 @@ [email protected]:
resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz"
integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==

[email protected]:
version "0.3.0"
resolved "https://registry.yarnpkg.com/console-polyfill/-/console-polyfill-0.3.0.tgz#84900902a18c47a5eba932be75fa44d23e8af861"
integrity sha512-w+JSDZS7XML43Xnwo2x5O5vxB0ID7T5BdqDtyqT6uiCAX2kZAgcWxNaGqT97tZfSHzfOcvrfsDAodKcJ3UvnXQ==

core-util-is@~1.0.0:
version "1.0.3"
resolved "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz"
Expand Down Expand Up @@ -986,6 +1003,13 @@ debug@4, [email protected], debug@^4.1.1, debug@^4.3.2, debug@^4.3.4:
dependencies:
ms "2.1.2"

decache@^3.0.5:
version "3.1.0"
resolved "https://registry.yarnpkg.com/decache/-/decache-3.1.0.tgz#4f5036fbd6581fcc97237ac3954a244b9536c2da"
integrity sha512-p7D6wJ5EJFFq1CcF2lu1XeqKFLBob8jRQGNAvFLTsV3CbSKBl3VtliAVlUIGz2i9H6kEFnI2Amaft5ZopIG2Fw==
dependencies:
find "^0.2.4"

decamelize@^4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz"
Expand Down Expand Up @@ -1139,6 +1163,13 @@ envinfo@^7.7.3:
resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.8.1.tgz#06377e3e5f4d379fea7ac592d5ad8927e0c4d475"
integrity sha512-/o+BXHmB7ocbHEAs6F2EnG0ogybVVUdkRunTT2glZU9XAaGmhqskrvKwqXuDfNjEO0LZKWdejEEpnq8aM0tOaw==

error-stack-parser@^2.0.4:
version "2.1.4"
resolved "https://registry.yarnpkg.com/error-stack-parser/-/error-stack-parser-2.1.4.tgz#229cb01cdbfa84440bfa91876285b94680188286"
integrity sha512-Sk5V6wVazPhq5MhpO+AUxJn5x7XSXGl1R93Vn7i+zS15KDVxQijejNCrz8340/2bgLBjR9GtEG8ZVKONDjcqGQ==
dependencies:
stackframe "^1.3.4"

es-abstract@^1.19.0, es-abstract@^1.20.4:
version "1.21.1"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.21.1.tgz#e6105a099967c08377830a0c9cb589d570dd86c6"
Expand Down Expand Up @@ -1456,6 +1487,13 @@ find-up@^4.0.0:
locate-path "^5.0.0"
path-exists "^4.0.0"

find@^0.2.4:
version "0.2.9"
resolved "https://registry.yarnpkg.com/find/-/find-0.2.9.tgz#4b73f1ff9e56ad91b76e716407fe5ffe6554bb8c"
integrity sha512-7a4/LCiInB9xYMnAUEjLilL9FKclwbwK7VlXw+h5jMvT2TDFeYFCHM24O1XdnC/on/hx8mxVO3FTQkyHZnOghQ==
dependencies:
traverse-chain "~0.1.0"

flat-cache@^3.0.4:
version "3.0.4"
resolved "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz"
Expand Down Expand Up @@ -1993,6 +2031,11 @@ is-weakref@^1.0.2:
dependencies:
call-bind "^1.0.2"

is_js@^0.9.0:
version "0.9.0"
resolved "https://registry.yarnpkg.com/is_js/-/is_js-0.9.0.tgz#0ab94540502ba7afa24c856aa985561669e9c52d"
integrity sha512-8Y5EHSH+TonfUHX2g3pMJljdbGavg55q4jmHzghJCdqYDbdNROC8uw/YFQwIRCRqRJT1EY3pJefz+kglw+o7sg==

isarray@~1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz"
Expand Down Expand Up @@ -2058,6 +2101,11 @@ json-stable-stringify-without-jsonify@^1.0.1:
resolved "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz"
integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==

json-stringify-safe@~5.0.0:
version "5.0.1"
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==

"jsx-ast-utils@^2.4.1 || ^3.0.0":
version "3.3.3"
resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-3.3.3.tgz#76b3e6e6cece5c69d49a5792c3d01bd1a0cdc7ea"
Expand Down Expand Up @@ -2150,6 +2198,11 @@ lru-cache@^6.0.0:
dependencies:
yallist "^4.0.0"

lru-cache@~2.2.1:
version "2.2.4"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.2.4.tgz#6c658619becf14031d0d0b594b16042ce4dc063d"
integrity sha512-Q5pAgXs+WEAfoEdw2qKQhNFFhMoFMTYqRVKKUMnzuiR7oKFHS7fWo848cPcTKw+4j/IdN17NyzdhVKgabFV0EA==

[email protected]:
version "1.2.0"
resolved "https://registry.npmjs.org/magicbell/-/magicbell-1.2.0.tgz"
Expand Down Expand Up @@ -2725,6 +2778,13 @@ regexpp@^3.2.0:
resolved "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz"
integrity sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==

request-ip@~2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/request-ip/-/request-ip-2.0.2.tgz#deeae6d4af21768497db8cd05fa37143f8f1257e"
integrity sha512-Y6LxqTmxLKKDk2I5tU2sxoCSKAnWJ42jmGqixNrH+oYoAyncpal7fFF5gqJ2bbgkRmb9qYNxdD6KFHfLS4dKBA==
dependencies:
is_js "^0.9.0"

require-directory@^2.1.1:
version "2.1.1"
resolved "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz"
Expand Down Expand Up @@ -2784,6 +2844,21 @@ rimraf@^3.0.0, rimraf@^3.0.2:
dependencies:
glob "^7.1.3"

rollbar@^2.26.1:
version "2.26.1"
resolved "https://registry.yarnpkg.com/rollbar/-/rollbar-2.26.1.tgz#45a69d9a1e95fee6501dd13ee40feb75d242be78"
integrity sha512-zphIb11bYUXP+9LJGfehukizyxINK8llwYxAeGjZTDdblyqT1Wmh1Fka3ucHjHSqeR/vZyIjTFGLj/PajUK5Gg==
dependencies:
async "~3.2.3"
console-polyfill "0.3.0"
error-stack-parser "^2.0.4"
json-stringify-safe "~5.0.0"
lru-cache "~2.2.1"
request-ip "~2.0.1"
source-map "^0.5.7"
optionalDependencies:
decache "^3.0.5"

run-parallel@^1.1.9:
version "1.2.0"
resolved "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz"
Expand Down Expand Up @@ -2922,11 +2997,21 @@ source-map-support@~0.5.20:
buffer-from "^1.0.0"
source-map "^0.6.0"

source-map@^0.5.7:
version "0.5.7"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
integrity sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==

source-map@^0.6.0:
version "0.6.1"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==

stackframe@^1.3.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-1.3.4.tgz#b881a004c8c149a5e8efef37d51b16e412943310"
integrity sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==

stream-http@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/stream-http/-/stream-http-3.2.0.tgz#1872dfcf24cb15752677e40e5c3f9cc1926028b5"
Expand Down Expand Up @@ -3092,6 +3177,11 @@ text-table@^0.2.0:
resolved "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz"
integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==

tiny-invariant@^1.1.0:
version "1.3.1"
resolved "https://registry.yarnpkg.com/tiny-invariant/-/tiny-invariant-1.3.1.tgz#8560808c916ef02ecfd55e66090df23a4b7aa642"
integrity sha512-AD5ih2NlSssTCwsMznbvwMZpJ1cbhkGd2uueNxzv2jDlEeZdU04JQfRnggJQ8DrcVBGjAsCKwFBbDlVNtEMlzw==

tmp@^0.2.1:
version "0.2.1"
resolved "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz"
Expand All @@ -3106,6 +3196,11 @@ to-regex-range@^5.0.1:
dependencies:
is-number "^7.0.0"

traverse-chain@~0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/traverse-chain/-/traverse-chain-0.1.0.tgz#61dbc2d53b69ff6091a12a168fd7d433107e40f1"
integrity sha512-up6Yvai4PYKhpNp5PkYtx50m3KbwQrqDwbuZP/ItyL64YEWHAvH6Md83LFLV/GRSk/BoUVwwgUzX6SOQSbsfAg==

"traverse@>=0.3.0 <0.4":
version "0.3.9"
resolved "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz"
Expand Down

0 comments on commit 607b7ab

Please sign in to comment.