Skip to content

Commit

Permalink
Merge pull request #99 from xendit/CC-8092/update-sentry-android
Browse files Browse the repository at this point in the history
[CC-8092] Update sentry-android
  • Loading branch information
andysg012 authored Mar 21, 2023
2 parents d8bde7d + e602a24 commit 8774406
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 22 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 3.8.1 (2023-03-17)
- Chore: Upgrade sentry-android to 6.15.0
- Chore: Update sentry dsn

## 3.8.0 (2023-03-13)
- Feat: Added storeCVN method for caching cvn on subsequent multi-use token purpose
- Feat: Added storeCVN test page
Expand Down Expand Up @@ -49,4 +53,4 @@ Features:

Features:

- Add `should_3ds` (boolean) field in multi use or skip authentication tokenization result, accessible using `.getShould_3DS`
- Add `should_3ds` (boolean) field in multi use or skip authentication tokenization result, accessible using `.getShould_3DS`
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,24 @@ Maven:
<dependency>
<groupId>com.xendit</groupId>
<artifactId>xendit-android</artifactId>
<version>3.8.0</version>
<version>3.8.1</version>
<type>pom</type>
</dependency>
```

Gradle:
```
compile 'com.xendit:xendit-android:3.8.0'
compile 'com.xendit:xendit-android:3.8.1'
```

Ivy:
```
<dependency org='com.xendit' name='xendit-android' rev='3.8.0'>
<dependency org='com.xendit' name='xendit-android' rev='3.8.1'>
<artifact name='xendit-android' ext='pom' ></artifact>
</dependency>
```

For more information, visit https://central.sonatype.dev/artifact/com.xendit/xendit-android/3.8.0/versions
For more information, visit https://central.sonatype.dev/artifact/com.xendit/xendit-android/3.8.1/versions

**Note**:

Expand Down
12 changes: 8 additions & 4 deletions xendit-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'

group 'com.xendit'
version '3.8.0'
version '3.8.1'

ext {
bintrayOrg = 'xendit'
Expand All @@ -27,7 +27,7 @@ ext {

licenseName = 'MIT'
licenseUrl = 'https://opensource.org/licenses/MIT'
allLicenses = ["MIT"]
allLicenses = ['MIT']
}

android {
Expand All @@ -36,17 +36,21 @@ android {
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName
versionName '3.8.1'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
consumerProguardFiles 'proguard-rules.pro'
buildConfigField('long', 'VERSION_CODE', "${defaultConfig.versionCode}")
buildConfigField('String','VERSION_NAME', "\"${defaultConfig.versionName}\"")
}
debug {
minifyEnabled false
consumerProguardFiles 'proguard-rules.pro'
buildConfigField('long', 'VERSION_CODE', "${defaultConfig.versionCode}")
buildConfigField('String','VERSION_NAME', "\"${defaultConfig.versionName}\"")
}
}
productFlavors {
Expand All @@ -68,7 +72,7 @@ dependencies {
implementation 'com.snowplowanalytics:snowplow-android-tracker:2.1.1@aar'

// sentry
api 'io.sentry:sentry-android:4.3.0'
api 'io.sentry:sentry-android:6.15.0'

// this dependency is not required if you are already using your own
// slf4j implementation
Expand Down
10 changes: 7 additions & 3 deletions xendit-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xendit">

<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true">
<meta-data android:name="io.sentry.dsn" android:value="https://[email protected]/262922" />
<meta-data android:name="io.sentry.auto-init" android:value="false" />

<meta-data
android:name="io.sentry.auto-init"
android:value="false" />

</application>

</manifest>
</manifest>
31 changes: 21 additions & 10 deletions xendit-android/src/main/java/com/xendit/Xendit.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import android.app.Activity;
import android.content.Context;
import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
Expand All @@ -28,7 +30,6 @@
import com.xendit.Models.BillingDetails;
import com.xendit.Models.Card;
import com.xendit.Models.Customer;
import com.xendit.Models.Jwt;
import com.xendit.Models.ThreeDSRecommendation;
import com.xendit.Models.Token;
import com.xendit.Models.XenditError;
Expand All @@ -43,14 +44,12 @@
import com.xendit.utils.PermissionUtils;
import com.xendit.utils.StoreCVNCallback;

import org.json.JSONArray;

import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.Map;

import io.sentry.Hint;
import io.sentry.Sentry;
import io.sentry.SentryEvent;
import io.sentry.SentryOptions;
Expand All @@ -73,8 +72,7 @@ public class Xendit {
private static final String CREATE_CREDIT_CARD_URL = PRODUCTION_XENDIT_BASE_URL + "/credit_card_tokens";
private static final String CREATE_CREDIT_CARD_TOKEN_URL = PRODUCTION_XENDIT_BASE_URL + "/v2/credit_card_tokens";
private static final String GET_3DS_URL = PRODUCTION_XENDIT_BASE_URL + "/3ds_bin_recommendation";
private static final String CREATE_JWT_URL = PRODUCTION_XENDIT_BASE_URL + "/credit_card_tokens/:token_id/jwt";
private static final String DNS_SERVER = "https://[email protected]/262922";
private static final String DNS_SERVER = "https://[email protected]/6314580";
private static final String CLIENT_IDENTIFIER = "Xendit Android SDK";
private static final String CLIENT_API_VERSION = "2.0.0";
private static final String CLIENT_TYPE = "SDK";
Expand Down Expand Up @@ -106,9 +104,21 @@ public Xendit(final Context context, String publishableKey) {
SentryAndroid.init(context, new Sentry.OptionsConfiguration<SentryAndroidOptions>() {
@Override
public void configure(SentryAndroidOptions sentryAndroidOptions) {
try {
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
String versionName = pInfo.versionName;
String applicationName = context.getApplicationInfo().loadLabel(context.getPackageManager()).toString();

sentryAndroidOptions.setTag("applicationName", applicationName);
sentryAndroidOptions.setTag("applicationVersionName", versionName);
sentryAndroidOptions.setTag("sdkVersionName", BuildConfig.VERSION_NAME);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}

sentryAndroidOptions.setBeforeSend(new SentryOptions.BeforeSendCallback() {
@Override
public SentryEvent execute(SentryEvent event, Object o) {
public SentryEvent execute(SentryEvent event, Hint hint) {
// decide whether to send the event
for (SentryException sentryException : event.getExceptions()) {
SentryStackTrace stackTrace = sentryException.getStacktrace();
Expand All @@ -121,6 +131,7 @@ public SentryEvent execute(SentryEvent event, Object o) {
return null;
}
});

sentryAndroidOptions.setDsn(DNS_SERVER);
}
});
Expand Down Expand Up @@ -881,10 +892,10 @@ private void _createAuthentication(String tokenId, String amount, String currenc

BaseRequest<Authentication> request = buildBaseRequest(Request.Method.POST, requestUrl, onBehalfOf, Authentication.class, new DefaultResponseHandler<>(handler));
request.addParam("amount", amount);
if (currency != null && currency != "") {
if (currency != null && !currency.isEmpty()) {
request.addParam("currency", currency);
}
if (cardCvn != null && cardCvn != "") {
if (cardCvn != null && !cardCvn.isEmpty()) {
request.addParam("card_cvn", cardCvn);
}
sendRequest(request, handler);
Expand Down Expand Up @@ -971,7 +982,7 @@ private BaseRequest buildBaseRequest(int method, String url, String onBehalfOf,
String encodedKey = encodeBase64(publishableKey + ":");
String basicAuthCredentials = "Basic " + encodedKey;
BaseRequest request = new BaseRequest<>(method, url, type, handler);
if (onBehalfOf != null && onBehalfOf != "") {
if (onBehalfOf != null && !onBehalfOf.isEmpty()) {
request.addHeader("for-user-id", onBehalfOf);
}
request.addHeader("Authorization", basicAuthCredentials.replace("\n", ""));
Expand Down

0 comments on commit 8774406

Please sign in to comment.