Skip to content

Commit a5c871d

Browse files
committed
modify adSearch API
1 parent b826309 commit a5c871d

File tree

7 files changed

+19
-81
lines changed

7 files changed

+19
-81
lines changed

app.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ App Analytics react-native 平台 SDK 由`封装层`和`Native SDK`两部分构
3535
- iOS 平台
3636
* 将最新的 .a 文件复制到 `lib/AppAnalytics/ios` 目录下
3737
4.`Native SDK` 功能选项对`封装层`代码进行必要的删减,详见“注意事项”第2条;
38-
5. 将 react-native SDK 集成您需要统计的工程中,并按 [集成文档](http://doc.talkingdata.com/posts/35) 进行必要配置和功能调用。
38+
5. 将 react-native SDK 集成您需要统计的工程中,并按 [集成文档](http://doc.talkingdata.com/posts/848) 进行必要配置和功能调用。
3939

4040
### 注意事项
4141
1. 分别选择 Android 和 iOS 平台进行功能定制时,请确保两个平台功能项一致。

example/TalkingDataAdTracking.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,6 @@ class TalkingDataAdSearch {
7777
this.end_date = end_date;
7878
}
7979

80-
setSearchTerm(search_term){
81-
this.search_term = search_term;
82-
}
83-
84-
setGoogleBusinessVertical(google_business_vertical){
85-
this.google_business_vertical = google_business_vertical;
86-
}
87-
88-
addCustom(key, value){
89-
this.custom[key] = value;
90-
}
91-
9280
get adSearchString(){
9381
return JSON.stringify({
9482
'destination':this.destination,
@@ -97,9 +85,6 @@ class TalkingDataAdSearch {
9785
'item_location_id':this.item_location_id,
9886
'start_date':this.start_date,
9987
'end_date':this.end_date,
100-
'search_term':this.search_term,
101-
'google_business_vertical':this.google_business_vertical,
102-
'custom':this.custom
10388
});
10489
}
10590

example/view/adtracking/adt_adsearch/adtAdSearch.js

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ export class ADTAdSearchScreen extends React.Component {
2323
item_location_id: '',
2424
start_date: '',
2525
end_date: '',
26-
search_term: '',
27-
google_business_vertical: '',
28-
custom:null,
2926
adSearch:new TalkingDataAdSearch(),
3027
key:'',
3128
value:''
@@ -62,26 +59,6 @@ export class ADTAdSearchScreen extends React.Component {
6259

6360
<View style={{marginTop: 20, justifyContent: 'space-between'}}>
6461

65-
<MyTextInput
66-
onChangeText={(key) => this.setState({key:key})}
67-
placeholder='key'
68-
/>
69-
70-
<MyTextInput
71-
onChangeText={(value) => this.setState({value: value})
72-
}
73-
placeholder='value'
74-
/>
75-
76-
<Button
77-
title={"添加自定义参数"}
78-
onPress={
79-
() => {
80-
this.state.adSearch.addCustom(this.state.key, this.state.value);
81-
}
82-
}
83-
/>
84-
8562
<View style={{marginTop: 20, justifyContent: 'space-between'}}/>
8663

8764
<MyTextInput
@@ -118,18 +95,6 @@ export class ADTAdSearchScreen extends React.Component {
11895
placeholder='业务事件截止日期(航班返程日期)'
11996
/>
12097

121-
<MyTextInput
122-
onChangeText={(search_term) => this.setState({search_term: search_term})
123-
}
124-
placeholder='搜索字符串'
125-
/>
126-
127-
<MyTextInput
128-
onChangeText={(google_business_vertical) => this.setState({google_business_vertical: google_business_vertical})
129-
}
130-
placeholder='用于区分各种业务类型的字符串'
131-
/>
132-
13398

13499

135100
<Button
@@ -142,8 +107,6 @@ export class ADTAdSearchScreen extends React.Component {
142107
this.state.adSearch.setItemLocationId(this.state.item_location_id);
143108
this.state.adSearch.setStartDate(this.state.start_date);
144109
this.state.adSearch.setEndDate(this.state.end_date);
145-
this.state.adSearch.setSearchTerm(this.state.search_term);
146-
this.state.adSearch.setGoogleBusinessVertical(this.state.google_business_vertical);
147110
TalkingDataAdTracking.onAdSearch(this.state.adSearch.adSearchString);
148111
}
149112
}

lib/AdTracking/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ android {
3232
dependencies {
3333
compile fileTree(dir: 'libs', include: ['*.jar'])
3434
compile 'com.facebook.react:react-native:+'
35-
compile files('src/main/libs/SaaS_AdTracking_Android_SDK_V4.0.27.jar')
35+
compile files('src/main/libs/SaaS_AdTracking_Android_SDK_V4.0.33.jar')
3636
}

lib/AdTracking/android/src/main/java/com/talkingdata/adtracking/TalkingDataAdTracking.java

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@
77
import com.facebook.react.bridge.ReactApplicationContext;
88
import com.facebook.react.bridge.ReactContextBaseJavaModule;
99
import com.facebook.react.bridge.ReactMethod;
10-
import com.tendcloud.appcpa.AdSearch;
1110
import com.tendcloud.appcpa.Order;
1211
import com.tendcloud.appcpa.ShoppingCart;
12+
import com.tendcloud.appcpa.TDSearch;
1313
import com.tendcloud.appcpa.TalkingDataAppCpa;
1414

1515
import org.json.JSONArray;
1616
import org.json.JSONObject;
17-
import java.util.Iterator;
18-
import java.util.Map;
19-
import java.util.HashMap;
2017

2118
public class TalkingDataAdTracking extends ReactContextBaseJavaModule {
2219
private Context context;
@@ -102,8 +99,8 @@ public void onReceiveDeepLink(String link){
10299
}
103100

104101
@ReactMethod
105-
public void onAdSearch(String adSearch){
106-
TalkingDataAppCpa.onAdSearch(getAdSearch(adSearch));
102+
public void onAdSearch(String tdSearch){
103+
TalkingDataAppCpa.onSearch(getSearch(tdSearch));
107104
}
108105

109106
@ReactMethod
@@ -219,32 +216,25 @@ private ShoppingCart getShoppingCart(String json){
219216
return shoppingCart;
220217
}
221218

222-
private AdSearch getAdSearch(String json){
223-
AdSearch adSearch = AdSearch.createAdSearch();
219+
private TDSearch getSearch(String json){
220+
TDSearch tdSearch = TDSearch.createAdSearch();
224221
try{
225222
JSONObject jsonObject = new JSONObject(json);
226-
adSearch.setDestination(jsonObject.optString("destination", null));
227-
adSearch.setOrigin(jsonObject.optString("origin", null));
228-
adSearch.setItemId(jsonObject.optString("item_id", null));
229-
adSearch.setItemLocationId(jsonObject.optString("item_location_id", null));
230-
adSearch.setStartDate(jsonObject.optString("start_date", null));
231-
adSearch.setEndDate(jsonObject.optString("end_date", null));
232-
adSearch.setSearchTerm(jsonObject.optString("search_term", null));
233-
adSearch.setGoogleBusinessVertical(jsonObject.optString("google_business_vertical", null));
234-
adSearch.setDestination(jsonObject.optString("destination", null));
235-
JSONObject custom = jsonObject.optJSONObject("custom");
236-
if(custom != null){
237-
Map<String, Object> map = new HashMap();
238-
Iterator iterator = custom.keys();
239-
while(iterator.hasNext()){
240-
String key = (String)iterator.next();
241-
map.put(key, custom.opt(key));
242-
}
243-
adSearch.setCustomParam(map);
223+
tdSearch.setCategory(jsonObject.optString("category", null));
224+
tdSearch.setContent(jsonObject.optString("content", null));
225+
tdSearch.setItemId(jsonObject.optString("item_id", null));
226+
tdSearch.setItemLocationId(jsonObject.optString("item_location_id", null));
227+
tdSearch.setDestination(jsonObject.optString("destination", null));
228+
tdSearch.setOrigin(jsonObject.optString("origin", null));
229+
if (jsonObject.has("start_date")){
230+
tdSearch.setStartDate(jsonObject.optLong("start_date", 0));
231+
}
232+
if (jsonObject.has("end_date")){
233+
tdSearch.setEndDate(jsonObject.optLong("end_date", 0));
244234
}
245235
}catch (Throwable t){
246236
t.printStackTrace();
247237
}
248-
return adSearch;
238+
return tdSearch;
249239
}
250240
}
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)