Skip to content

Commit 4431ae8

Browse files
committed
Release 1.2.0
1 parent 678dbba commit 4431ae8

File tree

8 files changed

+65
-149
lines changed

8 files changed

+65
-149
lines changed

README.md

Lines changed: 19 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -6,108 +6,39 @@ Debug FeathersJS API requests, find bottlenecks, read payloads and understand ho
66
77
![sample image](https://raw.githubusercontent.com/radenkovic/feathers-debugger/master/docs/sample.gif)
88

9+
## Features
910

10-
## Usage
11-
12-
> This plugin is still in active development.
13-
14-
15-
1. Install chrome extension
16-
17-
2. Add hook
18-
19-
Note: this will be npm package. For now you can install it manually.
20-
21-
Extension is pending Google review (on Google Store), until then you can download it from [releases](https://github.com/radenkovic/feathers-debugger/releases).
22-
23-
24-
25-
Create hook that will write file `feathers-debugger` to public folder.
26-
27-
```js
28-
// feathers-debugger.js
29-
const fs = require('fs');
30-
const path = require('path');
31-
32-
const PUBLIC_PATH = 'public';
11+
- Waterfall chart
12+
- Track request duration
13+
- Find API bottlenecks
14+
- Visualize Queries
15+
- Inspect Query params and errors (coming soon!)
3316

34-
// Remove file on every server start
35-
try {
36-
const stats = fs.statSync(path.join(PUBLIC_PATH, '/feathers-debugger'));
37-
if (stats['size'] > 2000000) {
38-
// Delete file if it's too large
39-
fs.unlinkSync(path.join(PUBLIC_PATH, '/feathers-debugger'));
40-
}
41-
} catch (e) {
42-
// NO_OP
43-
}
4417

45-
// Stream to write file
46-
const writer = fs.createWriteStream(
47-
path.join(PUBLIC_PATH, '/feathers-debugger'),
48-
{ flags: 'a' }
49-
);
50-
51-
module.exports = () => (ctx) => {
52-
if (!ctx._req_ts) {
53-
ctx._req_ts = Date.now();
54-
} else {
55-
ctx._req_duration = Date.now() - ctx._req_ts;
56-
}
57-
const payload = {
58-
id: ctx._req_id,
59-
path: ctx.path,
60-
type: ctx.type,
61-
method: ctx.method,
62-
provider: ctx.params ? ctx.params.provider : undefined,
63-
ts: ctx._req_ts,
64-
duration: ctx._req_duration,
65-
end: Date.now(),
66-
};
67-
if (payload.duration) {
68-
writer.write(JSON.stringify(payload) + '\n');
69-
}
70-
};
71-
72-
73-
```
74-
75-
3. Include that hook in `app.hooks.js`:
76-
77-
```js
78-
// app.hooks
79-
const feathersDebugger = require('./feathers-debugger')
80-
81-
module.exports = {
82-
before: {
83-
all: [
84-
feathersDebugger(),
85-
],
86-
// ....
87-
finally: {
88-
all: [
89-
feathersDebugger()
90-
]
91-
}
92-
```
93-
94-
4. (optional) gitignore `public/feathers-debugger`
95-
96-
5. Open devtools and click "Feathers" tab
97-
98-
Happy debugging!
18+
## Usage
9919

20+
1. Install chrome extension from [Chrome Web Store](https://chrome.google.com/webstore/detail/feathers-debugger/nmpoglofdnlpdkpdnjadngpjcocoffie)
10021

22+
2. Add [Feathers Debugger Service](https://www.npmjs.com/package/feathers-debugger-service) and configure it as explained [here](https://github.com/radenkovic/feathers-debugger-service).
10123

24+
3. Open Chrome devtools, and you will see Feathers tab on the right.
10225

26+
4. Happy Debugging!
10327

10428

10529
## Development
10630

31+
Contributions are welcome!
32+
10733
- git clone https://github.com/radenkovic/feathers-debugger
10834
- yarn
10935
- yarn dev
11036
- open [localhost:3000/devtools.html](http://localhost:3000/devtools.html)
11137

112-
38+
## Deployment
39+
- Bump version in package.json
40+
- Bump version in manifest.json
41+
- yarn build
42+
- Create github release
43+
- Upload to Chrome Store
11344

package.json

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
{
22
"name": "feathers-debugger",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"description": "FeathersJS Debugger Chrome Extension",
55
"main": "src/index.html",
66
"scripts": {
77
"dev": "parcel src/devtools.html --out-dir build/output --cache-dir build/cache src/popup.html --port 3000",
88
"build": "export NODE_ENV=production && parcel --cache-dir build/cache --no-source-maps build src/devtools.html src/popup.html"
99
},
10-
"keywords": ["feathers", "feathersjs", "feathers-debugger", "chrome", "extension"],
10+
"keywords": [
11+
"feathers",
12+
"feathersjs",
13+
"feathers-debugger",
14+
"chrome",
15+
"extension"
16+
],
1117
"author": "Dan Radenkovic",
1218
"license": "MIT",
1319
"repository": {
14-
"type" : "git",
15-
"url" : "https://github.com/radenkovic/feathers-debugger.git"
20+
"type": "git",
21+
"url": "https://github.com/radenkovic/feathers-debugger.git"
1622
},
1723
"bugs": {
18-
"url" : "https://github.com/radenkovic/feathers-debugger/issues",
19-
"email" : "dan@radenkovic.org"
24+
"url": "https://github.com/radenkovic/feathers-debugger/issues",
25+
"email": "dan@radenkovic.org"
2026
},
2127
"dependencies": {
22-
"lodash": "^4.17.20",
28+
"ms": "^2.1.2",
2329
"react": "^16.13.1",
2430
"react-dom": "^16.13.1",
2531
"react-tooltip": "^4.2.8",

src/components/Waterfall/Error.jsx

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/components/Waterfall/NoData.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,22 @@ export default function NoData({ error, port }) {
2929
</>
3030
)}
3131
<h1>{error ? 'Error' : 'No Data'}</h1>
32-
{error && (
32+
{error === 'Failed to fetch' && (
3333
<p>
3434
Feathers debugger <strong>not found</strong> on{' '}
3535
<a href={`http://localhost:${port}/feathers-debugger`}>
3636
http://localhost:{port}/feathers-debugger
3737
</a>
3838
</p>
3939
)}
40+
{error === 'version-not-supported' && (
41+
<p>
42+
<strong>Feathers Debugger extension is outdated.</strong>
43+
<br />
44+
Please update Feathers debugger extension and feathers debugger
45+
service.
46+
</p>
47+
)}
4048
<p>
4149
Make sure you installed Feathers Debugger hook in{' '}
4250
<code>app.hooks</code>.

src/components/Waterfall/Waterfall.jsx

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import React, { useEffect, useState } from 'react';
22
import styled, { css } from 'styled-components';
33
import ReactTooltip from 'react-tooltip';
4-
import sortBy from 'lodash/fp/sortBy';
5-
import compose from 'lodash/fp/compose';
6-
import filter from 'lodash/fp/filter';
7-
import get from 'lodash/get';
8-
4+
import packageJson from '../../../package.json';
95
import WaterfallItem from './WaterfallItem';
106
import NoData from './NoData';
117

@@ -162,43 +158,36 @@ export default function Waterfall() {
162158
);
163159
const [autoZoom, setAutozoom] = useState(true);
164160
const [tail, setTail] = useState(!!localStorage.getItem('tail') || false);
165-
const [startTs, setStartTs] = useState(0);
166161

167162
const toggleTail = val => {
168163
clearInterval(interval);
169164
if (val) setAutozoom(true);
170165
setTail(val);
171166
};
172167

173-
const fetchData = () =>
174-
fetch(`http://localhost:${port}/feathers-debugger`)
175-
.then(res => res.text())
168+
const fetchData = () => {
169+
const gt = Date.now() - timeframe * 1000 * 60; // timeframe from seconds to ms
170+
return fetch(
171+
`http://localhost:${port}/feathers-debugger?$sort[ts]=1&$limit=500&ts[$gt]=${gt}&$version=${packageJson.version}`
172+
)
173+
.then(res => res.json())
176174
.then(res => {
175+
if (res.message) throw new Error(res.message);
177176
setFetchError(false);
178-
const ARR = [];
179-
res.split('\n').forEach(item => {
180-
if (!item) return;
181-
ARR.push(JSON.parse(item));
182-
});
183-
setItems(ARR);
177+
setItems(res.data);
184178
})
185-
.catch(() => {
186-
setFetchError(true);
179+
.catch(e => {
180+
setFetchError(e.message);
187181
});
182+
};
188183

189184
useEffect(() => {
190185
fetchData();
191186
}, [timeframe]);
192187

193-
const data = compose(
194-
sortBy('ts'),
195-
filter(item => {
196-
if (startTs >= item.ts) return false;
197-
return item.ts > Date.now() - 1000 * 60 * timeframe;
198-
})
199-
)(items);
188+
const data = items;
200189

201-
const start = get(data[0], 'ts', 0);
190+
const start = data.length ? data[0].ts : 0;
202191

203192
useEffect(() => {
204193
if (!items.length) return;
@@ -245,10 +234,12 @@ export default function Waterfall() {
245234
};
246235

247236
// Filters
248-
249237
const clear = () => () => {
250-
if (!data.length) return null;
251-
return setStartTs(data[data.length - 1].ts); // to last item
238+
fetch(`http://localhost:${port}/feathers-debugger`, {
239+
method: 'delete',
240+
}).then(() => {
241+
setItems([]);
242+
});
252243
};
253244

254245
const toggleCondensed = () => {

src/components/Waterfall/WaterfallItem.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import stc from 'string-to-color';
33
import styled from 'styled-components';
4+
import ms from 'ms';
45

56
const Root = styled.div`
67
padding: 4px 0;
@@ -98,7 +99,7 @@ export default function WaterfallItem({
9899
<Method method={item.method}>{item.method}</Method>
99100
{item.path}
100101
<Duration style={{ color }}>{item.duration}ms</Duration>
101-
{previousItem && <small>+{prevOffset}ms</small>}
102+
{previousItem && <small>+{ms(prevOffset)}</small>}
102103
</Item>
103104
</Root>
104105
);

static/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version":2,
33
"name":"Feathers Debugger",
44
"description":"Debug FeathersJS API requests, find bottlenecks, read payloads and understand how your API is queried.",
5-
"version":"1.1",
5+
"version":"1.2.0",
66
"browser_action":{
77
"default_icon":"logo.png",
88
"default_popup": "popup.html"

yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3996,7 +3996,7 @@ lodash.words@^4.2.0:
39963996
resolved "https://registry.yarnpkg.com/lodash.words/-/lodash.words-4.2.0.tgz#5ecfeaf8ecf8acaa8e0c8386295f1993c9cf4036"
39973997
integrity sha1-Xs/q+Oz4rKqODIOGKV8Zk8nPQDY=
39983998

3999-
lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.4:
3999+
lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.4:
40004000
version "4.17.20"
40014001
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
40024002
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
@@ -4178,7 +4178,7 @@ ms@2.1.1:
41784178
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a"
41794179
integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==
41804180

4181-
ms@^2.1.1:
4181+
ms@^2.1.1, ms@^2.1.2:
41824182
version "2.1.2"
41834183
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
41844184
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==

0 commit comments

Comments
 (0)