How to use the amplitude-js.getInstance function in amplitude-js

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 BlueWallet / BlueWallet / analytics.js View on Github external
import amplitude from 'amplitude-js';
import Analytics from 'appcenter-analytics';

amplitude.getInstance().init('8b7cf19e8eea3cdcf16340f5fbf16330', null, {
  useNativeDeviceInfo: true,
});

let A = async event => {
  amplitude.getInstance().logEvent(event, {});
  try {
    Analytics.trackEvent(event);
  } catch (err) {
    console.log(err);
  }
};

A.ENUM = {
  INIT: 'INIT',
  GOT_NONZERO_BALANCE: 'GOT_NONZERO_BALANCE',
  CREATED_WALLET: 'CREATED_WALLET',
github unwelch / unwel.ch / frontend / src / tracking / index.js View on Github external
return new Promise(resolve => {
    const key =
      process.env.NODE_ENV === 'production'
        ? '16621e1ae779c55cd67c2eda1610325b'
        : 'd78524420bd27e783198933c03a59aca'

    amplitude.getInstance().init(key, null, null, resolve)
  })
}
github wavesplatform / WavesExplorerLite / src / js / services / AmplitudeAnalyticsService.js View on Github external
sendEvent(event) {
        let properties = {
            category: event.categoryName
        };

        if (event.properties) {
            properties = Object.assign({}, event.properties, properties);
        }

        amplitude.getInstance().logEvent(event.eventName, properties);
    }
}
github codeforthailand / election-live / src / util / analytics.js View on Github external
export function trackEvent(eventName, eventProperties) {
  if (process.env.NODE_ENV === "production") {
    try {
      const amplitude = require("amplitude-js")
      amplitude.getInstance().logEvent(eventName, eventProperties)
    } catch (e) {
      debug(eventName, eventProperties)
      debug("Failed to send event to Amplitude", e)
    }
  } else {
    debug(eventName, eventProperties)
  }
}
github arjun27 / rubberduck / src / content_script / utils / analytics.js View on Github external
export const setupUser = userInfo => {
  const { username: userId } = userInfo;
  amplitude.getInstance().setUserId(userId);
  let userIdentity = new amplitude.Identify();
  Object.keys(userInfo).forEach(function(key) {
    userIdentity.set(key, userInfo[key]);
  });
  amplitude.getInstance().identify(userIdentity);
};

amplitude-js

Javascript library for Amplitude Analytics

MIT
Latest version published 12 months ago

Package Health Score

72 / 100
Full package analysis