studiokit-scaffolding-js 4.12.0 → 4.12.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,8 @@
1
- import { ErrorInfo, PureComponent } from 'react';
2
- interface ErrorBoundaryState {
3
- error?: Error;
4
- errorInfo?: ErrorInfo;
1
+ import * as Sentry from '@sentry/react';
2
+ import { FunctionComponent } from 'react';
3
+ export interface ShowReportDialogButtonProps {
4
+ eventId: string;
5
+ className?: string;
5
6
  }
6
- export default class ErrorBoundary extends PureComponent<{}, ErrorBoundaryState> {
7
- constructor(props: {});
8
- componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
9
- render(): {} | null | undefined;
10
- }
11
- export {};
7
+ export declare const ShowReportDialogButton: FunctionComponent<ShowReportDialogButtonProps>;
8
+ export declare const ErrorBoundary: FunctionComponent<Sentry.ErrorBoundaryProps>;
@@ -1,17 +1,15 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
13
10
  };
14
- })();
11
+ return __assign.apply(this, arguments);
12
+ };
15
13
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
16
14
  if (k2 === undefined) k2 = k;
17
15
  Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
@@ -31,44 +29,73 @@ var __importStar = (this && this.__importStar) || function (mod) {
31
29
  __setModuleDefault(result, mod);
32
30
  return result;
33
31
  };
32
+ var __rest = (this && this.__rest) || function (s, e) {
33
+ var t = {};
34
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
35
+ t[p] = s[p];
36
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
37
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
38
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
39
+ t[p[i]] = s[p[i]];
40
+ }
41
+ return t;
42
+ };
43
+ var __importDefault = (this && this.__importDefault) || function (mod) {
44
+ return (mod && mod.__esModule) ? mod : { "default": mod };
45
+ };
34
46
  Object.defineProperty(exports, "__esModule", { value: true });
47
+ exports.ErrorBoundary = exports.ShowReportDialogButton = void 0;
48
+ var Button_1 = __importDefault(require("@material-ui/core/Button"));
49
+ var BugReport_1 = __importDefault(require("@material-ui/icons/BugReport"));
50
+ var Refresh_1 = __importDefault(require("@material-ui/icons/Refresh"));
35
51
  var Sentry = __importStar(require("@sentry/react"));
36
52
  var react_1 = __importStar(require("react"));
37
53
  var react_bootstrap_1 = require("react-bootstrap");
38
- var ErrorBoundary = /** @class */ (function (_super) {
39
- __extends(ErrorBoundary, _super);
40
- function ErrorBoundary(props) {
41
- var _this = _super.call(this, props) || this;
42
- _this.state = { error: undefined, errorInfo: undefined };
43
- return _this;
44
- }
45
- ErrorBoundary.prototype.componentDidCatch = function (error, errorInfo) {
46
- // Catch errors in any components below and re-render with error message
47
- this.setState({
48
- error: error,
49
- errorInfo: errorInfo
54
+ var react_redux_1 = require("react-redux");
55
+ var user_1 = require("../utils/user");
56
+ var ShowReportDialogButton = function (_a) {
57
+ var className = _a.className, eventId = _a.eventId;
58
+ var userInfo = react_redux_1.useSelector(function (state) {
59
+ var _a;
60
+ return (_a = state.models.user) === null || _a === void 0 ? void 0 : _a.userInfo;
61
+ });
62
+ var showDialog = react_1.useCallback(function () {
63
+ var user = userInfo
64
+ ? { name: user_1.displayName(userInfo) || undefined, email: userInfo.email || undefined }
65
+ : undefined;
66
+ Sentry.showReportDialog({
67
+ eventId: eventId,
68
+ user: user
50
69
  });
51
- // You can also log error messages to an error reporting service here
52
- Sentry.captureException(new Error(error.toString()));
53
- };
54
- ErrorBoundary.prototype.render = function () {
55
- if (!!this.state.error && !!this.state.errorInfo) {
56
- return (react_1.default.createElement(react_1.default.Fragment, null,
57
- react_1.default.createElement(react_bootstrap_1.Container, { className: "mt3" },
58
- react_1.default.createElement(react_bootstrap_1.Row, null,
59
- react_1.default.createElement(react_bootstrap_1.Col, { md: 8 },
60
- react_1.default.createElement("h2", null, "Oops! Something went wrong while processing your request."),
61
- react_1.default.createElement("p", null,
62
- "Please refresh the page and try again. If you have any questions or concerns please contact us at ",
63
- react_1.default.createElement("a", { href: "mailto:tlt@purdue.edu" }, "tlt@purdue.edu")),
64
- react_1.default.createElement("details", { className: "pre-wrap" },
65
- this.state.error.toString(),
66
- react_1.default.createElement("br", null),
67
- this.state.errorInfo.componentStack))))));
68
- }
69
- // Normally, just render children
70
- return this.props.children;
71
- };
72
- return ErrorBoundary;
73
- }(react_1.PureComponent));
74
- exports.default = ErrorBoundary;
70
+ }, [eventId, userInfo]);
71
+ return (react_1.default.createElement(Button_1.default, { className: className, "aria-label": "Send Crash Report", onClick: showDialog },
72
+ react_1.default.createElement(BugReport_1.default, null),
73
+ " Send Crash Report"));
74
+ };
75
+ exports.ShowReportDialogButton = ShowReportDialogButton;
76
+ var ErrorBoundary = function (_a) {
77
+ var children = _a.children, props = __rest(_a, ["children"]);
78
+ return (react_1.default.createElement(Sentry.ErrorBoundary
79
+ // set default props
80
+ , __assign({
81
+ // set default props
82
+ fallback: function (_a) {
83
+ var eventId = _a.eventId, resetError = _a.resetError;
84
+ return (react_1.default.createElement(react_bootstrap_1.Container, { className: "mt3" },
85
+ react_1.default.createElement(react_bootstrap_1.Row, null,
86
+ react_1.default.createElement(react_bootstrap_1.Col, { md: 8 },
87
+ react_1.default.createElement("h2", null, "Oops! Something went wrong while processing your request."),
88
+ react_1.default.createElement("p", { className: "mb2" }, "Please try reloading or refresh the page to try again."),
89
+ react_1.default.createElement("p", { className: "mb0" },
90
+ react_1.default.createElement(exports.ShowReportDialogButton, { className: "btn-primary", eventId: eventId }),
91
+ react_1.default.createElement(Button_1.default, { className: "ml2 btn-primary", "aria-label": "Reload", onClick: resetError },
92
+ react_1.default.createElement(Refresh_1.default, null),
93
+ " Reload")),
94
+ react_1.default.createElement("p", null,
95
+ "If the problem persists please contact us at",
96
+ ' ',
97
+ react_1.default.createElement("a", { href: "mailto:tlt@purdue.edu" }, "tlt@purdue.edu"),
98
+ ".")))));
99
+ } }, props), children));
100
+ };
101
+ exports.ErrorBoundary = ErrorBoundary;
@@ -83,7 +83,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
83
83
  };
84
84
  Object.defineProperty(exports, "__esModule", { value: true });
85
85
  var react_1 = __importStar(require("react"));
86
- var ErrorBoundary_1 = __importDefault(require("../ErrorBoundary"));
86
+ var ErrorBoundary_1 = require("../ErrorBoundary");
87
87
  var Loading_1 = __importDefault(require("../Loading"));
88
88
  function asyncComponent(importComponent, showLoader) {
89
89
  if (showLoader === void 0) { showLoader = true; }
@@ -127,7 +127,7 @@ function asyncComponent(importComponent, showLoader) {
127
127
  if (!ImportedComponent) {
128
128
  return showLoader ? react_1.default.createElement(Loading_1.default, null) : null;
129
129
  }
130
- return (react_1.default.createElement(ErrorBoundary_1.default, null,
130
+ return (react_1.default.createElement(ErrorBoundary_1.ErrorBoundary, null,
131
131
  react_1.default.createElement(ImportedComponent, __assign({}, this.props))));
132
132
  };
133
133
  return AsyncComponent;
@@ -39,3 +39,8 @@
39
39
  text-align: right;
40
40
  }
41
41
  }
42
+
43
+ /* Always display sentry feedback dialog on top of everything else. */
44
+ .sentry-error-embed-wrapper {
45
+ z-index: 9999 !important;
46
+ }
package/lib/startup.js CHANGED
@@ -25,7 +25,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.startup = void 0;
26
26
  var applicationinsights_web_1 = require("@microsoft/applicationinsights-web");
27
27
  var Sentry = __importStar(require("@sentry/react"));
28
- var tracing_1 = require("@sentry/tracing");
29
28
  var history_1 = require("history");
30
29
  var react_ga4_1 = __importDefault(require("react-ga4"));
31
30
  var configuration_1 = require("./constants/configuration");
@@ -86,7 +85,7 @@ var startup = function (appConfig, endpointMappings) {
86
85
  },
87
86
  // enable performance tracing and session replays
88
87
  integrations: [
89
- new tracing_1.Integrations.BrowserTracing({
88
+ new Sentry.BrowserTracing({
90
89
  routingInstrumentation: Sentry.reactRouterV5Instrumentation(history)
91
90
  }),
92
91
  new Sentry.Replay()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "studiokit-scaffolding-js",
3
- "version": "4.12.0",
3
+ "version": "4.12.1-alpha.2",
4
4
  "description": "Common scaffolding for Studio apps at Purdue",
5
5
  "repository": "https://gitlab.com/purdue-informatics/studiokit/studiokit-scaffolding-js",
6
6
  "license": "MIT",
@@ -85,7 +85,7 @@
85
85
  ]
86
86
  },
87
87
  "resolutions": {
88
- "@sentry/browser": "^7.38.0",
88
+ "@sentry/browser": "^7.77.0",
89
89
  "@types/react": "^17.0.0",
90
90
  "@types/react-router": "^5.1.11",
91
91
  "kind-of": "^6.0.3",
@@ -100,8 +100,7 @@
100
100
  "@material-ui/lab": "^4.0.0-alpha.57",
101
101
  "@microsoft/applicationinsights-web": "^2.5.11",
102
102
  "@redux-saga/types": "^1.1.0",
103
- "@sentry/react": "^7.38.0",
104
- "@sentry/tracing": "^7.38.0",
103
+ "@sentry/react": "^7.77.0",
105
104
  "@types/history": "^4.7.8",
106
105
  "@types/lodash": "^4.14.168",
107
106
  "@types/pluralize": "^0.0.29",