|
@@ -75,23 +75,23 @@ public class TrackingController {
|
|
|
Map<String, String> params = flatQueryParams(request);
|
|
Map<String, String> params = flatQueryParams(request);
|
|
|
String traceId = mediaTraceId(params);
|
|
String traceId = mediaTraceId(params);
|
|
|
if (traceId == null || traceId.isBlank()) {
|
|
if (traceId == null || traceId.isBlank()) {
|
|
|
- log.warn("[impression] 缺少 traceId, params={}", params.keySet());
|
|
|
|
|
|
|
+ log.warn("[腾讯][曝光] 缺少 traceId, params={}", params.keySet());
|
|
|
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "missing media trace id (click_id/oaid/imei/idfa)");
|
|
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "missing media trace id (click_id/oaid/imei/idfa)");
|
|
|
}
|
|
}
|
|
|
if (tencentPlacement == null) {
|
|
if (tencentPlacement == null) {
|
|
|
throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE, "tencent placement not configured");
|
|
throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE, "tencent placement not configured");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- log.info("[曝光] 收到曝光请求 | traceId={} | IP={} | 全部入参: {}", traceId, clientIp(request), params);
|
|
|
|
|
|
|
+ log.info("[腾讯][曝光] 收到曝光请求 | traceId={} | IP={} | 全部入参: {}", traceId, clientIp(request), params);
|
|
|
|
|
|
|
|
Map<String, Object> bidRequest = mediaBidRequest(request, "tencent", traceId, params, tencentPlacement);
|
|
Map<String, Object> bidRequest = mediaBidRequest(request, "tencent", traceId, params, tencentPlacement);
|
|
|
NormalizedBidResponse response = adxClient.requestBid(bidRequest);
|
|
NormalizedBidResponse response = adxClient.requestBid(bidRequest);
|
|
|
if (response == null) {
|
|
if (response == null) {
|
|
|
- log.warn("[impression] 百度ADX返回空响应, traceId={}", traceId);
|
|
|
|
|
|
|
+ log.warn("[腾讯][曝光] 百度ADX返回空响应, traceId={}", traceId);
|
|
|
throw new ResponseStatusException(HttpStatus.BAD_GATEWAY, "empty baidu ADX response");
|
|
throw new ResponseStatusException(HttpStatus.BAD_GATEWAY, "empty baidu ADX response");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- log.info("[impression] 百度ADX返回: qk={}, hasBid={}, showUrls={}, clickUrls={}",
|
|
|
|
|
|
|
+ log.info("[腾讯][曝光] 百度ADX返回: qk={}, hasBid={}, showUrls={}, clickUrls={}",
|
|
|
response.getQk(),
|
|
response.getQk(),
|
|
|
response.getBid() != null,
|
|
response.getBid() != null,
|
|
|
response.getBid() != null && response.getBid().getShowUrls() != null ? response.getBid().getShowUrls().size() : 0,
|
|
response.getBid() != null && response.getBid().getShowUrls() != null ? response.getBid().getShowUrls().size() : 0,
|
|
@@ -99,14 +99,14 @@ public class TrackingController {
|
|
|
|
|
|
|
|
BidRecord record = bidRecordFromMediaResponse(response, "tencent", traceId, "impression", params);
|
|
BidRecord record = bidRecordFromMediaResponse(response, "tencent", traceId, "impression", params);
|
|
|
hotStore.recordBid(record);
|
|
hotStore.recordBid(record);
|
|
|
- log.info("[impression] 已缓存bid, qk={}, traceId={}", record.getQk(), traceId);
|
|
|
|
|
|
|
+ log.info("[腾讯][曝光] 已缓存bid, qk={}, traceId={}", record.getQk(), traceId);
|
|
|
|
|
|
|
|
// 上报百度曝光
|
|
// 上报百度曝光
|
|
|
if (response.getBid() != null && response.getBid().getShowUrls() != null
|
|
if (response.getBid() != null && response.getBid().getShowUrls() != null
|
|
|
&& !response.getBid().getShowUrls().isEmpty()) {
|
|
&& !response.getBid().getShowUrls().isEmpty()) {
|
|
|
List<TrackingResult> trackingResults = adxClient.reportImpression(
|
|
List<TrackingResult> trackingResults = adxClient.reportImpression(
|
|
|
response.getBid().getShowUrls(), response.getBid().getPrice());
|
|
response.getBid().getShowUrls(), response.getBid().getPrice());
|
|
|
- log.info("[impression] 曝光上报完成, qk={}, results={}", response.getQk(), trackingResults);
|
|
|
|
|
|
|
+ log.info("[腾讯][曝光] 曝光上报完成, qk={}, results={}", response.getQk(), trackingResults);
|
|
|
recordTrackingResults(response.getQk(), "impression", trackingResults);
|
|
recordTrackingResults(response.getQk(), "impression", trackingResults);
|
|
|
}
|
|
}
|
|
|
return Map.of("qk", nvl(record.getQk()), "traceId", traceId);
|
|
return Map.of("qk", nvl(record.getQk()), "traceId", traceId);
|
|
@@ -139,21 +139,21 @@ public class TrackingController {
|
|
|
Map<String, String> params = flatQueryParams(request);
|
|
Map<String, String> params = flatQueryParams(request);
|
|
|
String traceId = mediaTraceId(params);
|
|
String traceId = mediaTraceId(params);
|
|
|
if (traceId == null || traceId.isBlank()) {
|
|
if (traceId == null || traceId.isBlank()) {
|
|
|
- log.warn("[click] 缺少 traceId, params={}", params.keySet());
|
|
|
|
|
|
|
+ log.warn("[腾讯][点击] 缺少 traceId, params={}", params.keySet());
|
|
|
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "missing media trace id (click_id/oaid/imei/idfa)");
|
|
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "missing media trace id (click_id/oaid/imei/idfa)");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- log.info("[点击] 收到点击请求 | traceId={} | IP={} | 全部入参: {}", traceId, clientIp(request), params);
|
|
|
|
|
|
|
+ log.info("[腾讯][点击] 收到点击请求 | traceId={} | IP={} | 全部入参: {}", traceId, clientIp(request), params);
|
|
|
|
|
|
|
|
// 先从 Redis 按 mediaTrace 查找已有 bid
|
|
// 先从 Redis 按 mediaTrace 查找已有 bid
|
|
|
BidRecord record = hotStore.findBidByMediaTrace("tencent", traceId);
|
|
BidRecord record = hotStore.findBidByMediaTrace("tencent", traceId);
|
|
|
if (record == null) {
|
|
if (record == null) {
|
|
|
- log.info("[click] Redis未命中, 发起竞价请求, traceId={}", traceId);
|
|
|
|
|
|
|
+ log.info("[腾讯][点击] Redis未命中, 发起竞价请求, traceId={}", traceId);
|
|
|
// 未找到,临时发起竞价请求
|
|
// 未找到,临时发起竞价请求
|
|
|
Map<String, Object> bidRequest = mediaBidRequest(request, "tencent", traceId, params, tencentPlacement);
|
|
Map<String, Object> bidRequest = mediaBidRequest(request, "tencent", traceId, params, tencentPlacement);
|
|
|
NormalizedBidResponse resp = adxClient.requestBid(bidRequest);
|
|
NormalizedBidResponse resp = adxClient.requestBid(bidRequest);
|
|
|
if (resp == null) {
|
|
if (resp == null) {
|
|
|
- log.warn("[click] 百度ADX返回空响应, traceId={}", traceId);
|
|
|
|
|
|
|
+ log.warn("[腾讯][点击] 百度ADX返回空响应, traceId={}", traceId);
|
|
|
throw new ResponseStatusException(HttpStatus.BAD_GATEWAY, "empty baidu ADX response");
|
|
throw new ResponseStatusException(HttpStatus.BAD_GATEWAY, "empty baidu ADX response");
|
|
|
}
|
|
}
|
|
|
BidRecord newRecord = bidRecordFromMediaResponse(resp, "tencent", traceId, "click", params);
|
|
BidRecord newRecord = bidRecordFromMediaResponse(resp, "tencent", traceId, "click", params);
|
|
@@ -163,18 +163,18 @@ public class TrackingController {
|
|
|
&& !resp.getBid().getShowUrls().isEmpty()) {
|
|
&& !resp.getBid().getShowUrls().isEmpty()) {
|
|
|
List<TrackingResult> impressionResults = adxClient.reportImpression(
|
|
List<TrackingResult> impressionResults = adxClient.reportImpression(
|
|
|
resp.getBid().getShowUrls(), resp.getBid().getPrice());
|
|
resp.getBid().getShowUrls(), resp.getBid().getPrice());
|
|
|
- log.info("[click] Redis未命中补竞价后,曝光上报完成, qk={}, results={}", record.getQk(), impressionResults);
|
|
|
|
|
|
|
+ log.info("[腾讯][点击] Redis未命中补竞价后,曝光上报完成, qk={}, results={}", record.getQk(), impressionResults);
|
|
|
recordTrackingResults(record.getQk(), "impression", impressionResults);
|
|
recordTrackingResults(record.getQk(), "impression", impressionResults);
|
|
|
}
|
|
}
|
|
|
- log.info("[click] 竞价成功, qk={}, traceId={}", record.getQk(), traceId);
|
|
|
|
|
|
|
+ log.info("[腾讯][点击] 竞价成功, qk={}, traceId={}", record.getQk(), traceId);
|
|
|
} else {
|
|
} else {
|
|
|
- log.info("[click] Redis命中, qk={}, traceId={}", record.getQk(), traceId);
|
|
|
|
|
|
|
+ log.info("[腾讯][点击] Redis命中, qk={}, traceId={}", record.getQk(), traceId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 上报百度点击
|
|
// 上报百度点击
|
|
|
List<TrackingResult> trackingResults = adxClient.reportClick(
|
|
List<TrackingResult> trackingResults = adxClient.reportClick(
|
|
|
record.getClickUrls() != null ? record.getClickUrls() : Collections.emptyList());
|
|
record.getClickUrls() != null ? record.getClickUrls() : Collections.emptyList());
|
|
|
- log.info("[click] 点击上报完成, qk={}, results={}", record.getQk(), trackingResults);
|
|
|
|
|
|
|
+ log.info("[腾讯][点击] 点击上报完成, qk={}, results={}", record.getQk(), trackingResults);
|
|
|
recordTrackingResults(record.getQk(), "click", trackingResults);
|
|
recordTrackingResults(record.getQk(), "click", trackingResults);
|
|
|
|
|
|
|
|
// 点击处理完成,缩减 Redis 数据(清除 clickUrls/landingPage/appStoreLink)
|
|
// 点击处理完成,缩减 Redis 数据(清除 clickUrls/landingPage/appStoreLink)
|
|
@@ -183,12 +183,12 @@ public class TrackingController {
|
|
|
try {
|
|
try {
|
|
|
hotStore.shrinkAfterClick(record);
|
|
hotStore.shrinkAfterClick(record);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- log.warn("[click] Redis缩减失败(不影响主流程), qk={}, error={}", record.getQk(), e.getMessage());
|
|
|
|
|
|
|
+ log.warn("[腾讯][点击] Redis缩减失败(不影响主流程), qk={}, error={}", record.getQk(), e.getMessage());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 重定向到 landing page 或 app store link
|
|
// 重定向到 landing page 或 app store link
|
|
|
if (destination != null && !destination.isBlank()) {
|
|
if (destination != null && !destination.isBlank()) {
|
|
|
- log.info("[click] 302重定向, qk={}, destination={}", record.getQk(), destination);
|
|
|
|
|
|
|
+ log.info("[腾讯][点击] 302重定向, qk={}, destination={}", record.getQk(), destination);
|
|
|
response.sendRedirect(destination);
|
|
response.sendRedirect(destination);
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
@@ -298,7 +298,7 @@ public class TrackingController {
|
|
|
List<Integer> appList = parseAppList(firstParam(params, "appList", "app_list", "applist"));
|
|
List<Integer> appList = parseAppList(firstParam(params, "appList", "app_list", "applist"));
|
|
|
if (!appList.isEmpty()) bidReq.put("appList", appList);
|
|
if (!appList.isEmpty()) bidReq.put("appList", appList);
|
|
|
|
|
|
|
|
- log.info("[百度ADX] 竞价请求 | traceId={} | body={}", traceId, bidReq);
|
|
|
|
|
|
|
+ log.info("[腾讯][百度ADX] 竞价请求 | traceId={} | body={}", traceId, bidReq);
|
|
|
|
|
|
|
|
return bidReq;
|
|
return bidReq;
|
|
|
}
|
|
}
|
|
@@ -373,7 +373,7 @@ public class TrackingController {
|
|
|
try {
|
|
try {
|
|
|
result.add(Integer.parseInt(item));
|
|
result.add(Integer.parseInt(item));
|
|
|
} catch (NumberFormatException e) {
|
|
} catch (NumberFormatException e) {
|
|
|
- log.warn("[百度ADX] 忽略非法 appList 值 | raw={} | item={}", value, item);
|
|
|
|
|
|
|
+ log.warn("[腾讯][百度ADX] 忽略非法 appList 值 | raw={} | item={}", value, item);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return result;
|
|
return result;
|