* Seed database with pageviews
This commit adds basic support for database seeding useful for testing,
especially dashboard changes, like intervals.
It creates two years of pageviews with random timestamps. There is lot
of room for improvement, such as adding sources, entry pages,
geolocation, devices, custom events, but this already helps us with
testing.
* Update CONTRIBUTING.md file
@ -8,21 +8,31 @@ The easiest way to get up and running is to [install](https://docs.docker.com/ge
Make sure Docker, Elixir, Erlang and Node.js are all installed on your development machine. The [`.tool-versions`](https://github.com/plausible/analytics/blob/master/.tool-versions) file is available to use with [asdf](https://github.com/asdf-vm/asdf) or similar tools.
### Start the environment:
### Start the environment
1. Run both `make postgres` and `make clickhouse`.
2. You can set up everything with `make install`, alternatively run each command separately:
1. Run `mix deps.get`. This will download the required Elixir dependencies.
2. Run `mix ecto.create`. This will create the required databases in both Postgres and Clickhouse.
3. Run `mix ecto.migrate` to build the database schema.
4. Run `npm ci --prefix assets` to install the required client-side dependencies.
5. Run `npm ci --prefix tracker` to install the required tracker dependencies.
6. Run `npm run deploy --prefix tracker` to generate tracker files in `priv/tracker/js`
7. Run `mix download_country_database` to fetch geolocation database
4. Run `mix run priv/repo/seeds.exs` to seed the database. Check the [Seeds](#Seeds) section for more.
5. Run `npm ci --prefix assets` to install the required client-side dependencies.
6. Run `npm ci --prefix tracker` to install the required tracker dependencies.
7. Run `npm run deploy --prefix tracker` to generate tracker files in `priv/tracker/js`
8. Run `mix download_country_database` to fetch geolocation database
3. Run `make server` or `mix phx.server` to start the Phoenix server.
4. The system is now available on `localhost:8000`.
### Creating an account
### Seeds
You can optionally seed your database to automatically create an account and a site with stats:
1. Run `mix run priv/repo/seeds.exs` to seed the database.
2. Start the server with `make server` and navigate to `http://localhost:8000/login`.
3. Log in with the following e-mail and password combination: `user@plausible.test` and `plausible`.
4. You should now have a `dummy.site` site with generated stats.
Alternatively, you can manually create a new account:
1. Navigate to `http://localhost:8000/register` and fill in the form.
2. Fill in the rest of the forms and for the domain use `dummy.site`