Class BatchEventAttributes

java.lang.Object
com.batch.android.BatchEventAttributes

public class BatchEventAttributes extends Object
Object holding attributes to be associated to an event Keys should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
  • Field Details

    • LABEL_KEY

      public static final String LABEL_KEY
      Reserved key used to set a label on events in the install centric data model and activate compatibility flows
      See Also:
    • TAGS_KEY

      public static final String TAGS_KEY
      Reserved key used to set tags on events in the install centric data model and activate compatibility flows
      See Also:
  • Constructor Details

    • BatchEventAttributes

      public BatchEventAttributes()
  • Method Details

    • put

      public BatchEventAttributes put(String key, String value)
      Add a string attribute for the specified key
      Parameters:
      key - Attribute key. Should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
      value - String value to add. Can't be longer than 64 characters, and can't be empty or null. For better results, you should trim/lowercase your strings, and use slugs when possible.
      Returns:
      Same BatchEventAttributes instance, for chaining
    • put

      public BatchEventAttributes put(String key, URI value)
      Add an URL attribute for the specified key
      Parameters:
      key - Attribute key. Should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
      value - URL value to add. Can't be longer than 2048 characters, and can't be empty or null.
      Returns:
      Same BatchEventAttributes instance, for chaining
    • put

      public BatchEventAttributes put(String key, float value)
      Add a float attribute for the specified key
      Parameters:
      key - Attribute key. Should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
      value - Float value to add.
      Returns:
      Same BatchEventAttributes instance, for chaining
    • put

      public BatchEventAttributes put(String key, double value)
      Add a double attribute for the specified key
      Parameters:
      key - Attribute key. Should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
      value - Double value to add.
      Returns:
      Same BatchEventAttributes instance, for chaining
    • put

      public BatchEventAttributes put(String key, int value)
      Add a integer attribute for the specified key
      Parameters:
      key - Attribute key. Should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
      value - Integer value to add.
      Returns:
      Same BatchEventAttributes instance, for chaining
    • put

      public BatchEventAttributes put(String key, long value)
      Add a long attribute for the specified key
      Parameters:
      key - Attribute key. Should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
      value - Long value to add.
      Returns:
      Same BatchEventAttributes instance, for chaining
    • put

      public BatchEventAttributes put(String key, boolean value)
      Add a boolean attribute for the specified key
      Parameters:
      key - Attribute key. Should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
      value - Boolean value to add.
      Returns:
      Same BatchEventAttributes instance, for chaining
    • put

      public BatchEventAttributes put(String key, Date value)
      Add a date attribute for the specified key
      Parameters:
      key - Attribute key. Should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
      value - Date value to add.
      Returns:
      Same BatchEventAttributes instance, for chaining
    • put

      Add an object attribute for the specified key
      Parameters:
      key - Attribute key. Should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
      value - BatchEventAttributes value to add.
      Returns:
      Same BatchEventAttributes instance, for chaining
    • putObjectList

      public BatchEventAttributes putObjectList(String key, List<BatchEventAttributes> value)
      Add a list of object attribute for the specified key
      Parameters:
      key - Attribute key. Should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
      value - A List of BatchEventAttributes value to add.
      Returns:
      Same BatchEventAttributes instance, for chaining
    • putStringList

      public BatchEventAttributes putStringList(String key, List<String> value)
      Add a list of string attribute for the specified key
      Parameters:
      key - Attribute key. Should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
      value - A List of String value to add.
      Returns:
      Same BatchEventAttributes instance, for chaining
    • validateEventAttributes

      public List<String> validateEventAttributes()
      Validate the event data.
      Returns:
      A list of human readable errors as strings if the event data does not validates successfully, An empty list if not. If the data does not validate, Batch will refuse to track an event with it.