Mocked-API icon indicating copy to clipboard operation
Mocked-API copied to clipboard

Analytics supporting changes and infrastructure.

Open computamike opened this issue 3 years ago • 7 comments

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)

computamike avatar Oct 25 '22 07:10 computamike

  • 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)

what-the-diff[bot] avatar Oct 25 '22 07:10 what-the-diff[bot]

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 avatar Oct 25 '22 07:10 computamike

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

computamike avatar Oct 25 '22 07:10 computamike

what's wrong with this pr??

HridoyHazard avatar Oct 26 '22 04:10 HridoyHazard

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 avatar Oct 26 '22 22:10 computamike

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

computamike avatar Oct 26 '22 22:10 computamike

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

computamike avatar Nov 19 '22 23:11 computamike