Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gouyelliot committed Oct 29, 2019
0 parents commit e92d981
Show file tree
Hide file tree
Showing 20 changed files with 1,218 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.iml
.gradle
/local.properties
.DS_Store
/build
/captures
.externalNativeBuild
.cxx

/.idea/*
!/.idea/runConfigurations/
14 changes: 14 additions & 0 deletions .idea/runConfigurations/dispatcher_test.xml

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

29 changes: 29 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
google()
jcenter()

}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
1 change: 1 addition & 0 deletions google-analytics-dispatcher/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
59 changes: 59 additions & 0 deletions google-analytics-dispatcher/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"

defaultConfig {
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

flavorDimensions "target-backend"

productFlavors {
production {
dimension "target-backend"
}

staging {
dimension "target-backend"
}
}

testOptions {
unitTests {
includeAndroidResources = true
}
}

}

dependencies {
api(name:'Batch', ext:'aar')
//api 'com.batch.android:batch-sdk:[1.15,)' TODO remove aar and use maven repo after 1.15 release
api 'androidx.annotation:annotation:1.1.0'
api 'com.google.android.gms:play-services-analytics:17.0.0'

testImplementation 'junit:junit:4.12'
testImplementation 'androidx.test.ext:junit:1.1.1'
testImplementation 'org.mockito:mockito-core:2.25.1'
testImplementation 'org.robolectric:robolectric:4.3'
testImplementation 'androidx.test.espresso:espresso-core:3.2.0'

// We use PowerMock to mock GoogleAnalytics in tests
testImplementation 'org.powermock:powermock-module-junit4:2.0.2'
testImplementation 'org.powermock:powermock-module-junit4-rule:2.0.2'
testImplementation 'org.powermock:powermock-api-mockito2:2.0.2'
testImplementation 'org.powermock:powermock-classloading-xstream:2.0.2'
}
Empty file.
Binary file added google-analytics-dispatcher/libs/Batch.aar
Binary file not shown.
21 changes: 21 additions & 0 deletions google-analytics-dispatcher/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
15 changes: 15 additions & 0 deletions google-analytics-dispatcher/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.batch.android.dispatcher.googleanalytics">

<application>
<service
android:name="com.batch.android.eventdispatcher.DispatcherDiscoveryService"
android:exported="false">
<meta-data
android:name="com.batch.android.eventdispatcher:com.batch.android.dispatcher.googleanalytics.GoogleAnalyticsRegistrar"
android:value="com.batch.android.eventdispatcher.DispatcherRegistrar" />
</service>
</application>

</manifest>

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.batch.android.dispatcher.googleanalytics;

import com.google.android.gms.analytics.HitBuilders;

public class BatchEventBuilder extends HitBuilders.EventBuilder {

/**
* Google Analytics internal UTM tag keys
*/
private static final String SOURCE = "&cs";
private static final String MEDIUM = "&cm";
private static final String CAMPAIGN = "&cn";
private static final String CONTENT = "&cc";

public BatchEventBuilder setCampaignSource(String source) {
if (source != null) {
this.set(SOURCE, source);
}
return this;
}

public BatchEventBuilder setCampaignMedium(String medium) {
if (medium != null) {
this.set(MEDIUM, medium);
}
return this;
}

public BatchEventBuilder setCampaignContent(String content) {
if (content != null) {
this.set(CONTENT, content);
}
return this;
}

public BatchEventBuilder setCampaignName(String name) {
if (name != null) {
this.set(CAMPAIGN, name);
}
return this;
}

}
Loading

0 comments on commit e92d981

Please sign in to comment.