-
Notifications
You must be signed in to change notification settings - Fork 50
Diagnostics app #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Diagnostics app #151
Changes from 9 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
0fa353c
Diagnostics app initial version.
rkistner b2b1586
Proper diagnostics page; use single sync storage.
rkistner 0590400
Dynamic schema.
rkistner be96a49
Fix type of Schema.tables.
rkistner 5224a23
Re-implement schema tracking.
rkistner 45026ff
Expand diagnostics and add schema generator.
rkistner f15d982
Merge remote-tracking branch 'origin/main' into diagnostics-app
rkistner 45c1d13
Add readme
benitav ca60edf
Apply suggestions from code review
benitav 17c6efa
Update demos/diagnostics-app/README.md
benitav 9fea989
Merge branch 'main' into diagnostics-app
benitav 5b3353c
Merge branch 'diagnostics-app' of github.com:powersync-ja/powersync-j…
benitav d9caa9d
Update pnpm-lock
benitav 84c2c58
Update readme
benitav 015f9fa
Merge branch 'main' into diagnostics-app
benitav cbccabd
Rename packages
benitav 26aa60a
Rename package
benitav 080fd10
Merge remote-tracking branch 'origin/main' into diagnostics-app
rkistner d434701
Readme tweaks.
rkistner ef707aa
Loading and error states for SQL Console.
rkistner 55fbee9
Loading state for main diagnostics page.
rkistner a975971
Track connection errors.
rkistner d37b684
Large layout redo.
rkistner fcde31f
Tweak icons.
rkistner 42ec594
Cleanup.
rkistner e61b3be
Add schema docs.
rkistner 500ac4b
Minor cleanup.
rkistner 575f7c0
Layout fixes.
rkistner 75e673d
Rename package.
rkistner c19246c
Use `useStatus()`.
rkistner 2f1e034
Add changeset.
rkistner 567429b
Move to tools/diagnostics-app
rkistner 1d59150
Add main Readme entry for diagnostics app
benitav 21801b9
Fix disconnectAndClear not clearing ps_untyped.
rkistner cb04453
Minor updates to readme.
rkistner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
.yarn/install-state.gz | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
# ide | ||
.idea | ||
.fleet | ||
.vscode | ||
|
||
# PWA | ||
**/public/workbox-*.js | ||
**/public/sw.js | ||
**/public/swe-worker-* | ||
**/public/worker-*.js | ||
**/public/fallback-*.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# diagnostics-app | ||
|
||
## 0.1.1 | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies [9bf5a76] | ||
- @journeyapps/powersync-react@1.1.0 | ||
- @journeyapps/powersync-sdk-web@0.3.3 | ||
|
||
## 0.0.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Diagnostics app | ||
|
||
This diagnostics app presents data from the perspective of a specific user (no server-side stats) and can be used to: | ||
- See stats about the user's local database. | ||
- Inspect tables and sync buckets on the device. | ||
- Identify common issues. | ||
- Get started quickly - play around with a SQLite database without creating an app. | ||
- Serve as a baseline to compare your own apps against if you run into issues such as slow sync. | ||
|
||
The app is currently available as a local standalone web app, and is largely based on the [web SDK](/packages/powersync-sdk-web/). | ||
|
||
## Running the app | ||
|
||
cd into this directory and run: | ||
``` | ||
pnpm install | ||
pnpm start | ||
``` | ||
|
||
Generate a [development token](https://docs.powersync.com/usage/installation/authentication-setup/development-tokens) and sign in. For development tokens, the PowerSync endpoint should be populated automatically. For some others like Supabase tokens, it needs to be entered manually. | ||
|
||
**Note**: Please see the known usability issues listed below. | ||
|
||
## Functionality | ||
|
||
### Database stats | ||
|
||
Details about the user's local database: | ||
|
||
 | ||
|
||
### Detected tables | ||
|
||
This only includes tables with synced data (tables with 0 synced rows won’t be present): | ||
|
||
 | ||
|
||
### Sync buckets | ||
|
||
 | ||
|
||
Similar to tables above, this only includes buckets with synced data. | ||
When syncing large amounts of data: | ||
- Total operations is calculated from the checkpoint, will be populated quickly. | ||
- Other stats are populated as the data is downloaded, so this may take a while. | ||
|
||
### Dynamic schema | ||
The schema is dynamically generated and automatically updated from downloaded data. The schema used is displayed in a separate page: | ||
|
||
 | ||
|
||
This does mean that if a table has 0 synced rows, it won’t be present in the schema, and queries referencing it will fail. | ||
|
||
Tables and columns are only added to this schema - nothing is automatically removed when removed from sync rules. To refresh the schema, use the “Clear & Redownload” button on the main page. | ||
|
||
### SQL console | ||
Same functionality as in the other demo apps: | ||
|
||
 | ||
|
||
## Known issues | ||
At this stage, we recommend running the app with the dev console open, as some errors are currently not being surfaced to the UI, including: | ||
* No errors are displayed when the token is invalid, or when it expires later. | ||
- The user is also “logged in” to the app with an invalid token after an initial delay | ||
* If the query in the SQL console contains an error, nothing is displayed. | ||
|
||
Other known issues: | ||
- When signed out, there is no automatic redirect to the login page. | ||
- When a lot of data is synced, the main dashboard may be slow. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "@journeyapps/powersync-diagnostics-app", | ||
rkistner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"version": "0.1.1", | ||
"private": true, | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc -b && vite build", | ||
"preview": "vite preview", | ||
"start": "pnpm build && pnpm preview" | ||
}, | ||
"dependencies": { | ||
"@journeyapps/powersync-react": "workspace:*", | ||
"@journeyapps/powersync-sdk-web": "workspace:*", | ||
"@journeyapps/wa-sqlite": "~0.1.1", | ||
"@mui/material": "^5.15.12", | ||
"@mui/x-data-grid": "^6.19.6", | ||
"js-logger": "^1.6.1", | ||
"lodash": "^4.17.21", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-router-dom": "^6.22.3" | ||
}, | ||
"devDependencies": { | ||
"@types/lodash": "^4.14.202", | ||
"@types/node": "^20.11.25", | ||
"@types/react": "^18.2.64", | ||
"@types/react-dom": "^18.2.21", | ||
"@vitejs/plugin-react": "^4.2.1", | ||
"autoprefixer": "^10.4.18", | ||
"babel-loader": "^9.1.3", | ||
"typescript": "^5.4.2", | ||
"vite": "^5.1.5", | ||
"vite-plugin-pwa": "^0.19.2", | ||
"vite-plugin-top-level-await": "^1.4.1", | ||
"vite-plugin-wasm": "^3.3.0" | ||
} | ||
} |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+35.8 KB
demos/diagnostics-app/public/images/diagnostics-app-detected-tables.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
:root { | ||
--foreground-rgb: 255, 255, 255; | ||
--background-start-rgb: 0, 0, 0; | ||
--background-end-rgb: 0, 0, 0; | ||
} | ||
|
||
body { | ||
color: rgb(var(--foreground-rgb)); | ||
min-height: 100vh; | ||
margin: 0; | ||
background: linear-gradient(to bottom, transparent, rgb(var(--background-end-rgb))) rgb(var(--background-start-rgb)); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { createRoot } from 'react-dom/client'; | ||
import { RouterProvider } from 'react-router-dom'; | ||
import { SystemProvider } from '../components/providers/SystemProvider'; | ||
import { ThemeProviderContainer } from '../components/providers/ThemeProviderContainer'; | ||
import { router } from './router'; | ||
|
||
const root = createRoot(document.getElementById('app')!); | ||
root.render(<App />); | ||
|
||
export function App() { | ||
return ( | ||
<ThemeProviderContainer> | ||
<SystemProvider> | ||
<RouterProvider router={router} /> | ||
</SystemProvider> | ||
</ThemeProviderContainer> | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import { LoginDetailsWidget } from '@/components/widgets/LoginDetailsWidget'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { DEFAULT_ENTRY_ROUTE } from '@/app/router'; | ||
import { connector } from '@/library/powersync/ConnectionManager'; | ||
|
||
export default function LoginPage() { | ||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<LoginDetailsWidget | ||
onSubmit={async (values) => { | ||
await connector.signIn(values); | ||
|
||
navigate(DEFAULT_ENTRY_ROUTE); | ||
}} | ||
/> | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from 'react'; | ||
import { CircularProgress, Grid, styled } from '@mui/material'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { DEFAULT_ENTRY_ROUTE, LOGIN_ROUTE } from './router'; | ||
import { connector } from '@/library/powersync/ConnectionManager'; | ||
|
||
export type LoginFormParams = { | ||
email: string; | ||
password: string; | ||
}; | ||
|
||
/** | ||
* This page shows a loading spinner we detect a session | ||
* and redirect either to the app or auth flow. | ||
*/ | ||
export default function EntryPage() { | ||
const navigate = useNavigate(); | ||
|
||
React.useEffect(() => { | ||
if (connector.hasCredentials()) { | ||
navigate(DEFAULT_ENTRY_ROUTE); | ||
} else { | ||
navigate(LOGIN_ROUTE); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<S.MainGrid container> | ||
<S.CenteredGrid item xs={12} md={6} lg={5}> | ||
<CircularProgress /> | ||
</S.CenteredGrid> | ||
</S.MainGrid> | ||
); | ||
} | ||
|
||
namespace S { | ||
export const CenteredGrid = styled(Grid)` | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
`; | ||
|
||
export const MainGrid = styled(CenteredGrid)` | ||
min-height: 100vh; | ||
`; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Outlet, createBrowserRouter } from 'react-router-dom'; | ||
import LoginPage from './login'; | ||
import EntryPage from './page'; | ||
import ViewsLayout from './views/layout'; | ||
import SQLConsolePage from './views/sql-console'; | ||
import SyncDiagnosticsPage from './views/sync-diagnostics'; | ||
import SchemaPage from './views/schema'; | ||
|
||
export const LOGIN_ROUTE = '/login'; | ||
export const SQL_CONSOLE_ROUTE = '/sql-console'; | ||
export const SYNC_DIAGNOSTICS_ROUTE = '/sync-diagnostics'; | ||
export const SCHEMA_ROUTE = '/schema'; | ||
|
||
/** | ||
* Navigate to this route after authentication | ||
*/ | ||
export const DEFAULT_ENTRY_ROUTE = SYNC_DIAGNOSTICS_ROUTE; | ||
|
||
export const router = createBrowserRouter([ | ||
{ | ||
path: '/', | ||
element: <EntryPage /> | ||
}, | ||
{ | ||
path: LOGIN_ROUTE, | ||
element: <LoginPage /> | ||
}, | ||
{ | ||
element: ( | ||
<ViewsLayout> | ||
<Outlet /> | ||
</ViewsLayout> | ||
), | ||
children: [ | ||
{ | ||
path: SQL_CONSOLE_ROUTE, | ||
element: <SQLConsolePage /> | ||
}, | ||
{ | ||
path: SYNC_DIAGNOSTICS_ROUTE, | ||
element: <SyncDiagnosticsPage /> | ||
}, | ||
{ | ||
path: SCHEMA_ROUTE, | ||
element: <SchemaPage /> | ||
} | ||
] | ||
} | ||
]); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.