Commit 1aaa4078 authored by she's avatar she

ios 模糊匹配回传

parent d46cff55
......@@ -2,3 +2,4 @@
/.gradle
/.gradle/
/.idea/
/.gradle/
......@@ -82,7 +82,7 @@ public class AppsflyerAdmapping {
})
.uid("parse-event")
.name("parse-event");
// adEventDataStream.print();
//ios模糊匹配
adEventDataStream
.addSink(new TiktokSink())
......
......@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fshark.overseas.advert.modle.AppsFlyerEvent;
import com.fshark.overseas.advert.modle.AppsflyerPurchase;
import com.fshark.overseas.advert.modle.EventTypeEnum;
import com.fshark.overseas.advert.modle.TiktokModle;
import com.google.gson.Gson;
......@@ -43,64 +44,76 @@ public class TiktokSink extends RichSinkFunction<AppsFlyerEvent> {
@Override
public void invoke(AppsFlyerEvent value, Context context) throws Exception {
if (!value.getGame_id().equals("com.chaosportal.shark") || !"pangle".equals(value.getMedia_source())) {
if (!value.getGame_id().equals("com.chaosportal.fshark") || !"Pangle".equals(value.getMedia_source())) {
return;
}
if (EventTypeEnum.installEvent(value) || EventTypeEnum.orderEvent(value)) {
String event_name = "";
if (EventTypeEnum.installEvent(value)) {
event_name = "InstallApp";
}
TiktokModle tiktokModle = new TiktokModle();
tiktokModle.setTiktokAppId(TIKTOK_APPID);
tiktokModle.setEvent(event_name);
tiktokModle.setTimestamp(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'hh:mm:ss'Z'").format(value.getEvent_time().atOffset(ZoneOffset.UTC)));
TiktokModle.ContextDTO contextDTO = new TiktokModle.ContextDTO();
contextDTO.setIp(value.getIp());
contextDTO.setUserAgent(value.getUser_agent());
contextDTO.setOriginUrl(value.getOriginal_url());
TiktokModle.ContextDTO.AppDTO appDTO = new TiktokModle.ContextDTO.AppDTO();
appDTO.setId(value.getApp_id().replace("id",""));
contextDTO.setApp(appDTO);
TiktokModle.ContextDTO.DeviceDTO deviceDTO = new TiktokModle.ContextDTO.DeviceDTO();
deviceDTO.setPlatform(value.getPlatform());
deviceDTO.setIdfa(value.getIdfa());
deviceDTO.setIdfv(value.getIdfv());
contextDTO.setDevice(deviceDTO);
TiktokModle.ContextDTO.AdDTO adDTO = new TiktokModle.ContextDTO.AdDTO();
adDTO.setPlacement("Pangle");
if (!"id_matching".equals(value.getMatch_type())) {
adDTO.setMatchType("probabilistic");
} else {
adDTO.setMatchType(value.getMatch_type());
}
adDTO.setCampaignId(Long.valueOf(value.getCampaign_id()));
adDTO.setAdId(Long.valueOf(value.getAd_set_id()));
adDTO.setCreativeId(Long.valueOf(value.getAd_id()));
adDTO.setRetargeting(value.getIs_retargeting());
adDTO.setAttributed(true);
adDTO.setAttributionType(value.getAttributed_touch_type() + "_through");
adDTO.setAttributionProvider("mmp");
contextDTO.setAd(adDTO);
tiktokModle.setContext(contextDTO);
if (EventTypeEnum.orderEvent(value)) {
JSONObject json = JSON.parseObject(value.getEvent_value());
String currency = json.getString("af_currency");
Integer revenue = Integer.valueOf(json.getString("af_revenue"));
TiktokModle.PropertiesDTO propertiesDTO = new TiktokModle.PropertiesDTO();
propertiesDTO.setCurrency(currency);
propertiesDTO.setValue(revenue);
ArrayList<TiktokModle.PropertiesDTO.ContentsDTO> contentsDTOS = new ArrayList<>();
TiktokModle.PropertiesDTO.ContentsDTO contentsDTOS1 = new TiktokModle.PropertiesDTO.ContentsDTO();
contentsDTOS1.setPrice(revenue);
contentsDTOS1.setQuantity(1);
contentsDTOS.add(contentsDTOS1);
propertiesDTO.setContents(contentsDTOS);
tiktokModle.setProperties(propertiesDTO);
if ("ios".equalsIgnoreCase(value.getPlatform()) && EventTypeEnum.orderEvent(value)) {
AppsflyerPurchase appsflyerPurchase = new Gson().fromJson(value.getEvent_value(), AppsflyerPurchase.class);
String bundleId = appsflyerPurchase.getBundle_id();
value.setGame_id(bundleId == null ? value.getGame_id() : bundleId);
}
try {
if (EventTypeEnum.installEvent(value) || EventTypeEnum.orderEvent(value)) {
String event_name = "Purchase";
if (EventTypeEnum.installEvent(value)) {
event_name = "InstallApp";
}
TiktokModle tiktokModle = new TiktokModle();
tiktokModle.setTiktokAppId(TIKTOK_APPID);
tiktokModle.setEvent(event_name);
tiktokModle.setTimestamp(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'hh:mm:ss'Z'").format(value.getEvent_time().atOffset(ZoneOffset.UTC)));
TiktokModle.ContextDTO contextDTO = new TiktokModle.ContextDTO();
contextDTO.setIp(value.getIp());
contextDTO.setUserAgent(value.getUser_agent());
contextDTO.setOriginUrl(value.getOriginal_url());
TiktokModle.ContextDTO.AppDTO appDTO = new TiktokModle.ContextDTO.AppDTO();
appDTO.setId(value.getApp_id().replace("id", ""));
contextDTO.setApp(appDTO);
TiktokModle.ContextDTO.DeviceDTO deviceDTO = new TiktokModle.ContextDTO.DeviceDTO();
deviceDTO.setPlatform(value.getPlatform());
deviceDTO.setIdfa(value.getIdfa());
deviceDTO.setIdfv(value.getIdfv());
contextDTO.setDevice(deviceDTO);
TiktokModle.ContextDTO.AdDTO adDTO = new TiktokModle.ContextDTO.AdDTO();
adDTO.setPlacement("Pangle");
if (!"id_matching".equals(value.getMatch_type())) {
adDTO.setMatchType("probabilistic");
} else {
adDTO.setMatchType(value.getMatch_type());
}
adDTO.setCampaignId(Long.valueOf(value.getCampaign_id()));
adDTO.setAdId(Long.valueOf(value.getAd_set_id()));
adDTO.setCreativeId(Long.valueOf(value.getAd_id()));
adDTO.setRetargeting(value.getIs_retargeting());
adDTO.setAttributed(true);
adDTO.setAttributionType(value.getAttributed_touch_type() + "_through");
adDTO.setAttributionProvider("mmp");
contextDTO.setAd(adDTO);
tiktokModle.setContext(contextDTO);
if (EventTypeEnum.orderEvent(value)) {
JSONObject json = JSON.parseObject(value.getEvent_value());
String currency = json.getString("af_currency");
Integer revenue = Integer.valueOf(json.getString("af_revenue"));
TiktokModle.PropertiesDTO propertiesDTO = new TiktokModle.PropertiesDTO();
propertiesDTO.setCurrency(currency);
propertiesDTO.setValue(revenue);
ArrayList<TiktokModle.PropertiesDTO.ContentsDTO> contentsDTOS = new ArrayList<>();
TiktokModle.PropertiesDTO.ContentsDTO contentsDTOS1 = new TiktokModle.PropertiesDTO.ContentsDTO();
contentsDTOS1.setPrice(revenue);
contentsDTOS1.setQuantity(1);
contentsDTOS.add(contentsDTOS1);
propertiesDTO.setContents(contentsDTOS);
tiktokModle.setProperties(propertiesDTO);
}
sendReport(tiktokModle);
}
} catch (Exception e) {
sendReport(tiktokModle);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment