Class MessageBuilder<T extends Message,​V extends MessageBuilder>

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      V anonymousId​(java.lang.String anonymousId)
      The Anonymous ID is a pseudo-unique substitute for a User ID, for cases when you don’t have an absolutely unique identifier.
      V anonymousId​(java.util.UUID anonymousId)
      Deprecated.
      Use anonymousId(String) instead.
      T build()
      Create a Message instance.
      V context​(java.util.Map<java.lang.String,​?> context)
      Set a map of information about the state of the device.
      V enableIntegration​(java.lang.String key, boolean enable)
      Set whether this message is sent to the specified integration or not.
      V integrationOptions​(java.lang.String key, java.util.Map<java.lang.String,​?> options)
      Pass in some options that will only be used by the target integration.
      V messageId​(java.lang.String messageId)
      The Message ID is a unique identifier for each message.
      V messageId​(java.util.UUID messageId)
      Deprecated.
      Use messageId(String) instead.
      protected abstract T realBuild​(Message.Type type, java.lang.String messageId, java.util.Date sentAt, java.util.Date timestamp, java.util.Map<java.lang.String,​?> context, java.lang.String anonymousId, java.lang.String userId, java.util.Map<java.lang.String,​java.lang.Object> integrations)  
      V sentAt​(java.util.Date sentAt)
      Set a sentAt for the event.
      V timestamp​(java.util.Date timestamp)
      Set a timestamp for the event.
      Message.Type type()
      Returns the Message.Type of the message this builder is constructing.
      V userId​(java.lang.String userId)
      The User ID is a persistent unique identifier for a user (such as a database ID).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • messageId

        public V messageId​(java.util.UUID messageId)
        Deprecated.
        Use messageId(String) instead.
        The Message ID is a unique identifier for each message. If not provided, one will be generated for you. This ID is typically used for deduping - messages with the same IDs as previous events may be dropped.
        See Also:
        Common Fields
      • messageId

        public V messageId​(java.lang.String messageId)
        The Message ID is a unique identifier for each message. If not provided, one will be generated for you. This ID is typically used for deduping - messages with the same IDs as previous events may be dropped.
        See Also:
        Common Fields
      • sentAt

        public V sentAt​(java.util.Date sentAt)
        Set a sentAt for the event. By default, the current sentAt is used, but you may override it for historical import.
        See Also:
        SentAt
      • timestamp

        public V timestamp​(java.util.Date timestamp)
        Set a timestamp for the event. By default, the current timestamp is used, but you may override it for historical import.
        See Also:
        Timestamp
      • context

        public V context​(java.util.Map<java.lang.String,​?> context)
        Set a map of information about the state of the device. You can add any custom data to the context dictionary that you'd like to have access to in the raw logs.

        Some keys in the context dictionary have semantic meaning and will be collected for you automatically, depending on the library you send data from. Some keys, such as location and speed need to be manually entered.

        See Also:
        Context
      • anonymousId

        public V anonymousId​(java.util.UUID anonymousId)
        Deprecated.
        Use anonymousId(String) instead.
        The Anonymous ID is a pseudo-unique substitute for a User ID, for cases when you don’t have an absolutely unique identifier.
        See Also:
        Identities, Anonymous ID
      • anonymousId

        public V anonymousId​(java.lang.String anonymousId)
        The Anonymous ID is a pseudo-unique substitute for a User ID, for cases when you don’t have an absolutely unique identifier.
        See Also:
        Identities, Anonymous ID
      • userId

        public V userId​(java.lang.String userId)
        The User ID is a persistent unique identifier for a user (such as a database ID).
        See Also:
        Identities, User ID
      • enableIntegration

        public V enableIntegration​(java.lang.String key,
                                   boolean enable)
        Set whether this message is sent to the specified integration or not. 'All' is a special key that applies when no key for a specific integration is found.
        See Also:
        Integrations
      • integrationOptions

        public V integrationOptions​(java.lang.String key,
                                    java.util.Map<java.lang.String,​?> options)
        Pass in some options that will only be used by the target integration. This will implicitly mark the integration as enabled.
        See Also:
        Integrations
      • realBuild

        protected abstract T realBuild​(Message.Type type,
                                       java.lang.String messageId,
                                       java.util.Date sentAt,
                                       java.util.Date timestamp,
                                       java.util.Map<java.lang.String,​?> context,
                                       java.lang.String anonymousId,
                                       java.lang.String userId,
                                       java.util.Map<java.lang.String,​java.lang.Object> integrations)
      • build

        public T build()
        Create a Message instance.
        Throws:
        java.lang.IllegalStateException - if both anonymousId and userId are not provided.