# medusa-plugin-stats

> A plugin to get store stastistics

Latest version **0.1.0** (published 2022-10-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install medusa-plugin-stats
pnpm add medusa-plugin-stats
yarn add medusa-plugin-stats
bun add medusa-plugin-stats
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2022-10-26 |
| First published | 2022-10-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 13.3 KB |
| Known vulnerabilities | 0 (+4 in 1 direct dependencies) |
| Install scripts | no |
| Author | Anup Aglawe |
| Maintainers | anup22 |
| Keywords | medusa, medusajs, starter, typescript, plugin, ecommerce, e-commerce |

## Links

- npm: https://www.npmjs.com/package/medusa-plugin-stats
- npm.io page: https://npm.io/package/medusa-plugin-stats

## Dependencies (5)

- [cors](https://npm.io/package/cors.md) ^2.8.5
- [typeorm](https://npm.io/package/typeorm.md) ^0.2.36
- [date-fns](https://npm.io/package/date-fns.md) ^2.29.3
- [@medusajs/medusa](https://npm.io/package/@medusajs/medusa.md) ^1.3.7
- [medusa-interfaces](https://npm.io/package/medusa-interfaces.md) ^1.3.3

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2022-10-26
- 0.0.9 — 2022-10-24
- 0.0.8 — 2022-10-24
- 0.0.7 — 2022-10-24
- 0.0.6 — 2022-10-24
- 0.0.5 — 2022-10-23
- 0.0.4 — 2022-10-23
- 0.0.3 — 2022-10-23
- 0.0.2 — 2022-10-23
- 0.0.1 — 2022-10-22

## README

## Medusa-plugin-stats

![banner image](./banner.png)

`medusa-plugin-stats` is MedusaJS plugin to retreive store statistics data.

⚠️ Note - Plugin only tested for Postgres DB, and under active development.

## Installation & Usage

1. Run - `yarn add medusa-plugin-stats` or `npm install medusa-plugin-stats`

2. Add plugin to your medusa-config.js - 

```js
plugins: [
  ...
  `medusa-plugin-stats`
  ]
```
3. GET `/admin/stats` with following params will return the statictics data

Query params -> 
```js
{
  entity:[ "sales", "products", "orders", "customers"],
  start: "02-24-2022" // start date in MM-dd-yyyy format,
  end: "11-24-2022" // end date in MM-dd-yyyy format,
  period: "day" // day | week | month | year
}
```

Response -> 
```json
{
    "stats": {
        "sales": {
            "timeseries": {
                "10-20-2022": 1000
            },
            "metrics": {
                "total": 1000
            },
            "period": "day"
        },
        "products": {
            "timeseries": {
                "10-22-2022": 7
            },
            "metrics": {
                "total": "7"
            },
            "period": "day"
        },
        "orders": {
            "timeseries": {
                "10-20-2022": 1,
                "10-22-2022": 1,
                "10-25-2022": 1
            },
            "metrics": {
                "total": "3"
            },
            "period": "day"
        }
    }
}
```

## Devlopment

- [x] Refactor API to allow options to each resource type

- [x] Add time series stats

- [ ] Add more stat metrics & dimensions. Required Suggestions

- [ ] Improve sales stat to allow multiple currencies

---
_Source: https://npm.io/package/medusa-plugin-stats · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
