Skip to content

Commit dbf0df2

Browse files
authored
Prep for kotlin release 0.10.0 (#38)
* Move code from src/main/java to src/main/kotlin * Update README with Kotlin examples and latest version
1 parent 5057a61 commit dbf0df2

File tree

23 files changed

+35
-32
lines changed

23 files changed

+35
-32
lines changed

README.md

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,79 +5,75 @@ Analytics framework for Android
55
Add the JitPack repository to the end of your root build.gradle:
66
```groovy
77
allprojects {
8-
repositories {
9-
...
10-
maven { url "https://jitpack.io" }
11-
}
12-
}
8+
repositories {
9+
...
10+
maven { url "https://jitpack.io" }
11+
}
12+
}
1313
```
1414

1515
In your module's build.gradle file, add the dependency:
1616
```groovy
1717
dependencies {
18-
implementation "com.github.busybusy.AnalyticsKit-Android:analyticskit:0.8.2"
19-
...
20-
}
18+
implementation "com.github.busybusy.AnalyticsKit-Android:analyticskit:0.10.0"
19+
...
20+
}
2121
```
2222

2323
You can include the implemented providers you want by adding them to the same dependency block:
2424
```groovy
2525
dependencies {
26-
...
27-
implementation "com.github.busybusy.AnalyticsKit-Android:mixpanel-provider:0.8.2"
28-
}
26+
...
27+
implementation "com.github.busybusy.AnalyticsKit-Android:mixpanel-provider:0.10.0"
28+
}
2929
```
3030

3131
## Usage
3232
In your Application's onCreate() method, register your provider SDKs as normal with your API keys.
3333
Then initialize AnalyticsKit-Android to work with those providers.
3434

35-
```java
35+
```kotlin
3636
AnalyticsKit.getInstance()
37-
.registerProvider(new MixpanelProvider(MixpanelAPI.getInstance(this, MIXPANEL_TOKEN)));
37+
.registerProvider(MixpanelProvider(MixpanelAPI.getInstance(this, MIXPANEL_TOKEN)))
3838
```
3939

4040
Send events where appropriate in your application code.
4141

42-
```java
43-
new AnalyticsEvent("Your Event Name")
42+
```kotlin
43+
AnalyticsEvent("Your Event Name")
4444
.putAttribute("key", "value")
45-
.send();
45+
.send()
4646
```
4747

4848
The framework provides a ```ContentViewEvent``` to facilitate capturing content views:
49-
```java
50-
new ContentViewEvent()
49+
```kotlin
50+
ContentViewEvent()
5151
.putAttribute("screen_name", "Dashboard")
5252
.putAttribute("category", "navigation")
53-
.send();
53+
.send()
5454
```
5555

5656
### Event Priorities
5757
By default, AnalyticsEvent objects have priority 0. However, you can
5858
set any integer priority on your events. It is up to you to decide on your priority scheme
5959
and provider filtering.
60-
```java
61-
new AnalyticsEvent("Readme Read Event")
60+
```kotlin
61+
AnalyticsEvent("Readme Read Event")
6262
.putAttribute("read", true)
6363
.setPriority(7)
64-
.send();
64+
.send()
6565
```
6666

6767
By default, providers will log all events regardless of priority. If desired, you can
6868
configure providers with a ```PriorityFilter``` so that only events that pass the
69-
```PriorityFilter```'s shouldLog() filter method will be logged by that provider.
69+
```PriorityFilter```'s shouldLog() filter function will be logged by that provider.
7070
In the following example, only AnalyticsEvent objects with priority less than 10 will be
7171
logged by the Mixpanel provider:
72-
```java
73-
mixpanelProvider.setPriorityFilter(new AnalyticsKitProvider.PriorityFilter()
74-
{
75-
@Override
76-
public boolean shouldLog(int priorityLevel)
77-
{
78-
return priorityLevel < 10;
79-
}
80-
});
72+
```kotlin
73+
myMixpanelApi = MixpanelAPI.getInstance(this, "YOUR MIXPANEL API TOKEN");
74+
val filter = PriorityFilter { priorityLevel -> priorityLevel < 10 }
75+
val filteringProvider = MixpanelProvider(mixpanelApi = myMixpanelApi, priorityFilter = filter)
76+
AnalyticsKit.getInstance().registerProvider(filteringProvider)
8177
```
8278

8379
## License

analyticskit/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ android {
4141
}
4242

4343
sourceSets {
44+
main.java.srcDirs += 'src/main/kotlin'
4445
test.java.srcDirs += 'src/test/kotlin'
4546
}
4647
}

firebase-provider/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ android {
4545
}
4646

4747
sourceSets {
48+
main.java.srcDirs += 'src/main/kotlin'
4849
test.java.srcDirs += 'src/test/kotlin'
4950
}
5051
}

flurry-provider/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ android {
4141
}
4242

4343
sourceSets {
44+
main.java.srcDirs += 'src/main/kotlin'
4445
test.java.srcDirs += 'src/test/kotlin'
4546
}
4647

google-analytics-provider/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ android {
4141
}
4242

4343
sourceSets {
44+
main.java.srcDirs += 'src/main/kotlin'
4445
test.java.srcDirs += 'src/test/kotlin'
4546
}
4647
}

graylog-provider/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ android {
4444
}
4545

4646
sourceSets {
47+
main.java.srcDirs += 'src/main/kotlin'
4748
test.java.srcDirs += 'src/test/kotlin'
4849
}
4950
}

intercom-provider/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ android {
4141
}
4242

4343
sourceSets {
44+
main.java.srcDirs += 'src/main/kotlin'
4445
test.java.srcDirs += 'src/test/kotlin'
4546
}
4647

mixpanel-provider/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ android {
4141
}
4242

4343
sourceSets {
44+
main.java.srcDirs += 'src/main/kotlin'
4445
test.java.srcDirs += 'src/test/kotlin'
4546
}
4647

0 commit comments

Comments
 (0)