How to use amplitude-js - 10 common examples

To help you get started, we’ve selected a few amplitude-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / amplitude-js_v4.x.x / flow_v0.104.x- / test_amplitude-js_v4.x.x.js View on Github external
function amplitudeClientTests() {
  const client: AmplitudeClient = amplitude.getInstance();

  //* Identify
  (client.Identify: typeof Identify);

  //* Revenue
  (client.Revenue: typeof Revenue);

  //* init
  client.init('key');
  client.init('key', 'uid');
  client.init('key', null, { batchEvents: false });
  client.init('key', 'uid', null, function(c: AmplitudeClient) {});

  //* isNewSession
  (client.isNewSession(): boolean);
github flow-typed / flow-typed / definitions / npm / amplitude-js_v4.x.x / flow_v0.104.x- / test_amplitude-js_v4.x.x.js View on Github external
function getInstanceTest() {
  (amplitude.getInstance(): AmplitudeClient);
  (amplitude.getInstance('name'): AmplitudeClient);

  // $ExpectError: getInstance only accepts strings
  amplitude.getInstance(5);

  // $ExpectError: getInstance only accepts strings
  amplitude.getInstance(new Date());
}
github flow-typed / flow-typed / definitions / npm / amplitude-js_v4.x.x / flow_v0.104.x- / test_amplitude-js_v4.x.x.js View on Github external
// @flow

/* eslint-disable no-unused-vars, no-undef, no-console */

import amplitude, { Identify, Revenue } from 'amplitude-js';
import type { AmplitudeClient } from 'amplitude-js';

/**
 * Common instances
 */

const client = amplitude.getInstance();
const identify = new Identify();
const revenue = new Revenue();
const callback = (responseCode: number, responseBody: string) => void 0;

/**
 * ALL THE TESTS START FROM HERE
 */

function getInstanceTest() {
  (amplitude.getInstance(): AmplitudeClient);
  (amplitude.getInstance('name'): AmplitudeClient);

  // $ExpectError: getInstance only accepts strings
  amplitude.getInstance(5);

  // $ExpectError: getInstance only accepts strings
github flow-typed / flow-typed / definitions / npm / amplitude-js_v4.x.x / flow_v0.104.x- / test_amplitude-js_v4.x.x.js View on Github external
function getInstanceTest() {
  (amplitude.getInstance(): AmplitudeClient);
  (amplitude.getInstance('name'): AmplitudeClient);

  // $ExpectError: getInstance only accepts strings
  amplitude.getInstance(5);

  // $ExpectError: getInstance only accepts strings
  amplitude.getInstance(new Date());
}
github flow-typed / flow-typed / definitions / npm / amplitude-js_v4.x.x / flow_v0.104.x- / test_amplitude-js_v4.x.x.js View on Github external
function identifyTests() {
  //* constructor
  (new Identify(): Identify);

  const i: Identify = new Identify();

  //* add
  i.add('foo', 1);
  i.add('bar', -10);

  // $ExpectError: add requies a name as first parameter
  i.add(15, 21);

  // $ExpectError: add requies a number as second parameter
  i.add('foo', 'bar');

  //* append
  i.append('foo', 1);
  i.append('foo', [1]);
github flow-typed / flow-typed / definitions / npm / amplitude-js_v4.x.x / flow_v0.104.x- / test_amplitude-js_v4.x.x.js View on Github external
// @flow

/* eslint-disable no-unused-vars, no-undef, no-console */

import amplitude, { Identify, Revenue } from 'amplitude-js';
import type { AmplitudeClient } from 'amplitude-js';

/**
 * Common instances
 */

const client = amplitude.getInstance();
const identify = new Identify();
const revenue = new Revenue();
const callback = (responseCode: number, responseBody: string) => void 0;

/**
 * ALL THE TESTS START FROM HERE
 */

function getInstanceTest() {
  (amplitude.getInstance(): AmplitudeClient);
  (amplitude.getInstance('name'): AmplitudeClient);

  // $ExpectError: getInstance only accepts strings
  amplitude.getInstance(5);

  // $ExpectError: getInstance only accepts strings
  amplitude.getInstance(new Date());
github flow-typed / flow-typed / definitions / npm / amplitude-js_v4.x.x / flow_v0.104.x- / test_amplitude-js_v4.x.x.js View on Github external
function identifyTests() {
  //* constructor
  (new Identify(): Identify);

  const i: Identify = new Identify();

  //* add
  i.add('foo', 1);
  i.add('bar', -10);

  // $ExpectError: add requies a name as first parameter
  i.add(15, 21);

  // $ExpectError: add requies a number as second parameter
  i.add('foo', 'bar');

  //* append
  i.append('foo', 1);
  i.append('foo', [1]);
  i.append('foo', 'bar');
  i.append('foo', ['bar']);
github flow-typed / flow-typed / definitions / npm / amplitude-js_v4.x.x / flow_v0.104.x- / test_amplitude-js_v4.x.x.js View on Github external
function revenueTests() {
  //* constructor
  (new Revenue(): Revenue);

  const r: Revenue = new Revenue();

  //* setProductId
  r.setProductId('pid');

  // $ExpectError: setProductId only accepts strings
  r.setProductId(5);

  // $ExpectError: setProductId only accepts strings
  r.setProductId();

  //* setQuantity
  r.setQuantity(5);
  r.setQuantity();
github flow-typed / flow-typed / definitions / npm / amplitude-js_v4.x.x / flow_v0.104.x- / test_amplitude-js_v4.x.x.js View on Github external
// @flow

/* eslint-disable no-unused-vars, no-undef, no-console */

import amplitude, { Identify, Revenue } from 'amplitude-js';
import type { AmplitudeClient } from 'amplitude-js';

/**
 * Common instances
 */

const client = amplitude.getInstance();
const identify = new Identify();
const revenue = new Revenue();
const callback = (responseCode: number, responseBody: string) => void 0;

/**
 * ALL THE TESTS START FROM HERE
 */

function getInstanceTest() {
  (amplitude.getInstance(): AmplitudeClient);
  (amplitude.getInstance('name'): AmplitudeClient);

  // $ExpectError: getInstance only accepts strings
  amplitude.getInstance(5);

  // $ExpectError: getInstance only accepts strings
  amplitude.getInstance(new Date());
}
github flow-typed / flow-typed / definitions / npm / amplitude-js_v4.x.x / flow_v0.104.x- / test_amplitude-js_v4.x.x.js View on Github external
function revenueTests() {
  //* constructor
  (new Revenue(): Revenue);

  const r: Revenue = new Revenue();

  //* setProductId
  r.setProductId('pid');

  // $ExpectError: setProductId only accepts strings
  r.setProductId(5);

  // $ExpectError: setProductId only accepts strings
  r.setProductId();

  //* setQuantity
  r.setQuantity(5);
  r.setQuantity();

  // $ExpectError: setProductId only accepts numbers
  r.setQuantity('foo');

amplitude-js

Javascript library for Amplitude Analytics

MIT
Latest version published 2 years ago

Package Health Score

65 / 100
Full package analysis