Skip to content

Commit

Permalink
Merge pull request #492 from adjust/v4281
Browse files Browse the repository at this point in the history
Version 4.28.1
  • Loading branch information
uerceg authored May 12, 2021
2 parents a5b9dbb + 93d6997 commit af7043f
Show file tree
Hide file tree
Showing 28 changed files with 125 additions and 50 deletions.
2 changes: 1 addition & 1 deletion Adjust/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ext {
coreMinSdkVersion = 9
coreCompileSdkVersion = 30
coreTargetSdkVersion = 30
coreVersionName = '4.28.0'
coreVersionName = '4.28.1'
defaultVersionCode = 1
webbridgeMinSdkVersion = 17

Expand Down
2 changes: 1 addition & 1 deletion Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private Adjust() {
*/
public static synchronized AdjustInstance getDefaultInstance() {
@SuppressWarnings("unused")
String VERSION = "!SDK-VERSION-STRING!:com.adjust.sdk:adjust-android:4.28.0";
String VERSION = "!SDK-VERSION-STRING!:com.adjust.sdk:adjust-android:4.28.1";

if (defaultInstance == null) {
defaultInstance = new AdjustInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class AdjustConfig {
public static final String URL_STRATEGY_CHINA = "url_strategy_china";
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 static final String AD_REVENUE_APPLOVIN_MAX = "applovin_max_sdk";
public static final String AD_REVENUE_MOPUB = "mopub";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
package com.adjust.sdk;

import android.net.Uri;

import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public final class LinkResolution {
public interface LinkResolutionCallback {
void resolvedLinkCallback(URL resolvedLink);
public final class AdjustLinkResolution {
public interface AdjustLinkResolutionCallback {
void resolvedLinkCallback(Uri resolvedLink);
}

// https://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html
private static volatile ExecutorService executor;

private static final int maxRecursions = 3;
private static final int maxRecursions = 10;
private static final String[] expectedUrlHostSuffixArray = {
"adjust.com",
"adj.st",
"go.link"
};

private LinkResolution() { }
private AdjustLinkResolution() { }

public static void resolveLink(final String url,
final String[] resolveUrlSuffixArray,
final LinkResolutionCallback linkResolutionCallback)
final AdjustLinkResolutionCallback adjustLinkResolutionCallback)
{
if (linkResolutionCallback == null) {
if (adjustLinkResolutionCallback == null) {
return;
}

if (url == null) {
linkResolutionCallback.resolvedLinkCallback(null);
adjustLinkResolutionCallback.resolvedLinkCallback(null);
return;
}

Expand All @@ -43,12 +45,13 @@ public static void resolveLink(final String url,
}

if (originalURL == null) {
linkResolutionCallback.resolvedLinkCallback(null);
adjustLinkResolutionCallback.resolvedLinkCallback(null);
return;
}

if (! urlMatchesSuffix(originalURL.getHost(), resolveUrlSuffixArray)) {
linkResolutionCallback.resolvedLinkCallback(originalURL);
adjustLinkResolutionCallback.resolvedLinkCallback(
AdjustLinkResolution.convertToUri(originalURL));
return;
}

Expand All @@ -64,40 +67,43 @@ public static void resolveLink(final String url,
executor.execute(new Runnable() {
@Override
public void run() {
requestAndResolve(finalOriginalURL, 0, linkResolutionCallback);
requestAndResolve(finalOriginalURL, 0, adjustLinkResolutionCallback);
}
});
}
private static void resolveLink(
final URL responseUrl,
final URL previousUrl,
final int recursionNumber,
final LinkResolutionCallback linkResolutionCallback)
final AdjustLinkResolutionCallback adjustLinkResolutionCallback)
{
// return (possible null) previous url when the current one does not exist
if (responseUrl == null) {
linkResolutionCallback.resolvedLinkCallback(previousUrl);
adjustLinkResolutionCallback.resolvedLinkCallback(
AdjustLinkResolution.convertToUri(previousUrl));
return;
}

// return found url with expected host
if (isTerminalUrl(responseUrl.getHost())) {
linkResolutionCallback.resolvedLinkCallback(responseUrl);
adjustLinkResolutionCallback.resolvedLinkCallback(
AdjustLinkResolution.convertToUri(responseUrl));
return;
}

// return previous (non-null) url when it reached the max number of recursive tries
if (recursionNumber > maxRecursions) {
linkResolutionCallback.resolvedLinkCallback(responseUrl);
adjustLinkResolutionCallback.resolvedLinkCallback(
AdjustLinkResolution.convertToUri(responseUrl));
return;
}

requestAndResolve(responseUrl, recursionNumber, linkResolutionCallback);
requestAndResolve(responseUrl, recursionNumber, adjustLinkResolutionCallback);
}

private static void requestAndResolve(final URL urlToRequest,
final int recursionNumber,
final LinkResolutionCallback linkResolutionCallback)
final AdjustLinkResolutionCallback adjustLinkResolutionCallback)
{
final URL httpsUrl = convertToHttps(urlToRequest);
URL resolvedURL = null;
Expand All @@ -122,7 +128,7 @@ private static void requestAndResolve(final URL urlToRequest,
resolveLink(resolvedURL,
httpsUrl,
recursionNumber + 1,
linkResolutionCallback);
adjustLinkResolutionCallback);
}
}

Expand Down Expand Up @@ -170,4 +176,12 @@ private static URL convertToHttps(final URL urlToConvert) {

return convertedUrl;
}

private static Uri convertToUri(URL url) {
if (url == null) {
return null;
}

return Uri.parse(url.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface Constants {

String SCHEME = "https";
String AUTHORITY = "app.adjust.com";
String CLIENT_SDK = "android4.28.0";
String CLIENT_SDK = "android4.28.1";
String LOGTAG = "Adjust";
String REFTAG = "reftag";
String INSTALL_REFERRER = "install_referrer";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ private Map<String, String> getAdRevenueParameters(AdjustAdRevenue adjustAdReven
PackageBuilder.addString(parameters, "screen_size", deviceInfo.screenSize);
PackageBuilder.addString(parameters, "secret_id", adjustConfig.secretId);
PackageBuilder.addString(parameters, "source", adjustAdRevenue.source);
PackageBuilder.addDouble(parameters, "revenue", adjustAdRevenue.revenue);
PackageBuilder.addDoubleWithoutRounding(parameters, "revenue", adjustAdRevenue.revenue);
PackageBuilder.addString(parameters, "currency", adjustAdRevenue.currency);
PackageBuilder.addInteger(parameters, "ad_impressions_count", adjustAdRevenue.adImpressionsCount);
PackageBuilder.addString(parameters, "ad_revenue_network", adjustAdRevenue.adRevenueNetwork);
Expand Down Expand Up @@ -1290,6 +1290,14 @@ private static void addDouble(Map<String, String> parameters, String key, Double
PackageBuilder.addString(parameters, key, doubleString);
}

private static void addDoubleWithoutRounding(Map<String, String> parameters, String key, Double value) {
if (value == null) {
return;
}
String doubleString = Double.toString(value);
PackageBuilder.addString(parameters, key, doubleString);
}

private static void addInteger(Map<String, String> parameters, String key, Integer value) {
if (value == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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_INDIA;
import static com.adjust.sdk.AdjustConfig.DATA_RESIDENCY_EU;
Expand All @@ -29,6 +30,10 @@ public class UrlStrategy {
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 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 final String baseUrlOverwrite;
private final String gdprUrlOverwrite;
private final String subscriptionUrlOverwrite;
Expand Down Expand Up @@ -134,6 +139,8 @@ private static List<String> baseUrlChoices(final String 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);
}
Expand All @@ -148,6 +155,8 @@ private static List<String> gdprUrlChoices(final String 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);
}
Expand All @@ -162,6 +171,8 @@ private static List<String> subscriptionUrlChoices(final String 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,
Expand Down
2 changes: 1 addition & 1 deletion Adjust/sdk-plugin-criteo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies {
// Add SDK via module.
compileOnly project(':sdk-core')
// Add SDK via Maven.
// implementation 'com.adjust.sdk:adjust-android:4.28.0'
// implementation 'com.adjust.sdk:adjust-android:4.28.1'
}

task adjustCriteoAndroidAar (type: Copy) {
Expand Down
2 changes: 1 addition & 1 deletion Adjust/sdk-plugin-imei/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies {
// Add SDK via module.
compileOnly project(':sdk-core')
// Add SDK via Maven.
// implementation 'com.adjust.sdk:adjust-android:4.28.0'
// implementation 'com.adjust.sdk:adjust-android:4.28.1'
}

task adjustImeiAndroidAar (type: Copy) {
Expand Down
2 changes: 1 addition & 1 deletion Adjust/sdk-plugin-oaid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies {
// Add SDK via module.
compileOnly project(':sdk-core')
// Add SDK via Maven.
// implementation 'com.adjust.sdk:adjust-android:4.28.0'
// implementation 'com.adjust.sdk:adjust-android:4.28.1'
}

task adjustOaidAndroidAar (type: Copy) {
Expand Down
2 changes: 1 addition & 1 deletion Adjust/sdk-plugin-sociomantic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies {
// Add SDK via module.
compileOnly project(':sdk-core')
// Add SDK via Maven.
// implementation 'com.adjust.sdk:adjust-android:4.28.0'
// implementation 'com.adjust.sdk:adjust-android:4.28.1'
}

task adjustSociomanticAndroidAar (type: Copy) {
Expand Down
2 changes: 1 addition & 1 deletion Adjust/sdk-plugin-trademob/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies {
// Add SDK via module.
compileOnly project(':sdk-core')
// Add SDK via Maven.
// implementation 'com.adjust.sdk:adjust-android:4.28.0'
// implementation 'com.adjust.sdk:adjust-android:4.28.1'
}

task adjustTrademobAndroidAar (type: Copy) {
Expand Down
2 changes: 1 addition & 1 deletion Adjust/sdk-plugin-webbridge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies {
// Add SDK via module.
compileOnly project(':sdk-core')
// Add SDK via Maven.
// implementation 'com.adjust.sdk:adjust-android:4.28.0'
// implementation 'com.adjust.sdk:adjust-android:4.28.1'
}

task adjustWebBridgeAndroidAar (type: Copy) {
Expand Down
2 changes: 1 addition & 1 deletion Adjust/sdk-plugin-webbridge/src/main/assets/adjust.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ var Adjust = {
if (this.adjustConfig) {
return this.adjustConfig.getSdkPrefix();
} else {
return 'web-bridge4.28.0';
return 'web-bridge4.28.1';
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ AdjustConfig.UrlStrategyIndia = "url_strategy_india";
AdjustConfig.UrlStrategyChina = "url_strategy_china";
AdjustConfig.DataResidencyEU = "data_residency_eu";
AdjustConfig.DataResidencyTR = "data_residency_tr";
AdjustConfig.DataResidencyUS = "data_residency_us";

AdjustConfig.LogLevelVerbose = 'VERBOSE',
AdjustConfig.LogLevelDebug = 'DEBUG',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public TestActivityPackage(ActivityPackage activityPackage) {
// default values
appToken = "123456789012";
environment = "sandbox";
clientSdk = "android4.28.0";
clientSdk = "android4.28.1";
suffix = "";
attribution = new AdjustAttribution();
playServices = true;
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
### Version 4.28.1 (12th May 2021)
#### Added
- [beta] Added data residency support for US region. You can choose this setting by calling `setUrlStrategy` method of `AdjustConfig` instance with `AdjustConfig.DATA_RESIDENCY_US` parameter.
- Added helper class `AdjustLinkResolution` to assist with resolution of links which are wrapping Adjust deep link.

#### Fixed
- Removed 5 decimal places formatting for ad revenue value.

---

### Version 4.28.0 (26th April 2021)
#### Added
- [beta] Added data residency support for Turkey region. You can choose this setting by calling `setUrlStrategy` method of `AdjustConfig` instance with `AdjustConfig.DATA_RESIDENCY_TR` parameter.
Expand Down
Loading

0 comments on commit af7043f

Please sign in to comment.