Package com.mparticle

Class MPEvent.Builder

    • 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, use build() to create the MPEvent 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, use build() to create the MPEvent 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
      • 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 via addCustomFlag(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 override startTime(double) and endTime(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.
        user customAttributes 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 using duration(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 using duration(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 of toString(). This can be used to persist an event object across app sessions.
        Parameters:
        builderString - a string originally acquired by calling toString()
        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 to parseString(String).
        Overrides:
        toString in class java.lang.Object
        Returns:
        a JSON object describing this builder