Freshpaint Android SDK Reference

Initialization and Configuration

Importing the SDK

import io.freshpaint.android.Freshpaint;
import io.freshpaint.android.Properties;

Initializing the SDK

Freshpaint freshpaint = new Freshpaint.Builder(getApplicationContext(), "<your environment id>")
    .trackApplicationLifecycleEvents()
    .recordScreenViews()
    .build();

Freshpaint.setSingletonInstance(freshpaint);

You can get your environment id from the Freshpaint sources page.

Before making the call to build() you can call different methods to customize the behavior of the Freshpaint SDK. Here are some of the supported customization options:

Android SDK API

track

The track call can be used to manually send data to your destinations.

Freshpaint
    .with(getActivity().getApplicationContext())
    .track("Purchase", new Properties().putValue("Price", 500));
ArgumentTypeRequiredDescription

event

String

Yes

The name of the event to send.

properties

Properties

No

Additional properties to attach to the event.

identify

The identify call attaches an identity or user properties to the user.

Freshpaint
    .with(getActivity().getApplicationContext())
    .identify("ada.lovelace@example.com", new Traits()
        .putValue("email", "ada.lovelace@example.com")
        .putValue("name", "Ada Lovelace")
    );
ArgumentTypeRequiredDescription

userId

String

No

The id to attach to the user.

traits

Traits

No

Additional user properties to attach to the user.

screen

The screen call triggers a screen event. This is the mobile equivalent of a pageview event. Some destinations will treat this event specially.

Freshpaint
    .with(getActivity().getApplicationContext())
    .screen("Home Screen", new Properties().putValue("A/B Test Variant", "A"));
ArgumentTypeRequiredDescription

name

String

Yes

The name of the screen.

properties

Properties

No

Additional properties to attach to the event.

group

The group call associates the user with a user group. Some destinations let you work with groups of users. For example, Amplitude lets you group users together and then perform analytics on the individual groups. Most often, a group of users is all users that work for a single organization.

Freshpaint
    .with(getActivity().getApplicationContext())
    .group("Google", new Traits()
        .putValue("plan", "enterprise")
        .putValue("sign-up-date", "04/04/2019")
    );
ArgumentTypeRequiredDescription

groupId

String

Yes

The id of the group to add the user to.

traits

Properties

No

Additional properties to attach to the group.

alias

The alias call can be used to specify one user id as an alias for another user id. Calling this will alias the current user's identity to the new provided identity. This is needed to implement identify for some destinations, specifically Mixpanel and Kissmetrics.

Freshpaint
    .with(getActivity().getApplicationContext())
    .alias("ada.lovelace@example.com");
ArgumentTypeRequiredDescription

newId

String

Yes

The id you want to alias the current user's identity to.

reset

The reset call clears any local Freshpaint data attached to this user. This does not clear any local data for any of your destinations. For example this may be useful if a user logs out and logs in to a different account.

Freshpaint
    .with(getActivity().getApplicationContext())
    .reset();

Last updated