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

Analytics supporting changes and infrastructure. #277

Open
wants to merge 27 commits into
base: dev
Choose a base branch
from

Conversation

computamike
Copy link
Collaborator

Pull request template

IMPORTANT: Please review the CONTRIBUTING.md file for detailed contributing guidelines.

Describe your changes

Link to issue this resolves

Screenshot of changes(if relevant)

@what-the-diff
Copy link

what-the-diff bot commented Oct 25, 2022

  • Added a new environment variable PLAUSIBLE_CONFIGURATION to the .env.example file
  • Added plausibleLogger middleware in app.ts
  • Updated docker-compose with Plausible Analytics Engine configuration and added volumes for data persistence
  • Created console-analytics middleware as an example of how to implement custom analytics logging (not used)
  • Created plausible middleware that logs all requests into Plausible Analytics Engine
  • Create public/custom1,js which is loaded by swagger UI when it loads /docs endpoint (this script adds the tracking code from Plausible)

@computamike
Copy link
Collaborator Author

This Pull request is for @ageddesi to see what I managed to get working. Getting it working locally is somewhat of a challenge,

FIrstly you need an address that ISN'T localhost - so running this locally you will need a host file entry - depending on your envurinment add an entry in yourt host file. I have been testing this with the following host entry

127.0.0.1 MockedApi.local

You will need a plausible.conf file - an example is included. You will need a secret - most of this is taken from : https://plausible.io/docs/self-hosting

create a secret and add it to the .plausible configuration file

$ openssl rand -base64 64 | tr -d '\n' ; echo

now stand the docker-compose file up - at the end of this you should have the following conainers running

image

I turned off mockedAPI as I run locally

you can connect to plausible at : http://localhost:8000/

you can connect to the API at http://mockedapi.local:3000/

logging into plausible you need to add a website - so add a site for mockedpi.local.

There is a Javascript file that needs to be added (i created custom.js to register that - will work on making it more generic) - which should send the request to plausible.

hope these somewhat hasty instructions are going to b ok for you.

@computamike
Copy link
Collaborator Author

gotchas : Make sure you browse to http://mockedapi.local:3000 - if you hit localhost:3000 then the adress that will be passed to plausible will be ignore and you'll see no traffic

@HridoyHazard
Copy link

what's wrong with this pr??

@computamike
Copy link
Collaborator Author

what's wrong with this pr??

I had been chatting to @ageddesi about analytics - and he asked for a PR to see what I had managed to do - I had some questions or thoughts about how we log visits to API end points.

@computamike
Copy link
Collaborator Author

The tests are failing because the middleware I have developed for analystics is having some problem with environment settings.

app.ts Outdated Show resolved Hide resolved
app.ts Show resolved Hide resolved
@computamike computamike changed the title Work in progress Analytics supporting changes and infrastructure. Oct 31, 2022
@computamike
Copy link
Collaborator Author

I am rebasing this branch and will update as soon as I pick apart what has changed since I first set up this branch

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

Successfully merging this pull request may close these issues.

3 participants