From f37379bf8d08965a2c27b5ed933eeb98f202c493 Mon Sep 17 00:00:00 2001 From: juncong lee Date: Tue, 6 Jan 2026 16:30:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=95=B0=E4=BA=8B=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E6=8A=A5=E6=97=B6=E5=8E=BB=E9=99=A4=E7=89=B9=E6=AE=8A=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SDKManager/ShuShuMangage/ShuShuEvent.cs | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/Assets/Script/SDKManager/ShuShuMangage/ShuShuEvent.cs b/Assets/Script/SDKManager/ShuShuMangage/ShuShuEvent.cs index 8ad3e92..023a7ad 100644 --- a/Assets/Script/SDKManager/ShuShuMangage/ShuShuEvent.cs +++ b/Assets/Script/SDKManager/ShuShuMangage/ShuShuEvent.cs @@ -1,12 +1,37 @@ using System.Collections.Generic; using System.Linq; +using System.Text.RegularExpressions; using AnyThinkAds.ThirdParty.LitJson; +using GoogleMobileAds.Api; using ThinkingData.Analytics; namespace WZ { public class ShuShuEvent : D_MonoSingleton { + public static string FormatEventName(string eventName) + { + if (string.IsNullOrEmpty(eventName)) + return eventName; + + // 替换所有非字母、数字、中文字符为下划线 + string formatted = Regex.Replace(eventName, @"[^a-zA-Z0-9\u4e00-\u9fa5]", "_"); + + // 将连续多个下划线合并为一个 + formatted = Regex.Replace(formatted, @"_+", "_"); + + // 去除首尾的下划线 + formatted = formatted.Trim('_'); + + // 只保留49个字符 + if (formatted.Length > 49) + { + // 确保截断后最后一个字符不是下划线 + formatted = formatted.Substring(0, 49); + } + + return formatted; + } /// /// 设置用户属性 /// @@ -52,7 +77,7 @@ namespace WZ extraInfo[key1] = value1; } - Track(eventName, extraInfo); + Track(FormatEventName(eventName), extraInfo); } /// @@ -60,7 +85,7 @@ namespace WZ /// public void Track(string eventName, Dictionary properties) { - TDAnalytics.Track(eventName, properties); + TDAnalytics.Track(FormatEventName(eventName), properties); } /// @@ -72,7 +97,7 @@ namespace WZ pair => pair.Key, pair => (object)pair.Value ); - TDAnalytics.Track(eventName, newProperties); + TDAnalytics.Track(FormatEventName(eventName), newProperties); } /// @@ -85,18 +110,22 @@ namespace WZ /// 单次展示收益 /// 广告展示点位 /// 第几次展示该格式的广告 - public void OnAdRevenueEvent(string ad_platform, string ad_source, string ad_unit_name, string ad_format, double revenue, string position, int number) + public void OnAdRevenueEvent(string ad_platform, string ad_source, string ad_unit_name, + AdsType ad_format, double revenue, string position, + int number,int positionNum, NativeType nativeType) { TDAnalytics.Track("ad_impression", new Dictionary { { "ad_platform", ad_platform }, { "ad_source", ad_source }, { "ad_unit_name", ad_unit_name }, - { "ad_format", ad_format }, + { "ad_format", ad_format.ToString() }, { "value", revenue }, { "currency", "USD" }, { "position", position }, - { "number", number } + { "format_number", number }, + { "position_number", positionNum}, + { "native_type", nativeType} }); } }