Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @amplitude/analytics-node

Index

Functions

  • Adds a new plugin.

    const plugin = {
    name: 'myPlugin',
    type: PluginType.ENRICHMENT,
    setup(config: Config) {
    return;
    },
    execute(context: Event) {
    return context;
    },
    };
    amplitude.add(plugin);

    Parameters

    Returns Types.AmplitudeReturn<void>

  • Flush all unsent events.

    flush();
    

    Returns Types.AmplitudeReturn<void>

  • Sends a group identify event containing group property operations.

    const id = new Identify();
    id.set('skills', ['js', 'ts']);
    const groupType = 'org';
    const groupName = 'engineering';
    groupIdentify(groupType, groupName, id);

    // alternatively, this tracking method is awaitable
    const result = await groupIdentify(groupType, groupName, id).promise;
    console.log(result.event); // {...}
    console.log(result.code); // 200
    console.log(result.message); // "Event tracked successfully"

    Parameters

    Returns Types.AmplitudeReturn<Types.Result>

  • Sends an identify event containing user property operations

    const id = new Identify();
    id.set('colors', ['rose', 'gold']);
    identify(id);

    // alternatively, this tracking method is awaitable
    const result = await identify(id).promise;
    console.log(result.event); // {...}
    console.log(result.code); // 200
    console.log(result.message); // "Event tracked successfully"

    Parameters

    Returns Types.AmplitudeReturn<Types.Result>

  • Initializes the Amplitude SDK with your apiKey, optional configurations. This method must be called before any other operations.

    await init(API_KEY, options).promise;
    

    Parameters

    Returns Types.AmplitudeReturn<void>

  • Removes a plugin.

    amplitude.remove('myPlugin');
    

    Parameters

    • pluginName: string

    Returns Types.AmplitudeReturn<void>

  • Sends a revenue event containing revenue property operations.

    const rev = new Revenue();
    rev.setRevenue(100);
    revenue(rev);

    // alternatively, this tracking method is awaitable
    const result = await revenue(rev).promise;
    console.log(result.event); // {...}
    console.log(result.code); // 200
    console.log(result.message); // "Event tracked successfully"

    Parameters

    Returns Types.AmplitudeReturn<Types.Result>

  • Assigns a user to group

    const groupType = 'orgId';
    const groupName = '15';
    setGroup(groupType, groupName, { user_id: '12345' })

    Parameters

    • groupType: string
    • groupName: string | string[]
    • Optional eventOptions: Types.EventOptions

    Returns Types.AmplitudeReturn<Types.Result>

  • setOptOut(optOut: boolean): void
  • Sets a new optOut config value. This toggles event tracking on/off.

    // Stops tracking
    setOptOut(true);

    // Starts/resumes tracking
    setOptOut(false);

    Parameters

    • optOut: boolean

    Returns void

  • Tracks user-defined event, with specified type, optional event properties and optional overwrites.

    // event tracking with event type only
    track('Page Load');

    // event tracking with event type and additional event properties
    track('Page Load', { loadTime: 1000 });

    // event tracking with event type, additional event properties, and overwritten event options
    track('Page Load', { loadTime: 1000 }, { sessionId: -1 });

    // alternatively, this tracking method is awaitable
    const result = await track('Page Load').promise;
    console.log(result.event); // {...}
    console.log(result.code); // 200
    console.log(result.message); // "Event tracked successfully"

    Parameters

    Returns Types.AmplitudeReturn<Types.Result>

Generated using TypeDoc