Skip to content
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

_desktop.db mechanism for storing app preferences, audit logs and suchlike #101

Open
simonw opened this issue Sep 11, 2021 · 3 comments
Open
Labels
Milestone

Comments

@simonw
Copy link
Owner

simonw commented Sep 11, 2021

If I'm going to have default plugins and I'm going to let users uninstall them, I need a way of remembering what they uninstalled.

I quite like the idea of doing this as an audit log - so every time a user installs or uninstalls or upgrades a plugin we record that permanently somewhere. This could be really useful for debugging later on.

Obviously this should be a SQLite database somewhere. But what should it be called?

Some options:

  • prefs.db or preferences.db
  • config.db - could be confused with Datasette's concept of configuration (e.g plugin configuration)
  • settings.db - definitely confused with Datasette's --setting mechanism

So preferences.db is probably the best option - but do I risk confusion over preferences v.s. settings v.s. configuration v.s. metadata? And what if there's stuff I end up storing in there that doesn't classify as user preferences?

I could call it _desktop.db since it's the internal database for stuff relating to the Datasette Desktop app.

Originally posted by @simonw in #72 (comment)

@simonw
Copy link
Owner Author

simonw commented Sep 11, 2021

What kind of stuff could go in here?

  • Plugin audit log, needed by Ability to uninstall a plugin #72 to persist the fact that default plugins may have been deliberately uninstalled
  • Persistent network settings, e.g. that the user wants the app to be available to the rest of the network
  • Maybe authentication credentials such that other users on the network have to sign in to view
  • Saved bookmarks and history, see Some kind of bookmarking/history mechanism #85
  • A log of recently run queries too (a specialized case of history)
  • API keys and other credentials needed by potential future plugins, e.g. Dogsheep stuff

@simonw
Copy link
Owner Author

simonw commented Sep 11, 2021

And a really fun idea I've been contemplating: imagine a form of plugin which is pure JavaScript and can be installed by copying and pasting a chunk of code into a textarea and hitting "save".

@simonw
Copy link
Owner Author

simonw commented Sep 11, 2021

So where does this thing go? I think it goes in the app.getPath("userData") folder.

One problem: the Electron shell knows where that is, but the datasette process doesn't without the shell telling it. So I think the shell sets that as another environment variable here:

datasette-app/main.js

Lines 167 to 172 in f83a929

process = cp.spawn(datasette_bin, this.serverArgs(), {
env: {
DATASETTE_API_TOKEN: this.apiToken,
DATASETTE_SECRET: RANDOM_SECRET,
},
});
- maybe DATASETTE_USER_DATA or DATASETTE_DESKTOP_DB (a full path to the _desktop.db file).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant