Browser JavaScript client for Ophan.
$ npm install ophan-tracker-js
-
Install dependencies
$ brew install lighttpd .../ophan/tracker-js $ npm install
-
In another terminal window:
.../ophan/tracker-js $ lighttpd -f lighttpd.conf -D
-
Install FoxyProxy (https://getfoxyproxy.org/downloads/) in your browser and create a rule that forces j.ophan.co.uk to localhost 8000. (For me FoxyProxy needed a few switches on and off before it decided to start talking to lighttpd.)
-
In another terminal window, start a server that is running the Guardian frontend
-
Navigate to where you are running the Guardian locally (e.g. https://localhost:9000/uk)
-
Ensure FoxyProxy is enabled
-
Develop with pleasure
When you make a change to Tracker JS, you must release on both these systems:
We use changesets
for automated publishing of the NPM package:
-
Add a changeset, run the following command and follow the instructions
.../ophan/tracker-js $ npx changeset
-
When you raise a PR, the changeset bot won’t correctly see that you have included a changeset – it only checks for the .changesets folder in the root of the repository, whereas we have it in a subdirectory. Don’t worry.
-
When the PR is merged, the
changesets
github action will create a new PR, example here. On merging this generated PR, the action will publish to NPM. (This checks the subdirectory correctly.)
- https://j.ophan.co.uk/ - CDN/S3, deployed through RiffRaff and used by some Guardian sites like https://jobs.theguardian.com/. An advantage of this approach is that sites using it immediately get Tracker JS updates, without developer intervention.
The generated files from Rollup are only used for publishing to the CDN to use SystemJS / AMD
You can see example usage of the library on theguardian.com here