Builder.io Forum Tracking
This is an extremely simple NPM package that is meant primarily to be used with Unpkg's CDN to add quick tracking to our forum pages.
Building
First we need to create a keys.json
file with this shape:
{
"MIXPANEL_PUBLIC_KEY": "some-random-api-key-here-for-mixpanel",
"AMPLITUDE_PUBLIC_KEY": "some-random-api-key-here-for-amplitude",
"SOMESERVICE_PUBLIC_KEY" "you-get-the-idea"
}
(Right now only MIXPANEL_PUBLIC_KEY
and AMPLITUDE_PUBLIC_KEY
are required).
Then run:
$ npm install
$ npm run build
Publishing
Once you are properly authenticated with the npm
CLI tool, increment the version
field in package.json
and then just run:
$ npm publish
The version number has to change every time we publish; NPM won't let us overwrite existing versions.
Then, go to the forum's theme settings, edit its HTML/CSS, and add/replace this in the </body>
section:
<script src="//unpkg.com/@builder.io/forum-tracking@<VERSION>/dist/index.browser.js" async defer></script>
where <VERSION>
is the version number in package.json
.