|
|
@@ -167,24 +167,14 @@ public class TencentClient {
|
|
|
|
|
|
/**
|
|
|
* 构造 callback POST 请求,始终携带鉴权 header。
|
|
|
- * 2025-03-31 起腾讯不再支持 HTTP 无鉴权上报,所有请求均需鉴权。
|
|
|
*/
|
|
|
private HttpRequest buildCallbackRequest(String callbackUrl, byte[] payload) {
|
|
|
- // 强制 https(兼容旧的 http://tracking.e.qq.com 格式)
|
|
|
- String url = callbackUrl;
|
|
|
- if (url.startsWith("http://tracking.e.qq.com")) {
|
|
|
- url = url.replace("http://tracking.e.qq.com", "https://api.e.qq.com");
|
|
|
- } else if (url.startsWith("http://")) {
|
|
|
- url = url.replace("http://", "https://");
|
|
|
- }
|
|
|
-
|
|
|
HttpRequest.Builder reqBuilder = HttpRequest.newBuilder()
|
|
|
- .uri(URI.create(url))
|
|
|
+ .uri(URI.create(callbackUrl))
|
|
|
.POST(HttpRequest.BodyPublishers.ofByteArray(payload))
|
|
|
.header("Content-Type", "application/json")
|
|
|
.timeout(Duration.ofSeconds(15));
|
|
|
|
|
|
- // 始终添加鉴权 header
|
|
|
String currentToken = accessTokenSupplier.get();
|
|
|
if (currentToken != null && !currentToken.isBlank()) {
|
|
|
long timestamp = Instant.now().getEpochSecond();
|
|
|
@@ -255,12 +245,20 @@ public class TencentClient {
|
|
|
UserAction.ActionParam param = new UserAction.ActionParam();
|
|
|
param.setValue((int) (payment.getPayment() * 100)); // 分
|
|
|
action.setActionParam(param);
|
|
|
+ } else if ("START_APP".equals(actionType)) {
|
|
|
+ // 留存行为必须带 length_of_stay(文档要求)
|
|
|
+ UserAction.ActionParam param = new UserAction.ActionParam();
|
|
|
+ int lengthOfStay = switch (payment.getAct()) {
|
|
|
+ case 8 -> 7; // 7日留存
|
|
|
+ case 9 -> 3; // 3日留存
|
|
|
+ default -> 1; // 次日留存 (act=4 或其他)
|
|
|
+ };
|
|
|
+ param.setLengthOfStay(lengthOfStay);
|
|
|
+ action.setActionParam(param);
|
|
|
} else if ("CUSTOM".equals(actionType)) {
|
|
|
UserAction.ActionParam param = new UserAction.ActionParam();
|
|
|
String customAction = switch (payment.getAct()) {
|
|
|
- case 7 -> "key_behavior";
|
|
|
- case 8 -> "7day_retention";
|
|
|
- case 9 -> "3day_retention";
|
|
|
+ case 7 -> "UV_CORE_ACTION"; // 关键行为(文档标准值)
|
|
|
default -> "custom_" + payment.getAct();
|
|
|
};
|
|
|
param.setCustomAction(customAction);
|