|
|
||
|---|---|---|
| .. | ||
| Editor | ||
| Plugins | ||
| Runtime | ||
| ~Sample | ||
| Editor.meta | ||
| Plugins.meta | ||
| README.md | ||
| README.md.meta | ||
| Runtime.meta | ||
| ~Sample.meta | ||
README.md
Guru Unity Analytics
GuruAnalyticsLib 的 Unity 插件库
Change Logs
1.9.0
- Android 端对齐 0.3.1+.
Hash: 0457eba963a9049fb6a16708b921573ef36c99b1
- iOS 端对齐 0.3.3
Hash: c86d19fb38c8260f468e38d756aca84e89d58c8b
- 新增自打点的错误上报功能, 但需要项目内接入 GuruSDKCallbacks 对象才能完成日志回发的功能
- 错误上报开在 Plugin 外部应关依赖云控开启, 默认关闭.
1.8.4
- 优化Android 端 Worker 调用逻辑, 重启 Worker 有助于让打点数据更准确
1.8.3
- 修复 fg 打点上报时长不正确的问题
1.8.2
- 修复参数类型转换的BUG, param数据转换为JSON对象
1.8.1
- 修复自打点浮点参数精度问题
- 添加太极020数值设置接口
1.7.5
- 删除
androidx.appcompat:appcompat库依赖
Document
-
项目整合插件后, 请一定要在各插件的初始化后上报各相关ID:
-
相关接口如下
-
UID
// ---- 需要等待中台初始化后上报: // 上报中台返回的用户ID string uid = IPMConfig.IPM_UID GuruAnalytics.SetUid(uid); -
DeviceID
// 上报设备ID string deviceId = IPMConfig.IPM_DEVICE_ID GuruAnalytics.SetDeviceId(DeviceID); -
FirebaseID
// ---- 需要Firebase Analytic 初始化后, 异步获取对应的ID: private static async void InitFirebaseAnalytics() { Debug.Log($"---[ANA] IPM UID: {IPMConfig.IPM_UID}"); var task = FirebaseAnalytics.GetAnalyticsInstanceIdAsync(); await task; if (task.IsCompleted) { var fid = task.Result; if (!string.IsNullOrEmpty(fid)) { Debug.Log($"---[ANA] Firebase ID: {fid}"); GuruAnalytics.SetFirebaseId(fid); } } else { Debug.LogError("---- Get Firebase Analytics Instance Fail"); } } -
AdjustID
// ---- Adjust 启动后调用: string adjustID = Adjust.getAdid(); GuruAnalytics.SetAdjustId(adjustID); -
AdID
string adId = ""; Adjust.getGoogleAdId(id => { Debug.Log($"---- [ADJ] ADId: {id}"); adId = id; GuruAnalytics.SetAdId(id); }); -
上报用户属性:
string item_category = "main"; int level = 7; GuruAnalytics.SetUserProperty("item_category", item_category); GuruAnalytics.SetUserProperty("level", level.ToString()); -
上报视图名称
string screenName = "MainView"; GuruAnalytics.SetScreen(screenName); -
上报自定义打点:
string eventName = "user_get_coin"; Dictionary<string, dynamic> data = new Dictionary<string, dynamic>() { { "level", 7 }, { "user_coin", 105L }, { "win_rate", 21.25f }, { "b_level", 7 }, { "result", "retry" } }; GuruAnalytics.LogEvent(eventName, data);
依赖台配置说明
本项目已开始使用 ExternalDependencyManager 简称 EDM 来解决各种库的依赖问题
详细配置可见: Dependencies.xml
IOS 项目注意配置如下图:
--> 取消勾选 Link frameworks statically
Android 项目配置:
于主菜单 BuildSettings/PlayerSettings/PubishSettings:
开启如下选项:
- Custom Main Gradle Template
- Custom Properties Gradle Template
之后会在项目的 Plugins/Android内生成对应的文件.
(A) 修改 gradleTemplate.properties
添加一下内容支持 AndroidX
org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
org.gradle.parallel=true
android.enableR8=false
unityStreamingAssets=.unity3d**STREAMING_ASSETS**
android.useAndroidX=true
android.enableJetifier=true
**ADDITIONAL_PROPERTIES**
(B) 修改 mainTemplate.gradle
于 dependency 内添加如下依赖 (目前会自动添加, 无需手动添加)
dependencies {
...
implementation 'androidx.core:core:1.7.0'
compile 'com.mapzen:on-the-road:0.8.1'
// basicDependencies
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'com.google.code.gson:gson:2.8.5'
// roomDependencies
implementation 'androidx.room:room-runtime:2.4.3'
implementation 'androidx.room:room-rxjava2:2.4.3'
// retrofitDependencies
implementation 'com.squareup.retrofit2:retrofit:2.7.1'
implementation 'com.squareup.retrofit2:converter-gson:2.7.1'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.7.1'
// okhttpDependencies
implementation 'androidx.work:work-runtime:2.7.1'
implementation 'androidx.work:work-runtime-ktx:2.7.1'
implementation 'androidx.work:work-rxjava2:2.7.1'
// process
implementation 'androidx.lifecycle:lifecycle-process:2.4.0'
// okhttp3
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
...
}
最低 minTarget 设置为 21
(D) 修改 proguard-user.txt 文件, 在最后追加此插件的相关代码
若项目使用了 ProGuard 压缩混淆, 需要修改此文件, 否则可能造成JAVA类无法被找到
...
-keep class com.guru.** { *; }
-keep class guru.core.** { *; }
示例项目
- 示例项目位于 ~Sample 目录内. 详见 CuruAnalyticsDemo.cs
- 示例借用了 BallSortPuzzle 的
AppID和BundleID
