|
1 | | -# The JavaScript client for Flare to catch frontend errors |
| 1 | +# Flare JavaScript Client |
2 | 2 |
|
3 | | -Read the JavaScript error tracking section in [the Flare documentation](https://flareapp.io/docs/javascript-error-tracking/installation) for more information. |
| 3 | +The official JavaScript/TypeScript client for [Flare](https://flareapp.io) error tracking |
| 4 | +by [Spatie](https://spatie.be). Captures frontend errors, collects browser context (cookies, request data, query |
| 5 | +params), and reports them to the Flare backend. Includes framework integrations for React and Vue, and a Vite plugin for |
| 6 | +sourcemap uploads. |
4 | 7 |
|
5 | | -## Maintenance |
| 8 | +Read the JavaScript error tracking section |
| 9 | +in [the Flare documentation](https://flareapp.io/docs/javascript-error-tracking/installation) for more information. |
6 | 10 |
|
7 | | -There are a few commands that can be run from the root of this repository to execute on all packages at once. |
| 11 | +## Packages |
8 | 12 |
|
9 | | -| Command | Description | |
10 | | -|--------------|-------------------------------------------------------| |
11 | | -| `build` | Build all packages to their respective `dist` folders | |
12 | | -| `test` | Run tests for all packages that have them | |
13 | | -| `typescript` | Check types for all packages that have them | |
14 | | -| `format` | Run Prettier across all packages | |
| 13 | +This is a npm workspaces monorepo containing the following packages: |
15 | 14 |
|
16 | | -## Publishing |
| 15 | +| Package | npm | Description | |
| 16 | +|------------------------------------|--------------------------------------------------------------------|------------------------------------------------------------------------------------| |
| 17 | +| [`packages/js`](packages/js) | [`@flareapp/js`](https://www.npmjs.com/package/@flareapp/js) | Core client for error capture, stack traces, context collection, and API reporting | |
| 18 | +| [`packages/react`](packages/react) | [`@flareapp/react`](https://www.npmjs.com/package/@flareapp/react) | React error boundary component and React 19 error handler | |
| 19 | +| [`packages/vue`](packages/vue) | [`@flareapp/vue`](https://www.npmjs.com/package/@flareapp/vue) | Vue error handler plugin | |
| 20 | +| [`packages/vite`](packages/vite) | [`@flareapp/vite`](https://www.npmjs.com/package/@flareapp/vite) | Vite build plugin for sourcemap uploads | |
| 21 | +| [`playground`](playground) | (private) | Local dev/test app for all integrations | |
17 | 22 |
|
18 | | -To publish a new package version: |
| 23 | +## Local development |
19 | 24 |
|
20 | | -- Update the version number in the package's `package.json` `version` field |
21 | | -- Run `npm publish` from the package directory |
| 25 | +### Prerequisites |
| 26 | + |
| 27 | +- Node.js >= 18 (see `.node-version` for the exact version used in development) |
| 28 | +- npm (comes with Node.js) |
| 29 | + |
| 30 | +### Setup |
| 31 | + |
| 32 | +```bash |
| 33 | +# Clone the repo |
| 34 | +git clone https://github.com/spatie/flare-client-js.git |
| 35 | +cd flare-client-js |
| 36 | + |
| 37 | +# Install all dependencies (root + all workspaces) |
| 38 | +npm install |
| 39 | + |
| 40 | +# Build all packages |
| 41 | +npm run build |
| 42 | +``` |
| 43 | + |
| 44 | +### Commands |
| 45 | + |
| 46 | +All commands are run from the repository root: |
| 47 | + |
| 48 | +| Command | Description | |
| 49 | +|----------------------|-------------------------------------------------------| |
| 50 | +| `npm run build` | Build all packages to their respective `dist` folders | |
| 51 | +| `npm run test` | Run tests for all packages that have them | |
| 52 | +| `npm run typescript` | Type-check all packages | |
| 53 | +| `npm run format` | Run Prettier across all files | |
| 54 | +| `npm run playground` | Build packages, then start the playground dev server | |
| 55 | + |
| 56 | +### Playground |
| 57 | + |
| 58 | +The playground is a local Vite dev app for manually testing all integrations. Each page has |
| 59 | +buttons that trigger different error types. |
| 60 | + |
| 61 | +```bash |
| 62 | +# Copy the env file and add your Flare API keys |
| 63 | +cp playground/.env.example playground/.env.local |
| 64 | + |
| 65 | +# Start the playground |
| 66 | +npm run playground |
| 67 | +``` |
| 68 | + |
| 69 | +See the [playground README](playground/README.md) for more details. |
| 70 | + |
| 71 | +### Code style |
| 72 | + |
| 73 | +Formatting is handled by Prettier. A pre-commit hook (Husky + lint-staged) automatically formats staged files on commit. |
| 74 | + |
| 75 | +To manually format all files: |
| 76 | + |
| 77 | +```bash |
| 78 | +npm run format |
| 79 | +``` |
| 80 | + |
| 81 | +See `.prettierrc` for the full configuration. |
| 82 | + |
| 83 | +### CI |
| 84 | + |
| 85 | +GitHub Actions runs on every push: |
| 86 | + |
| 87 | +- **Test**: installs dependencies, builds all packages, runs all tests |
| 88 | +- **TypeScript**: installs dependencies, builds all packages, type-checks all packages |
| 89 | + |
| 90 | +## Versioning and releasing |
| 91 | + |
| 92 | +Each package is versioned and published independently. |
| 93 | + |
| 94 | +### Bumping a version |
| 95 | + |
| 96 | +1. Update the `version` field in the package's `package.json` |
| 97 | +2. Commit the version bump |
| 98 | +3. Tag the commit using the format `<package-name>@<version>` (e.g. `@flareapp/js@1.2.0`) |
| 99 | +4. Push the commit and tag |
| 100 | + |
| 101 | +```bash |
| 102 | +# Example: releasing @flareapp/js v1.2.0 |
| 103 | +cd packages/js |
| 104 | +# Update version in package.json to 1.2.0, then: |
| 105 | +cd ../.. |
| 106 | +git add packages/js/package.json |
| 107 | +git commit -m "Release @flareapp/js v1.2.0" |
| 108 | +git tag @flareapp/js@1.2.0 |
| 109 | +git push origin main --tags |
| 110 | +``` |
| 111 | + |
| 112 | +### Publishing to npm |
| 113 | + |
| 114 | +Run `npm publish` from the individual package directory. The `prepublishOnly` script in each package automatically runs |
| 115 | +a build before publishing. |
| 116 | + |
| 117 | +```bash |
| 118 | +cd packages/js |
| 119 | +npm publish |
| 120 | +``` |
| 121 | + |
| 122 | +All packages have `"publishConfig": { "access": "public" }` so they are published as public scoped packages. |
| 123 | + |
| 124 | +### Publishing multiple packages |
| 125 | + |
| 126 | +When releasing changes that span multiple packages, publish them in dependency order: |
| 127 | + |
| 128 | +1. `@flareapp/js` (core, no internal dependencies) |
| 129 | +2. `@flareapp/vite` (no internal dependencies) |
| 130 | +3. `@flareapp/react` (depends on `@flareapp/js`) |
| 131 | +4. `@flareapp/vue` (depends on `@flareapp/js`) |
| 132 | + |
| 133 | +## Project structure |
| 134 | + |
| 135 | +``` |
| 136 | +flare-client-js/ |
| 137 | +├── packages/ |
| 138 | +│ ├── js/ # Core client |
| 139 | +│ ├── react/ # React integration |
| 140 | +│ ├── vue/ # Vue integration |
| 141 | +│ └── vite/ # Vite sourcemap plugin |
| 142 | +├── playground/ # Local dev/test app |
| 143 | +├── .github/ # GitHub Actions workflows |
| 144 | +├── .husky/ # Git hooks (pre-commit formatting) |
| 145 | +└── package.json # Root workspace config |
| 146 | +``` |
22 | 147 |
|
23 | 148 | ## License |
24 | 149 |
|
|
0 commit comments