@acquireweb/analytics

1.2.0 • Public • Published

Acquire Web Analytics

Usage

Install

The analytics library is distributed on NPM for ease of access. It can be added to a project with the following commands:

# npm
npm i --save-dev @acquireweb/analytics
# pnpm
pnpm add -D @acquireweb/analytics

Configure

Use the configureAnalytics export to set the API Endpoint and API Key.

import {configureAnalytics} from '@acquireweb/analytics';

// Set a single setting
configureAnalytics({
  apiKey: '12345678',
});

// Set multiple settings
configureAnalytics({
  apiKey: '12345678',
  endpoint: 'https://localhost:3000/',
});

[!NOTE] The default endpoint is https://api.wayfinder.acquiredigital.com/api/analytics/web/basic so you may not need to change this.

Logging

Use the logEvent export to send an event.

logEvent({
  event: 'script_loaded',
  data: {
    service: 'web_directory',
    origin: window.location.origin,
    environment: 'live',
  },
});

Events will be batched, so you can use the function without getting rate limited.

Development

Install dependencies

This project uses PNPM for dependency management.

# Enable corepack
corepack enable

# Install dependencies
pnpm install

Development Server

Start the development server on http://localhost:5173:

pnpm run dev

The index.html file includes an example logging configuration. You can edit this to test different endpoints.

There are buttons to test sending 1, 10 and 500 events. You can edit the data in the examples to change the payload that gets sent to the server.

Production

Build the application for production:

pnpm run build

Release

[!NOTE] Make sure to bump the version number before creating a new release.

To release a new version to NPM, you need to create a new release on GitHub. This will trigger a workflow which builds and releases the package.

Readme

Keywords

none

Package Sidebar

Install

npm i @acquireweb/analytics

Weekly Downloads

22

Version

1.2.0

License

none

Unpacked Size

10.9 kB

Total Files

5

Last publish

Collaborators

  • lnelson-acq
  • acquireaccounts
  • mattmacquire