Skip to content
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

Add sentry integration #124

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

# run tests!
# run tests!
- run: yarn test
- run: yarn build

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).


[![CircleCI](https://circleci.com/gh/NouamaneTazi/japcalculator/tree/master.svg?style=svg)](https://circleci.com/gh/NouamaneTazi/japcalculator/tree/master)

## Available Scripts

In the project directory, you can run:
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"dependencies": {
"@material-ui/core": "^4.9.2",
"@material-ui/icons": "^4.9.1",
"@sentry/react": "^6.13.3",
"@sentry/tracing": "^6.13.3",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
Expand Down
4 changes: 3 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from "react";
import "./App.css";

import { CalculatorPage } from "./pages";
import React from "react";

const App = () => {
return (
<div className="App">
<h1>Big title</h1>
<CalculatorPage />
</div>
);
Expand Down
54 changes: 28 additions & 26 deletions src/components/CalculatorModal/CalculatorModal.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { FOOD_ITEMS, FoodItem } from "../../data/food";
import React, { useState } from "react";
import { withStyles } from "@material-ui/core/styles";

import { Button } from "@material-ui/core";
import { CSSProperties } from "@material-ui/styles";
import Dialog from "@material-ui/core/Dialog";
import DialogContent from "@material-ui/core/DialogContent";
import IconButton from "@material-ui/core/IconButton";
import CloseIcon from "@material-ui/icons/Close";

import { CustomTheme } from "../../style/theme";
import { Button } from "@material-ui/core";

import Dialog from "@material-ui/core/Dialog";
import DialogContent from "@material-ui/core/DialogContent";
import { default as FoodTile } from "../FoodTile/FoodTile";

import { FOOD_ITEMS, FoodItem } from "../../data/food";
import IconButton from "@material-ui/core/IconButton";
import { withStyles } from "@material-ui/core/styles";

type ClassNames =
| "container"
Expand All @@ -30,18 +28,17 @@ type Props = OwnProps;
export const CalculatorModal: React.FC<Props> = (props: Props) => {
const { classes, onClose, open } = props;

const [values, setValues] = useState<
{ [k in string]: { value: number; kcal: number } }
>({});
const [values, setValues] = useState<{
[k in string]: { value: number; kcal: number };
}>({});

const handleChange = (itemName: string, itemKcal: number) => (
value: number
) => {
setValues({
...values,
[itemName]: { value, kcal: value * itemKcal }
});
};
const handleChange =
(itemName: string, itemKcal: number) => (value: number) => {
setValues({
...values,
[itemName]: { value, kcal: value * itemKcal },
});
};

const result = Object.keys(values).reduce((acc: number, itemName: string) => {
return acc + values[itemName].kcal;
Expand All @@ -68,7 +65,12 @@ export const CalculatorModal: React.FC<Props> = (props: Props) => {
))}
</div>
<div className={classes.buttonContainer}>
<Button variant="contained">{result} Kcal</Button>
<Button
onClick={() => console.error("klklklklk")}
variant="contained"
>
{result} Kcal
</Button>
</div>
</DialogContent>
</Dialog>
Expand All @@ -80,22 +82,22 @@ const styles = (theme: CustomTheme): Record<ClassNames, CSSProperties> => ({
mainFoodItems: {
display: "flex",
flexWrap: "wrap",
justifyContent: "space-evenly"
justifyContent: "space-evenly",
},
closeContainer: {
display: "flex",
justifyContent: "flex-end"
justifyContent: "flex-end",
},
itemContainer: {
display: "flex",
alignItems: "flex-end",
margin: theme.spacing(5)
margin: theme.spacing(5),
},
buttonContainer: {
display: "flex",
justifyContent: "center",
marginBottom: theme.spacing(3)
}
marginBottom: theme.spacing(3),
},
});

export default withStyles(styles)(CalculatorModal);
24 changes: 19 additions & 5 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";

import * as Sentry from "@sentry/react";
import * as serviceWorker from "./serviceWorker";
import { Provider } from "react-redux";

import App from "./App";
import { ConnectedRouter } from "connected-react-router";
import { Integrations } from "@sentry/tracing";
import { Provider } from "react-redux";
import React from "react";
import ReactDOM from "react-dom";
import ThemeProvider from "@material-ui/styles/ThemeProvider";
import { store } from "./redux/config";
import { history } from "./redux/Router/router";
import { store } from "./redux/config";
import { theme } from "./style/theme";

Sentry.init({
dsn: "https://[email protected]/6009070",
integrations: [new Integrations.BrowserTracing()],

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
});

ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}>
Expand Down
77 changes: 76 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,81 @@
resolved "https://registry.yarnpkg.com/@redux-saga/types/-/types-1.1.0.tgz#0e81ce56b4883b4b2a3001ebe1ab298b84237204"
integrity sha512-afmTuJrylUU/0OtqzaRkbyYFFNgCF73Bvel/sw90pvGrWIZ+vyoIJqA6eMSoA6+nb443kTmulmBtC9NerXboNg==

"@sentry/[email protected]":
version "6.13.3"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.13.3.tgz#d4511791b1e484ad48785eba3bce291fdf115c1e"
integrity sha512-jwlpsk2/u1cofvfYsjmqcnx50JJtf/T6HTgdW+ih8+rqWC5ABEZf4IiB/H+KAyjJ3wVzCOugMq5irL83XDCfqQ==
dependencies:
"@sentry/core" "6.13.3"
"@sentry/types" "6.13.3"
"@sentry/utils" "6.13.3"
tslib "^1.9.3"

"@sentry/[email protected]":
version "6.13.3"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.13.3.tgz#5cbbb995128e793ebebcbf1d3b7514e0e5e8b221"
integrity sha512-obm3SjgCk8A7nB37b2AU1eq1q7gMoJRrGMv9VRIyfcG0Wlz/5lJ9O3ohUk+YZaaVfZMxXn6hFtsBiOWmlv7IIA==
dependencies:
"@sentry/hub" "6.13.3"
"@sentry/minimal" "6.13.3"
"@sentry/types" "6.13.3"
"@sentry/utils" "6.13.3"
tslib "^1.9.3"

"@sentry/[email protected]":
version "6.13.3"
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.13.3.tgz#cc09623a69b5343315fdb61c7fdd0be74b72299f"
integrity sha512-eYppBVqvhs5cvm33snW2sxfcw6G20/74RbBn+E4WDo15hozis89kU7ZCJDOPkXuag3v1h9igns/kM6PNBb41dw==
dependencies:
"@sentry/types" "6.13.3"
"@sentry/utils" "6.13.3"
tslib "^1.9.3"

"@sentry/[email protected]":
version "6.13.3"
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.13.3.tgz#a675a79bcc830142e4f95e6198a2efde2cd3901e"
integrity sha512-63MlYYRni3fs5Bh8XBAfVZ+ctDdWg0fapSTP1ydIC37fKvbE+5zhyUqwrEKBIiclEApg1VKX7bkKxVdu/vsFdw==
dependencies:
"@sentry/hub" "6.13.3"
"@sentry/types" "6.13.3"
tslib "^1.9.3"

"@sentry/react@^6.13.3":
version "6.13.3"
resolved "https://registry.yarnpkg.com/@sentry/react/-/react-6.13.3.tgz#f9607e0a60d52efd0baa96a14e694b6059f9379a"
integrity sha512-fdfmD9XNpGDwdkeLyd+iq+kqtNeghpH3wiez2rD81ZBvrn70uKaO2/yYDE71AXC6fUOwQuJmdfAuqBcNJkYIEw==
dependencies:
"@sentry/browser" "6.13.3"
"@sentry/minimal" "6.13.3"
"@sentry/types" "6.13.3"
"@sentry/utils" "6.13.3"
hoist-non-react-statics "^3.3.2"
tslib "^1.9.3"

"@sentry/tracing@^6.13.3":
version "6.13.3"
resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.13.3.tgz#ca657d4afa99c50f15e638fe38405bac33e780ee"
integrity sha512-yyOFIhqlprPM0g4f35Icear3eZk2mwyYcGEzljJfY2iU6pJwj1lzia5PfSwiCW7jFGMmlBJNhOAIpfhlliZi8Q==
dependencies:
"@sentry/hub" "6.13.3"
"@sentry/minimal" "6.13.3"
"@sentry/types" "6.13.3"
"@sentry/utils" "6.13.3"
tslib "^1.9.3"

"@sentry/[email protected]":
version "6.13.3"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.13.3.tgz#63ad5b6735b0dfd90b3a256a9f8e77b93f0f66b2"
integrity sha512-Vrz5CdhaTRSvCQjSyIFIaV9PodjAVFkzJkTRxyY7P77RcegMsRSsG1yzlvCtA99zG9+e6MfoJOgbOCwuZids5A==

"@sentry/[email protected]":
version "6.13.3"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.13.3.tgz#188754d40afe693c3fcae410f9322531588a9926"
integrity sha512-zYFuFH3MaYtBZTeJ4Yajg7pDf0pM3MWs3+9k5my9Fd+eqNcl7dYQYJbT9gyC0HXK1QI4CAMNNlHNl4YXhF91ag==
dependencies:
"@sentry/types" "6.13.3"
tslib "^1.9.3"

"@sheerun/mutationobserver-shim@^0.3.2":
version "0.3.2"
resolved "https://registry.yarnpkg.com/@sheerun/mutationobserver-shim/-/mutationobserver-shim-0.3.2.tgz#8013f2af54a2b7d735f71560ff360d3a8176a87b"
Expand Down Expand Up @@ -10935,7 +11010,7 @@ ts-pnp@^1.1.6:
resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92"
integrity sha512-csd+vJOb/gkzvcCHgTGSChYpy5f1/XKNsmvBGO4JXS+z1v2HobugDz4s1IeFXM3wZB44uczs+eazB5Q/ccdhQw==

tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0:
tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
version "1.14.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
integrity "sha1-zy04vcNKE0vK8QkcQfZhni9nLQA= sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
Expand Down