Skip to content

Commit 7d744ad

Browse files
Merge pull request #36 from BranchMetrics/INTENG-21514
[INTENG-21514] Fix bug with Marketing Cloud Visitor ID not being included
2 parents ac34e51 + 26776e9 commit 7d744ad

File tree

7 files changed

+166
-39
lines changed

7 files changed

+166
-39
lines changed

AdobeBranchExample/build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
apply plugin: 'com.android.application'
22

33
android {
4+
namespace 'io.branch.adobe.demo'
45
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
56
defaultConfig {
67
applicationId "io.branch.adobe.demo"
@@ -38,10 +39,10 @@ dependencies {
3839
api project(path: ':AdobeBranchExtension')
3940

4041
// Adobe
41-
implementation 'com.adobe.marketing.mobile:analytics:2.0.3'
42-
implementation 'com.adobe.marketing.mobile:userprofile:2.0.1'
43-
implementation 'com.adobe.marketing.mobile:core:2.6.2'
44-
implementation 'com.adobe.marketing.mobile:lifecycle:2.0.4'
45-
implementation 'com.adobe.marketing.mobile:identity:2.0.3'
46-
implementation 'com.adobe.marketing.mobile:signal:2.0.1'
42+
implementation 'com.adobe.marketing.mobile:analytics:3.0.1'
43+
implementation 'com.adobe.marketing.mobile:userprofile:3.0.0'
44+
implementation 'com.adobe.marketing.mobile:core:3.2.0'
45+
implementation 'com.adobe.marketing.mobile:lifecycle:3.0.1'
46+
implementation 'com.adobe.marketing.mobile:identity:3.0.1'
47+
implementation 'com.adobe.marketing.mobile:signal:3.0.0'
4748
}

AdobeBranchExample/src/main/java/io/branch/adobe/demo/DemoApplication.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import io.branch.adobe.extension.AdobeBranchExtension;
1919
import io.branch.referral.Branch;
20+
import io.branch.referral.BranchLogger;
2021
import io.branch.referral.PrefHelper;
2122

2223
public class DemoApplication extends Application {
@@ -27,12 +28,12 @@ public class DemoApplication extends Application {
2728
public void onCreate() {
2829
super.onCreate();
2930

30-
Branch.enableLogging();
31+
Branch.enableLogging(BranchLogger.BranchLogLevel.VERBOSE);
3132

33+
Analytics.setVisitorIdentifier("custom_identifier_1234"); // to test custom visitor ID (key: "vid")
3234

3335
// Initialize
3436
initAdobeBranch();
35-
Analytics.setVisitorIdentifier("custom_identifier_1234"); // to test custom visitor ID (key: "vid")
3637
}
3738

3839
private void initAdobeBranch() {

AdobeBranchExample/src/main/java/io/branch/adobe/demo/SwagActivity.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import androidx.appcompat.app.AppCompatActivity;
1010
import androidx.appcompat.widget.Toolbar;
1111

12-
import com.adobe.marketing.mobile.ExtensionError;
13-
import com.adobe.marketing.mobile.ExtensionErrorCallback;
12+
import com.adobe.marketing.mobile.Extension;
13+
import com.adobe.marketing.mobile.ExtensionHelper;
1414
import com.adobe.marketing.mobile.MobileCore;
1515
import com.google.android.material.floatingactionbutton.FloatingActionButton;
1616
import com.google.android.material.snackbar.Snackbar;
@@ -28,7 +28,7 @@
2828
import io.branch.referral.util.LinkProperties;
2929
import io.branch.referral.util.ShareSheetStyle;
3030

31-
public class SwagActivity extends AppCompatActivity implements View.OnClickListener, ExtensionErrorCallback<ExtensionError> {
31+
public class SwagActivity extends AppCompatActivity implements View.OnClickListener {
3232
private static final String TAG = "Branch::SwagActivity";
3333

3434
public static final String SWAG_DATA = "swag";
@@ -75,21 +75,18 @@ protected void onResume() {
7575

7676
@Override
7777
public void onClick(View view) {
78-
switch (view.getId()) {
79-
case R.id.add_to_cart:
80-
doAddToCart(view);
81-
break;
82-
83-
case R.id.purchase:
84-
doPurchase(view);
85-
break;
78+
int id = view.getId();
79+
if (id == R.id.add_to_cart) {
80+
doAddToCart(view);
81+
} else if (id == R.id.purchase) {
82+
doPurchase(view);
8683
}
8784
}
88-
89-
@Override
90-
public void error(final ExtensionError extensionError) {
91-
Log.e(TAG, String.format("An error occurred while dispatching event %d %s", extensionError.getErrorCode(), extensionError.getErrorName()));
92-
}
85+
86+
//
87+
// public void error(final ExtensionError extensionError) {
88+
// Log.e(TAG, String.format("An error occurred while dispatching event %d %s", extensionError.getErrorCode(), extensionError.getErrorName()));
89+
// }
9390

9491

9592
private void init(String swagData) {

AdobeBranchExtension/build.gradle

Lines changed: 135 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1-
apply plugin: 'com.android.library'
1+
plugins {
2+
id 'com.android.library'
3+
id 'maven-publish'
4+
id 'signing'
5+
}
26

37
android {
8+
namespace 'io.branch.adobe.extension'
9+
10+
buildFeatures {
11+
buildConfig = true
12+
}
13+
414
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
515

616
defaultConfig {
@@ -14,11 +24,21 @@ android {
1424
}
1525

1626
buildTypes {
27+
debug {
28+
enableUnitTestCoverage = true
29+
enableAndroidTestCoverage = true
30+
buildConfigField "long", "VERSION_CODE", project.VERSION_CODE
31+
buildConfigField "String", "VERSION_NAME", "\"${project.VERSION_NAME}\""
32+
}
33+
1734
release {
1835
minifyEnabled false
1936
consumerProguardFile('proguard-rules.pro')
37+
buildConfigField "long", "VERSION_CODE", project.VERSION_CODE
38+
buildConfigField "String", "VERSION_NAME", "\"${project.VERSION_NAME}\""
2039
}
2140
}
41+
2242
compileOptions {
2343
sourceCompatibility JavaVersion.VERSION_1_8
2444
targetCompatibility JavaVersion.VERSION_1_8
@@ -36,21 +56,127 @@ dependencies {
3656
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
3757

3858
// Branch
39-
api 'io.branch.sdk.android:library:5.11.0'
59+
api 'io.branch.sdk.android:library:5.13.0'
4060
implementation ('com.google.android.gms:play-services-ads-identifier:17.0.0')
4161
// for Huawei devices without GMS, adding it requires bumping up min api level to 19 though, so we
4262
// leave it up to the client to add it following Branch documentation here: https://help.branch.io/developers-hub/docs/android-basic-integration
4363
//implementation 'com.huawei.hms:ads-identifier:3.4.28.305'
4464

4565
// Adobe
46-
androidTestImplementation 'com.adobe.marketing.mobile:analytics:2.0.3'
47-
androidTestImplementation 'com.adobe.marketing.mobile:userprofile:2.0.1'
48-
implementation 'com.adobe.marketing.mobile:core:2.6.2'
49-
implementation 'com.adobe.marketing.mobile:lifecycle:2.0.4'
50-
implementation 'com.adobe.marketing.mobile:identity:2.0.3'
51-
implementation 'com.adobe.marketing.mobile:signal:2.0.1'
66+
androidTestImplementation 'com.adobe.marketing.mobile:analytics:3.0.1'
67+
androidTestImplementation 'com.adobe.marketing.mobile:userprofile:3.0.0'
68+
implementation 'com.adobe.marketing.mobile:core:3.2.0'
69+
implementation 'com.adobe.marketing.mobile:lifecycle:3.0.1'
70+
implementation 'com.adobe.marketing.mobile:identity:3.0.1'
71+
implementation 'com.adobe.marketing.mobile:signal:3.0.0'
5272

5373
androidTestImplementation project(path: ':AdobeBranchExtension')
5474
}
5575

56-
apply from: 'https://raw.githubusercontent.com/BranchMetrics/GradleToMavenOptionalDependencies/master/gradle-maven-push.gradle'
76+
def isReleaseBuild() {
77+
return !VERSION_NAME.contains("SNAPSHOT")
78+
}
79+
80+
def getReleaseRepositoryUrl() {
81+
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
82+
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
83+
}
84+
85+
def getSnapshotRepositoryUrl() {
86+
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
87+
: "https://oss.sonatype.org/content/repositories/snapshots/"
88+
}
89+
90+
def getRepositoryUsername() {
91+
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
92+
}
93+
94+
def getRepositoryPassword() {
95+
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
96+
}
97+
98+
publishing {
99+
publications {
100+
mavenJava(MavenPublication) {
101+
from components.findByName('release')
102+
groupId = GROUP
103+
artifactId = POM_ARTIFACT_ID
104+
version = VERSION_NAME
105+
106+
// // Attach sources and Javadocs
107+
// artifact androidSourcesJar
108+
// artifact androidJavadocsJar
109+
110+
// Configure POM
111+
pom {
112+
name.set(POM_NAME)
113+
description.set(POM_DESCRIPTION)
114+
url.set(POM_URL)
115+
packaging = POM_PACKAGING
116+
117+
scm {
118+
url.set(POM_SCM_URL)
119+
connection.set(POM_SCM_CONNECTION)
120+
developerConnection.set(POM_SCM_DEV_CONNECTION)
121+
}
122+
123+
licenses {
124+
license {
125+
name.set(POM_LICENCE_NAME)
126+
url.set(POM_LICENCE_URL)
127+
distribution.set(POM_LICENCE_DIST)
128+
}
129+
}
130+
131+
developers {
132+
developer {
133+
id.set(POM_DEVELOPER_ID)
134+
name.set(POM_DEVELOPER_NAME)
135+
}
136+
}
137+
138+
// Optional dependencies
139+
withXml {
140+
asNode().dependencies.dependency.findAll {
141+
it.artifactId.text() == 'okhttp' || it.artifactId.text() == 'firebase-appindexing'
142+
}.each {
143+
if (it.optional)
144+
it.optional.value = 'true'
145+
else
146+
it.appendNode('optional', 'true')
147+
}
148+
}
149+
}
150+
}
151+
}
152+
153+
repositories {
154+
maven {
155+
url = isReleaseBuild() ? getReleaseRepositoryUrl() : getSnapshotRepositoryUrl()
156+
credentials {
157+
username = getRepositoryUsername()
158+
password = getRepositoryPassword()
159+
}
160+
}
161+
}
162+
}
163+
164+
signing {
165+
useGpgCmd()
166+
sign publishing.publications.mavenJava
167+
}
168+
169+
task androidSourcesJar(type: Jar) {
170+
archiveClassifier.set("sources")
171+
from android.sourceSets.main.java.srcDirs
172+
}
173+
174+
task androidJavadocs(type: Javadoc) {
175+
source = android.sourceSets.main.java.srcDirs
176+
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
177+
}
178+
179+
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
180+
archiveClassifier.set("javadoc")
181+
from androidJavadocs.destinationDir
182+
}

AdobeBranchExtension/src/main/java/io/branch/adobe/extension/AdobeBranchExtension.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,12 @@ private void handleSharedStateEvent(final Event event) {
193193
if (ADOBE_ANALYTICS_EXTENSION.equals(stateowner)) {
194194
extensionSharedState = getApi().getSharedState(ADOBE_ANALYTICS_EXTENSION, event, true, resolution);
195195
} else if (ADOBE_IDENTITY_EXTENSION.equals(stateowner)) {
196-
extensionSharedState = getApi().getSharedState(ADOBE_ANALYTICS_EXTENSION, event, true, resolution);
196+
extensionSharedState = getApi().getSharedState(ADOBE_IDENTITY_EXTENSION, event, true, resolution);
197197
}
198198

199199
if (extensionSharedState != null) {
200200
for (Map.Entry<String, Object> entry : extensionSharedState.getValue().entrySet()) {
201-
BranchLogger.d(String.format("identity extension shared state = %s", extensionSharedState));
201+
BranchLogger.d(String.format("identity extension shared state = %s", entry.toString()));
202202

203203
Object value = entry.getValue();
204204
if (value == null) continue;
@@ -209,15 +209,18 @@ private void handleSharedStateEvent(final Event event) {
209209
switch (key) {
210210
case IDENTITY_ID:
211211
// pass Adobe Experience Cloud ID (https://app.gitbook.com/@aep-sdks/s/docs/using-mobile-extensions/mobile-core/identity/identity-api-reference#getExperienceCloudIdTitle)
212+
BranchLogger.d(TAG + "Setting Branch Request Metadata's $marketing_cloud_visitor_id to Adobe Experience Cloud ID: " + valueAsString);
212213
branch.setRequestMetadata("$marketing_cloud_visitor_id", valueAsString);
213214
break;
214215
case ANALYTICS_VISITOR_ID:
215216
// pass Adobe Custom Visitor ID (https://aep-sdks.gitbook.io/docs/using-mobile-extensions/adobe-analytics/analytics-api-reference#getvisitoridentifier)
217+
BranchLogger.d(TAG + "Setting Branch Request Metadata's $analytics_visitor_id to Adobe Custom Visitor ID: " + valueAsString);
216218
branch.setRequestMetadata("$analytics_visitor_id", valueAsString);
217219
break;
218220
case ANALYTICS_TRACKING_ID:
219221
// pass Adobe Tracking ID (https://aep-sdks.gitbook.io/docs/using-mobile-extensions/adobe-analytics/analytics-api-reference#gettrackingidentifier)
220222
// if MARKETING_CLOUD_VISITOR_ID is set this will always be null unless the Adobe Launch client set a grace period to support both IDs (https://docs.adobe.com/content/help/en/id-service/using/implementation/setup-analytics.html#:~:text=Grace%20periods%20can%20run%20for,a%20grace%20period%20if%20required.&text=You%20need%20a%20grace%20period,the%20same%20Analytics%20report%20suite.)
223+
BranchLogger.d(TAG + "Setting Branch Request Metadata's $adobe_visitor_id to Adobe Tracking ID: " + valueAsString);
221224
branch.setRequestMetadata("$adobe_visitor_id", valueAsString);
222225
break;
223226
}

build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
54
repositories {
65
google()
76
mavenCentral()
@@ -10,7 +9,7 @@ buildscript {
109
}
1110
}
1211
dependencies {
13-
classpath 'com.android.tools.build:gradle:3.5.1'
12+
classpath "com.android.tools.build:gradle:8.3.2"
1413

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

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ BUILD_TOOLS_VERSION=30.0.2
3535
SUPPORT_LIB_VERSION=26.0.0
3636

3737
ANDROID_BUILD_TARGET_SDK_MINIMUM=21
38-
ANDROID_BUILD_TARGET_SDK_VERSION=32
38+
ANDROID_BUILD_TARGET_SDK_VERSION=34
3939
ANDROID_BUILD_TOOLS_VERSION=30.0.2
40-
ANDROID_BUILD_SDK_VERSION=32
40+
ANDROID_BUILD_SDK_VERSION=34
4141

4242
android.useAndroidX=true
4343
android.enableJetifier=true

0 commit comments

Comments
 (0)