From 397572b92b7570f3dbc95e484c6707f86ae138a2 Mon Sep 17 00:00:00 2001 From: Mahdi ZTD Date: Tue, 28 May 2024 13:41:02 +0200 Subject: [PATCH 1/7] refac:refactor setUrlStrategy and dataResidency remove UrlStrategy Constants remove DataResidency Constants rename URL_CHINA to URL_WORLD --- .../adjust/examples/GlobalApplication.java | 10 + .../main/assets/AdjustExample-WebView.html | 2 + .../java/com/adjust/sdk/ActivityHandler.java | 14 +- .../java/com/adjust/sdk/AdjustConfig.java | 36 ++-- .../main/java/com/adjust/sdk/Constants.java | 5 + .../sdk/network/ActivityPackageSender.java | 7 +- .../com/adjust/sdk/network/UrlStrategy.java | 190 +++++++----------- .../src/main/assets/adjust_config.js | 9 + .../sdk/webbridge/AdjustBridgeInstance.java | 17 ++ 9 files changed, 149 insertions(+), 141 deletions(-) diff --git a/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java b/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java index 7c94a43bd..852fa8cf5 100644 --- a/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java +++ b/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java @@ -26,6 +26,9 @@ import com.adjust.sdk.OnSessionTrackingFailedListener; import com.adjust.sdk.OnSessionTrackingSucceededListener; +import java.util.ArrayList; +import java.util.List; + /** * Created by pfms on 17/12/14. */ @@ -62,6 +65,13 @@ public void onFinishedEventTrackingSucceeded(AdjustEventSuccess eventSuccessResp } }); + List urlStrategy = new ArrayList<>(); + urlStrategy.add("adjust.com"); + urlStrategy.add("adjust.cn"); + urlStrategy.add("eu.adjust.com"); + + config.setUrlStrategy(urlStrategy , false, false); + // Set event failure tracking delegate. config.setOnEventTrackingFailedListener(new OnEventTrackingFailedListener() { @Override diff --git a/Adjust/example-app-webbridge/src/main/assets/AdjustExample-WebView.html b/Adjust/example-app-webbridge/src/main/assets/AdjustExample-WebView.html index ca50acab6..bca5cfab1 100755 --- a/Adjust/example-app-webbridge/src/main/assets/AdjustExample-WebView.html +++ b/Adjust/example-app-webbridge/src/main/assets/AdjustExample-WebView.html @@ -72,6 +72,8 @@

Adjust Web View SDK Demo adjustConfig.setSessionFailureCallback(sessionFailureCallback); adjustConfig.setDeferredDeeplinkCallback(deferredDeeplinkCallback); + + Adjust.initSdk(adjustConfig); window.onload = function() { diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java index eca861816..41791ce66 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java @@ -952,6 +952,7 @@ public void run() { IActivityPackageSender packageHandlerActivitySender = new ActivityPackageSender( adjustConfig.urlStrategy, + adjustConfig.useSubdomains, adjustConfig.basePath, adjustConfig.gdprPath, adjustConfig.subscriptionPath, @@ -967,6 +968,7 @@ public void run() { IActivityPackageSender attributionHandlerActivitySender = new ActivityPackageSender( adjustConfig.urlStrategy, + adjustConfig.useSubdomains, adjustConfig.basePath, adjustConfig.gdprPath, adjustConfig.subscriptionPath, @@ -982,6 +984,7 @@ public void run() { IActivityPackageSender sdkClickHandlerActivitySender = new ActivityPackageSender( adjustConfig.urlStrategy, + adjustConfig.useSubdomains, adjustConfig.basePath, adjustConfig.gdprPath, adjustConfig.subscriptionPath, @@ -997,6 +1000,7 @@ public void run() { IActivityPackageSender purchaseVerificationHandlerActivitySender = new ActivityPackageSender( adjustConfig.urlStrategy, + adjustConfig.useSubdomains, adjustConfig.basePath, adjustConfig.gdprPath, adjustConfig.subscriptionPath, @@ -2496,10 +2500,12 @@ private void verifyPurchaseI(final AdjustPurchase purchase, final OnPurchaseVeri return; } // from this moment on we know that we can ping client callback in case of error - if (adjustConfig.urlStrategy != null && - (adjustConfig.urlStrategy.equals(AdjustConfig.DATA_RESIDENCY_EU) || - adjustConfig.urlStrategy.equals(AdjustConfig.DATA_RESIDENCY_US) || - adjustConfig.urlStrategy.equals(AdjustConfig.DATA_RESIDENCY_TR))) { +// if (adjustConfig.urlStrategy != null && +// (adjustConfig.urlStrategy.equals(AdjustConfig.DATA_RESIDENCY_EU) || +// adjustConfig.urlStrategy.equals(AdjustConfig.DATA_RESIDENCY_US) || +// adjustConfig.urlStrategy.equals(AdjustConfig.DATA_RESIDENCY_TR))) { +// + if (adjustConfig.isDataResidency != null && adjustConfig.isDataResidency) { logger.warn("Purchase verification not available for data residency users right now"); return; } diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java index 04d5c6cd9..a47e6c9f2 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java @@ -3,6 +3,7 @@ import android.content.Context; import java.util.ArrayList; +import java.util.List; /** * Created by pfms on 06/11/14. @@ -34,7 +35,9 @@ public class AdjustConfig { String externalDeviceId; boolean preinstallTrackingEnabled; Boolean needsCost; - String urlStrategy; + List urlStrategy; + Boolean useSubdomains; + Boolean isDataResidency; String preinstallFilePath; String fbAppId; boolean shouldReadDeviceIdsOnce; @@ -46,14 +49,6 @@ public class AdjustConfig { public static final String ENVIRONMENT_SANDBOX = "sandbox"; public static final String ENVIRONMENT_PRODUCTION = "production"; - public static final String URL_STRATEGY_INDIA = "url_strategy_india"; - public static final String URL_STRATEGY_CHINA = "url_strategy_china"; - public static final String URL_STRATEGY_CN = "url_strategy_cn"; - public static final String URL_STRATEGY_CN_ONLY = "url_strategy_cn_only"; - public static final String DATA_RESIDENCY_EU = "data_residency_eu"; - public static final String DATA_RESIDENCY_TR = "data_residency_tr"; - public static final String DATA_RESIDENCY_US = "data_residency_us"; - public AdjustConfig(Context context, String appToken, String environment) { init(context, appToken, environment, false); } @@ -164,21 +159,20 @@ public boolean isValid() { return true; } - public void setUrlStrategy(String urlStrategy) { - if (urlStrategy == null || urlStrategy.isEmpty()) { + public void setUrlStrategy(List domains, Boolean useSubdomains ,Boolean isDataResidency) { + if (domains == null || domains.isEmpty()) { logger.error("Invalid url strategy"); return; } - if (!urlStrategy.equals(URL_STRATEGY_INDIA) - && !urlStrategy.equals(URL_STRATEGY_CHINA) - && !urlStrategy.equals(URL_STRATEGY_CN) - && !urlStrategy.equals(URL_STRATEGY_CN_ONLY) - && !urlStrategy.equals(DATA_RESIDENCY_EU) - && !urlStrategy.equals(DATA_RESIDENCY_TR) - && !urlStrategy.equals(DATA_RESIDENCY_US)) { - logger.warn("Unrecognised url strategy %s", urlStrategy); + if (useSubdomains == null) { + useSubdomains = false; + } + if (isDataResidency == null) { + isDataResidency = false; } - this.urlStrategy = urlStrategy; + this.urlStrategy = domains; + this.useSubdomains = useSubdomains; + this.isDataResidency = isDataResidency; } public void readDeviceIdsOnce() { @@ -297,7 +291,7 @@ public Boolean getNeedsCost() { return needsCost; } - public String getUrlStrategy() { + public List getUrlStrategy() { return urlStrategy; } diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/Constants.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/Constants.java index 571153fbc..90e8ffee0 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/Constants.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/Constants.java @@ -28,6 +28,11 @@ public interface Constants { String SUBSCRIPTION_URL = "https://subscription.adjust.com"; String PURCHASE_VERIFICATION_URL = "https://ssrv.adjust.com"; + String BASE_URL_FORMAT = "https://app.%s"; + String GDPR_URL_FORMAT = "https://gdpr.%s"; + String SUBSCRIPTION_URL_FORMAT = "https://subscription.%s"; + String PURCHASE_VERIFICATION_URL_FORMAT = "https://ssrv.%s"; + String SCHEME = "https"; String AUTHORITY = "app.adjust.com"; String CLIENT_SDK = "android5.0.0"; diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/ActivityPackageSender.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/ActivityPackageSender.java index 759a5ece3..89a1064cf 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/ActivityPackageSender.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/ActivityPackageSender.java @@ -35,6 +35,7 @@ import java.net.URLEncoder; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; import javax.net.ssl.HttpsURLConnection; @@ -54,7 +55,8 @@ public class ActivityPackageSender implements IActivityPackageSender { private IConnectionOptions connectionOptions; private Context context; - public ActivityPackageSender(final String adjustUrlStrategy, + public ActivityPackageSender(final List adjustUrlStrategy, + final Boolean useSubdomains, final String basePath, final String gdprPath, final String subscriptionPath, @@ -76,7 +78,8 @@ public ActivityPackageSender(final String adjustUrlStrategy, AdjustFactory.getGdprUrl(), AdjustFactory.getSubscriptionUrl(), AdjustFactory.getPurchaseVerificationUrl(), - adjustUrlStrategy); + adjustUrlStrategy, + useSubdomains); httpsURLConnectionProvider = AdjustFactory.getHttpsURLConnectionProvider(); connectionOptions = AdjustFactory.getConnectionOptions(); } diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/UrlStrategy.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/UrlStrategy.java index ae434da78..4671972bc 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/UrlStrategy.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/UrlStrategy.java @@ -3,48 +3,16 @@ import com.adjust.sdk.ActivityKind; import com.adjust.sdk.Constants; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; -import static com.adjust.sdk.AdjustConfig.DATA_RESIDENCY_TR; -import static com.adjust.sdk.AdjustConfig.DATA_RESIDENCY_US; -import static com.adjust.sdk.AdjustConfig.URL_STRATEGY_CHINA; -import static com.adjust.sdk.AdjustConfig.URL_STRATEGY_CN; -import static com.adjust.sdk.AdjustConfig.URL_STRATEGY_CN_ONLY; -import static com.adjust.sdk.AdjustConfig.URL_STRATEGY_INDIA; -import static com.adjust.sdk.AdjustConfig.DATA_RESIDENCY_EU; - public class UrlStrategy { - private static final String BASE_URL_INDIA = "https://app.adjust.net.in"; - private static final String GDPR_URL_INDIA = "https://gdpr.adjust.net.in"; - private static final String SUBSCRIPTION_URL_INDIA = "https://subscription.adjust.net.in"; - private static final String PURCHASE_VERIFICATION_URL_INDIA = "https://ssrv.adjust.net.in"; - - private static final String BASE_URL_CHINA = "https://app.adjust.world"; - private static final String GDPR_URL_CHINA = "https://gdpr.adjust.world"; - private static final String SUBSCRIPTION_URL_CHINA = "https://subscription.adjust.world"; - private static final String PURCHASE_VERIFICATION_URL_CHINA = "https://ssrv.adjust.world"; - - private static final String BASE_URL_CN = "https://app.adjust.cn"; - private static final String GDPR_URL_CN = "https://gdpr.adjust.cn"; - private static final String SUBSCRIPTION_URL_CN = "https://subscription.adjust.cn"; - private static final String PURCHASE_VERIFICATION_URL_CN = "https://ssrv.adjust.cn"; - - private static final String BASE_URL_EU = "https://app.eu.adjust.com"; - private static final String GDPR_URL_EU = "https://gdpr.eu.adjust.com"; - private static final String SUBSCRIPTION_URL_EU = "https://subscription.eu.adjust.com"; - private static final String PURCHASE_VERIFICATION_URL_EU = "https://ssrv.eu.adjust.com"; - - private static final String BASE_URL_TR = "https://app.tr.adjust.com"; - private static final String GDPR_URL_TR = "https://gdpr.tr.adjust.com"; - private static final String SUBSCRIPTION_URL_TR = "https://subscription.tr.adjust.com"; - private static final String PURCHASE_VERIFICATION_URL_TR = "https://ssrv.tr.adjust.com"; - - private static final String BASE_URL_US = "https://app.us.adjust.com"; - private static final String GDPR_URL_US = "https://gdpr.us.adjust.com"; - private static final String SUBSCRIPTION_URL_US = "https://subscription.us.adjust.com"; - private static final String PURCHASE_VERIFICATION_URL_US = "https://ssrv.us.adjust.com"; + private static final String BASE_URL_WORLD = "https://app.adjust.world"; + private static final String GDPR_URL_WORLD = "https://gdpr.adjust.world"; + private static final String SUBSCRIPTION_URL_WORLD = "https://subscription.adjust.world"; + private static final String PURCHASE_VERIFICATION_URL_WORLD = "https://ssrv.adjust.world"; private final String baseUrlOverwrite; private final String gdprUrlOverwrite; @@ -64,17 +32,18 @@ public UrlStrategy(final String baseUrlOverwrite, final String gdprUrlOverwrite, final String subscriptionUrlOverwrite, final String purchaseVerificationUrlOverwrite, - final String adjustUrlStrategy) + final List adjustUrlStrategy, + final Boolean useSubdomains) { this.baseUrlOverwrite = baseUrlOverwrite; this.gdprUrlOverwrite = gdprUrlOverwrite; this.subscriptionUrlOverwrite = subscriptionUrlOverwrite; this.purchaseVerificationUrlOverwrite = purchaseVerificationUrlOverwrite; - baseUrlChoicesList = baseUrlChoices(adjustUrlStrategy); - gdprUrlChoicesList = gdprUrlChoices(adjustUrlStrategy); - subscriptionUrlChoicesList = subscriptionUrlChoices(adjustUrlStrategy); - purchaseVerificationUrlChoicesList = purchaseVerificationUrlChoices(adjustUrlStrategy); + baseUrlChoicesList = baseUrlChoices(adjustUrlStrategy, useSubdomains); + gdprUrlChoicesList = gdprUrlChoices(adjustUrlStrategy, useSubdomains); + subscriptionUrlChoicesList = subscriptionUrlChoices(adjustUrlStrategy, useSubdomains); + purchaseVerificationUrlChoicesList = purchaseVerificationUrlChoices(adjustUrlStrategy, useSubdomains); wasLastAttemptSuccess = false; choiceIndex = 0; @@ -154,84 +123,77 @@ public String targetUrlByActivityKind(final ActivityKind activityKind) { } } - private static List baseUrlChoices(final String urlStrategy) { - if (URL_STRATEGY_INDIA.equals(urlStrategy)) { - return Arrays.asList(BASE_URL_INDIA, Constants.BASE_URL); - } else if (URL_STRATEGY_CHINA.equals(urlStrategy)) { - return Arrays.asList(BASE_URL_CHINA, Constants.BASE_URL); - } else if (URL_STRATEGY_CN.equals(urlStrategy)) { - return Arrays.asList(BASE_URL_CN, Constants.BASE_URL); - } else if (URL_STRATEGY_CN_ONLY.equals(urlStrategy)) { - return Arrays.asList(BASE_URL_CN); - } else if (DATA_RESIDENCY_EU.equals(urlStrategy)) { - return Collections.singletonList(BASE_URL_EU); - } else if (DATA_RESIDENCY_TR.equals(urlStrategy)) { - return Collections.singletonList(BASE_URL_TR); - } else if (DATA_RESIDENCY_US.equals(urlStrategy)) { - return Collections.singletonList(BASE_URL_US); - } else { - return Arrays.asList(Constants.BASE_URL, BASE_URL_INDIA, BASE_URL_CHINA); + private static List baseUrlChoices(final List urlStrategy,final Boolean useSubdomains) { + + if (urlStrategy == null || urlStrategy.isEmpty()) { + return Arrays.asList(Constants.BASE_URL, BASE_URL_WORLD); + } + if (useSubdomains != null && useSubdomains){ + List baseUrls = new ArrayList<>(); + for (String url : urlStrategy) { + baseUrls.add(String.format(Constants.BASE_URL_FORMAT, url)); + } + return baseUrls; + }else { + List baseUrls = new ArrayList<>(); + for (String url : urlStrategy) { + baseUrls.add(String.format("https://%s", url)); + } + return baseUrls; } } - private static List gdprUrlChoices(final String urlStrategy) { - if (URL_STRATEGY_INDIA.equals(urlStrategy)) { - return Arrays.asList(GDPR_URL_INDIA, Constants.GDPR_URL); - } else if (URL_STRATEGY_CHINA.equals(urlStrategy)) { - return Arrays.asList(GDPR_URL_CHINA, Constants.GDPR_URL); - } else if (URL_STRATEGY_CN.equals(urlStrategy)) { - return Arrays.asList(GDPR_URL_CN, Constants.GDPR_URL); - } else if (URL_STRATEGY_CN_ONLY.equals(urlStrategy)) { - return Arrays.asList(GDPR_URL_CN); - } else if (DATA_RESIDENCY_EU.equals(urlStrategy)) { - return Collections.singletonList(GDPR_URL_EU); - } else if (DATA_RESIDENCY_TR.equals(urlStrategy)) { - return Collections.singletonList(GDPR_URL_TR); - } else if (DATA_RESIDENCY_US.equals(urlStrategy)) { - return Collections.singletonList(GDPR_URL_US); - } else { - return Arrays.asList(Constants.GDPR_URL, GDPR_URL_INDIA, GDPR_URL_CHINA); + private static List gdprUrlChoices(final List urlStrategy,final Boolean useSubdomains) { + if (urlStrategy == null || urlStrategy.isEmpty()) { + return Arrays.asList(Constants.GDPR_URL, GDPR_URL_WORLD); + } + if (useSubdomains != null && useSubdomains){ + List baseUrls = new ArrayList<>(); + for (String url : urlStrategy) { + baseUrls.add(String.format(Constants.GDPR_URL_FORMAT, url)); + } + return baseUrls; + }else { + List baseUrls = new ArrayList<>(); + for (String url : urlStrategy) { + baseUrls.add(String.format("https://%s", url)); + } + return baseUrls; } } - private static List subscriptionUrlChoices(final String urlStrategy) { - if (URL_STRATEGY_INDIA.equals(urlStrategy)) { - return Arrays.asList(SUBSCRIPTION_URL_INDIA, Constants.SUBSCRIPTION_URL); - } else if (URL_STRATEGY_CHINA.equals(urlStrategy)) { - return Arrays.asList(SUBSCRIPTION_URL_CHINA, Constants.SUBSCRIPTION_URL); - } else if (URL_STRATEGY_CN.equals(urlStrategy)) { - return Arrays.asList(SUBSCRIPTION_URL_CN, Constants.SUBSCRIPTION_URL); - } else if (URL_STRATEGY_CN_ONLY.equals(urlStrategy)) { - return Arrays.asList(SUBSCRIPTION_URL_CN); - } else if (DATA_RESIDENCY_EU.equals(urlStrategy)) { - return Collections.singletonList(SUBSCRIPTION_URL_EU); - } else if (DATA_RESIDENCY_TR.equals(urlStrategy)) { - return Collections.singletonList(SUBSCRIPTION_URL_TR); - } else if (DATA_RESIDENCY_US.equals(urlStrategy)) { - return Collections.singletonList(SUBSCRIPTION_URL_US); - } else { - return Arrays.asList(Constants.SUBSCRIPTION_URL, - SUBSCRIPTION_URL_INDIA, - SUBSCRIPTION_URL_CHINA); + private static List subscriptionUrlChoices(final List urlStrategy,final Boolean useSubdomains) { + if (urlStrategy == null || urlStrategy.isEmpty()) { + return Arrays.asList(Constants.SUBSCRIPTION_URL, SUBSCRIPTION_URL_WORLD); + } + if (useSubdomains != null && useSubdomains){ + List baseUrls = new ArrayList<>(); + for (String url : urlStrategy) { + baseUrls.add(String.format(Constants.SUBSCRIPTION_URL_FORMAT, url)); + } + return baseUrls; + }else { + List baseUrls = new ArrayList<>(); + for (String url : urlStrategy) { + baseUrls.add(String.format("https://%s", url)); + } + return baseUrls; } } - private static List purchaseVerificationUrlChoices(final String urlStrategy) { - if (URL_STRATEGY_INDIA.equals(urlStrategy)) { - return Arrays.asList(PURCHASE_VERIFICATION_URL_INDIA, Constants.PURCHASE_VERIFICATION_URL); - } else if (URL_STRATEGY_CHINA.equals(urlStrategy)) { - return Arrays.asList(PURCHASE_VERIFICATION_URL_CHINA, Constants.PURCHASE_VERIFICATION_URL); - } else if (URL_STRATEGY_CN.equals(urlStrategy)) { - return Arrays.asList(PURCHASE_VERIFICATION_URL_CN, Constants.PURCHASE_VERIFICATION_URL); - } else if (URL_STRATEGY_CN_ONLY.equals(urlStrategy)) { - return Arrays.asList(PURCHASE_VERIFICATION_URL_CN); - } else if (DATA_RESIDENCY_EU.equals(urlStrategy)) { - return Collections.singletonList(PURCHASE_VERIFICATION_URL_EU); - } else if (DATA_RESIDENCY_TR.equals(urlStrategy)) { - return Collections.singletonList(PURCHASE_VERIFICATION_URL_TR); - } else if (DATA_RESIDENCY_US.equals(urlStrategy)) { - return Collections.singletonList(PURCHASE_VERIFICATION_URL_US); - } else { - return Arrays.asList(Constants.PURCHASE_VERIFICATION_URL, - PURCHASE_VERIFICATION_URL_INDIA, - PURCHASE_VERIFICATION_URL_CHINA); + private static List purchaseVerificationUrlChoices(final List urlStrategy,final Boolean useSubdomains) { + if (urlStrategy == null || urlStrategy.isEmpty()) { + return Arrays.asList(Constants.PURCHASE_VERIFICATION_URL, PURCHASE_VERIFICATION_URL_WORLD); + } + if (useSubdomains != null && useSubdomains){ + List baseUrls = new ArrayList<>(); + for (String url : urlStrategy) { + baseUrls.add(String.format(Constants.PURCHASE_VERIFICATION_URL_FORMAT, url)); + } + return baseUrls; + }else { + List baseUrls = new ArrayList<>(); + for (String url : urlStrategy) { + baseUrls.add(String.format("https://%s", url)); + } + return baseUrls; } } } diff --git a/Adjust/sdk-plugin-webbridge/src/main/assets/adjust_config.js b/Adjust/sdk-plugin-webbridge/src/main/assets/adjust_config.js index e6c2133a0..a536c97e2 100644 --- a/Adjust/sdk-plugin-webbridge/src/main/assets/adjust_config.js +++ b/Adjust/sdk-plugin-webbridge/src/main/assets/adjust_config.js @@ -41,6 +41,9 @@ function AdjustConfig(appToken, environment, legacy) { this.deferredDeeplinkCallbackFunction = null; this.fbPixelDefaultEventToken = null; this.fbPixelMapping = []; + this.urlStrategy = []; + this.useSubDomain = null; + this.isDataResidency = null; this.preinstallTrackingEnabled = null; this.preinstallFilePath = null; this.fbAppId = null; @@ -200,6 +203,12 @@ AdjustConfig.prototype.addFbPixelMapping = function(fbEventNameKey, adjEventToke this.fbPixelMapping.push(adjEventTokenValue); }; +AdjustConfig.prototype.setUrlStrategy = function(urlStrategy, useSubDomain , isDataResidency) { + this.urlStrategy = urlStrategy; + this.useSubDomain = useSubDomain; + this.isDataResidency = isDataResidency; +}; + AdjustConfig.prototype.setPreinstallTrackingEnabled = function(preinstallTrackingEnabled) { this.preinstallTrackingEnabled = preinstallTrackingEnabled; }; diff --git a/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java b/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java index 1246316b2..b3b89855e 100644 --- a/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java +++ b/Adjust/sdk-plugin-webbridge/src/main/java/com/adjust/sdk/webbridge/AdjustBridgeInstance.java @@ -36,6 +36,10 @@ import org.json.JSONArray; import org.json.JSONObject; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + /** * Created by uerceg on 22/07/16. */ @@ -162,6 +166,9 @@ public void initSdk(String adjustConfigString) { Object deferredDeeplinkCallbackNameField = jsonAdjustConfig.get("deferredDeeplinkCallbackName"); Object fbPixelDefaultEventTokenField = jsonAdjustConfig.get("fbPixelDefaultEventToken"); Object fbPixelMappingField = jsonAdjustConfig.get("fbPixelMapping"); + Object urlStrategyField = jsonAdjustConfig.get("urlStrategy"); + Object useSubDomainField = jsonAdjustConfig.get("useSubDomain"); + Object isDataResidencyField = jsonAdjustConfig.get("isDataResidency"); Object preinstallTrackingEnabledField = jsonAdjustConfig.get("preinstallTrackingEnabled"); Object preinstallFilePathField = jsonAdjustConfig.get("preinstallFilePath"); Object fbAppIdField = jsonAdjustConfig.get("fbAppId"); @@ -331,6 +338,16 @@ public boolean launchReceivedDeeplink(Uri deeplink) { AdjustFactory.getLogger().error("AdjustBridgeInstance.configureFbPixel: %s", e.getMessage()); } + // Set url strategy + String[] urlStrategyArray = AdjustBridgeUtil.jsonArrayToArray((JSONArray) urlStrategyField); + List urlStrategy = Arrays.asList(urlStrategyArray); + + Boolean useSubDomain = AdjustBridgeUtil.fieldToBoolean(useSubDomainField); + Boolean isDataResidency = AdjustBridgeUtil.fieldToBoolean(isDataResidencyField); + if (urlStrategy != null && !urlStrategy.isEmpty() && useSubDomain != null && isDataResidency != null) { + adjustConfig.setUrlStrategy(urlStrategy,useSubDomain,isDataResidency); + } + // Preinstall tracking Boolean preinstallTrackingEnabled = AdjustBridgeUtil.fieldToBoolean(preinstallTrackingEnabledField); if (preinstallTrackingEnabled != null) { From 52dfa30929d887ed83add4fd914bca58932f8197 Mon Sep 17 00:00:00 2001 From: Mahdi ZTD Date: Tue, 28 May 2024 13:55:17 +0200 Subject: [PATCH 2/7] refac: commenting out the usage of url strategy in example-app --- .../java/com/adjust/examples/GlobalApplication.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java b/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java index 852fa8cf5..e8e8b6e13 100644 --- a/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java +++ b/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java @@ -65,12 +65,12 @@ public void onFinishedEventTrackingSucceeded(AdjustEventSuccess eventSuccessResp } }); - List urlStrategy = new ArrayList<>(); - urlStrategy.add("adjust.com"); - urlStrategy.add("adjust.cn"); - urlStrategy.add("eu.adjust.com"); - - config.setUrlStrategy(urlStrategy , false, false); +// List urlStrategy = new ArrayList<>(); +// urlStrategy.add("adjust.com"); +// urlStrategy.add("adjust.cn"); +// urlStrategy.add("eu.adjust.com"); +// +// config.setUrlStrategy(urlStrategy , true, false); // Set event failure tracking delegate. config.setOnEventTrackingFailedListener(new OnEventTrackingFailedListener() { From 30574449ac9370afce0b3df28d3e7529503b866c Mon Sep 17 00:00:00 2001 From: Mahdi ZTD Date: Tue, 28 May 2024 14:20:25 +0200 Subject: [PATCH 3/7] refac:avoiding of have default value for useSubdomains and isDataResidency flags --- .../main/java/com/adjust/examples/GlobalApplication.java | 3 ++- .../sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java b/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java index e8e8b6e13..3ff7c24c3 100644 --- a/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java +++ b/Adjust/example-app-java/src/main/java/com/adjust/examples/GlobalApplication.java @@ -65,11 +65,12 @@ public void onFinishedEventTrackingSucceeded(AdjustEventSuccess eventSuccessResp } }); + + // Set url strategy // List urlStrategy = new ArrayList<>(); // urlStrategy.add("adjust.com"); // urlStrategy.add("adjust.cn"); // urlStrategy.add("eu.adjust.com"); -// // config.setUrlStrategy(urlStrategy , true, false); // Set event failure tracking delegate. diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java index a47e6c9f2..a225508c7 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java @@ -165,10 +165,12 @@ public void setUrlStrategy(List domains, Boolean useSubdomains ,Boolean return; } if (useSubdomains == null) { - useSubdomains = false; + logger.error("useSubdomains cannot be null"); + return; } if (isDataResidency == null) { - isDataResidency = false; + logger.error("isDataResidency cannot be null"); + return; } this.urlStrategy = domains; this.useSubdomains = useSubdomains; From 14fb95ae229c9f9953f7745aaccca8d8f19d13cd Mon Sep 17 00:00:00 2001 From: Mahdi ZTD Date: Tue, 28 May 2024 14:21:46 +0200 Subject: [PATCH 4/7] refac:avoiding of have default value for useSubdomains and isDataResidency flags --- .../src/main/java/com/adjust/sdk/ActivityHandler.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java index 41791ce66..392bafe21 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java @@ -2500,11 +2500,6 @@ private void verifyPurchaseI(final AdjustPurchase purchase, final OnPurchaseVeri return; } // from this moment on we know that we can ping client callback in case of error -// if (adjustConfig.urlStrategy != null && -// (adjustConfig.urlStrategy.equals(AdjustConfig.DATA_RESIDENCY_EU) || -// adjustConfig.urlStrategy.equals(AdjustConfig.DATA_RESIDENCY_US) || -// adjustConfig.urlStrategy.equals(AdjustConfig.DATA_RESIDENCY_TR))) { -// if (adjustConfig.isDataResidency != null && adjustConfig.isDataResidency) { logger.warn("Purchase verification not available for data residency users right now"); return; From a6d518ceb876677d2fb950e693e8e9192c47e487 Mon Sep 17 00:00:00 2001 From: Mahdi ZTD Date: Tue, 28 May 2024 17:43:05 +0200 Subject: [PATCH 5/7] refac:use primitive boolean for setUrlStrategy clean up the UrlStrategy.java class fire purchaseVerification callback onFail when the isDataResidency is true --- .../java/com/adjust/sdk/ActivityHandler.java | 7 +- .../java/com/adjust/sdk/AdjustConfig.java | 14 +--- .../sdk/network/ActivityPackageSender.java | 2 +- .../com/adjust/sdk/network/UrlStrategy.java | 75 +++++++++---------- 4 files changed, 47 insertions(+), 51 deletions(-) diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java index 392bafe21..45629cb87 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java @@ -2500,8 +2500,13 @@ private void verifyPurchaseI(final AdjustPurchase purchase, final OnPurchaseVeri return; } // from this moment on we know that we can ping client callback in case of error - if (adjustConfig.isDataResidency != null && adjustConfig.isDataResidency) { + if (adjustConfig.isDataResidency) { logger.warn("Purchase verification not available for data residency users right now"); + AdjustPurchaseVerificationResult result = new AdjustPurchaseVerificationResult( + "not_verified", + 109, + "Purchase verification not available for data residency users right now"); + callback.onVerificationFinished(result); return; } if (!checkActivityStateI(activityState)) { diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java index a225508c7..3a1d65cdb 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java @@ -36,8 +36,8 @@ public class AdjustConfig { boolean preinstallTrackingEnabled; Boolean needsCost; List urlStrategy; - Boolean useSubdomains; - Boolean isDataResidency; + boolean useSubdomains; + boolean isDataResidency; String preinstallFilePath; String fbAppId; boolean shouldReadDeviceIdsOnce; @@ -159,19 +159,11 @@ public boolean isValid() { return true; } - public void setUrlStrategy(List domains, Boolean useSubdomains ,Boolean isDataResidency) { + public void setUrlStrategy(List domains, boolean useSubdomains, boolean isDataResidency) { if (domains == null || domains.isEmpty()) { logger.error("Invalid url strategy"); return; } - if (useSubdomains == null) { - logger.error("useSubdomains cannot be null"); - return; - } - if (isDataResidency == null) { - logger.error("isDataResidency cannot be null"); - return; - } this.urlStrategy = domains; this.useSubdomains = useSubdomains; this.isDataResidency = isDataResidency; diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/ActivityPackageSender.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/ActivityPackageSender.java index 89a1064cf..f8449f2ac 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/ActivityPackageSender.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/ActivityPackageSender.java @@ -56,7 +56,7 @@ public class ActivityPackageSender implements IActivityPackageSender { private Context context; public ActivityPackageSender(final List adjustUrlStrategy, - final Boolean useSubdomains, + final boolean useSubdomains, final String basePath, final String gdprPath, final String subscriptionPath, diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/UrlStrategy.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/UrlStrategy.java index 4671972bc..4ca814e0d 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/UrlStrategy.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/UrlStrategy.java @@ -5,7 +5,6 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; public class UrlStrategy { @@ -14,6 +13,9 @@ public class UrlStrategy { private static final String SUBSCRIPTION_URL_WORLD = "https://subscription.adjust.world"; private static final String PURCHASE_VERIFICATION_URL_WORLD = "https://ssrv.adjust.world"; + private final List adjustUrlStrategy; + private final boolean useSubdomains; + private final String baseUrlOverwrite; private final String gdprUrlOverwrite; private final String subscriptionUrlOverwrite; @@ -33,17 +35,20 @@ public UrlStrategy(final String baseUrlOverwrite, final String subscriptionUrlOverwrite, final String purchaseVerificationUrlOverwrite, final List adjustUrlStrategy, - final Boolean useSubdomains) + final boolean useSubdomains) { + this.adjustUrlStrategy = adjustUrlStrategy; + this.useSubdomains = useSubdomains; + this.baseUrlOverwrite = baseUrlOverwrite; this.gdprUrlOverwrite = gdprUrlOverwrite; this.subscriptionUrlOverwrite = subscriptionUrlOverwrite; this.purchaseVerificationUrlOverwrite = purchaseVerificationUrlOverwrite; - baseUrlChoicesList = baseUrlChoices(adjustUrlStrategy, useSubdomains); - gdprUrlChoicesList = gdprUrlChoices(adjustUrlStrategy, useSubdomains); - subscriptionUrlChoicesList = subscriptionUrlChoices(adjustUrlStrategy, useSubdomains); - purchaseVerificationUrlChoicesList = purchaseVerificationUrlChoices(adjustUrlStrategy, useSubdomains); + baseUrlChoicesList = baseUrlChoices(); + gdprUrlChoicesList = gdprUrlChoices(); + subscriptionUrlChoicesList = subscriptionUrlChoices(); + purchaseVerificationUrlChoicesList = purchaseVerificationUrlChoices(); wasLastAttemptSuccess = false; choiceIndex = 0; @@ -123,77 +128,71 @@ public String targetUrlByActivityKind(final ActivityKind activityKind) { } } - private static List baseUrlChoices(final List urlStrategy,final Boolean useSubdomains) { + private List baseUrlChoices() { - if (urlStrategy == null || urlStrategy.isEmpty()) { + if (adjustUrlStrategy == null || adjustUrlStrategy.isEmpty()) { return Arrays.asList(Constants.BASE_URL, BASE_URL_WORLD); } - if (useSubdomains != null && useSubdomains){ + if (useSubdomains) { List baseUrls = new ArrayList<>(); - for (String url : urlStrategy) { + for (String url : adjustUrlStrategy) { baseUrls.add(String.format(Constants.BASE_URL_FORMAT, url)); } return baseUrls; }else { List baseUrls = new ArrayList<>(); - for (String url : urlStrategy) { + for (String url : adjustUrlStrategy) { baseUrls.add(String.format("https://%s", url)); } return baseUrls; } } - private static List gdprUrlChoices(final List urlStrategy,final Boolean useSubdomains) { - if (urlStrategy == null || urlStrategy.isEmpty()) { + private List gdprUrlChoices() { + if (adjustUrlStrategy == null || adjustUrlStrategy.isEmpty()) { return Arrays.asList(Constants.GDPR_URL, GDPR_URL_WORLD); } - if (useSubdomains != null && useSubdomains){ - List baseUrls = new ArrayList<>(); - for (String url : urlStrategy) { + List baseUrls = new ArrayList<>(); + if (useSubdomains) { + for (String url : adjustUrlStrategy) { baseUrls.add(String.format(Constants.GDPR_URL_FORMAT, url)); } - return baseUrls; }else { - List baseUrls = new ArrayList<>(); - for (String url : urlStrategy) { + for (String url : adjustUrlStrategy) { baseUrls.add(String.format("https://%s", url)); } - return baseUrls; } + return baseUrls; } - private static List subscriptionUrlChoices(final List urlStrategy,final Boolean useSubdomains) { - if (urlStrategy == null || urlStrategy.isEmpty()) { + private List subscriptionUrlChoices() { + if (adjustUrlStrategy == null || adjustUrlStrategy.isEmpty()) { return Arrays.asList(Constants.SUBSCRIPTION_URL, SUBSCRIPTION_URL_WORLD); } - if (useSubdomains != null && useSubdomains){ - List baseUrls = new ArrayList<>(); - for (String url : urlStrategy) { + List baseUrls = new ArrayList<>(); + if (useSubdomains) { + for (String url : adjustUrlStrategy) { baseUrls.add(String.format(Constants.SUBSCRIPTION_URL_FORMAT, url)); } - return baseUrls; }else { - List baseUrls = new ArrayList<>(); - for (String url : urlStrategy) { + for (String url : adjustUrlStrategy) { baseUrls.add(String.format("https://%s", url)); } - return baseUrls; } + return baseUrls; } - private static List purchaseVerificationUrlChoices(final List urlStrategy,final Boolean useSubdomains) { - if (urlStrategy == null || urlStrategy.isEmpty()) { + private List purchaseVerificationUrlChoices() { + if (adjustUrlStrategy == null || adjustUrlStrategy.isEmpty()) { return Arrays.asList(Constants.PURCHASE_VERIFICATION_URL, PURCHASE_VERIFICATION_URL_WORLD); } - if (useSubdomains != null && useSubdomains){ - List baseUrls = new ArrayList<>(); - for (String url : urlStrategy) { + List baseUrls = new ArrayList<>(); + if (useSubdomains){ + for (String url : adjustUrlStrategy) { baseUrls.add(String.format(Constants.PURCHASE_VERIFICATION_URL_FORMAT, url)); } - return baseUrls; }else { - List baseUrls = new ArrayList<>(); - for (String url : urlStrategy) { + for (String url : adjustUrlStrategy) { baseUrls.add(String.format("https://%s", url)); } - return baseUrls; } + return baseUrls; } } From 83b12806fc919316a6e54b17c427f0656c3f5193 Mon Sep 17 00:00:00 2001 From: Mahdi ZTD Date: Wed, 29 May 2024 11:08:05 +0200 Subject: [PATCH 6/7] refac:use Constants.java for no subdomain formats --- .../main/java/com/adjust/sdk/Constants.java | 2 ++ .../com/adjust/sdk/network/UrlStrategy.java | 35 ++++++++++++------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/Constants.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/Constants.java index 90e8ffee0..6b3ff6050 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/Constants.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/Constants.java @@ -33,6 +33,8 @@ public interface Constants { String SUBSCRIPTION_URL_FORMAT = "https://subscription.%s"; String PURCHASE_VERIFICATION_URL_FORMAT = "https://ssrv.%s"; + String BASE_URL_NO_SUB_DOMAIN_FORMAT = "https://%s"; + String SCHEME = "https"; String AUTHORITY = "app.adjust.com"; String CLIENT_SDK = "android5.0.0"; diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/UrlStrategy.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/UrlStrategy.java index 4ca814e0d..4f1c73f63 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/UrlStrategy.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/UrlStrategy.java @@ -1,7 +1,16 @@ package com.adjust.sdk.network; +import static com.adjust.sdk.Constants.BASE_URL; +import static com.adjust.sdk.Constants.BASE_URL_FORMAT; +import static com.adjust.sdk.Constants.BASE_URL_NO_SUB_DOMAIN_FORMAT; +import static com.adjust.sdk.Constants.GDPR_URL; +import static com.adjust.sdk.Constants.GDPR_URL_FORMAT; +import static com.adjust.sdk.Constants.PURCHASE_VERIFICATION_URL; +import static com.adjust.sdk.Constants.PURCHASE_VERIFICATION_URL_FORMAT; +import static com.adjust.sdk.Constants.SUBSCRIPTION_URL; +import static com.adjust.sdk.Constants.SUBSCRIPTION_URL_FORMAT; + import com.adjust.sdk.ActivityKind; -import com.adjust.sdk.Constants; import java.util.ArrayList; import java.util.Arrays; @@ -131,66 +140,66 @@ public String targetUrlByActivityKind(final ActivityKind activityKind) { private List baseUrlChoices() { if (adjustUrlStrategy == null || adjustUrlStrategy.isEmpty()) { - return Arrays.asList(Constants.BASE_URL, BASE_URL_WORLD); + return Arrays.asList(BASE_URL, BASE_URL_WORLD); } if (useSubdomains) { List baseUrls = new ArrayList<>(); for (String url : adjustUrlStrategy) { - baseUrls.add(String.format(Constants.BASE_URL_FORMAT, url)); + baseUrls.add(String.format(BASE_URL_FORMAT, url)); } return baseUrls; }else { List baseUrls = new ArrayList<>(); for (String url : adjustUrlStrategy) { - baseUrls.add(String.format("https://%s", url)); + baseUrls.add(String.format(BASE_URL_NO_SUB_DOMAIN_FORMAT, url)); } return baseUrls; } } private List gdprUrlChoices() { if (adjustUrlStrategy == null || adjustUrlStrategy.isEmpty()) { - return Arrays.asList(Constants.GDPR_URL, GDPR_URL_WORLD); + return Arrays.asList(GDPR_URL, GDPR_URL_WORLD); } List baseUrls = new ArrayList<>(); if (useSubdomains) { for (String url : adjustUrlStrategy) { - baseUrls.add(String.format(Constants.GDPR_URL_FORMAT, url)); + baseUrls.add(String.format(GDPR_URL_FORMAT, url)); } }else { for (String url : adjustUrlStrategy) { - baseUrls.add(String.format("https://%s", url)); + baseUrls.add(String.format(BASE_URL_NO_SUB_DOMAIN_FORMAT, url)); } } return baseUrls; } private List subscriptionUrlChoices() { if (adjustUrlStrategy == null || adjustUrlStrategy.isEmpty()) { - return Arrays.asList(Constants.SUBSCRIPTION_URL, SUBSCRIPTION_URL_WORLD); + return Arrays.asList(SUBSCRIPTION_URL, SUBSCRIPTION_URL_WORLD); } List baseUrls = new ArrayList<>(); if (useSubdomains) { for (String url : adjustUrlStrategy) { - baseUrls.add(String.format(Constants.SUBSCRIPTION_URL_FORMAT, url)); + baseUrls.add(String.format(SUBSCRIPTION_URL_FORMAT, url)); } }else { for (String url : adjustUrlStrategy) { - baseUrls.add(String.format("https://%s", url)); + baseUrls.add(String.format(BASE_URL_NO_SUB_DOMAIN_FORMAT, url)); } } return baseUrls; } private List purchaseVerificationUrlChoices() { if (adjustUrlStrategy == null || adjustUrlStrategy.isEmpty()) { - return Arrays.asList(Constants.PURCHASE_VERIFICATION_URL, PURCHASE_VERIFICATION_URL_WORLD); + return Arrays.asList(PURCHASE_VERIFICATION_URL, PURCHASE_VERIFICATION_URL_WORLD); } List baseUrls = new ArrayList<>(); if (useSubdomains){ for (String url : adjustUrlStrategy) { - baseUrls.add(String.format(Constants.PURCHASE_VERIFICATION_URL_FORMAT, url)); + baseUrls.add(String.format(PURCHASE_VERIFICATION_URL_FORMAT, url)); } }else { for (String url : adjustUrlStrategy) { - baseUrls.add(String.format("https://%s", url)); + baseUrls.add(String.format(BASE_URL_NO_SUB_DOMAIN_FORMAT, url)); } } return baseUrls; From fa72ebd8bcb8375470cfb92296516e797d3537e1 Mon Sep 17 00:00:00 2001 From: Mahdi ZTD Date: Wed, 29 May 2024 11:43:42 +0200 Subject: [PATCH 7/7] refac:rename list urlStrategy to urlStrategyDomains --- .../java/com/adjust/sdk/ActivityHandler.java | 8 ++--- .../java/com/adjust/sdk/AdjustConfig.java | 8 ++--- .../sdk/network/ActivityPackageSender.java | 4 +-- .../com/adjust/sdk/network/UrlStrategy.java | 30 +++++++++---------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java index 45629cb87..9b78a73fe 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java @@ -951,7 +951,7 @@ public void run() { IActivityPackageSender packageHandlerActivitySender = new ActivityPackageSender( - adjustConfig.urlStrategy, + adjustConfig.urlStrategyDomains, adjustConfig.useSubdomains, adjustConfig.basePath, adjustConfig.gdprPath, @@ -967,7 +967,7 @@ public void run() { IActivityPackageSender attributionHandlerActivitySender = new ActivityPackageSender( - adjustConfig.urlStrategy, + adjustConfig.urlStrategyDomains, adjustConfig.useSubdomains, adjustConfig.basePath, adjustConfig.gdprPath, @@ -983,7 +983,7 @@ public void run() { IActivityPackageSender sdkClickHandlerActivitySender = new ActivityPackageSender( - adjustConfig.urlStrategy, + adjustConfig.urlStrategyDomains, adjustConfig.useSubdomains, adjustConfig.basePath, adjustConfig.gdprPath, @@ -999,7 +999,7 @@ public void run() { IActivityPackageSender purchaseVerificationHandlerActivitySender = new ActivityPackageSender( - adjustConfig.urlStrategy, + adjustConfig.urlStrategyDomains, adjustConfig.useSubdomains, adjustConfig.basePath, adjustConfig.gdprPath, diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java index 3a1d65cdb..d9e103b6c 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java @@ -35,7 +35,7 @@ public class AdjustConfig { String externalDeviceId; boolean preinstallTrackingEnabled; Boolean needsCost; - List urlStrategy; + List urlStrategyDomains; boolean useSubdomains; boolean isDataResidency; String preinstallFilePath; @@ -164,7 +164,7 @@ public void setUrlStrategy(List domains, boolean useSubdomains, boolean logger.error("Invalid url strategy"); return; } - this.urlStrategy = domains; + this.urlStrategyDomains = domains; this.useSubdomains = useSubdomains; this.isDataResidency = isDataResidency; } @@ -285,8 +285,8 @@ public Boolean getNeedsCost() { return needsCost; } - public List getUrlStrategy() { - return urlStrategy; + public List getUrlStrategyDomains() { + return urlStrategyDomains; } public String getPreinstallFilePath() { diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/ActivityPackageSender.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/ActivityPackageSender.java index f8449f2ac..9eded4f26 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/ActivityPackageSender.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/ActivityPackageSender.java @@ -55,7 +55,7 @@ public class ActivityPackageSender implements IActivityPackageSender { private IConnectionOptions connectionOptions; private Context context; - public ActivityPackageSender(final List adjustUrlStrategy, + public ActivityPackageSender(final List urlStrategyDomains, final boolean useSubdomains, final String basePath, final String gdprPath, @@ -78,7 +78,7 @@ public ActivityPackageSender(final List adjustUrlStrategy, AdjustFactory.getGdprUrl(), AdjustFactory.getSubscriptionUrl(), AdjustFactory.getPurchaseVerificationUrl(), - adjustUrlStrategy, + urlStrategyDomains, useSubdomains); httpsURLConnectionProvider = AdjustFactory.getHttpsURLConnectionProvider(); connectionOptions = AdjustFactory.getConnectionOptions(); diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/UrlStrategy.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/UrlStrategy.java index 4f1c73f63..56c909f0a 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/UrlStrategy.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/network/UrlStrategy.java @@ -22,7 +22,7 @@ public class UrlStrategy { private static final String SUBSCRIPTION_URL_WORLD = "https://subscription.adjust.world"; private static final String PURCHASE_VERIFICATION_URL_WORLD = "https://ssrv.adjust.world"; - private final List adjustUrlStrategy; + private final List urlStrategyDomains; private final boolean useSubdomains; private final String baseUrlOverwrite; @@ -43,10 +43,10 @@ public UrlStrategy(final String baseUrlOverwrite, final String gdprUrlOverwrite, final String subscriptionUrlOverwrite, final String purchaseVerificationUrlOverwrite, - final List adjustUrlStrategy, + final List urlStrategyDomains, final boolean useSubdomains) { - this.adjustUrlStrategy = adjustUrlStrategy; + this.urlStrategyDomains = urlStrategyDomains; this.useSubdomains = useSubdomains; this.baseUrlOverwrite = baseUrlOverwrite; @@ -139,66 +139,66 @@ public String targetUrlByActivityKind(final ActivityKind activityKind) { private List baseUrlChoices() { - if (adjustUrlStrategy == null || adjustUrlStrategy.isEmpty()) { + if (urlStrategyDomains == null || urlStrategyDomains.isEmpty()) { return Arrays.asList(BASE_URL, BASE_URL_WORLD); } if (useSubdomains) { List baseUrls = new ArrayList<>(); - for (String url : adjustUrlStrategy) { + for (String url : urlStrategyDomains) { baseUrls.add(String.format(BASE_URL_FORMAT, url)); } return baseUrls; }else { List baseUrls = new ArrayList<>(); - for (String url : adjustUrlStrategy) { + for (String url : urlStrategyDomains) { baseUrls.add(String.format(BASE_URL_NO_SUB_DOMAIN_FORMAT, url)); } return baseUrls; } } private List gdprUrlChoices() { - if (adjustUrlStrategy == null || adjustUrlStrategy.isEmpty()) { + if (urlStrategyDomains == null || urlStrategyDomains.isEmpty()) { return Arrays.asList(GDPR_URL, GDPR_URL_WORLD); } List baseUrls = new ArrayList<>(); if (useSubdomains) { - for (String url : adjustUrlStrategy) { + for (String url : urlStrategyDomains) { baseUrls.add(String.format(GDPR_URL_FORMAT, url)); } }else { - for (String url : adjustUrlStrategy) { + for (String url : urlStrategyDomains) { baseUrls.add(String.format(BASE_URL_NO_SUB_DOMAIN_FORMAT, url)); } } return baseUrls; } private List subscriptionUrlChoices() { - if (adjustUrlStrategy == null || adjustUrlStrategy.isEmpty()) { + if (urlStrategyDomains == null || urlStrategyDomains.isEmpty()) { return Arrays.asList(SUBSCRIPTION_URL, SUBSCRIPTION_URL_WORLD); } List baseUrls = new ArrayList<>(); if (useSubdomains) { - for (String url : adjustUrlStrategy) { + for (String url : urlStrategyDomains) { baseUrls.add(String.format(SUBSCRIPTION_URL_FORMAT, url)); } }else { - for (String url : adjustUrlStrategy) { + for (String url : urlStrategyDomains) { baseUrls.add(String.format(BASE_URL_NO_SUB_DOMAIN_FORMAT, url)); } } return baseUrls; } private List purchaseVerificationUrlChoices() { - if (adjustUrlStrategy == null || adjustUrlStrategy.isEmpty()) { + if (urlStrategyDomains == null || urlStrategyDomains.isEmpty()) { return Arrays.asList(PURCHASE_VERIFICATION_URL, PURCHASE_VERIFICATION_URL_WORLD); } List baseUrls = new ArrayList<>(); if (useSubdomains){ - for (String url : adjustUrlStrategy) { + for (String url : urlStrategyDomains) { baseUrls.add(String.format(PURCHASE_VERIFICATION_URL_FORMAT, url)); } }else { - for (String url : adjustUrlStrategy) { + for (String url : urlStrategyDomains) { baseUrls.add(String.format(BASE_URL_NO_SUB_DOMAIN_FORMAT, url)); } }