Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
feat: dynamic domain (#17)
Browse files Browse the repository at this point in the history
* fix: url parse bug

* fix: change comments

* feat: change version

* feat: api change

* fix: change detail

* fix: add comment

* fix: change domain

* fix: no test header

* fix: chang default domain
  • Loading branch information
wp-byte authored May 19, 2021
1 parent bd8ed1a commit 906aae5
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 11 deletions.
12 changes: 12 additions & 0 deletions business-core/src/main/java/com/tiktok/TikTokBusinessSdk.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public class TikTokBusinessSdk {
* api available version
*/
private static String apiAvailableVersion = "v1.1";
/**
* api treckEvent sent Domain
*/
private static String apiTrackDomain = "business-api.tiktok.com";
/**
* {@link LogLevel} of initialized sdk
*/
Expand Down Expand Up @@ -435,6 +439,14 @@ public static void setApiAvailableVersion(String apiAvailableVersion) {
TikTokBusinessSdk.apiAvailableVersion = apiAvailableVersion;
}

public static String getApiTrackDomain() {
return apiTrackDomain;
}

public static void setApiTrackDomain(String apiTrackDomain) {
TikTokBusinessSdk.apiTrackDomain = apiTrackDomain;
}

/**
* Should be called whenever the user info changes <br/>
* - when the user logins in <br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ public void fetchGlobalConfig(int delaySeconds) {
JSONObject businessSdkConfig = (JSONObject) requestResult.get("business_sdk_config");
Boolean enableSDK = (Boolean) businessSdkConfig.get("enable_sdk");
String availableVersion = (String) businessSdkConfig.get("available_version");
String trackEventDomain = (String) businessSdkConfig.get("domain");

TikTokBusinessSdk.setSdkGlobalSwitch(enableSDK);
logger.debug("enable_sdk=" + enableSDK);
Expand All @@ -370,6 +371,7 @@ public void fetchGlobalConfig(int delaySeconds) {
clearAllImmediately();
}
TikTokBusinessSdk.setApiAvailableVersion(availableVersion);
TikTokBusinessSdk.setApiTrackDomain(trackEventDomain);
logger.debug("available_version=" + availableVersion);
TikTokBusinessSdk.setGlobalConfigFetched();
} catch (JSONException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class TTRequest {
headParamMap.put("Content-Type", "application/json");
headParamMap.put("Connection", "Keep-Alive");
// headParamMap.put("X-USE-PPE", "1");
// headParamMap.put("X-TT-ENV", "ppe_opensite_i18n_m");
// headParamMap.put("X-TT-ENV", "ppe_bofang");

String ua = String.format("tiktok-business-android-sdk/%s/%s",
BuildConfig.VERSION_NAME,
Expand All @@ -75,7 +75,7 @@ public static JSONObject getBusinessSDKConfig(Map<String, Object> options) {
paramsMap.put("tiktok_app_id", TikTokBusinessSdk.getTTAppId());
paramsMap.putAll(options);

String url = "https://ads.tiktok.com/open_api/business_sdk_config/get/?" + TTUtil.mapToString(paramsMap, "&");
String url = "https://business-api.tiktok.com/open_api/business_sdk_config/get/?" + TTUtil.mapToString(paramsMap, "&");
logger.debug(url);
String result = HttpRequestUtil.doGet(url, getHeadParamMap);
logger.debug(result);
Expand Down Expand Up @@ -128,9 +128,8 @@ public static synchronized List<TTAppEvent> reportAppEvent(JSONObject basePayloa
failedRequests = 0;
successfulRequests = 0;
notifyChange();

String url = "https://ads.tiktok.com/open_api/" + TikTokBusinessSdk.getApiAvailableVersion() + "/app/batch/";
// String url = "http://10.231.253.20:6789/open_api/" + TikTokBusinessSdk.getApiAvailableVersion() + "/app/batch/";
// dynamic req domain and version
String url = "https://" + TikTokBusinessSdk.getApiTrackDomain() + "/open_api/" + TikTokBusinessSdk.getApiAvailableVersion() + "/app/batch/";

List<TTAppEvent> failedEventsToBeSaved = new ArrayList<>();
List<TTAppEvent> failedEventsToBeDiscarded = new ArrayList<>();
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android.enableJetifier=true

GROUP=com.tiktok

VERSION_NAME=1.2.3
VERSION_NAME=1.2.4

mavenGroupId = com.tiktok
mavenArtifactId = tiktok-business-android-sdk
2 changes: 0 additions & 2 deletions samples/.settings/org.eclipse.buildship.core.prefs

This file was deleted.

2 changes: 0 additions & 2 deletions samples/TestApp/.settings/org.eclipse.buildship.core.prefs

This file was deleted.

2 changes: 1 addition & 1 deletion samples/internalmonitor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencies {
implementation project(':business-core')
// implementation 'com.tiktok:tiktok-business-android-sdk:1.1.0-alpha.2'

// implementation 'com.github.bytedance:tiktok-business-android-sdk:1.2.3'
//implementation 'com.github.bytedance:tiktok-business-android-sdk:1.2.4'
implementation 'androidx.cardview:cardview:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
Expand Down

0 comments on commit 906aae5

Please sign in to comment.