@guardian/ophan-tracker-js v2.1.1
Ophan Tracker JS
Browser JavaScript client for Ophan.
Install
$ npm install ophan-tracker-js
Contribute
Proxy 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
Publish
Two formats for release
When you make a change to Tracker JS, you must release on both these systems:
NPM
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.)
S3 Bucket
- 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.
Rollup
The generated files from Rollup are only used for publishing to the CDN to use SystemJS / AMD
Example Usage
You can see example usage of the library on theguardian.com here
27 days ago
2 months ago
2 months ago
3 months ago
3 months ago
4 months ago
4 months ago
5 months ago
6 months ago