diff --git a/Example/build.gradle b/Example/build.gradle index c061666..020a8cf 100644 --- a/Example/build.gradle +++ b/Example/build.gradle @@ -1,13 +1,13 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 23 - buildToolsVersion "23.0.2" + compileSdkVersion 25 + buildToolsVersion "25.0.1" defaultConfig { applicationId "com.leanplum.android.segment" minSdkVersion 15 - targetSdkVersion 23 + targetSdkVersion 25 versionCode 1 versionName project.bintrayPackageVersion } @@ -17,11 +17,12 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + return Void; } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:23.2.1' + compile 'com.android.support:appcompat-v7:25.1.0' compile 'com.segment.analytics.android:analytics:4.0.4' compile project(':LeanplumIntegration') diff --git a/Example/src/test/java/com/leanplum/segment/LeanplumIntegrationTest.java b/Example/src/test/java/com/leanplum/segment/LeanplumIntegrationTest.java index be914d1..5f8374e 100644 --- a/Example/src/test/java/com/leanplum/segment/LeanplumIntegrationTest.java +++ b/Example/src/test/java/com/leanplum/segment/LeanplumIntegrationTest.java @@ -33,6 +33,8 @@ import static com.segment.analytics.Utils.createTraits; import static org.junit.Assert.*; +import static org.mockito.Matchers.anyDouble; +import static org.mockito.Matchers.anyString; import static org.mockito.MockitoAnnotations.initMocks; import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.when; @@ -99,14 +101,17 @@ public void identify() throws Exception { @Test public void track() throws Exception { Traits traits = createTraits("foo").putEmail("foo@bar.com"); + TrackPayload trackPayload = new TrackPayloadBuilder().traits(traits).build(); - PowerMockito.doNothing().when(Leanplum.class, "track", "", ""); + PowerMockito.doNothing().when(Leanplum.class, "track", anyString(), anyString()); Leanplum.track(trackPayload.event(), trackPayload.properties()); - PowerMockito.verifyStatic(Mockito.times(1)); + trackPayload.properties().putValue(10); + PowerMockito.doNothing().when(Leanplum.class, "track", anyString(), anyDouble(), anyString()); integration.track(trackPayload); + PowerMockito.verifyStatic(Mockito.times(2)); } @Test diff --git a/LeanplumIntegration/build.gradle b/LeanplumIntegration/build.gradle index 5189b44..7e25f3e 100644 --- a/LeanplumIntegration/build.gradle +++ b/LeanplumIntegration/build.gradle @@ -6,12 +6,12 @@ group = project.bintrayGroupId version = project.bintrayPackageVersion android { - compileSdkVersion 23 - buildToolsVersion "23.0.2" + compileSdkVersion 25 + buildToolsVersion "25.0.1" defaultConfig { minSdkVersion 15 - targetSdkVersion 23 + targetSdkVersion 25 versionCode 1 versionName project.bintrayPackageVersion } @@ -21,10 +21,13 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + return Void; } dependencies { + //noinspection GradleDynamicVersion provided 'com.segment.analytics.android:analytics:4.+' + //noinspection GradleDynamicVersion compile 'com.leanplum:Leanplum:+' } diff --git a/LeanplumIntegration/src/main/java/com/leanplum/segment/LeanplumIntegration.java b/LeanplumIntegration/src/main/java/com/leanplum/segment/LeanplumIntegration.java index 1b0861b..66add77 100644 --- a/LeanplumIntegration/src/main/java/com/leanplum/segment/LeanplumIntegration.java +++ b/LeanplumIntegration/src/main/java/com/leanplum/segment/LeanplumIntegration.java @@ -81,7 +81,19 @@ public void identify(final IdentifyPayload identify) { @Override public void track(TrackPayload track) { logger.verbose("Track: %s", track); - Leanplum.track(track.event(), track.properties()); + // Since Leanplum has value field that can be associated with any event, + // we have to extract that field from Segment and send it with our event as a value. + Double value = 0.0D; + + if (track.properties() != null) { + value = track.properties().getDouble("value", 0.0D); + } + + if (value != 0.0D) { + Leanplum.track(track.event(), value, track.properties()); + } else { + Leanplum.track(track.event(), track.properties()); + } } @Override diff --git a/README.md b/README.md index 3624995..2112a7e 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ modules build.gradle file: ```groovy dependencies { compile 'com.segment.analytics.android:analytics:4.0.4' - compile 'com.leanplum.segment:LeanplumIntegration:1.0.0' + compile 'com.leanplum.segment:LeanplumIntegration:1.1.0' } ``` Please add at least the following permissions to your applications AndroidManifest.xml: @@ -65,18 +65,18 @@ analytics.onIntegrationReady(LeanplumIntegration.LEANPLUM_SEGMENT_KEY, We have included a sample application. 1. To run the sample app, open this folder in Android Studio. -2. Choose & run target `Example` +1. Choose & run target `Example` ## Tests We have included unit tests for the integration. 1. To run the unit tests, open this folder in Android Studio. -2. Choose & run target `LeanplumIntegrationTests` +1. Choose & run target `LeanplumIntegrationTests` ## Install Specific Version of SDK's By default this integration pulls in the latest versions of the Leanplum SDK and the Segment SDK. If you rather want to use a specific version, simply exclude them from the integration and specify the required versions in your build.gradle file directly. ```groovy -compile('com.leanplum.segment:LeanplumIntegration:1.0.0') { +compile('com.leanplum.segment:LeanplumIntegration:1.1.0') { exclude group: 'com.segment.analytics.android', module: 'analytics' exclude group: 'com.leanplum', module: 'Leanplum' } @@ -93,18 +93,24 @@ To upload a new version to jCenter or mavenCentral we use bintray.com. bintrayUser=benmarten bintrayApiKey= [...] ``` -3. Increase the package version in gradle.properties project file: +1. Checkout a new release branch from develop: - ```groovy - bintrayPackageVersion=1.0.0 + ```bash + git checkout develop + git checkout -b release/NEW_VERSION + ``` +1. Run the bump version script: + + ```bash + sh bump_version.sh ``` -4. Run gradle build & upload scripts +1. Run gradle build & upload scripts ```bash - ./gradlew install - ./gradlew bintrayUpload + ./gradle install + ./gradle bintrayUpload ``` -5. Go to bintray.com to double check your new release. +1. Go to bintray.com to double check your new release. ## License See LICENSE file. diff --git a/build.gradle b/build.gradle index 5955a93..8839641 100644 --- a/build.gradle +++ b/build.gradle @@ -5,9 +5,9 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.2' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + classpath 'com.android.tools.build:gradle:2.2.3' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } @@ -17,7 +17,7 @@ allprojects { repositories { jcenter() maven { - url "http://www.leanplum.com/leanplum-sdks/" + url "https://repo.leanplum.com/" } } } diff --git a/bump_version.sh b/bump_version.sh new file mode 100644 index 0000000..9fe0a1b --- /dev/null +++ b/bump_version.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash + +set -o errexit +set -o pipefail +set -o nounset +#set -x + +# Set magic variables for current file & dir +__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +__file="${__dir}/$(basename "${BASH_SOURCE[0]}")" +__base="$(basename ${__file} .sh)" +__root="$(cd "$(dirname "${__dir}")" && pwd)" + +echo $__dir + +HR="--------------------------------------------------------------------------------\n" + +# Use colors, but only if connected to a terminal, and that terminal +# supports them. +if which tput >/dev/null 2>&1; then + ncolors=$(tput colors) +fi +if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then + R="$(tput setaf 1)" + G="$(tput setaf 2)" + B="$(tput setaf 4)" + Y="$(tput setaf 3)" + BD="$(tput bold)" + N="$(tput sgr0)" +else + R="" + G="" + B="" + Y="" + BD="" + N="" +fi + +# Ask a Question, https://gist.github.com/davejamesmiller/1965569 +function ask() { + while true; do + if [ "${2:-}" = "Y" ]; then + prompt="Y/n" + default=Y + elif [ "${2:-}" = "N" ]; then + prompt="y/N" + default=N + else + prompt="y/n" + default= + fi + + # Ask the question (not using "read -p" as it uses stderr not stdout) + echo "$1 [$prompt] " + + # Read the answer (use /dev/tty in case stdin is redirected from somewhere else) + read REPLY /dev/null| grep "$(basename "$1")" || { + echo "${R}Error patching version info in file: $__dir/$1${N}" && exit 1 + } + echo "Updated versions in file: $1" +} + +function main() { + read -p "${B}Enter the new version number: ${N}" VERSION_NEW + replace_version "README.md" "{{LP_SEG_VERSION}}" $VERSION_NEW + replace_version "gradle.properties" "{{LP_SEG_VERSION}}" $VERSION_NEW +} + +main diff --git a/gradle.properties b/gradle.properties index 26993c8..0285010 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,7 +20,7 @@ bintrayGroupId=com.leanplum.segment bintrayArtifactId=LeanplumIntegration bintrayPackageName=Leanplum-Segment -bintrayPackageVersion=1.0.1 +bintrayPackageVersion=1.1.0 bintrayDescription=Leanplum SDK integration for the Segment iOS SDK. bintrayGithub=Leanplum/Leanplum-Segment-Android bintrayAuthor=Leanplum Inc. diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 122a0dc..fac1efe 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Dec 28 10:00:20 PST 2015 +#Tue Dec 13 17:25:16 CET 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip