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} }); } }