Skip to content

Interfaces

Michael edited this page Sep 4, 2017 · 4 revisions

Overview

Currently, Ganalytics works with two types of interface.

  1. Category Interfaces that produce output events. Example:
interface CategoryInterface {
    fun action()
    fun otherAction(String label)
}

will produce next events:

  • invocation categoryInterface.action() -> category="categoryinterface", action="action"
  • invocation categoryInterface.otherAction("test") -> category="categoryinterface", action="otherAction", label="test"
  1. Group Interfaces that produce Category Interfaces. They have next structure:
interface GroupInterface {
    fun category1(): CategoryInterface1
    fun category2(): CategoryInterface2
}

Category Interfaces

Those types of interfaces are used for producing output events. Here is the summary of annotations that can be used in such interfaces (next will be the list of annotations with scope and brief description):

  1. For interfaces:
  • @Category - explicit denotation of category of all events produced by this interface
  • @Convention - specific naming convention that will be used for formulating output categories and actions produced by this interface
  • @HasPrefix/@NoPrefix - denotation that either all methods of this interface will produce an action with some prefix or none of them will produce any prefixes
  1. For methods:
  • @Action - explicit denotation of action of event produced by this method
  • @HasPrefix/@NoPrefix - denotation that either this method will produce action with some prefix or it is forbidden to produce prefix for that method
  1. For parameters:
  • @Label - explicit designation how input parameter of the method should be converted to output label

Group Interfaces

Those types of interfaces are used for producing Category Interfaces. Here is the summary of annotations that can be used in such interfaces (next will be the list of annotations with scope and brief description):

  1. For interfaces:
  • @Convention - specific naming convention that will be used for formulating output categories and actions produced by all Category Interfaces produced by this Group Interface
  • @HasPrefix/@NoPrefix - denotation that either all methods of all Category Interfaces produced by this interface will produce an action with some prefix or none of them will produce any prefixes
  1. For methods:
  • @Category - explicit denotation of category of all events produced by interface returned from this method
  • @Convention - specific naming convention that will be used for formulating output categories and actions produced by Category Interface returned from this method
  • @HasPrefix/@NoPrefix - denotation that either all methods of Category Interface, returned from this method, will produce an action with some prefix or none of them will produce any prefixes

Note: To be more clear all annotations from Group Interface method will work same as annotation for Category Interface. So the choice where to place, example, @HasPrefix annotation: to category interface or to method of group interface that will return this category interface - will depends on the design and architecture of project.

From (v1.1)

Added supporting of properties. Now, if you have a Group interface like:

interface GroupInterface {
    fun category1(): CategoryInterface1
    fun category2(): CategoryInterface2
}

You can transform it to:

interface SampleGroupInterface {
    val category1: CategoryInterface1 
    val category2: CategoryInterface2 
}

So the invocation will be look like, for example,

groupInterface.category1.action()

instead of

groupInterface.category1().action()

л

Clone this wiki locally