Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
benmarten committed Dec 22, 2016
2 parents 49cc27d + b1a8ede commit 17ed593
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 28 deletions.
9 changes: 5 additions & 4 deletions Example/build.gradle
Original file line number Diff line number Diff line change
@@ -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
}
Expand All @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -99,14 +101,17 @@ public void identify() throws Exception {
@Test
public void track() throws Exception {
Traits traits = createTraits("foo").putEmail("[email protected]");

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
Expand Down
9 changes: 6 additions & 3 deletions LeanplumIntegration/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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:+'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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'
}
Expand All @@ -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.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -17,7 +17,7 @@ allprojects {
repositories {
jcenter()
maven {
url "http://www.leanplum.com/leanplum-sdks/"
url "https://repo.leanplum.com/"
}
}
}
Expand Down
86 changes: 86 additions & 0 deletions bump_version.sh
Original file line number Diff line number Diff line change
@@ -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/tty

# Default?
if [ -z "$REPLY" ]; then
REPLY=$default
fi

# Check if the reply is valid
case "$REPLY" in
Y*|y*) return 0 ;;
N*|n*) return 1 ;;
esac
done
}

function replace_version() {
sed -i '' -e "s|$2|$3|g" "$__dir/$1"
env git status --porcelain 2>/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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 17ed593

Please sign in to comment.