Package com.segment.analytics
Class Analytics
java.lang.Object
com.segment.analytics.Analytics
public class Analytics extends Object
The entry point into the Segment for Java library.
The idea is simple: one pipeline for all your data. Segment is the single hub to collect, translate and route your data with the flip of a switch.
Analytics for Java will automatically batch events and upload it periodically to Segment's servers for you. You only need to instrument Segment once, then flip a switch to install new tools.
This class is the main entry point into the client API. Use builder(java.lang.String) to construct your
own instances.
- See Also:
- Segment
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAnalytics.BuilderFluent API for creatingAnalyticsinstances. -
Method Summary
Modifier and Type Method Description static Analytics.Builderbuilder(String writeKey)Start building anAnalyticsinstance.voidenqueue(com.segment.analytics.messages.MessageBuilder builder)Enqueue the given message to be uploaded to Segment's servers.voidflush()Flush events in the message queue.booleanoffer(com.segment.analytics.messages.MessageBuilder builder)Inserts the message into queue if it is possible to do so immediately without violating capacity restrictions, returningtrueupon success andfalseif no space is currently available.voidshutdown()Stops this instance from processing further requests.
-
Method Details
-
builder
Start building anAnalyticsinstance.- Parameters:
writeKey- Your project write key available on the Segment dashboard.
-
enqueue
public void enqueue(com.segment.analytics.messages.MessageBuilder builder)Enqueue the given message to be uploaded to Segment's servers. -
offer
public boolean offer(com.segment.analytics.messages.MessageBuilder builder)Inserts the message into queue if it is possible to do so immediately without violating capacity restrictions, returningtrueupon success andfalseif no space is currently available.- Parameters:
builder-
-
flush
public void flush()Flush events in the message queue. -
shutdown
public void shutdown()Stops this instance from processing further requests.
-