Skip to content

Commit

Permalink
Merge pull request #15 from rudderlabs/release/2.3.0
Browse files Browse the repository at this point in the history
chore(release): pulling release/2.3.0 into master
  • Loading branch information
desusai7 committed May 2, 2023
2 parents c2fe02f + 388616e commit 88c21d7
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 15 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Changelog

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [2.3.0](https://github.com/rudderlabs/rudder-integration-appsflyer-android/compare/v0.1.1...v2.3.0) (2023-05-02)


### Features

* add ci/cd ([#10](https://github.com/rudderlabs/rudder-integration-appsflyer-android/issues/10)) ([c2fe02f](https://github.com/rudderlabs/rudder-integration-appsflyer-android/commit/c2fe02fabcce06d2872768cbdb102a7f7fb31984))
* updated to the latest version of appsflyer android sdk 6.9.4 ([dd36221](https://github.com/rudderlabs/rudder-integration-appsflyer-android/commit/dd36221eabb8e278eaa276b15b74186f40895745))
* upgraded to the latest version of appsflyer sdk and added support for new events ([f5259f0](https://github.com/rudderlabs/rudder-integration-appsflyer-android/commit/f5259f0f17618ba9ea51ef1499240736d69d64ae))


### Bug Fixes

* fixed issue with event name mapping ([b3c7c4f](https://github.com/rudderlabs/rudder-integration-appsflyer-android/commit/b3c7c4f679252f7fff5aea9e73969b30867e2618))
5 changes: 3 additions & 2 deletions appsflyer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

// rudder core sdk
implementation 'com.rudderstack.android.sdk:core:[1.8.0,)'
compileOnly 'com.rudderstack.android.sdk:core:[1.12, 2.0)'

// appsflyer dependencies
implementation 'com.appsflyer:af-android-sdk:6.9.4'
implementation 'com.appsflyer:af-android-sdk:[6.10.1, 7.0)'
implementation 'com.android.installreferrer:installreferrer:2.2'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
Expand All @@ -27,8 +28,13 @@
public class AppsFlyerIntegrationFactory extends RudderIntegration<AppsFlyerLib> {
private static final String APPSFLYER_KEY = "AppsFlyer";
private static final String FIRST_PURCHASE = "first_purchase";
public static final String CREATIVE = "creative";
private Boolean isNewScreenEnabled = false;

static final List<String> TRACK_RESERVED_KEYWORDS = Arrays.asList(ECommerceParamNames.QUERY, ECommerceParamNames.PRICE, ECommerceParamNames.PRODUCT_ID, ECommerceParamNames.CATEGORY,
ECommerceParamNames.CURRENCY, ECommerceParamNames.PRODUCTS, ECommerceParamNames.QUANTITY, ECommerceParamNames.TOTAL,
ECommerceParamNames.REVENUE, ECommerceParamNames.ORDER_ID, ECommerceParamNames.SHARE_MESSAGE, CREATIVE, ECommerceParamNames.RATING);

public static RudderIntegration.Factory FACTORY = new Factory() {
@Override
public RudderIntegration<?> create(Object settings, RudderClient client, RudderConfig config) {
Expand All @@ -52,7 +58,7 @@ private AppsFlyerIntegrationFactory(Object config, RudderConfig rudderConfig) {

private void processEvents(RudderMessage message) {
String eventType = message.getType();
String afEventName;
String afEventName = null;
Map<String, Object> afEventProps = new HashMap<>();
if (eventType != null) {
switch (eventType) {
Expand All @@ -64,7 +70,7 @@ private void processEvents(RudderMessage message) {
switch (eventName) {
case ECommerceEvents.PRODUCTS_SEARCHED:
if (property.containsKey(ECommerceParamNames.QUERY)) {
afEventProps.put(AFInAppEventParameterName.SEARCH_STRING, property.get("query"));
afEventProps.put(AFInAppEventParameterName.SEARCH_STRING, property.get(ECommerceParamNames.QUERY));
}
afEventName = AFInAppEventType.SEARCH;
break;
Expand Down Expand Up @@ -100,7 +106,7 @@ private void processEvents(RudderMessage message) {
afEventProps.put(AFInAppEventParameterName.CONTENT_LIST, products.toArray());
}
}
afEventName = "af_list_view";
afEventName = AFInAppEventType.LIST_VIEW;
break;
case ECommerceEvents.PRODUCT_ADDED_TO_WISH_LIST:
if (property.containsKey(ECommerceParamNames.PRICE))
Expand Down Expand Up @@ -141,7 +147,7 @@ private void processEvents(RudderMessage message) {
afEventName = AFInAppEventType.PURCHASE;
break;
case FIRST_PURCHASE:
makeOrderCompletedEvent(property,afEventProps);
makeOrderCompletedEvent(property, afEventProps);
afEventName = FIRST_PURCHASE;
break;
case ECommerceEvents.PRODUCT_REMOVED:
Expand All @@ -151,12 +157,43 @@ private void processEvents(RudderMessage message) {
afEventProps.put(AFInAppEventParameterName.CONTENT_TYPE, property.get(ECommerceParamNames.CATEGORY));
afEventName = "remove_from_cart";
break;
case ECommerceEvents.PROMOTION_VIEWED:
if (property.containsKey(CREATIVE))
afEventProps.put(AFInAppEventParameterName.AD_REVENUE_AD_TYPE, property.get(CREATIVE));
if (property.containsKey(ECommerceParamNames.CURRENCY))
afEventProps.put(AFInAppEventParameterName.CURRENCY, property.get(ECommerceParamNames.CURRENCY));
afEventName = AFInAppEventType.AD_VIEW;
break;
case ECommerceEvents.PROMOTION_CLICKED:
if (property.containsKey(CREATIVE))
afEventProps.put(AFInAppEventParameterName.AD_REVENUE_AD_TYPE, property.get(CREATIVE));
if (property.containsKey(ECommerceParamNames.CURRENCY))
afEventProps.put(AFInAppEventParameterName.CURRENCY, property.get(ECommerceParamNames.CURRENCY));
afEventName = AFInAppEventType.AD_CLICK;
break;
case ECommerceEvents.PAYMENT_INFO_ENTERED:
afEventName = AFInAppEventType.ADD_PAYMENT_INFO;
break;
case ECommerceEvents.PRODUCT_SHARED:
case ECommerceEvents.CART_SHARED:
if (property.containsKey(ECommerceParamNames.SHARE_MESSAGE))
afEventProps.put(AFInAppEventParameterName.DESCRIPTION, property.get(ECommerceParamNames.SHARE_MESSAGE));
afEventName = AFInAppEventType.SHARE;
break;
case ECommerceEvents.PRODUCT_REVIEWED:
if (property.containsKey(ECommerceParamNames.PRODUCT_ID))
afEventProps.put(AFInAppEventParameterName.CONTENT_ID, property.get(ECommerceParamNames.PRODUCT_ID));
if (property.containsKey(ECommerceParamNames.RATING))
afEventProps.put(AFInAppEventParameterName.RATING_VALUE, property.get(ECommerceParamNames.RATING));
afEventName = AFInAppEventType.RATE;
break;
default:
afEventName = eventName.toLowerCase().replace(" ", "_");
}
} else {
afEventName = eventName.toLowerCase().replace(" ", "_");
}
attachAllCustomProperties(afEventProps, property);
AppsFlyerLib.getInstance().logEvent(RudderClient.getApplication(), afEventName, afEventProps);
}
break;
Expand Down Expand Up @@ -191,6 +228,19 @@ private void processEvents(RudderMessage message) {
}
}

private void attachAllCustomProperties(Map<String, Object> afEventProps, Map<String, Object> properties) {
if (properties == null || properties.size() == 0) {
return;
}
for (String key : properties.keySet()) {
Object value = properties.get(key);
if (TRACK_RESERVED_KEYWORDS.contains(key) || TextUtils.isEmpty(key)) {
continue;
}
afEventProps.put(key, value);
}
}

private void makeOrderCompletedEvent(Map<String, Object> eventProperties, Map<String, Object> afEventProps) {
if (eventProperties.containsKey(ECommerceParamNames.TOTAL))
afEventProps.put(AFInAppEventParameterName.PRICE, eventProperties.get(ECommerceParamNames.TOTAL));
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@

VERSION_NAME=2.2.0
VERSION_NAME=2.3.0
android.enableJetifier=true
org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
POM_NAME=Rudder-Integration-AppsFlyer-Android
POM_DESCRIPTION=RudderStack\'s Native SDK Integration support for AppsFlyer.
POM_LICENCE_URL=http://opensource.org/licenses/MIT
POM_DEVELOPER_NAME=Rudderstack, Inc.
kotlin.code.style=official
VERSION_CODE=1
VERSION_CODE=2
POM_LICENCE_DIST=repo
GROUP=com.rudderstack.android.integration
POM_DEVELOPER_ID=Rudderstack
POM_LICENCE_NAME=The MIT License (MIT)
POM_URL=https://github.com/rudderlabs/rudder-integration-appsflyer-android
POM_SCM_URL=https://github.com/rudderlabs/rudder-integration-appsflyer-android/tree/master
POM_SCM_CONNECTION=scm:git:git://github.com/rudderlabs/rudder-integration-appsflyer-android.git
POM_SCM_DEV_CONNECTION=scm:git:git://github.com:rudderlabs/rudder-integration-appsflyer-android.git
POM_SCM_DEV_CONNECTION=scm:git:git://github.com:rudderlabs/rudder-integration-appsflyer-android.git
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
{"version":"2.2.0","dependencies":{"properties-reader":"^2.2.0"}}
{
"version": "2.3.0",
"dependencies": {
"properties-reader": "^2.2.0"
}
}
1 change: 1 addition & 0 deletions sample-kotlin/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/build
local.properties
13 changes: 11 additions & 2 deletions sample-kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,24 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

Properties properties = new Properties()
File localPropertiesFile = new File(project.projectDir, "local.properties")
if (localPropertiesFile.exists()) {
properties.load(localPropertiesFile.newDataInputStream())
}

android {
compileSdkVersion 33
defaultConfig {
applicationId "com.rudderstack.test.android"
applicationId "com.desu.venkat.android"
minSdkVersion 19
targetSdkVersion 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField("String", "DATA_PLANE_URL", properties.getProperty('dataplaneUrl', '\"https://hosted.rudderlabs.com\"'))
buildConfigField("String", "CONTROL_PLANE_URL", properties.getProperty('controlplaneUrl', '\"https://api.rudderstack.com\"'))
buildConfigField("String", "WRITE_KEY", properties.getProperty('writeKey', '\"\"'))
}
buildTypes {
release {
Expand All @@ -43,7 +52,7 @@ dependencies {

implementation 'com.rudderstack.android.sdk:core:1.+'
implementation project(':appsflyer')
implementation 'com.appsflyer:af-android-sdk:6.2.0'
implementation 'com.appsflyer:af-android-sdk:6.10.2'
implementation 'com.android.installreferrer:installreferrer:2.2'
implementation 'com.google.code.gson:gson:2.8.6'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,44 @@ class MainActivity : AppCompatActivity() {
productSharedEvent.event(),
productSharedEvent.properties()
)


val cartSharedEvent = CartSharedEvent()
.withCart(cart)
.withSocialChannel("facebook")
.withShareMessage("some message")
.withRecipient("[email protected]")
MainApplication.rudderClient.track(
cartSharedEvent.event(),
cartSharedEvent.properties()
);

val promotionViewedEvent = PromotionViewedEvent()
.withPromotion(
ECommercePromotion(
"firstPromotion",
"mail",
"launch",
"head"
)
);
MainApplication.rudderClient.track(
promotionViewedEvent.event(),
promotionViewedEvent.properties()
)

val promotionClickedEvent = PromotionClickedEvent()
.withPromotion(
ECommercePromotion(
"firstPromotion",
"mail",
"launch",
"head"
)
)
MainApplication.rudderClient.track(
promotionClickedEvent.event(),
promotionClickedEvent.properties()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class MainApplication : Application() {
AppsFlyerLib.getInstance().start(this);
rudderClient = RudderClient.getInstance(
this,
WRITE_KEY,
BuildConfig.WRITE_KEY,
RudderConfig.Builder()
.withDataPlaneUrl(DATA_PLANE_URL)
.withDataPlaneUrl(BuildConfig.DATA_PLANE_URL)
.withFactory(AppsFlyerIntegrationFactory.FACTORY)
.withLogLevel(RudderLogger.RudderLogLevel.DEBUG)
.build()
Expand Down

0 comments on commit 88c21d7

Please sign in to comment.