Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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]);
// @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());
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']);
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);
};