public class AnalyticsClient extends Object
| Constructor and Description |
|---|
AnalyticsClient(String writeKey)
Creates a new Segment.io client.
|
AnalyticsClient(String writeKey,
Options options)
Creates a new Segment.io client.
|
| Modifier and Type | Method and Description |
|---|---|
void |
alias(String from,
String to)
Aliases an anonymous user into an identified user.
|
void |
alias(String from,
String to,
Context context)
Aliases an anonymous user into an identified user.
|
void |
alias(String from,
String to,
org.joda.time.DateTime timestamp)
Aliases an anonymous user into an identified user.
|
void |
alias(String from,
String to,
org.joda.time.DateTime timestamp,
Context context)
Aliases an anonymous user into an identified user.
|
void |
alias(String from,
String to,
org.joda.time.DateTime timestamp,
Context context,
Callback callback)
Aliases an anonymous user into an identified user.
|
void |
close()
Closes the queue and the threads associated with flushing the queue
|
void |
flush()
Blocks until all messages in the queue are flushed.
|
Options |
getOptions() |
AnalyticsStatistics |
getStatistics() |
String |
getWriteKey() |
void |
identify(String userId,
Traits traits)
Identifying a user ties all of their actions to an id, and associates
user traits to that id.
|
void |
identify(String userId,
Traits traits,
Context context)
Identifying a user ties all of their actions to an id, and associates
user traits to that id.
|
void |
identify(String userId,
Traits traits,
org.joda.time.DateTime timestamp,
Context context)
Identifying a user ties all of their actions to an id, and associates
user traits to that id.
|
void |
identify(String userId,
Traits traits,
org.joda.time.DateTime timestamp,
Context context,
Callback callback)
Identifying a user ties all of their actions to an id, and associates
user traits to that id.
|
void |
setWriteKey(String writeKey) |
void |
track(String userId,
String event)
Whenever a user triggers an event, you’ll want to track it.
|
void |
track(String userId,
String event,
EventProperties properties)
Whenever a user triggers an event, you’ll want to track it.
|
void |
track(String userId,
String event,
EventProperties properties,
org.joda.time.DateTime timestamp)
Whenever a user triggers an event, you’ll want to track it.
|
void |
track(String userId,
String event,
EventProperties properties,
org.joda.time.DateTime timestamp,
Context context)
Whenever a user triggers an event, you’ll want to track it.
|
void |
track(String userId,
String event,
EventProperties properties,
org.joda.time.DateTime timestamp,
Context context,
Callback callback)
Whenever a user triggers an event, you’ll want to track it.
|
public AnalyticsClient(String writeKey)
writeKey - Your segment.io writeKey. You can get one of these by
registering for a project at https://segment.iopublic AnalyticsClient(String writeKey, Options options)
writeKey - Your segment.io writeKey. You can get one of these by
registering for a project at https://segment.iooptions - Options to configure the behavior of the Segment.io clientpublic void identify(String userId, Traits traits)
userId - the user's id after they are logged in. It's the same id as
which you would recognize a signed-in user in your system.traits - a dictionary with keys like email, name, subscriptionPlan or
age. You only need to record a trait once, no need to send it
again.public void identify(String userId, Traits traits, Context context)
userId - the user's id after they are logged in. It's the same id as
which you would recognize a signed-in user in your system.traits - a dictionary with keys like subscriptionPlan or age. You only
need to record a trait once, no need to send it again.context - an object that describes anything that doesn't fit into this
event's properties (such as the user's IP)public void identify(String userId, Traits traits, org.joda.time.DateTime timestamp, Context context)
userId - the user's id after they are logged in. It's the same id as
which you would recognize a signed-in user in your system.traits - a dictionary with keys like subscriptionPlan or age. You only
need to record a trait once, no need to send it again.timestamp - a DateTime representing when the identify took place.
If the identify just happened, leave it blank and we'll use
the server's time. If you are importing data from the past,
make sure you provide this argument.context - an object that describes anything that doesn't fit into this
event's properties (such as the user's IP)public void identify(String userId, Traits traits, org.joda.time.DateTime timestamp, Context context, Callback callback)
userId - the user's id after they are logged in. It's the same id as
which you would recognize a signed-in user in your system.traits - a dictionary with keys like subscriptionPlan or age. You only
need to record a trait once, no need to send it again.timestamp - a DateTime representing when the identify took place.
If the identify just happened, leave it blank and we'll use
the server's time. If you are importing data from the past,
make sure you provide this argument.context - an object that describes anything that doesn't fit into this
event's properties (such as the user's IP)callback - a callback that is fired when this track's batch is flushed to
the server. Note: this callback is fired on the same thread as
the async event loop that made the request. You should not
perform any kind of long running operation on it.public void track(String userId, String event)
userId - the user's id after they are logged in. It's the same id as
which you would recognize a signed-in user in your system.event - describes what this user just did. It's a human readable
description like "Played a Song", "Printed a Report" or
"Updated Status".public void track(String userId, String event, EventProperties properties)
userId - the user's id after they are logged in. It's the same id as
which you would recognize a signed-in user in your system.event - describes what this user just did. It's a human readable
description like "Played a Song", "Printed a Report" or
"Updated Status".properties - a dictionary with items that describe the event in more
detail. This argument is optional, but highly
recommended—you’ll find these properties extremely useful
later.public void track(String userId, String event, EventProperties properties, org.joda.time.DateTime timestamp)
userId - the user's id after they are logged in. It's the same id as
which you would recognize a signed-in user in your system.event - describes what this user just did. It's a human readable
description like "Played a Song", "Printed a Report" or
"Updated Status".properties - a dictionary with items that describe the event in more
detail. This argument is optional, but highly
recommended—you’ll find these properties extremely useful
later.timestamp - a DateTime object representing when the track took
place. If the event just happened, leave it blank and we'll
use the server's time. If you are importing data from the
past, make sure you provide this argument.public void track(String userId, String event, EventProperties properties, org.joda.time.DateTime timestamp, Context context)
userId - the user's id after they are logged in. It's the same id as
which you would recognize a signed-in user in your system.event - describes what this user just did. It's a human readable
description like "Played a Song", "Printed a Report" or
"Updated Status".properties - a dictionary with items that describe the event in more
detail. This argument is optional, but highly
recommended—you’ll find these properties extremely useful
later.timestamp - a DateTime object representing when the track took
place. If the event just happened, leave it blank and we'll
use the server's time. If you are importing data from the
past, make sure you provide this argument.context - an object that describes anything that doesn't fit into this
event's properties (such as the user's IP)public void track(String userId, String event, EventProperties properties, org.joda.time.DateTime timestamp, Context context, Callback callback)
userId - the user's id after they are logged in. It's the same id as
which you would recognize a signed-in user in your system.event - describes what this user just did. It's a human readable
description like "Played a Song", "Printed a Report" or
"Updated Status".properties - a dictionary with items that describe the event in more
detail. This argument is optional, but highly
recommended—you’ll find these properties extremely useful
later.timestamp - a DateTime object representing when the track took
place. If the event just happened, leave it blank and we'll
use the server's time. If you are importing data from the
past, make sure you provide this argument.context - an object that describes anything that doesn't fit into this
event's properties (such as the user's IP)callback - a callback that is fired when this track's batch is flushed to
the server. Note: this callback is fired on the same thread as
the async event loop that made the request. You should not
perform any kind of long running operation on it.public void alias(String from, String to)
from - the anonymous user's id before they are logged in.to - the identified user's id after they're logged in.public void alias(String from, String to, org.joda.time.DateTime timestamp)
from - the anonymous user's id before they are logged in.to - the identified user's id after they're logged in.timestamp - a DateTime object representing when the track took
place. If the event just happened, leave it blank and we'll
use the server's time. If you are importing data from the
past, make sure you provide this argument.public void alias(String from, String to, Context context)
from - the anonymous user's id before they are logged in.to - the identified user's id after they're logged in.context - an object that describes anything that doesn't fit into this
event's properties (such as the user's IP)public void alias(String from, String to, org.joda.time.DateTime timestamp, Context context)
from - the anonymous user's id before they are logged in.to - the identified user's id after they're logged in.timestamp - a DateTime object representing when the track took
place. If the event just happened, leave it blank and we'll
use the server's time. If you are importing data from the
past, make sure you provide this argument.context - an object that describes anything that doesn't fit into this
event's properties (such as the user's IP)public void alias(String from, String to, org.joda.time.DateTime timestamp, Context context, Callback callback)
from - the anonymous user's id before they are logged in.to - the identified user's id after they're logged in.timestamp - a DateTime object representing when the track took
place. If the event just happened, leave it blank and we'll
use the server's time. If you are importing data from the
past, make sure you provide this argument.context - an object that describes anything that doesn't fit into this
event's properties (such as the user's IP)callback - a callback that is fired when this track's batch is flushed to
the server. Note: this callback is fired on the same thread as
the async event loop that made the request. You should not
perform any kind of long running operation on it.public void flush()
public void close()
public String getWriteKey()
public void setWriteKey(String writeKey)
public Options getOptions()
public AnalyticsStatistics getStatistics()
Copyright © 2014. All Rights Reserved.