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 class
Analytics.Builder
Fluent API for creatingAnalytics
instances. -
Method Summary
Modifier and Type Method Description static Analytics.Builder
builder(String writeKey)
Start building anAnalytics
instance.void
enqueue(com.segment.analytics.messages.MessageBuilder builder)
Enqueue the given message to be uploaded to Segment's servers.void
flush()
Flush events in the message queue.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, returningtrue
upon success andfalse
if no space is currently available.void
shutdown()
Stops this instance from processing further requests.
-
Method Details
-
builder
Start building anAnalytics
instance.- 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, returningtrue
upon success andfalse
if 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.
-