Skip to content

Commit

Permalink
Merge pull request #31 from infinum/fix/update-deps
Browse files Browse the repository at this point in the history
Generator refactor and update
  • Loading branch information
bojankoma authored Sep 7, 2020
2 parents 9e4f9ef + f35d004 commit 158932f
Show file tree
Hide file tree
Showing 109 changed files with 990 additions and 758 deletions.
66 changes: 66 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
Change Log
==========

## Version 1.1.6

_2020-09-01_

* **BREAKING**: Removed activity field from Screen class due to Firebase deprecated _setCurrentScreen_ method.
* **BREAKING**: Implement LiveCollector configuration class.
* **BREAKING**: Rename Collar plugin extension parameter _filePath_ to _fileName_.
* Update Kotlin to 1.4.0.
* Update various dependencies.
* Implement latest changes on GeneratorTask.
* Update Gradle wrapper to 6.6.
* Set explicit dependency version for Kotlin Reflect to avoid adding multiple versions resolution.
* Add Javadoc to exposed classes and methods.
* Update KotlinPoet to 1.6.0.
* Update Detekt to 1.11.0.
* Implement redaction feature.
* Replace Moshi with KotlinX Serialization in generators
* Make description optional in generator models
* Make members optional in AnalyticsModel
* Make GenerateTask inherit from SourceTask

## Version 1.1.5

_2020-04-28_
Expand Down
47 changes: 29 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ buildscript {
maven { url "https://dl.bintray.com/infinum/android" }
}
dependencies {
classpath "co.infinum.collar:collar-plugin:1.1.5"
classpath "co.infinum.collar:collar-plugin:1.1.6"
}
}
```
Expand All @@ -46,7 +46,7 @@ buildscript {
maven(url = "https://dl.bintray.com/infinum/android")
}
dependencies {
classpath("co.infinum.collar:collar-plugin:1.1.5")
classpath("co.infinum.collar:collar-plugin:1.1.6")
}
}
```
Expand Down Expand Up @@ -250,28 +250,32 @@ javaCompileOptions {
### Plugin extension
```gradle
collar {
version "1.1.5"
version "1.1.6"
}
```
You can set a specific _Collar_ version to be used.

## Debug UI

![UI](ui.jpg)

A separate package and no-op package is provided if you want to visually track what has been sent through Collar.
You can search, filter and clear all sent analytics.
In your app `build.gradle` or `build.gradle.kts` add:
**Groovy**
```gradle
debugImplementation "co.infinum.collar:collar-ui:1.1.5"
releaseImplementation "co.infinum.collar:collar-ui-no-op:1.1.5"
debugImplementation "co.infinum.collar:collar-ui:1.1.6"
releaseImplementation "co.infinum.collar:collar-ui-no-op:1.1.6"
```
**KotlinDSL**
```kotlin
debugImplementation("co.infinum.collar:collar-ui:1.1.5")
releaseImplementation("co.infinum.collar:collar-ui-no-op:1.1.5")
debugImplementation("co.infinum.collar:collar-ui:1.1.6")
releaseImplementation("co.infinum.collar:collar-ui-no-op:1.1.6")
```

In order to start tracking with UI you must use _LiveCollector_ as in this example:
```kotlin
Collar.attach(object : LiveCollector(true, false) {
Collar.attach(object : LiveCollector() {

override fun onScreen(screen: Screen) =
super.onScreen(screen).run {
Expand All @@ -289,42 +293,49 @@ In order to start tracking with UI you must use _LiveCollector_ as in this examp
}
})
```
If you put the first parameter *showSystemNotification* as *true* in *LiveCollector*, a notification will show once analytics are gathered and clicking on it will open a dedicated screen.
Second parameter *showInAppNotification* with value *true* in *LiveCollector* will show a Snackbar-ish popup once analytics are gathered inside the current running Activity.
_LiveCollector_ constructor has a _Configuration_ parameter that consists of following members.
If you put the first parameter *showSystemNotification* as *true* in *Configuration*, a notification will show once analytics are gathered and clicking on it will open a dedicated screen.
Second parameter *showInAppNotification* with value *true* in *Configuration* will show a Snackbar-ish popup once analytics are gathered inside the current running Activity.
These parameters are default values per collector session but can be changed via _CollarActivity_ menu and will remain valid until the next session.
Otherwise if set to *false* notification will **not** be shown but you can always run the UI with following command of getting the launch Intent:
Otherwise if set to *false* notification will **not** be shown but you can always run the UI with following command of getting the launch Intent instead of clicking the actual notification:
```kotlin
startActivity(
CollarUi.launchIntent().apply {
addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
}
)
```
Also you can use a dedicated method with default Intent setup:
Alternatively, you can use a dedicated method with default Intent setup:
```kotlin
CollarUi.show()
```
Third parameter in *Configuration* is a set of keywords to redact if found in screen names, analytics events names and parameters and user properties names or values.

![Notification](notification.jpg) ![In app notification](in_app_notification.jpg)

### Redaction
In order to prevent potential leaks of user sensitive data, developers have an option to implement a set of keywords to be replaced by a • in length of the matched keyword.
This set of keywords is provided to _LiveCollector_ via _Configuration_.

![Notification](notification.jpg)![UI](ui.jpg)
![Redacted notification](redacted_notification.jpg)![UI](redacted_ui.jpg)

## Tasks
### Generate

Gradle plugin supports code generation from a JSON formatted file.
You will need to specify `filePath` and `packageName` in `collar` plugin extension.
You will need to specify `fileName` and `packageName` in `collar` plugin extension.
For example:

```
collar {
version "1.1.5"
version "1.1.6"
filePath = "example.json"
packageName = "co.infinum.collar.sample.analytics.generated"
variant = "main" // main by default
}
```
JSON file has to be formatted in the same way as it is in `sample` project module.
If you don't want to use this task simply don't specify mandatory data.
Using this file is just a temporary and fetching the tracking plan will be implemented soon in future releases.
If you don't want to use this task simply don't specify data parameters in plugin extension.
Using this file is just a temporary solution and fetching the tracking plan will be implemented soon in future releases.

To run the task you can:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package co.infinum.collar.annotations

/**
* An analytics event name annotation
*
* @property value Holds the actual name of the event. If empty, class name will be taken and formatted into snake case.
* @property enabled Determines if this annotation will be processed or skipped.
* @constructor Default values are provided with an empty value and enabled annotation ready for processing.
*/
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
annotation class EventName(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package co.infinum.collar.annotations

/**
* An event parameter name annotation
*
* @property value Holds the actual name of the event parameter name. If empty, actual field name will be taken.
* @property enabled Determines if this annotation will be processed or skipped.
* @constructor Default values are provided with an empty value and enabled annotation ready for processing.
*/
@Target(AnnotationTarget.FIELD)
@Retention(AnnotationRetention.RUNTIME)
annotation class EventParameterName(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package co.infinum.collar.annotations

/**
* A user property name annotation
*
* @property value Holds the actual name of the user property. If empty, actual field name will be taken.
* @property enabled Determines if this annotation will be processed or skipped.
* @constructor Default values are provided with an empty value and enabled annotation ready for processing.
*/
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.RUNTIME)
annotation class PropertyName(
Expand Down
32 changes: 18 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
"compileSdk": 29,
"targetSdk" : 29,

"buildTools": "29.0.3"
"buildTools": "30.0.1"
]

apply from: "dependencies.gradle"
Expand Down Expand Up @@ -36,19 +36,23 @@ allprojects {
maven { url "https://dl.bintray.com/infinum/android" }
}

// configurations.all {
// resolutionStrategy {
// dependencySubstitution {
// substitute module(packages.collar.annotations) with project(':annotations')
// substitute module(packages.collar.core) with project(':core')
// substitute module(packages.collar.ui) with project(':ui')
// substitute module(packages.collar.ui_no_op) with project(':ui-no-op')
// substitute module(packages.collar.processor) with project(':processor')
// substitute module(packages.collar.generator) with project(':generator')
// substitute module(packages.collar.plugin) with project(':plugin')
// }
// }
// }
def buildProperties = new Properties()
file(rootDir.absolutePath+"/build.properties").withInputStream { buildProperties.load(it) }
if (buildProperties.getProperty("build.debug").toBoolean()) {
configurations.all {
resolutionStrategy {
dependencySubstitution {
substitute module(packages.collar.annotations) with project(':annotations')
substitute module(packages.collar.core) with project(':core')
substitute module(packages.collar.ui) with project(':ui')
substitute module(packages.collar.ui_no_op) with project(':ui-no-op')
substitute module(packages.collar.processor) with project(':processor')
substitute module(packages.collar.generator) with project(':generator')
substitute module(packages.collar.plugin) with project(':plugin')
}
}
}
}
}

subprojects {
Expand Down
1 change: 1 addition & 0 deletions build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build.debug=false
Loading

0 comments on commit 158932f

Please sign in to comment.