Package com.mparticle
Class MPEvent.Builder
- java.lang.Object
-
- com.mparticle.MPEvent.Builder
-
- Enclosing class:
- MPEvent
public static class MPEvent.Builder extends java.lang.Object
Class used to build anMPEvent
object.- See Also:
MParticle.logEvent(BaseEvent)
-
-
Constructor Summary
Constructors Constructor Description Builder(MPEvent event)
Use this to convert an existing MPEvent to a Builder, useful in modifying and duplicating events.Builder(java.lang.String eventName)
Starting point of the builder with two required parameters.Builder(java.lang.String eventName, MParticle.EventType eventType)
Starting point of the builder with two required parameters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description MPEvent.Builder
addCustomFlag(java.lang.String key, java.lang.String value)
Add a custom flag to this event.MPEvent
build()
Create the MPEvent.MPEvent.Builder
category(java.lang.String category)
The Google Analytics category with which to associate this event.MPEvent.Builder
customAttributes(java.util.Map<java.lang.String,java.lang.String> customAttributes)
MPEvent.Builder
customFlags(java.util.Map<java.lang.String,java.util.List<java.lang.String>> customFlags)
Bulk add custom flags to this event.MPEvent.Builder
duration(double durationMillis)
The total length of this event, in milliseconds.MPEvent.Builder
endTime()
Events can have a duration associate with them.MPEvent.Builder
eventName(java.lang.String eventName)
The name of the event to be tracked, required not null.MPEvent.Builder
eventType(MParticle.EventType eventType)
The type of the event to be tracked.MPEvent.Builder
info(java.util.Map<java.lang.String,java.lang.String> info)
Deprecated.usercustomAttributes
instead Data attributes to associate with the event.MPEvent.Builder
internalNavigationDirection(boolean entering)
Beta API, subject to change.static MPEvent.Builder
parseString(java.lang.String builderString)
Use this method to deserialize the result oftoString()
.MPEvent.Builder
shouldUploadEvent(boolean shouldUploadEvent)
Manually choose to skip uploading this event to mParticle server and only forward to kits.MPEvent.Builder
startTime()
Events can have a duration associate with them.java.lang.String
toString()
Use this method to serialize an event builder to persist the object across app sessions.
-
-
-
Constructor Detail
-
Builder
public Builder(@NonNull java.lang.String eventName, @NonNull MParticle.EventType eventType)
Starting point of the builder with two required parameters. The rest of the fields of this class are optional. Once the desired fields have been set, usebuild()
to create theMPEvent
object.- Parameters:
eventName
- the name of the event to be tracked (required)eventType
- the type of the event to be tracked (required)
-
Builder
public Builder(@NonNull java.lang.String eventName)
Starting point of the builder with two required parameters. The rest of the fields of this class are optional. Once the desired fields have been set, usebuild()
to create theMPEvent
object.- Parameters:
eventName
- the name of the event to be tracked (required)
-
Builder
public Builder(@NonNull MPEvent event)
Use this to convert an existing MPEvent to a Builder, useful in modifying and duplicating events.- Parameters:
event
-
-
-
Method Detail
-
eventName
@NonNull public MPEvent.Builder eventName(@NonNull java.lang.String eventName)
The name of the event to be tracked, required not null.- Parameters:
eventName
-- Returns:
- returns this builder for easy method chaining
-
eventType
@NonNull public MPEvent.Builder eventType(@NonNull MParticle.EventType eventType)
The type of the event to be tracked.- Parameters:
eventType
-- Returns:
- returns this builder for easy method chaining
- See Also:
MParticle.EventType
-
addCustomFlag
@NonNull public MPEvent.Builder addCustomFlag(@Nullable java.lang.String key, @Nullable java.lang.String value)
Add a custom flag to this event. Flag keys can have multiple values - if the provided flag key already has an associated value, the value will be appended.- Parameters:
key
- (required) a flag key, retrieve this from the mParticle docs or solution team for your intended services(s)value
- (required) a flag value to be send to the service indicated by the flag key- Returns:
- returns this builder for easy method chaining
-
customFlags
@NonNull public MPEvent.Builder customFlags(@Nullable java.util.Map<java.lang.String,java.util.List<java.lang.String>> customFlags)
Bulk add custom flags to this event. This will replace any flags previously set viaaddCustomFlag(String, String)
- Parameters:
customFlags
- (required) a map containing the custom flags for the MPEvent- Returns:
- returns this builder for easy method chaining
-
category
@NonNull public MPEvent.Builder category(@Nullable java.lang.String category)
The Google Analytics category with which to associate this event.- Parameters:
category
-- Returns:
- returns this builder for easy method chaining
-
duration
@NonNull public MPEvent.Builder duration(double durationMillis)
The total length of this event, in milliseconds. This will overridestartTime(double)
andendTime(double)
.- Parameters:
durationMillis
-- Returns:
- returns this builder for easy method chaining
-
info
@Deprecated @NonNull public MPEvent.Builder info(@Nullable java.util.Map<java.lang.String,java.lang.String> info)
Deprecated.usercustomAttributes
instead Data attributes to associate with the event.- Parameters:
info
-- Returns:
- returns this builder for easy method chaining
-
customAttributes
@NonNull public MPEvent.Builder customAttributes(@Nullable java.util.Map<java.lang.String,java.lang.String> customAttributes)
-
startTime
@NonNull public MPEvent.Builder startTime()
Events can have a duration associate with them. This method will set the start time to the current time. Note that by usingduration(double)
, this value will be ignored.- Returns:
- returns this builder for easy method chaining
-
endTime
@NonNull public MPEvent.Builder endTime()
Events can have a duration associate with them. This method will set the end time to the current time. Note that by usingduration(double)
, this value will be ignored.- Returns:
- returns this builder for easy method chaining
-
internalNavigationDirection
@NonNull public MPEvent.Builder internalNavigationDirection(boolean entering)
Beta API, subject to change. Used internally to signify if a user is entering or exiting a screen.- Parameters:
entering
- True if a user is navigating to a screen, False when navigating away- Returns:
- returns this builder for easy method chaining
-
shouldUploadEvent
@NonNull public MPEvent.Builder shouldUploadEvent(boolean shouldUploadEvent)
Manually choose to skip uploading this event to mParticle server and only forward to kits. Note that if this method is not called, the default is to upload to mParticle as well as forward to kits to match the previous behavior.- Parameters:
shouldUploadEvent
-- Returns:
- returns this builder for easy method chaining
-
build
@NonNull public MPEvent build()
Create the MPEvent. In development mode this method will throw an IllegalStateException if this MPEvent is invalid.- Returns:
- returns the MPEvent object to be logged
- See Also:
MParticle.logEvent(BaseEvent)
-
parseString
@Nullable public static MPEvent.Builder parseString(@NonNull java.lang.String builderString)
Use this method to deserialize the result oftoString()
. This can be used to persist an event object across app sessions.- Parameters:
builderString
- a string originally acquired by callingtoString()
- Returns:
- returns this builder for easy method chaining
-
toString
@NonNull public java.lang.String toString()
Use this method to serialize an event builder to persist the object across app sessions. The JSON string produced by this method should be passed toparseString(String)
.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a JSON object describing this builder
-
-