Skip to content

Commit

Permalink
Support for custom systems (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
kgpax authored Sep 29, 2023
1 parent 6ace5ea commit 1b441c9
Show file tree
Hide file tree
Showing 32 changed files with 506 additions and 99 deletions.
5 changes: 5 additions & 0 deletions .changeset/sour-trees-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@envyjs/webui': minor
---

Added support for self-hosting and customization of the Envy viewer
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ bin
# examples/next.js
**/.next/
**/next-env.d.ts

# other
.DS_Store
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ Envy will trace the network calls from every application in your stack and allow
_Note: Envy is intended for development usage only, and is not a replacement for optimized production telemetry_

<div align="center">
<img alt="Envy" src="https://raw.githubusercontent.com/FormidableLabs/envy/main//envy-example.png" />
<img alt="Envy" src="https://raw.githubusercontent.com/FormidableLabs/envy/main/envy-example.png" />
</div>

## Contents

- [Getting Started](#getting-started)
- [Customizing](#customizing)
- [Production Bundles](#production-bundles)
- [Contributing](#contributing)

Expand Down Expand Up @@ -125,11 +126,17 @@ enableTracing({ serviceName: 'your-website-name' }).then(() => {

_Browsers prevent full timing data from being accessed from cross-origin requests unless the server responds with the [Timing-Allow-Origin](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Timing-Allow-Origin) header_.

### Production Bundles
## Customizing

Whilst Envy will run as a zero-config standalone viewer, it is also possible to run the Envy viewer locally from your application and to define your own systems to customize how traces are presented.

See the [customization docs](docs/customizing.md) for more information.

## Production Bundles

Envy is designed to enhance your developer experience and is not intended for production usage. Depending on your application, there are various ways to exclude it from your bundle in production.

#### Dynamic Imports (Typescript)
### Dynamic Imports (Typescript)

```ts
if (process.env.NODE_ENV !== 'production') {
Expand All @@ -139,7 +146,7 @@ if (process.env.NODE_ENV !== 'production') {
}
```

#### Dynamic Require (Javascript)
### Dynamic Require (Javascript)

```ts
if (process.env.NODE_ENV !== 'production') {
Expand All @@ -148,7 +155,7 @@ if (process.env.NODE_ENV !== 'production') {
}
```

#### Disabling Tracing
### Disabling Tracing

This option is the simplest, but will leave the code in your output bundle. Depending on your application and its deployment and packaging method, this may be acceptable in your usage.

Expand Down
107 changes: 107 additions & 0 deletions docs/customizing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Customizing Envy

## Creating your own systems

A system is a `class` which defines the following:

- What identifies the trace as belonging to the system, e.g., the hostname, path, etc.
- What icon to display for the system
- What data to show in the list view for the trace
- What data to show in the detail for the trace

**Let's start by example:**

In the application you are sending traces from, you can create a new `class` like the following:

```tsx
// ./src/systems/CatFactsSystem.tsx

import { System, Trace } from '@envyjs/webui';

export default class CatFactsSystem implements System<null> {
name = 'Cat Facts API';

isMatch(trace: Trace) {
// this system applies to all traces which are requests to the `cat-fact.herokuapp.com` host
return trace.http?.host === 'cat-fact.herokuapp.com';
}

getIconUri() {
// to avoid the need for external resources, icons can be defined as base64 data
return '<base64_image_data>';
}

getTraceRowData() {
// this is the text which will be displayed below the host and path in the list view
return {
data: 'This is a cat fact',
};
}
}
```

Once you have that system, we need to register it with the Envy viewer. The only way to do this currently is to host the envy viewer yourself as a react component, and pass the systems to register in the props.

For example:

```tsx
// ./src/MyEnvyViewer.tsx

import EnvyViewer from '@envyjs/webui';
import { createRoot } from 'react-dom/client';

import CatFactsSystem from './systems/CatFactsSystem';

function MyEnvyViewer() {
return <EnvyViewer systems={[new CatFactsSystem()]} />;
}
```

Then, you would serve this component up either on a new route in your application, or as a separate application. For example, using parcel you might have the following:

```tsx
// src/myEnvyViewer.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>My custome Envy viewer</title>
</head>
<body>
<main id="root"></main>
<script type="module" src="myEnvyViewer.js"></script>
</body>
</html>


// src/myEnvyViewer.js
import EnvyViewer from '@envyjs/webui';
import { createRoot } from 'react-dom/client';

import MyEnvyViewer from './MyEnvyViewer';

const container = document.getElementById('root');
const root = createRoot(container);

root.render(<MyEnvyViewer />);
```

Finally, in your `package.json`, you would have to start the `@envyjs/webui` collector, opting out of launching the default viewer UI, and load your UI instead:

```
// package.json
{
"scripts": {
"start:envy": "concurrently \"yarn start:collector\" \"yarn start:viewer\"",
"start:collector": "npx @envyjs/webui --noUi",
"start:viewer": "parcel ./src/myEnvyViewer.html --port 4002 --no-cache"
}
}
```

Then, running `yarn start:envy` in your application would start the collector process and launch your customized viewer:

<div align="center">
<img alt="An example of a custom system defining the presentation of a trace" src="../envy-custom-system.png" />
</div>
Binary file added envy-custom-system.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion examples/apollo-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
"license": "MIT",
"private": true,
"scripts": {
"start": "parcel ./src/index.html --port 4001 --no-cache"
"start": "yarn start:web",
"start:custom-viewer": "concurrently \"yarn start:envy\" \"yarn start:web\" \"yarn start:viewer\"",
"start:web": "parcel ./src/index.html --port 4001 --no-cache",
"start:envy": "npx @envyjs/webui --noUi",
"start:viewer": "parcel ./src/viewer/viewer.html --port 4002 --no-cache"
},
"dependencies": {
"@envyjs/web": "*",
"@envyjs/webui": "*",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"urql": "^4.0.5"
Expand Down
2 changes: 1 addition & 1 deletion examples/apollo-client/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<link href="index.css" rel="stylesheet" />
</head>
<body>
<main id="app" className="bg-red-500"></main>
<main id="app"></main>
<script type="module" src="index.js"></script>
</body>
</html>
19 changes: 19 additions & 0 deletions examples/apollo-client/src/viewer/systems/CatFacts.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { System, Trace } from '@envyjs/webui';

export default class CatFactsSystem implements System<null> {
name = 'Cat Facts API';

isMatch(trace: Trace) {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i4zMTI5LTU2Ljg3NS00Ni43MjU4LDExLjg5ODgtMjQuNDEyOCwzMi41NDc2LTQyLDU2Ljg3NS00Ni43MjQ3Wm0yNi4yNSwwVjIzNy4zOTg4YzI0LjIzNzcsNC43MjQzLDQ0Ljk3NjIsMjIuMzExOSw1Ni44NzUsNDYuNzI0N0M0MTAuMzUxMiwzMDguNTM2NCwzODkuNjEyNywzMjYuMTIzOSwzNjUuMzc1LDMzMC44NDkzWiIvPjwvZz48L3N2Zz4=';
}

getTraceRowData() {
return {
data: 'Cat fact',
};
}
}
32 changes: 32 additions & 0 deletions examples/apollo-client/src/viewer/systems/CocktailDb.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { System, Trace } from '@envyjs/webui';

type CocktailDbData = {
name: string;
};

export default class CocktailDbSystem implements System<CocktailDbData> {
name = 'Cocktail Database';

isMatch(trace: Trace) {
return trace.http?.host === 'www.thecocktaildb.com';
}

getData(trace: Trace) {
const data = trace.http?.responseBody ? JSON.parse(trace.http?.responseBody) : null;

return {
name: data?.drinks[0].strDrink ?? '',
};
}

getIconUri() {
return 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHNoYXBlLXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiB0ZXh0LXJlbmRlcmluZz0iZ2VvbWV0cmljUHJlY2lzaW9uIiBpbWFnZS1yZW5kZXJpbmc9Im9wdGltaXplUXVhbGl0eSIgZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIHZpZXdCb3g9IjAgMCA1MDUgNTEyLjQ0Ij48cGF0aCBmaWxsPSIjRkRDNDU0IiBkPSJNNDU5LjIzNSAxNDUuNDQ1YzIwLjU3NCA4MS45NDggMTcuMDU0IDE1OS43MjItNTAuMTI0IDE4MS41ODctMzcuNTcyIDEyLjE0OS02Ny45NzkgNy43MDItOTEuNjI5LTEyLjM4OS0zM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LS4xNDJjNDQuNDU2LTE0LjQ2OCA1OC43MjYtNDYuNjM2IDU1LjYzMS05MC44NzQtMy4zMjctNDcuNTg2LTI1LjkwNi0xMDkuMDExLTUzLjQ3My0xNzcuNTg3LTEyLjQzMS0zMC45MjYtMTIuNTM4LTMwLjkwOS0zNS42NDEtMjUuOTQ0LTQuMjU0LjkxMi05LjA4MyAxLjk1My0xMy45NDcgMi45MTFMMjgxLjY5IDQxLjQ0N2MtMy44NTggMS4wODItNi43NDggMi43OTktOC43MjIgNS4wOTN6Ii8+PC9zdmc+';
}

getTraceRowData(trace: Trace) {
const data = this.getData(trace);
return {
data: data.name,
};
}
}
11 changes: 11 additions & 0 deletions examples/apollo-client/src/viewer/viewer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Envy - Custom viewer</title>
</head>
<body>
<main id="root"></main>
<script type="module" src="viewer.js"></script>
</body>
</html>
10 changes: 10 additions & 0 deletions examples/apollo-client/src/viewer/viewer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import EnvyViewer from '@envyjs/webui';
import { createRoot } from 'react-dom/client';

import CatFactsSystem from './systems/CatFacts';
import CocktailDbSystem from './systems/CocktailDb';

const container = document.getElementById('root');
const root = createRoot(container);

root.render(<EnvyViewer systems={[new CatFactsSystem(), new CocktailDbSystem()]} />);
18 changes: 0 additions & 18 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
export default {
preset: 'ts-jest',
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
diagnostics: {
ignoreCodes: [1343],
},
astTransformers: {
before: [
{
path: 'ts-jest-mock-import-meta',
options: { metaObjectReplacement: { url: 'https://www.url.com/' } },
},
],
},
},
],
},
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/src/**/?(*.)+(spec|test).[jt]s?(x)'],
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"build": "turbo run build",
"lint": "turbo run lint",
"test": "turbo run test",
"example:apollo": "concurrently \"cd examples/apollo && yarn start\" \"wait-on tcp:4000 && (cd examples/apollo-client && yarn start)\"",
"example:express": "concurrently \"cd examples/express && yarn start\" \"wait-on tcp:4000 && (cd examples/express-client && yarn dev)\"",
"example:apollo": "concurrently \"cd examples/apollo && yarn start\" \"cd examples/apollo-client && yarn start:custom-viewer\"",
"example:express": "concurrently \"cd examples/express && yarn start\" \"cd examples/express-client && yarn dev\"",
"example:next": "cd examples/next && yarn && yarn dev",
"changeset": "changeset"
},
Expand Down
23 changes: 17 additions & 6 deletions packages/webui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@
"name": "@envyjs/webui",
"version": "0.3.2",
"description": "Envy Web UI",
"source": [
"src/index.html"
],
"targets": {
"main": false,
"viewer": {
"source": "src/index.html",
"distDir": "dist"
}
},
"main": "dist/integration.cjs.js",
"module": "dist/integration.esm.js",
"types": "dist/integration.d.ts",
"bin": {
"envy": "bin/start.cjs"
},
Expand All @@ -25,9 +32,11 @@
"test:watch": "jest --watch --coverage",
"test:coverage": "jest --coverage && open ./coverage/lcov-report/index.html",
"prebuild": "rimraf dist && rimraf bin",
"build": "yarn build:parcel && yarn build:scripts",
"build:parcel": "cross-env NODE_ENV=production parcel build --no-cache",
"build:scripts": "copyfiles --flat ./src/scripts/start.cjs ./src/scripts/startCollector.cjs ./src/scripts/startViewer.cjs ./bin",
"build": "yarn build:app && yarn build:integration && yarn build:typedefs && yarn build:bin",
"build:app": "cross-env NODE_ENV=production parcel build --no-cache",
"build:integration": "tailwindcss -i ./src/styles/base.css -o ./dist/viewer.css && node ./src/scripts/buildIntegration.cjs",
"build:typedefs": "tsc --project ./tsconfig.types.json",
"build:bin": "copyfiles --flat ./src/scripts/start.cjs ./src/scripts/startCollector.cjs ./src/scripts/startViewer.cjs ./bin",
"lint": "tsc --noEmit && eslint ./src --ext .ts,.tsx"
},
"dependencies": {
Expand Down Expand Up @@ -59,6 +68,8 @@
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
"crypto-browserify": "^3.12.0",
"esbuild": "^0.19.3",
"esbuild-plugin-inline-import": "^1.0.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"events": "^3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/webui/src/components/ui/FiltersAndActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function FiltersAndActions() {
label="Systems:"
multiSelect
items={systems.map(x => ({
icon: x.getIconPath?.(null) ?? defaultSystem.getIconPath(),
icon: x.getIconUri?.(null) ?? defaultSystem.getIconUri(),
value: x.name,
}))}
onChange={handleSystemsChange}
Expand Down
12 changes: 6 additions & 6 deletions packages/webui/src/components/ui/TraceDetail.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { act, cleanup, render, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {
SystemRequestDetailsComponent,
SystemResponseDetailsComponent,
getIconPath,
RequestDetailsComponent,
ResponseDetailsComponent,
getIconUri,
getRequestBody,
getResponseBody,
} from '@/systems';
Expand Down Expand Up @@ -88,15 +88,15 @@ describe('TraceDetail', () => {
clearSelectedTraceFn = jest.fn();

// having to do this here, like this, so that we can override some of the mock return values later
jest.mocked(SystemRequestDetailsComponent).mockImplementation(({ trace, ...props }: any) => {
jest.mocked(RequestDetailsComponent).mockImplementation(({ trace, ...props }: any) => {
return <div {...props}>Mock SystemRequestDetailsComponent component: {trace.id}</div>;
});
jest.mocked(SystemResponseDetailsComponent).mockImplementation(({ trace, ...props }: any) => {
jest.mocked(ResponseDetailsComponent).mockImplementation(({ trace, ...props }: any) => {
return <div {...props}>Mock SystemResponseDetailsComponent component: {trace.id}</div>;
});
jest.mocked(getRequestBody).mockReturnValue('mock_request_body');
jest.mocked(getResponseBody).mockReturnValue('mock_response_body');
jest.mocked(getIconPath).mockReturnValue('mock_icon.jpg');
jest.mocked(getIconUri).mockReturnValue('mock_icon.jpg');

setUseApplicationData({
getSelectedTrace: getSelectedTraceFn as () => Trace,
Expand Down
Loading

0 comments on commit 1b441c9

Please sign in to comment.