SDK 迁移指南
Update your User Reporting implementation from version 1.0 to version 2.0 to access the latest features and updates.
阅读时间4 分钟最后更新于 1 个月前
User Reporting SDK 现已更新,并影响整个 API。 最显著的是,为了更好地聚焦开发和支持,公共 API 范围已经大幅缩减。
User Reporting 1.0 是指旧版 SDK;您可以在这里找到参考分发。User Reporting 2.0 是指 Unity Package Manager 中可用的更新 SDK。
重大变化
- 整个 API 现在位于 命名空间中。
Unity.Services.UserReporting - 该 API 现在通过 使用单个访问点。
Unity.Services.UserReporting.Instance - 整个源代码已不再公开,因此 等辅助工具在 SDK 中不再可用。
CyclicalList - 该 SDK 使用外部依赖项,而不是包含源代码依赖项和提供对其的访问,比如 解析器或
SimpleJSON类;两者都已被移除。PngHelper - 一些错误修复尚未进行回溯,其中包括修复了发送报告时可能发生的内存泄露。
- 已被移除。
AsyncUnityUserReportingPlatform - 示例 prefab GUI 现在会根据显示进行缩放。
SimpleJSONPngHelper使用新的示例预制件
旧版 SDK 中包含的示例起点已经进行了更新和替换。它提供了相同的最终用户功能,并且可以在场景中进行替换。创建报告
用户报告对象不再手动创建。一次只能创建并发送一个报告。正在进行的报告被称为“进行中”报告。如果创建新的用户报告,它将清除先前的进行中报告(如果存在的话)。UserReportingService.Instance.CreateNewUserReport();发送报告
该 SDK 现在一次只处理一个报告。该 API 不是将 UserReport 对象提供给 send 方法,而是有一个单独的调用来发送进行中报告:UserReportingService.Instance.SendUserReport(...)UserReportingService.Instance.SendUserReport((uploadProgress) =>{ // The progressUpdate Action uses the uploadProgress float to indicate progress from 0.0 -> 1.0 Debug.Log("${uploadProgress:P}");},(success) =>{ // The result Action uses the success bool to indicate whether or not the submission succeeded if (!success) { Debug.Log("Failed to send report!"); }});
关于添加数据的一般性更改
将个别对象值添加到个别报告对象的列表时,使用了一个专用函数,其参数与过去使用的构造函数相同并适用于各处。 请查看以下示例,这种情况下添加了一个新的报告维度: 1.0 添加新报告维度示例:2.0 添加新报告维度示例:UserReport current;UnityUserReporting.CurrentClient.CreateUserReport((report) => { current = report;});current.Dimensions.Add(new UserReportNamedValue("Category", “Value”));
UserReportingService.Instance.AddDimensionValue("Category", “Value”);添加自定义附件
该 SDK 现在有一个函数,可以将附件添加到进行中报告,而不是直接将附件添加到用户报告对象本身:添加(设备)元数据:“设备元数据”通常简称为元数据。同样,现在有一个专门用于此目的的函数。string content = "{}"; // An empty JSON object for example purposes.UserReportingService.Instance.AddAttachmentToReport("Sample Attachment JSON", "SampleAttachment.json", Encoding.UTF8.GetBytes(content), "application/json");
UserReportingService.Instance.AddMetadata(“Example Name”, “Example Value”)