public final class LilyAi extends java.lang.Object
First obtain api-key and token to access Lily.Ai analytics.
Place the obtained api-key and token in meta-data tags in your AndroidManifest.xml inside application tag:
<application ...>
<meta-data android:name="ai.lily.analytics.api_token" android:value="PLACE_YOUR_API_TOKEN_HERE" />
<meta-data android:name="ai.lily.analytics.api_key" android:value="PLACE_YOUR_API_KEY_HERE" />
<meta-data android:name="ai.lily.analytics.endpoint" android:value="PLACE_YOUR_ENDPOINT_HERE" />
</application>
Now you can call getInstance(Context) to obtain LilyAi instance
You might want to keep your api-key and token more secure. In this case obfuscate those as you please and
to obtain LilyAi instance use getInstance(Context, String) with your token or getInstance(Context, String, String, String) with both.
When initiated LilyAi tries to restore a unique id (UUID or lpid) of the user from it's shared preferences or
generates a new one, if not present, and stores it. You can override this by calling setUUID(String) with your own id for the user.
Also you can use getUUID() to check what UUID is currently used by LilyAi or call resetUUID() to
drop the stored UUID value and generate a new random UUID.
Once you obtained an instance of LilyAi and done with setting up the UUID you can call either of track(JSONObject) or
track(JSONObject, LilyAiListener) methods to send your data.
| Modifier and Type | Method and Description |
|---|---|
void |
addHeader(java.lang.String name,
java.lang.String value) |
static LilyAi |
getInstance(android.content.Context context)
Get instance of LilyAI.
|
static LilyAi |
getInstance(android.content.Context context,
java.lang.String token)
Get instance of LilyAI.
|
static LilyAi |
getInstance(android.content.Context context,
java.lang.String baseUrl,
java.lang.String token,
java.lang.String apiKey)
Get instance of LilyAI.
|
java.lang.String |
getUUID()
Get current UUID value stored by LilyAI.
|
void |
resetUUID()
Reset the stored UUID to a new random value.
|
void |
setAnalyticsProviderID(java.lang.String aid) |
void |
setAnalyticsSessionID(java.lang.String sid) |
void |
setExperimentId(java.lang.String expid) |
void |
setHashedUserEmail(java.lang.String uem) |
void |
setReferer(java.lang.String src,
java.lang.String mdm,
java.lang.String pgpath,
java.lang.String pgcat,
java.lang.String pgtype) |
void |
setSessionDuration(long sessionDuration)
Set session duration time.
|
void |
setUserID(java.lang.String uid) |
void |
setUserSourceIP(java.lang.String sip) |
void |
setUUID(java.lang.String uuid)
Set a new custom UUID value.
|
void |
setVisitorId(java.lang.String vid) |
void |
track(org.json.JSONObject data)
Send your data to LilyAI.
|
void |
track(org.json.JSONObject data,
LilyAiListener listener)
Send your data to LilyAI.
|
public static LilyAi getInstance(android.content.Context context)
To use this method you should provide api-key and token in meta-data tags in your AndroidManifest.xml inside application tag:
<application ...>
<meta-data android:name="ai.lily.analytics.api_token" android:value="PLACE_YOUR_API_TOKEN_HERE" />
<meta-data android:name="ai.lily.analytics.api_key" android:value="PLACE_YOUR_API_KEY_HERE" />
<meta-data android:name="ai.lily.analytics.endpoint" android:value="PLACE_YOUR_ENDPOINT_HERE" />
</application>
context - The application context.public static LilyAi getInstance(android.content.Context context, java.lang.String token)
To use this method you should provide api-key in meta-data tag in your AndroidManifest.xml inside application tag:
<application ...>
<meta-data android:name="ai.lily.analytics.api_key" android:value="PLACE_YOUR_API_KEY_HERE" />
<meta-data android:name="ai.lily.analytics.endpoint" android:value="PLACE_YOUR_ENDPOINT_HERE" />
</application>
context - The application context.token - Your api token string.public static LilyAi getInstance(android.content.Context context, java.lang.String baseUrl, java.lang.String token, java.lang.String apiKey)
context - The application context.token - Your api token string.apiKey - Your api-key string.public void resetUUID()
public void setUUID(java.lang.String uuid)
uuid - New UUID value to store and use. Can't be null or empty string.public java.lang.String getUUID()
public void setSessionDuration(long sessionDuration)
sessionDuration - max session duration time (millis)public void track(org.json.JSONObject data)
track(JSONObject, LilyAiListener) with listener set to null.data - Your JSON data.public void track(org.json.JSONObject data, LilyAiListener listener)
LilyAiListener will be called on the MainLooper.data - Your JSON data. If data is null LilyAiListener.onError(String) will be called with message "JSON data is null".listener - Callbacks for data send success or error. Can be null.public void addHeader(java.lang.String name, java.lang.String value)
public void setUserID(java.lang.String uid)
public void setAnalyticsProviderID(java.lang.String aid)
public void setAnalyticsSessionID(java.lang.String sid)
public void setHashedUserEmail(java.lang.String uem)
public void setReferer(java.lang.String src, java.lang.String mdm, java.lang.String pgpath, java.lang.String pgcat, java.lang.String pgtype)
public void setExperimentId(java.lang.String expid)
public void setUserSourceIP(java.lang.String sip)
public void setVisitorId(java.lang.String vid)