New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

analytics-client

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

analytics-client

Convenient builders to compose analytics tools

  • 0.7.0-roman-web-397b52550d1d7f688cf8bfec36e9a3cbc77b8787
  • roman-web-397b52550d1d7f688cf8bfec36e9a3cbc77b8787
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.2K
increased by5.43%
Maintainers
1
Weekly downloads
 
Created

Analytics client

Client part of analytics services used at balena.

Installation

npm install --save analytics-client

Usage

URL query parameters tool.

import { AnalyticsUrlParams } from 'analytics-client';

const urlParamsHandler = new AnalyticsUrlParams(mixpanel);

urlParamsHandler.consumeUrlParameters(window.location.search);

const signupUrl = '/signup?' + urlParamsHandler.getDeviceIdsQueryString();

UI experiments definition.

import { createClient, LocalExperiment } from 'analytics-client';

const client = createClient({projectName: 'my-project'});

type Variation = 'modal' | 'sidebar-left' | 'sidebar-right';
const experiment = new LocalExperiment<Variation>('WelcomeUI', client)
    .define('modal', 50)
    .define('sidebar-left', 25)
    .define('sidebar-right', 25);

switch (experiment.engage(client.deviceId())) {
    case 'modal':
        showModal();
        break;
    // ...
}

Tracking a page view.

import { createClient, WebTracker, createWebTracker } from 'analytics-client';
const client = createClient({ projectName: 'my-project' });
createWebTracker(client).trackPageView();

Using without npm packages

Load the script from unpkg CDN (replacing {version} with an actual version you need to use):

<script src="https://unpkg.com/analytics-client@{version}/dist/bundle.js"></script>

Then use the analyticsClient variable:

const urlParamsHandler = new analyticsClient.AnalyticsUrlParams();

FAQs

Package last updated on 27 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts