-
Notifications
You must be signed in to change notification settings - Fork 4
Interfaces
Currently, Ganalytics works with two types of interface.
- 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"
- Group Interfaces that produce Category Interfaces. They have next structure:
interface GroupInterface {
fun category1(): CategoryInterface1
fun category2(): CategoryInterface2
}
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):
- 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
- 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
- For parameters:
-
@Label
- explicit designation how input parameter of the method should be converted to output label
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):
- 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
- 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.
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()
л