1.7.1 • Published 9 months ago
@formo/analytics v1.7.1
Installation Guide
NPM - YARN
Option 1 - tracking code
Add the following to your index.html
:
<script>
const script = document.createElement('script');
const apiKey = 'YOUR_API_KEY';
// Add any configuration parameters you'd like here
const config = {};
script.src = 'https://unpkg.com/@formo/analytics';
script.onload = function () {
FormoAnalytics.init(apiKey).then((sdkInstance) => setSdk(sdkInstance));
};
document.head.appendChild(script);
</script>
Option 2 - using npm package
- Install the npm package:
yarn add @formo/analytics
or
npm install @formo/analytics --save
- Initialize the SDK and keep an instance of it ready to reference in other parts of your app. To do this, add the following code on your app’s load:
import { FormoAnalytics } from '@formo/analytics';
const sdk = await FormoAnalytics.init(API_KEY);
Development notes
To run a local version of the script:
- Run
yarn build-cjs && yarn build-esm && yarn webpack --mode=production
ornpm run build
at the root level to build the script. - To authorize device, login into npmjs using
npm login
ornpm adduser
- Run
yarn publish
ornpm run publish
to publish new versions of the package.