feat:1、添加项目
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &3471622134282543401
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 57277738888238098}
|
||||
- component: {fileID: 1362306111410183020}
|
||||
m_Layer: 0
|
||||
m_Name: DataEyeAnalytics
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &57277738888238098
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3471622134282543401}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1362306111410183020
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3471622134282543401}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 33ebde6e0f859403daec2a001ebd2661, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
enableLog: 1
|
||||
networkType: 1
|
||||
tokens:
|
||||
- appid: 1007
|
||||
serverUrl: http://deapi.adsgreat.cn/v1/sdk/report
|
||||
mode: 0
|
||||
timeZone: 0
|
||||
timeZoneId:
|
||||
reyunAppID:
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 986ad473b78d14e08b1f05d368cb1591
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,829 @@
|
||||
/*
|
||||
*
|
||||
Copyright 2019, ThinkingData, Inc
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
SDK VERSION:2.1.4
|
||||
*/
|
||||
#if !(UNITY_5_4_OR_NEWER)
|
||||
#define DISABLE_TA
|
||||
#warning "Your Unity version is not supported by us - DataEyeAnalyticsSDK disabled"
|
||||
#endif
|
||||
#if !(UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN)
|
||||
#define DISABLE_TA
|
||||
#warning "Your Unity Platfrom is not supported by us - DataEyeAnalyticsSDK disabled"
|
||||
#endif
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using DataEyeAnalytics.Utils;
|
||||
using DataEyeAnalytics.Wrapper;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DataEyeAnalytics
|
||||
{
|
||||
/// <summary>
|
||||
/// Dynamic super properties interfaces.
|
||||
/// </summary>
|
||||
public interface IDynamicSuperProperties
|
||||
{
|
||||
Dictionary<string, object> GetDynamicSuperProperties();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 内部使用的特殊事件类, 不要直接使用此类。
|
||||
/// </summary>
|
||||
public class DataEyeAnalyticsEvent
|
||||
{
|
||||
public enum Type
|
||||
{
|
||||
FIRST,
|
||||
UPDATABLE,
|
||||
OVERWRITABLE
|
||||
}
|
||||
|
||||
public DataEyeAnalyticsEvent(string eventName, Dictionary<string, object> properties) {
|
||||
EventName = eventName;
|
||||
Properties = properties;
|
||||
}
|
||||
|
||||
public Type? EventType { get; set; }
|
||||
public string EventName { get; }
|
||||
public Dictionary<string, object> Properties { get; }
|
||||
|
||||
public DateTime EventTime { get; set; }
|
||||
public string ExtraId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 首次(唯一)事件。默认情况下采集设备首次事件。请咨询数数客户成功获取支持。
|
||||
/// </summary>
|
||||
public class TDFirstEvent : DataEyeAnalyticsEvent
|
||||
{
|
||||
public TDFirstEvent(string eventName, Dictionary<string, object> properties) : base(eventName, properties)
|
||||
{
|
||||
EventType = Type.FIRST;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置用于检测是否首次的 ID,默认情况下会使用设备 ID
|
||||
/// </summary>
|
||||
/// <param name="firstCheckId">用于首次事件检测的 ID</param>
|
||||
public void SetFirstCheckId(string firstCheckId)
|
||||
{
|
||||
ExtraId = firstCheckId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 可被更新的事件。请咨询数数客户成功获取支持。
|
||||
/// </summary>
|
||||
public class TDUpdatableEvent : DataEyeAnalyticsEvent
|
||||
{
|
||||
public TDUpdatableEvent(string eventName, Dictionary<string, object> properties, string eventId) : base(eventName, properties)
|
||||
{
|
||||
EventType = Type.UPDATABLE;
|
||||
ExtraId = eventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 可被重写的事件。请咨询数数客户成功获取支持。
|
||||
/// </summary>
|
||||
public class TDOverWritableEvent : DataEyeAnalyticsEvent
|
||||
{
|
||||
public TDOverWritableEvent(string eventName, Dictionary<string, object> properties, string eventId) : base(eventName, properties)
|
||||
{
|
||||
EventType = Type.OVERWRITABLE;
|
||||
ExtraId = eventId;
|
||||
}
|
||||
}
|
||||
|
||||
// 自动采集事件类型
|
||||
[Flags]
|
||||
public enum AUTO_TRACK_EVENTS
|
||||
{
|
||||
NONE = 0,
|
||||
APP_START = 1 << 0, // 当应用进入前台的时候触发上报,对应 ta_app_start
|
||||
APP_END = 1 << 1, // 当应用进入后台的时候触发上报,对应 ta_app_end
|
||||
APP_CRASH = 1 << 4, // 当出现未捕获异常的时候触发上报,对应 ta_app_crash
|
||||
APP_INSTALL = 1 << 5, // 应用安装后首次打开的时候触发上报,对应 ta_app_install
|
||||
ALL = APP_START | APP_END | APP_INSTALL | APP_CRASH
|
||||
}
|
||||
|
||||
public class DataEyeAnalyticsAPI : MonoBehaviour
|
||||
{
|
||||
#region settings
|
||||
[System.Serializable]
|
||||
public struct Token
|
||||
{
|
||||
public string appid;
|
||||
public string serverUrl;
|
||||
public TAMode mode;
|
||||
public TATimeZone timeZone;
|
||||
public string timeZoneId;
|
||||
|
||||
//热云appid
|
||||
public string reyunAppID;
|
||||
|
||||
public Token(string appId, string serverUrl, TAMode mode, TATimeZone timeZone, string reyunAppID, string timeZoneId = null)
|
||||
{
|
||||
appid = appId;
|
||||
this.serverUrl = serverUrl;
|
||||
this.mode = mode;
|
||||
this.timeZone = timeZone;
|
||||
this.timeZoneId = timeZoneId;
|
||||
this.reyunAppID = reyunAppID;
|
||||
}
|
||||
|
||||
public string getTimeZoneId()
|
||||
{
|
||||
switch (timeZone)
|
||||
{
|
||||
case TATimeZone.UTC:
|
||||
return "UTC";
|
||||
case TATimeZone.Asia_Shanghai:
|
||||
return "Asia/Shanghai";
|
||||
case TATimeZone.Asia_Tokyo:
|
||||
return "Asia/Tokyo";
|
||||
case TATimeZone.America_Los_Angeles:
|
||||
return "America/Los_Angeles";
|
||||
case TATimeZone.America_New_York:
|
||||
return "America/New_York";
|
||||
case TATimeZone.Other:
|
||||
return timeZoneId;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public enum TATimeZone
|
||||
{
|
||||
Local,
|
||||
UTC,
|
||||
Asia_Shanghai,
|
||||
Asia_Tokyo,
|
||||
America_Los_Angeles,
|
||||
America_New_York,
|
||||
Other = 100
|
||||
}
|
||||
|
||||
public enum TAMode
|
||||
{
|
||||
NORMAL = 0,
|
||||
DEBUG = 1,
|
||||
DEBUG_ONLY = 2
|
||||
}
|
||||
|
||||
public enum NetworkType
|
||||
{
|
||||
DEFAULT = 1,
|
||||
WIFI = 2,
|
||||
ALL = 3
|
||||
}
|
||||
|
||||
[Header("Configuration")]
|
||||
[Tooltip("是否打开 Log")]
|
||||
public bool enableLog = true;
|
||||
[Tooltip("设置网络类型")]
|
||||
public NetworkType networkType = NetworkType.DEFAULT;
|
||||
|
||||
[Header("Project")]
|
||||
[Tooltip("项目相关配置, APP ID 会在项目申请时给出")]
|
||||
[HideInInspector]
|
||||
public Token[] tokens = new Token[1];
|
||||
|
||||
#endregion
|
||||
|
||||
public readonly string VERSION = "2.1.4";
|
||||
|
||||
/// <summary>
|
||||
/// 设置自定义访客 ID,用于替换系统生成的访客 ID
|
||||
/// </summary>
|
||||
/// <param name="FIRSTId">访客 ID</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void Identify(string FIRSTId, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).Identify(FIRSTId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回当前的访客 ID.
|
||||
/// </summary>
|
||||
/// <returns>访客 ID</returns>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static string GetDistinctId(string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
return getInstance(appId).GetDistinctId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置账号 ID. 该方法不会上传用户登录事件.
|
||||
/// </summary>
|
||||
/// <param name="account">账号 ID</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void Login(string account, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).Login(account);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空账号 ID. 该方法不会上传用户登出事件.
|
||||
/// </summary>
|
||||
/// <param name="appId">项目 ID(可选) </param>
|
||||
public static void Logout(string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).Logout();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主动触发上报缓存事件到服务器.
|
||||
/// </summary>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void Flush(string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).Flush();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开启自动采集功能.
|
||||
/// </summary>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void EnableAutoTrack(AUTO_TRACK_EVENTS events, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).EnableAutoTrack(events);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// track 简单事件. 该事件会先缓存在本地,达到触发上报条件或者主动调用 Flush 时会上报到服务器.
|
||||
/// </summary>
|
||||
/// <param name="eventName">事件名称</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void Track(string eventName, string appId = "")
|
||||
{
|
||||
Track(eventName, null, appId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// track 事件及事件属性. 该事件会先缓存在本地,达到触发上报条件或者主动调用 Flush 时会上报到服务器.
|
||||
/// </summary>
|
||||
/// <param name="eventName">事件名称</param>
|
||||
/// <param name="properties">Properties</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void Track(string eventName, Dictionary<string, object> properties, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).Track(eventName, properties);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// track 事件及事件属性,并指定 #event_time 属性. 该事件会先缓存在本地,达到触发上报条件或者主动调用 Flush 时会上报到服务器. 从 v1.3.0 开始,会考虑 date 的时区信息。支持 UTC 和 local 时区.
|
||||
/// </summary>
|
||||
/// <param name="eventName">事件名称</param>
|
||||
/// <param name="properties">事件属性</param>
|
||||
/// <param name="date">事件时间</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void Track(string eventName, Dictionary<string, object> properties, DateTime date, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).Track(eventName, properties, date);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static void Track(DataEyeAnalyticsEvent analyticsEvent, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).Track(analyticsEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置公共事件属性. 公共事件属性指的就是每个事件都会带有的属性.
|
||||
/// </summary>
|
||||
/// <param name="superProperties">公共事件属性</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void SetSuperProperties(Dictionary<string, object> superProperties, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).SetSuperProperties(superProperties);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除某个公共事件属性.
|
||||
/// </summary>
|
||||
/// <param name="property">属性名称</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void UnsetSuperProperty(string property, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).UnsetSuperProperty(property);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回当前公共事件属性.
|
||||
/// </summary>
|
||||
/// <returns>公共事件属性</returns>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static Dictionary<string, object> GetSuperProperties(string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
return getInstance(appId).GetSuperProperties();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空公共事件属性.
|
||||
/// </summary>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void ClearSuperProperties(string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).ClearSuperProperty();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 记录事件时长. 调用 TimeEvent 为某事件开始计时,当 track 传该事件时,SDK 会在在事件属性中加入 #duration 这一属性来表示事件时长,单位为秒.
|
||||
/// </summary>
|
||||
/// <param name="eventName">事件名称</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void TimeEvent(string eventName, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).TimeEvent(eventName);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置用户属性. 该接口上传的属性将会覆盖原有的属性值.
|
||||
/// </summary>
|
||||
/// <param name="properties">用户属性</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void UserSet(Dictionary<string, object> properties, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).UserSet(properties);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置用户属性. 该接口上传的属性将会覆盖原有的属性值.
|
||||
/// </summary>
|
||||
/// <param name="properties">用户属性</param>
|
||||
/// <param name="dateTime">用户属性设置的时间</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void UserSet(Dictionary<string, object> properties, DateTime dateTime, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).UserSet(properties, dateTime);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置一个用户属性.
|
||||
/// </summary>
|
||||
/// <param name="property">用户属性名称</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void UserUnset(string property, string appId = "")
|
||||
{
|
||||
List<string> properties = new List<string>();
|
||||
properties.Add(property);
|
||||
UserUnset(properties, appId);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重置一组用户属性
|
||||
/// </summary>
|
||||
/// <param name="properties">用户属性列表</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void UserUnset(List<string> properties, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).UserUnset(properties);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置一组用户属性, 并指定操作时间
|
||||
/// </summary>
|
||||
/// <param name="properties">用户属性列表</param>
|
||||
/// <param name="dateTime">操作时间</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void UserUnset(List<string> properties, DateTime dateTime, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).UserUnset(properties, dateTime);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置用户属性. 当该属性之前已经有值的时候,将会忽略这条信息.
|
||||
/// </summary>
|
||||
/// <param name="properties">用户属性</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void UserSetOnce(Dictionary<string, object> properties, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).UserSetOnce(properties);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置用户属性. 当该属性之前已经有值的时候,将会忽略这条信息.
|
||||
/// </summary>
|
||||
/// <param name="properties">用户属性</param>
|
||||
/// <param name="dateTime">操作时间</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void UserSetOnce(Dictionary<string, object> properties, DateTime dateTime, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).UserSetOnce(properties, dateTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 对数值类用户属性进行累加. 如果该属性还未被设置,则会赋值 0 后再进行计算.
|
||||
/// </summary>
|
||||
/// <param name="property">属性名称</param>
|
||||
/// <param name="value">数值</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void UserAdd(string property, object value, string appId = "")
|
||||
{
|
||||
Dictionary<string, object> properties = new Dictionary<string, object>()
|
||||
{
|
||||
{ property, value }
|
||||
};
|
||||
UserAdd(properties, appId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 对数值类用户属性进行累加. 如果属性还未被设置,则会赋值 0 后再进行计算.
|
||||
/// </summary>
|
||||
/// <param name="properties">用户属性</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void UserAdd(Dictionary<string, object> properties, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).UserAdd(properties);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 对数值类用户属性进行累加. 如果属性还未被设置,则会赋值 0 后再进行计算.
|
||||
/// </summary>
|
||||
/// <param name="properties">用户属性</param>
|
||||
/// <param name="dateTime">操作时间</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void UserAdd(Dictionary<string, object> properties, DateTime dateTime, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).UserAdd(properties, dateTime);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 对 List 类型的用户属性进行追加.
|
||||
/// </summary>
|
||||
/// <param name="properties">用户属性</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void UserAppend(Dictionary<string, object> properties, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).UserAppend(properties);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 对 List 类型的用户属性进行追加.
|
||||
/// </summary>
|
||||
/// <param name="properties">用户属性</param>
|
||||
/// <param name="dateTime">操作时间</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void UserAppend(Dictionary<string, object> properties, DateTime dateTime, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).UserAppend(properties, dateTime);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除用户数据. 之后再查询该名用户的用户属性,但该用户产生的事件仍然可以被查询到
|
||||
/// </summary>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void UserDelete(string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).UserDelete();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除用户数据并指定操作时间.
|
||||
/// </summary>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void UserDelete(DateTime dateTime, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).UserDelete(dateTime);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置允许上报数据到服务器的网络类型.
|
||||
/// </summary>
|
||||
/// <param name="networkType">网络类型</param>
|
||||
/// <param name="appId">项目 ID(可选)</param>
|
||||
public static void SetNetworkType(NetworkType networkType, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).SetNetworkType(networkType);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the device identifier.
|
||||
/// </summary>
|
||||
/// <returns>The device identifier.</returns>
|
||||
public static string GetDeviceId()
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
return getInstance("").GetDeviceId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the dynamic super properties.
|
||||
/// </summary>
|
||||
/// <param name="dynamicSuperProperties">Dynamic super properties interface.</param>
|
||||
/// <param name="appId">App ID (optional).</param>
|
||||
public static void SetDynamicSuperProperties(IDynamicSuperProperties dynamicSuperProperties, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).SetDynamicSuperProperties(dynamicSuperProperties);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止上报数据,并且清空本地缓存数据(未上报的数据、已设置的访客ID、账号ID、公共属性)
|
||||
/// </summary>
|
||||
/// <param name="appId">项目ID</param>
|
||||
public static void OptOutTracking(string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).OptOutTracking();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止上报数据,清空本地缓存数据,并且发送 user_del 到服务端.
|
||||
/// </summary>
|
||||
/// <param name="appId">项目ID</param>
|
||||
public static void OptOutTrackingAndDeleteUser(string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).OptOutTrackingAndDeleteUser();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 恢复上报数据
|
||||
/// </summary>
|
||||
/// <param name="appId">项目ID</param>
|
||||
public static void OptInTracking(string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).OptInTracking();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 暂停/恢复上报数据,本地缓存不会被清空
|
||||
/// </summary>
|
||||
/// <param name="enabled">是否打开上报数据</param>
|
||||
/// <param name="appId">项目ID</param>
|
||||
public static void EnableTracking(bool enabled, string appId = "")
|
||||
{
|
||||
if (tracking_enabled)
|
||||
{
|
||||
getInstance(appId).EnableTracking(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建轻量级实例,轻量级实例与主实例共享项目ID. 访客ID、账号ID、公共属性不共享
|
||||
/// </summary>
|
||||
/// <param name="appId">项目ID</param>
|
||||
/// <returns>轻量级实例的 token </returns>
|
||||
public static string CreateLightInstance(string appId = "") {
|
||||
if (tracking_enabled)
|
||||
{
|
||||
DataEyeAnalyticsWrapper lightInstance = getInstance(appId).CreateLightInstance();
|
||||
instance_lock.EnterWriteLock();
|
||||
try
|
||||
{
|
||||
sInstances.Add(lightInstance.GetAppId(), lightInstance);
|
||||
} finally
|
||||
{
|
||||
instance_lock.ExitWriteLock();
|
||||
}
|
||||
return lightInstance.GetAppId();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 传入时间戳校准 SDK 时间.
|
||||
/// </summary>
|
||||
/// <param name="timestamp">当前 Unix timestamp, 单位 毫秒</param>
|
||||
public static void CalibrateTime(long timestamp)
|
||||
{
|
||||
DataEyeAnalyticsWrapper.CalibrateTime(timestamp);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 传入 NTP Server 地址校准 SDK 时间.
|
||||
///
|
||||
/// 您可以根据您用户所在地传入访问速度较快的 NTP Server 地址, 例如 time.asia.apple.com
|
||||
/// SDK 默认情况下会等待 3 秒,去获取时间偏移数据,并用该偏移校准之后的数据.
|
||||
/// 如果在 3 秒内未因网络原因未获得正确的时间偏移,本次应用运行期间将不会再校准时间.
|
||||
/// </summary>
|
||||
/// <param name="timestamp">可用的 NTP 服务器地址</param>
|
||||
public static void CalibrateTimeWithNtp(string ntpServer)
|
||||
{
|
||||
DataEyeAnalyticsWrapper.CalibrateTimeWithNtp(ntpServer);
|
||||
}
|
||||
|
||||
//多实例场景,设置默认的appid
|
||||
public static void setDefaultAppid(string appid)
|
||||
{
|
||||
if (sInstances.Count > 0 && sInstances.ContainsKey(appid))
|
||||
{
|
||||
default_appid = appid;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否加密
|
||||
/// </summary>
|
||||
public static void EnableEncrypt(bool enabled, string appId = "")
|
||||
{
|
||||
getInstance(appId).EnableEncrypt(enabled);
|
||||
}
|
||||
|
||||
#region internal
|
||||
|
||||
void Awake()
|
||||
{
|
||||
#if DISABLE_TA
|
||||
tracking_enabled = false;
|
||||
#endif
|
||||
DE_Log.EnableLog(enableLog);
|
||||
DataEyeAnalyticsWrapper.SetVersionInfo("");
|
||||
if (TA_instance == null)
|
||||
{
|
||||
DontDestroyOnLoad(gameObject);
|
||||
TA_instance = this;
|
||||
} else
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
if (tracking_enabled)
|
||||
{
|
||||
default_appid = tokens[0].appid;
|
||||
instance_lock.EnterWriteLock();
|
||||
try
|
||||
{
|
||||
DataEyeAnalyticsWrapper.EnableLog(enableLog);
|
||||
foreach (Token token in tokens)
|
||||
{
|
||||
//Debug.Log("token:"+token.appid);
|
||||
if (!string.IsNullOrEmpty(token.appid))
|
||||
{
|
||||
DataEyeAnalyticsWrapper wrapper = new DataEyeAnalyticsWrapper(token);
|
||||
wrapper.SetNetworkType(networkType);
|
||||
sInstances.Add(token.appid,wrapper);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
instance_lock.ExitWriteLock();
|
||||
}
|
||||
if (sInstances.Count == 0)
|
||||
{
|
||||
tracking_enabled = false;
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// getInstance(default_appid).SetNetworkType(networkType);
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private static DataEyeAnalyticsAPI TA_instance;
|
||||
private static string default_appid; // 如果用户调用接口时不指定项目 ID,默认使用第一个项目 ID
|
||||
private static bool tracking_enabled = true;
|
||||
private static ReaderWriterLockSlim instance_lock = new ReaderWriterLockSlim();
|
||||
private static readonly Dictionary<string, DataEyeAnalyticsWrapper> sInstances =
|
||||
new Dictionary<string, DataEyeAnalyticsWrapper>();
|
||||
|
||||
private static DataEyeAnalyticsWrapper getInstance(string appid)
|
||||
{
|
||||
instance_lock.EnterReadLock();
|
||||
try
|
||||
{
|
||||
if (sInstances.Count > 0 && sInstances.ContainsKey(appid))
|
||||
{
|
||||
return sInstances[appid];
|
||||
}
|
||||
return sInstances[default_appid];
|
||||
} finally
|
||||
{
|
||||
instance_lock.ExitReadLock();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33ebde6e0f859403daec2a001ebd2661
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c3596aacf52e4dce91260e35b40c684
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,147 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
|
||||
namespace DataEyeAnalytics.Editors
|
||||
{
|
||||
[CustomEditor(typeof(DataEyeAnalyticsAPI))]
|
||||
[CanEditMultipleObjects]
|
||||
public class DE_Inspectors : Editor
|
||||
{
|
||||
private ReorderableList _stringArray;
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
|
||||
var appId = this.serializedObject.FindProperty("tokens");
|
||||
|
||||
_stringArray = new ReorderableList(appId.serializedObject, appId, true, true, true, true)
|
||||
{
|
||||
drawHeaderCallback = DrawListHeader,
|
||||
drawElementCallback = DrawListElement,
|
||||
onRemoveCallback = RemoveListElement,
|
||||
onAddCallback = AddListElement
|
||||
};
|
||||
|
||||
_stringArray.elementHeight = 5 * (EditorGUIUtility.singleLineHeight + 10);
|
||||
|
||||
_stringArray.serializedProperty.isExpanded = true;
|
||||
}
|
||||
|
||||
void DrawListHeader(Rect rect)
|
||||
{
|
||||
var arect = rect;
|
||||
arect.height = EditorGUIUtility.singleLineHeight + 10;
|
||||
arect.x += 14;
|
||||
arect.width = 80;
|
||||
GUIStyle style = new GUIStyle();
|
||||
style.fontStyle = FontStyle.Bold;
|
||||
|
||||
GUI.Label(arect, "Instance Configurations",style);
|
||||
}
|
||||
|
||||
void DrawListElement(Rect rect, int index, bool isActive, bool isFocused)
|
||||
{
|
||||
var spacing = 5;
|
||||
var xSpacing = 85;
|
||||
var arect = rect;
|
||||
SerializedProperty item = _stringArray.serializedProperty.GetArrayElementAtIndex(index);
|
||||
var serElem = this._stringArray.serializedProperty.GetArrayElementAtIndex(index);
|
||||
arect.height = EditorGUIUtility.singleLineHeight;
|
||||
arect.width = 240;
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
EditorGUI.PropertyField(arect, item, new GUIContent((index + 1) + " (default)"));
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.PropertyField(arect, item, new GUIContent("" + (index + 1)));
|
||||
|
||||
}
|
||||
arect.y += EditorGUIUtility.singleLineHeight + spacing;
|
||||
GUIStyle style = new GUIStyle();
|
||||
style.fontStyle = FontStyle.Bold;
|
||||
|
||||
|
||||
EditorGUI.LabelField(arect, "APP ID:", style);
|
||||
arect.x += xSpacing;
|
||||
EditorGUI.PropertyField(arect, serElem.FindPropertyRelative("appid"), GUIContent.none);
|
||||
|
||||
arect.y += EditorGUIUtility.singleLineHeight + spacing;
|
||||
arect.x -= xSpacing;
|
||||
|
||||
EditorGUI.LabelField(arect, "SERVER URL:", style);
|
||||
arect.x += xSpacing;
|
||||
EditorGUI.PropertyField(new Rect(arect.x, arect.y, arect.width, arect.height), serElem.FindPropertyRelative("serverUrl"), GUIContent.none);
|
||||
|
||||
arect.y += EditorGUIUtility.singleLineHeight + spacing;
|
||||
arect.x -= xSpacing;
|
||||
|
||||
EditorGUI.LabelField(arect, "MODE:", style);
|
||||
arect.x += xSpacing;
|
||||
EditorGUI.PropertyField(arect, serElem.FindPropertyRelative("mode"), GUIContent.none);
|
||||
|
||||
arect.y += EditorGUIUtility.singleLineHeight + spacing;
|
||||
arect.x -= xSpacing;
|
||||
|
||||
EditorGUI.LabelField(arect, "TimeZone:", style);
|
||||
arect.x += xSpacing;
|
||||
var a = serElem.FindPropertyRelative("timeZone");
|
||||
if (a.intValue == 100)
|
||||
{
|
||||
EditorGUI.PropertyField(new Rect(arect.x, arect.y, 115, arect.height), a, GUIContent.none);
|
||||
arect.x += 125;
|
||||
EditorGUI.PropertyField(new Rect(arect.x, arect.y, 115, arect.height), serElem.FindPropertyRelative("timeZoneId"), GUIContent.none);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.PropertyField(arect, a, GUIContent.none);
|
||||
}
|
||||
|
||||
arect.y += EditorGUIUtility.singleLineHeight + spacing;
|
||||
arect.x -= xSpacing;
|
||||
|
||||
EditorGUI.LabelField(arect, "Reyun AppID", style);
|
||||
arect.x += xSpacing;
|
||||
EditorGUI.PropertyField(new Rect(arect.x, arect.y, arect.width, arect.height), serElem.FindPropertyRelative("reyunAppID"), GUIContent.none);
|
||||
}
|
||||
|
||||
void AddListElement(ReorderableList list)
|
||||
{
|
||||
if (list.serializedProperty != null)
|
||||
{
|
||||
list.serializedProperty.arraySize++;
|
||||
list.index = list.serializedProperty.arraySize - 1;
|
||||
SerializedProperty item = list.serializedProperty.GetArrayElementAtIndex(list.index);
|
||||
item.FindPropertyRelative("appid").stringValue = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
ReorderableList.defaultBehaviours.DoAddButton(list);
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveListElement(ReorderableList list)
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("Warnning", "Do you want to remove this element?", "Remove", "Cancel"))
|
||||
{
|
||||
ReorderableList.defaultBehaviours.DoRemoveButton(list);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
DrawDefaultInspector();
|
||||
this.serializedObject.Update();
|
||||
var property = _stringArray.serializedProperty;
|
||||
property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, property.displayName);
|
||||
if (property.isExpanded)
|
||||
{
|
||||
|
||||
_stringArray.DoLayoutList();
|
||||
}
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4131b20258fa347c898e6e4126f5a247
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,85 @@
|
||||
#if UNITY_IPHONE
|
||||
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
|
||||
namespace DataEyeAnalytics.Editors
|
||||
{
|
||||
public class DE_PostProcessBuild
|
||||
{
|
||||
[PostProcessBuild]
|
||||
public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
|
||||
{
|
||||
if (buildTarget != BuildTarget.iOS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string projPath = PBXProject.GetPBXProjectPath(path);
|
||||
|
||||
PBXProject proj = new PBXProject();
|
||||
proj.ReadFromString(File.ReadAllText(projPath));
|
||||
|
||||
string mainTargetGuid;
|
||||
string unityFrameworkTargetGuid;
|
||||
|
||||
var unityMainTargetGuidMethod = proj.GetType().GetMethod("GetUnityMainTargetGuid");
|
||||
var unityFrameworkTargetGuidMethod = proj.GetType().GetMethod("GetUnityFrameworkTargetGuid");
|
||||
|
||||
if (unityMainTargetGuidMethod != null && unityFrameworkTargetGuidMethod != null)
|
||||
{
|
||||
mainTargetGuid = (string)unityMainTargetGuidMethod.Invoke(proj, null);
|
||||
unityFrameworkTargetGuid = (string)unityFrameworkTargetGuidMethod.Invoke(proj, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
mainTargetGuid = proj.TargetGuidByName ("Unity-iPhone");
|
||||
unityFrameworkTargetGuid = mainTargetGuid;
|
||||
}
|
||||
|
||||
proj.AddBuildProperty(unityFrameworkTargetGuid, "OTHER_LDFLAGS", "-ObjC");
|
||||
proj.AddFrameworkToProject (unityFrameworkTargetGuid, "Foundation.framework", false);
|
||||
proj.AddFrameworkToProject (unityFrameworkTargetGuid, "MobileCoreServices.framework", false);
|
||||
proj.AddFrameworkToProject (unityFrameworkTargetGuid, "WebKit.framework", false);
|
||||
proj.AddFileToBuild (unityFrameworkTargetGuid, proj.AddFile ("usr/lib/libz.tbd", "Frameworks/libz.tbd", PBXSourceTree.Sdk));
|
||||
proj.AddFileToBuild (unityFrameworkTargetGuid, proj.AddFile ("usr/lib/libsqlite3.tbd", "Frameworks/libsqlite3.tbd", PBXSourceTree.Sdk));
|
||||
File.WriteAllText(projPath, proj.WriteToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if UNITY_EDITOR && UNITY_ANDROID
|
||||
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Android;
|
||||
using UnityEngine;
|
||||
|
||||
using System.Xml;
|
||||
using System.Collections.Generic;
|
||||
|
||||
class DE_PostProcessBuild : IPostGenerateGradleAndroidProject
|
||||
{
|
||||
// 拷贝个性化配置文件 ta_public_config.xml
|
||||
public int callbackOrder { get { return 0; } }
|
||||
public void OnPostGenerateGradleAndroidProject(string path)
|
||||
{
|
||||
// 拷贝个性化配置文件 ta_public_config.xml
|
||||
string desPath = path + "/../launcher/src/main/res/values/ta_public_config.xml";
|
||||
if (File.Exists(desPath))
|
||||
{
|
||||
File.Delete(desPath);
|
||||
}
|
||||
TextAsset textAsset = Resources.Load<TextAsset>("ta_public_config");
|
||||
if (textAsset != null && textAsset.bytes != null)
|
||||
{
|
||||
File.WriteAllBytes(desPath, textAsset.bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f350415b0482442a3b0374013f3f9dbd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efe5e95f8073844fcbaedf8453895210
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,37 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace DataEyeAnalytics.Utils
|
||||
{
|
||||
public class DE_Log
|
||||
{
|
||||
private static bool enableLog;
|
||||
public static void EnableLog(bool enabled)
|
||||
{
|
||||
enableLog = enabled;
|
||||
}
|
||||
|
||||
public static void d(string message)
|
||||
{
|
||||
if (enableLog)
|
||||
{
|
||||
Debug.Log(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void e(string message)
|
||||
{
|
||||
if (enableLog)
|
||||
{
|
||||
Debug.LogError(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void w(string message)
|
||||
{
|
||||
if (enableLog)
|
||||
{
|
||||
Debug.LogWarning(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf27cc4612e60430ca5f468134d9a5b0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,604 @@
|
||||
/*
|
||||
* MIT License. Forked from GA_MiniJSON.
|
||||
* I modified it so that it could be used for TD limitations.
|
||||
*/
|
||||
// using UnityEngine;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace DataEyeAnalytics.Utils
|
||||
{
|
||||
/* Based on the JSON parser from
|
||||
* http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html
|
||||
*
|
||||
* I simplified it so that it doesn't throw exceptions
|
||||
* and can be used in Unity iPhone with maximum code stripping.
|
||||
*/
|
||||
/// <summary>
|
||||
/// This class encodes and decodes JSON strings.
|
||||
/// Spec. details, see http://www.json.org/
|
||||
///
|
||||
/// JSON uses Arrays and Objects. These correspond here to the datatypes ArrayList and Hashtable.
|
||||
/// All numbers are parsed to floats.
|
||||
/// </summary>
|
||||
public class DE_MiniJSON
|
||||
{
|
||||
/// <summary>
|
||||
/// Parses the string json into a value
|
||||
/// </summary>
|
||||
/// <param name="json">A JSON string.</param>
|
||||
/// <returns>An List<object>, a Dictionary<string, object>, a double, an integer,a string, null, true, or false</returns>
|
||||
public static Dictionary<string, object> Deserialize(string json)
|
||||
{
|
||||
// save the string for debug information
|
||||
if (json == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return Parser.Parse(json);
|
||||
}
|
||||
|
||||
sealed class Parser : IDisposable
|
||||
{
|
||||
const string WORD_BREAK = "{}[],:\"";
|
||||
|
||||
public static bool IsWordBreak(char c)
|
||||
{
|
||||
return Char.IsWhiteSpace(c) || WORD_BREAK.IndexOf(c) != -1;
|
||||
}
|
||||
|
||||
enum TOKEN
|
||||
{
|
||||
NONE,
|
||||
CURLY_OPEN,
|
||||
CURLY_CLOSE,
|
||||
SQUARED_OPEN,
|
||||
SQUARED_CLOSE,
|
||||
COLON,
|
||||
COMMA,
|
||||
STRING,
|
||||
NUMBER,
|
||||
TRUE,
|
||||
FALSE,
|
||||
NULL
|
||||
};
|
||||
|
||||
StringReader json;
|
||||
|
||||
Parser(string jsonString)
|
||||
{
|
||||
json = new StringReader(jsonString);
|
||||
}
|
||||
|
||||
public static Dictionary<string, object> Parse(string jsonString)
|
||||
{
|
||||
using (var instance = new Parser(jsonString))
|
||||
{
|
||||
return instance.ParseObject();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
json.Dispose();
|
||||
json = null;
|
||||
}
|
||||
|
||||
Dictionary<string, object> ParseObject()
|
||||
{
|
||||
Dictionary<string, object> table = new Dictionary<string, object>();
|
||||
|
||||
// ditch opening brace
|
||||
json.Read();
|
||||
|
||||
// {
|
||||
while (true)
|
||||
{
|
||||
switch (NextToken)
|
||||
{
|
||||
case TOKEN.NONE:
|
||||
return null;
|
||||
case TOKEN.COMMA:
|
||||
continue;
|
||||
case TOKEN.CURLY_CLOSE:
|
||||
return table;
|
||||
default:
|
||||
// name
|
||||
string name = ParseString();
|
||||
if (name == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// :
|
||||
if (NextToken != TOKEN.COLON)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// ditch the colon
|
||||
json.Read();
|
||||
|
||||
// value
|
||||
table[name] = ParseValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<object> ParseArray()
|
||||
{
|
||||
List<object> array = new List<object>();
|
||||
|
||||
// ditch opening bracket
|
||||
json.Read();
|
||||
|
||||
// [
|
||||
var parsing = true;
|
||||
while (parsing)
|
||||
{
|
||||
TOKEN nextToken = NextToken;
|
||||
|
||||
switch (nextToken)
|
||||
{
|
||||
case TOKEN.NONE:
|
||||
return null;
|
||||
case TOKEN.COMMA:
|
||||
continue;
|
||||
case TOKEN.SQUARED_CLOSE:
|
||||
parsing = false;
|
||||
break;
|
||||
default:
|
||||
object value = ParseByToken(nextToken);
|
||||
|
||||
array.Add(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
object ParseValue()
|
||||
{
|
||||
TOKEN nextToken = NextToken;
|
||||
return ParseByToken(nextToken);
|
||||
}
|
||||
|
||||
object ParseByToken(TOKEN token)
|
||||
{
|
||||
switch (token)
|
||||
{
|
||||
case TOKEN.STRING:
|
||||
string str = ParseString();
|
||||
DateTime dateTime;
|
||||
if (DateTime.TryParse(str, out dateTime))
|
||||
{
|
||||
return dateTime;
|
||||
}
|
||||
return str;
|
||||
case TOKEN.NUMBER:
|
||||
return ParseNumber();
|
||||
case TOKEN.CURLY_OPEN:
|
||||
return ParseObject();
|
||||
case TOKEN.SQUARED_OPEN:
|
||||
return ParseArray();
|
||||
case TOKEN.TRUE:
|
||||
return true;
|
||||
case TOKEN.FALSE:
|
||||
return false;
|
||||
case TOKEN.NULL:
|
||||
return null;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
string ParseString()
|
||||
{
|
||||
StringBuilder s = new StringBuilder();
|
||||
char c;
|
||||
|
||||
// ditch opening quote
|
||||
json.Read();
|
||||
|
||||
bool parsing = true;
|
||||
while (parsing)
|
||||
{
|
||||
|
||||
if (json.Peek() == -1)
|
||||
{
|
||||
parsing = false;
|
||||
break;
|
||||
}
|
||||
|
||||
c = NextChar;
|
||||
switch (c)
|
||||
{
|
||||
case '"':
|
||||
parsing = false;
|
||||
break;
|
||||
case '\\':
|
||||
if (json.Peek() == -1)
|
||||
{
|
||||
parsing = false;
|
||||
break;
|
||||
}
|
||||
|
||||
c = NextChar;
|
||||
switch (c)
|
||||
{
|
||||
case '"':
|
||||
case '\\':
|
||||
case '/':
|
||||
s.Append(c);
|
||||
break;
|
||||
case 'b':
|
||||
s.Append('\b');
|
||||
break;
|
||||
case 'f':
|
||||
s.Append('\f');
|
||||
break;
|
||||
case 'n':
|
||||
s.Append('\n');
|
||||
break;
|
||||
case 'r':
|
||||
s.Append('\r');
|
||||
break;
|
||||
case 't':
|
||||
s.Append('\t');
|
||||
break;
|
||||
case 'u':
|
||||
var hex = new char[4];
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
hex[i] = NextChar;
|
||||
}
|
||||
|
||||
s.Append((char)Convert.ToInt32(new string(hex), 16));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
s.Append(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return s.ToString();
|
||||
}
|
||||
|
||||
object ParseNumber()
|
||||
{
|
||||
string number = NextWord;
|
||||
|
||||
if (number.IndexOf('.') == -1)
|
||||
{
|
||||
long parsedInt;
|
||||
Int64.TryParse(number, out parsedInt);
|
||||
return parsedInt;
|
||||
}
|
||||
|
||||
double parsedDouble;
|
||||
Double.TryParse(number, out parsedDouble);
|
||||
return parsedDouble;
|
||||
}
|
||||
|
||||
void EatWhitespace()
|
||||
{
|
||||
while (Char.IsWhiteSpace(PeekChar))
|
||||
{
|
||||
json.Read();
|
||||
|
||||
if (json.Peek() == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char PeekChar
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToChar(json.Peek());
|
||||
}
|
||||
}
|
||||
|
||||
char NextChar
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToChar(json.Read());
|
||||
}
|
||||
}
|
||||
|
||||
string NextWord
|
||||
{
|
||||
get
|
||||
{
|
||||
StringBuilder word = new StringBuilder();
|
||||
|
||||
while (!IsWordBreak(PeekChar))
|
||||
{
|
||||
word.Append(NextChar);
|
||||
|
||||
if (json.Peek() == -1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return word.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
TOKEN NextToken
|
||||
{
|
||||
get
|
||||
{
|
||||
EatWhitespace();
|
||||
|
||||
if (json.Peek() == -1)
|
||||
{
|
||||
return TOKEN.NONE;
|
||||
}
|
||||
|
||||
switch (PeekChar)
|
||||
{
|
||||
case '{':
|
||||
return TOKEN.CURLY_OPEN;
|
||||
case '}':
|
||||
json.Read();
|
||||
return TOKEN.CURLY_CLOSE;
|
||||
case '[':
|
||||
return TOKEN.SQUARED_OPEN;
|
||||
case ']':
|
||||
json.Read();
|
||||
return TOKEN.SQUARED_CLOSE;
|
||||
case ',':
|
||||
json.Read();
|
||||
return TOKEN.COMMA;
|
||||
case '"':
|
||||
return TOKEN.STRING;
|
||||
case ':':
|
||||
return TOKEN.COLON;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
case '-':
|
||||
return TOKEN.NUMBER;
|
||||
}
|
||||
|
||||
switch (NextWord)
|
||||
{
|
||||
case "false":
|
||||
return TOKEN.FALSE;
|
||||
case "true":
|
||||
return TOKEN.TRUE;
|
||||
case "null":
|
||||
return TOKEN.NULL;
|
||||
}
|
||||
|
||||
return TOKEN.NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a IDictionary / IList object or a simple type (string, int, etc.) into a JSON string
|
||||
/// </summary>
|
||||
/// <param name="json">A Dictionary<string, object> / List<object></param>
|
||||
/// <returns>A JSON encoded string, or null if object 'json' is not serializable</returns>
|
||||
public static string Serialize(object obj, Func<DateTime, string> func = null)
|
||||
{
|
||||
return Serializer.Serialize(obj, func);
|
||||
}
|
||||
|
||||
sealed class Serializer
|
||||
{
|
||||
StringBuilder builder;
|
||||
Func<DateTime, string> func;
|
||||
|
||||
Serializer()
|
||||
{
|
||||
builder = new StringBuilder();
|
||||
}
|
||||
|
||||
public static string Serialize(object obj, Func<DateTime, string> func)
|
||||
{
|
||||
var instance = new Serializer();
|
||||
instance.func = func;
|
||||
|
||||
instance.SerializeValue(obj);
|
||||
|
||||
return instance.builder.ToString();
|
||||
}
|
||||
|
||||
void SerializeValue(object value)
|
||||
{
|
||||
IList asList;
|
||||
IDictionary asDict;
|
||||
string asStr;
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
builder.Append("null");
|
||||
}
|
||||
else if ((asStr = value as string) != null)
|
||||
{
|
||||
SerializeString(asStr);
|
||||
}
|
||||
else if (value is bool)
|
||||
{
|
||||
builder.Append((bool)value ? "true" : "false");
|
||||
}
|
||||
else if ((asList = value as IList) != null)
|
||||
{
|
||||
SerializeArray(asList);
|
||||
}
|
||||
else if ((asDict = value as IDictionary) != null)
|
||||
{
|
||||
SerializeObject(asDict);
|
||||
}
|
||||
else if (value is char)
|
||||
{
|
||||
SerializeString(new string((char)value, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
SerializeOther(value);
|
||||
}
|
||||
}
|
||||
|
||||
void SerializeObject(IDictionary obj)
|
||||
{
|
||||
bool first = true;
|
||||
|
||||
builder.Append('{');
|
||||
|
||||
foreach (object e in obj.Keys)
|
||||
{
|
||||
if (!first)
|
||||
{
|
||||
builder.Append(',');
|
||||
}
|
||||
|
||||
SerializeString(e.ToString());
|
||||
builder.Append(':');
|
||||
|
||||
SerializeValue(obj[e]);
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
builder.Append('}');
|
||||
}
|
||||
|
||||
void SerializeArray(IList anArray)
|
||||
{
|
||||
builder.Append('[');
|
||||
|
||||
bool first = true;
|
||||
|
||||
foreach (object obj in anArray)
|
||||
{
|
||||
if (!first)
|
||||
{
|
||||
builder.Append(',');
|
||||
}
|
||||
|
||||
SerializeValue(obj);
|
||||
|
||||
first = false;
|
||||
}
|
||||
|
||||
builder.Append(']');
|
||||
}
|
||||
|
||||
void SerializeString(string str)
|
||||
{
|
||||
builder.Append('\"');
|
||||
|
||||
char[] charArray = str.ToCharArray();
|
||||
foreach (var c in charArray)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case '"':
|
||||
builder.Append("\\\"");
|
||||
break;
|
||||
case '\\':
|
||||
builder.Append("\\\\");
|
||||
break;
|
||||
case '\b':
|
||||
builder.Append("\\b");
|
||||
break;
|
||||
case '\f':
|
||||
builder.Append("\\f");
|
||||
break;
|
||||
case '\n':
|
||||
builder.Append("\\n");
|
||||
break;
|
||||
case '\r':
|
||||
builder.Append("\\r");
|
||||
break;
|
||||
case '\t':
|
||||
builder.Append("\\t");
|
||||
break;
|
||||
default:
|
||||
int codepoint = Convert.ToInt32(c);
|
||||
if ((codepoint >= 32) && (codepoint <= 126))
|
||||
{
|
||||
builder.Append(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.Append("\\u");
|
||||
builder.Append(codepoint.ToString("x4"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
builder.Append('\"');
|
||||
}
|
||||
|
||||
void SerializeOther(object value)
|
||||
{
|
||||
// NOTE: decimals lose precision during serialization.
|
||||
// They always have, I'm just letting you know.
|
||||
// Previously floats and doubles lost precision too.
|
||||
if (value is float)
|
||||
{
|
||||
builder.Append(((float)value).ToString("R"));
|
||||
}
|
||||
else if (value is int
|
||||
|| value is uint
|
||||
|| value is long
|
||||
|| value is sbyte
|
||||
|| value is byte
|
||||
|| value is short
|
||||
|| value is ushort
|
||||
|| value is ulong)
|
||||
{
|
||||
builder.Append(value);
|
||||
}
|
||||
else if (value is double
|
||||
|| value is decimal)
|
||||
{
|
||||
builder.Append(Convert.ToDouble(value).ToString("R", System.Globalization.CultureInfo.InvariantCulture));
|
||||
}
|
||||
else if (value is DateTime)
|
||||
{
|
||||
builder.Append('\"');
|
||||
DateTime dateTime = (DateTime) value;
|
||||
if (null != func)
|
||||
{
|
||||
builder.Append(func((DateTime) value));
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.Append(dateTime.ToString("yyyy-MM-dd HH:mm:ss.fff"));
|
||||
}
|
||||
builder.Append('\"');
|
||||
}
|
||||
else
|
||||
{
|
||||
SerializeString(value.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46039f66576614c9d94fa7590896e331
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,120 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace DataEyeAnalytics.Utils
|
||||
{
|
||||
public class DE_PropertiesChecker
|
||||
{
|
||||
private static readonly Regex keyPattern = new Regex(@"^[a-zA-Z][a-zA-Z\d_#]{0,49}$");
|
||||
|
||||
public static bool IsNumeric(object AObject)
|
||||
{
|
||||
return AObject is sbyte
|
||||
|| AObject is byte
|
||||
|| AObject is short
|
||||
|| AObject is ushort
|
||||
|| AObject is int
|
||||
|| AObject is uint
|
||||
|| AObject is long
|
||||
|| AObject is ulong
|
||||
|| AObject is double
|
||||
|| AObject is decimal
|
||||
|| AObject is float;
|
||||
}
|
||||
|
||||
public static bool IsList(object obj) {
|
||||
if (obj == null)
|
||||
return false;
|
||||
return (obj.GetType().IsGenericType && obj.GetType().GetGenericTypeDefinition() == typeof(List<>)) || obj is Array;
|
||||
}
|
||||
|
||||
public static bool CheckProperties<V>(Dictionary<string, V> properties)
|
||||
{
|
||||
if (properties == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
foreach(KeyValuePair<string, V> kv in properties) {
|
||||
if (!CheckString(kv.Key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(kv.Value is string || kv.Value is DateTime || kv.Value is bool || IsNumeric(kv.Value) || IsList(kv.Value)))
|
||||
{
|
||||
DE_Log.w("TA.PropertiesChecker - property values must be one of: string, numberic, Boolean, DateTime, Array");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (kv.Value is string && System.Text.Encoding.UTF8.GetBytes(Convert.ToString(kv.Value)).Length > 2048) {
|
||||
DE_Log.w("TA.PropertiesChecker - the string is too long: " + (string)(object)kv.Value);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsNumeric(kv.Value)) {
|
||||
double number = Convert.ToDouble(kv.Value);
|
||||
if (number > 9999999999999.999 || number < -9999999999999.999)
|
||||
{
|
||||
DE_Log.w("TA.PropertiesChecker - number value is invalid: " + number + ", 数据范围是-9E15至9E15,小数点最多保留3位");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CheckProperteis(List<string> properties)
|
||||
{
|
||||
if (properties == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach(string value in properties)
|
||||
{
|
||||
if (!CheckString(value))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CheckString(string eventName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(eventName))
|
||||
{
|
||||
DE_Log.w("TA.PropertiesChecker - the string is null");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (keyPattern.IsMatch(eventName))
|
||||
{
|
||||
return true;
|
||||
} else
|
||||
{
|
||||
DE_Log.w("TA.PropertiesChecker - the string is invalid for TA: " + eventName + ", " +
|
||||
"事件名和属性名规则: 必须以字母开头,只能包含:数字,字母(忽略大小写)和下划线“_”,长度最大为50个字符。请注意配置时不要带有空格。");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void MergeProperties(Dictionary<string, object> source, Dictionary<string, object> dest)
|
||||
{
|
||||
if (null == source) return;
|
||||
foreach (KeyValuePair<string, object> kv in source)
|
||||
{
|
||||
if (dest.ContainsKey(kv.Key))
|
||||
{
|
||||
dest[kv.Key] = kv.Value;
|
||||
} else
|
||||
{
|
||||
dest.Add(kv.Key, kv.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9aa6d703ca6b841bda83b94121c2f172
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57bb4a9644e4f47f48024ccf8af3de0c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,376 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using DataEyeAnalytics.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DataEyeAnalytics.Wrapper
|
||||
{
|
||||
public partial class DataEyeAnalyticsWrapper
|
||||
{
|
||||
#if UNITY_ANDROID && !(UNITY_EDITOR)
|
||||
private static readonly string JSON_CLASS = "org.json.JSONObject";
|
||||
private static readonly AndroidJavaClass sdkClass = new AndroidJavaClass("cn.dataeye.android.DataEyeAnalyticsSDK");
|
||||
|
||||
private AndroidJavaObject instance;
|
||||
/// <summary>
|
||||
/// Convert Dictionary object to JSONObject in Java.
|
||||
/// </summary>
|
||||
/// <returns>The JSONObject instance.</returns>
|
||||
/// <param name="data">The Dictionary containing some data </param>
|
||||
private static AndroidJavaObject getJSONObject(string dataString)
|
||||
{
|
||||
if (dataString.Equals("null"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return new AndroidJavaObject(JSON_CLASS, dataString);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DE_Log.w("DataEyeAnalytics: unexpected exception: " + e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private string getTimeString(DateTime dateTime) {
|
||||
long dateTimeTicksUTC = TimeZoneInfo.ConvertTimeToUtc(dateTime).Ticks;
|
||||
|
||||
DateTime dtFrom = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
long currentMillis = (dateTimeTicksUTC - dtFrom.Ticks) / 10000;
|
||||
|
||||
AndroidJavaObject date = new AndroidJavaObject("java.util.Date", currentMillis);
|
||||
return instance.Call<string>("getTimeString", date);
|
||||
}
|
||||
|
||||
private static void enable_log(bool enableLog) {
|
||||
sdkClass.CallStatic("enableTrackLog", enableLog);
|
||||
}
|
||||
private static void setVersionInfo(string libName, string version) {
|
||||
sdkClass.CallStatic("setCustomerLibInfo", libName, version);
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
AndroidJavaObject context = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic<AndroidJavaObject>("currentActivity"); //获得Context
|
||||
// AndroidJavaObject config = configClass.CallStatic<AndroidJavaObject>("getInstance", context, token.appid, token.serverUrl);
|
||||
// config.Call("setModeInt", (int) token.mode);
|
||||
|
||||
// string timeZoneId = token.getTimeZoneId();
|
||||
// if (null != timeZoneId && timeZoneId.Length > 0)
|
||||
// {
|
||||
// AndroidJavaObject timeZone = new AndroidJavaClass("java.util.TimeZone").CallStatic<AndroidJavaObject>("getTimeZone", timeZoneId);
|
||||
// if (null != timeZone)
|
||||
// {
|
||||
// config.Call("setDefaultTimeZone", timeZone);
|
||||
// }
|
||||
// }
|
||||
|
||||
instance = sdkClass.CallStatic<AndroidJavaObject>("sharedInstance", context, token.appid, token.serverUrl);
|
||||
|
||||
|
||||
Debug.Log(" " + token.reyunAppID);
|
||||
if(token.reyunAppID != null && token.reyunAppID != "")
|
||||
instance.Call("reyunAppID", token.reyunAppID);
|
||||
}
|
||||
|
||||
private void flush()
|
||||
{
|
||||
instance.Call("flush");
|
||||
}
|
||||
|
||||
private AndroidJavaObject getDate(DateTime dateTime)
|
||||
{
|
||||
long dateTimeTicksUTC = TimeZoneInfo.ConvertTimeToUtc(dateTime).Ticks;
|
||||
|
||||
DateTime dtFrom = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
long currentMillis = (dateTimeTicksUTC - dtFrom.Ticks) / 10000;
|
||||
return new AndroidJavaObject("java.util.Date", currentMillis);
|
||||
}
|
||||
|
||||
private void track(string eventName, string properties, DateTime dateTime)
|
||||
{
|
||||
AndroidJavaObject date = getDate(dateTime);
|
||||
AndroidJavaClass tzClass = new AndroidJavaClass("java.util.TimeZone");
|
||||
AndroidJavaObject tz = null;
|
||||
|
||||
if (token.timeZone == DataEyeAnalyticsAPI.TATimeZone.Local)
|
||||
{
|
||||
switch (dateTime.Kind)
|
||||
{
|
||||
case DateTimeKind.Local:
|
||||
tz = tzClass.CallStatic<AndroidJavaObject>("getDefault");
|
||||
break;
|
||||
case DateTimeKind.Utc:
|
||||
tz = tzClass.CallStatic<AndroidJavaObject>("getTimeZone", "UTC");
|
||||
break;
|
||||
case DateTimeKind.Unspecified:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tz = tzClass.CallStatic<AndroidJavaObject>("getTimeZone", token.getTimeZoneId());
|
||||
}
|
||||
|
||||
instance.Call("track", eventName, getJSONObject(properties), date, tz);
|
||||
}
|
||||
|
||||
private void track(DataEyeAnalyticsEvent taEvent)
|
||||
{
|
||||
AndroidJavaObject javaEvent = null;
|
||||
switch(taEvent.EventType)
|
||||
{
|
||||
case DataEyeAnalyticsEvent.Type.FIRST:
|
||||
javaEvent = new AndroidJavaObject("cn.dataeye.android.DataEyeFirstEvent",
|
||||
taEvent.EventName, getJSONObject(getFinalEventProperties(taEvent.Properties)));
|
||||
|
||||
string extraId = taEvent.ExtraId;
|
||||
if (!string.IsNullOrEmpty(extraId))
|
||||
{
|
||||
javaEvent.Call("setFirstCheckId", extraId);
|
||||
}
|
||||
|
||||
break;
|
||||
case DataEyeAnalyticsEvent.Type.UPDATABLE:
|
||||
javaEvent = new AndroidJavaObject("cn.dataeye.android.TDUpdatableEvent",
|
||||
taEvent.EventName, getJSONObject(getFinalEventProperties(taEvent.Properties)), taEvent.ExtraId);
|
||||
break;
|
||||
case DataEyeAnalyticsEvent.Type.OVERWRITABLE:
|
||||
javaEvent = new AndroidJavaObject("cn.dataeye.android.TDOverWritableEvent",
|
||||
taEvent.EventName, getJSONObject(getFinalEventProperties(taEvent.Properties)), taEvent.ExtraId);
|
||||
break;
|
||||
}
|
||||
if (null == javaEvent) {
|
||||
DE_Log.w("Unexpected java event object. Returning...");
|
||||
return;
|
||||
}
|
||||
|
||||
if (taEvent.EventTime != DateTime.MinValue) {
|
||||
AndroidJavaObject date = getDate(taEvent.EventTime);
|
||||
AndroidJavaClass tzClass = new AndroidJavaClass("java.util.TimeZone");
|
||||
AndroidJavaObject tz = null;
|
||||
|
||||
if (token.timeZone == DataEyeAnalyticsAPI.TATimeZone.Local)
|
||||
{
|
||||
switch (taEvent.EventTime.Kind)
|
||||
{
|
||||
case DateTimeKind.Local:
|
||||
tz = tzClass.CallStatic<AndroidJavaObject>("getDefault");
|
||||
break;
|
||||
case DateTimeKind.Utc:
|
||||
tz = tzClass.CallStatic<AndroidJavaObject>("getTimeZone", "UTC");
|
||||
break;
|
||||
case DateTimeKind.Unspecified:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tz = tzClass.CallStatic<AndroidJavaObject>("getTimeZone", token.getTimeZoneId());
|
||||
}
|
||||
javaEvent.Call("setEventTime", date, tz);
|
||||
}
|
||||
instance.Call("track", javaEvent);
|
||||
}
|
||||
|
||||
private void track(string eventName, string properties)
|
||||
{
|
||||
instance.Call("track", eventName, getJSONObject(properties));
|
||||
}
|
||||
|
||||
private void setSuperProperties(string superProperties)
|
||||
{
|
||||
instance.Call("setSuperProperties", getJSONObject(superProperties));
|
||||
}
|
||||
|
||||
private void unsetSuperProperty(string superPropertyName)
|
||||
{
|
||||
instance.Call("unsetSuperProperty", superPropertyName);
|
||||
}
|
||||
|
||||
private void clearSuperProperty()
|
||||
{
|
||||
instance.Call("clearSuperProperties");
|
||||
}
|
||||
|
||||
private Dictionary<string, object> getSuperProperties()
|
||||
{
|
||||
Dictionary<string, object> result = null;
|
||||
AndroidJavaObject superPropertyObject = instance.Call<AndroidJavaObject>("getSuperProperties");
|
||||
if (null != superPropertyObject)
|
||||
{
|
||||
string superPropertiesString = superPropertyObject.Call<string>("toString");
|
||||
result = DE_MiniJSON.Deserialize(superPropertiesString);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void timeEvent(string eventName)
|
||||
{
|
||||
instance.Call("timeEvent", eventName);
|
||||
}
|
||||
|
||||
private void identify(string uniqueId)
|
||||
{
|
||||
instance.Call("identify", uniqueId);
|
||||
}
|
||||
|
||||
private string getDistinctId()
|
||||
{
|
||||
return instance.Call<string>("getDistinctId");
|
||||
}
|
||||
|
||||
private void login(string uniqueId)
|
||||
{
|
||||
instance.Call("login", uniqueId);
|
||||
}
|
||||
|
||||
private void userSetOnce(string properties)
|
||||
{
|
||||
instance.Call("user_setOnce", getJSONObject(properties));
|
||||
}
|
||||
|
||||
private void userSetOnce(string properties, DateTime dateTime)
|
||||
{
|
||||
instance.Call("user_setOnce", getJSONObject(properties), getDate(dateTime));
|
||||
}
|
||||
|
||||
private void userSet(string properties)
|
||||
{
|
||||
instance.Call("user_set", getJSONObject(properties));
|
||||
}
|
||||
|
||||
private void userSet(string properties, DateTime dateTime)
|
||||
{
|
||||
instance.Call("user_set", getJSONObject(properties), getDate(dateTime));
|
||||
}
|
||||
|
||||
private void userUnset(List<string> properties)
|
||||
{
|
||||
instance.Call("user_unset", properties.ToArray());
|
||||
}
|
||||
|
||||
private void userUnset(List<string> properties, DateTime dateTime)
|
||||
{
|
||||
Dictionary<string, object> finalProperties = new Dictionary<string, object>();
|
||||
foreach(string s in properties)
|
||||
{
|
||||
finalProperties.Add(s, 0);
|
||||
}
|
||||
|
||||
instance.Call("user_unset", getJSONObject(DE_MiniJSON.Serialize(finalProperties)), getDate(dateTime));
|
||||
}
|
||||
|
||||
private void userAdd(string properties)
|
||||
{
|
||||
instance.Call("user_add", getJSONObject(properties));
|
||||
}
|
||||
|
||||
private void userAdd(string properties, DateTime dateTime)
|
||||
{
|
||||
instance.Call("user_add", getJSONObject(properties), getDate(dateTime));
|
||||
}
|
||||
|
||||
private void userAppend(string properties)
|
||||
{
|
||||
instance.Call("user_append", getJSONObject(properties));
|
||||
}
|
||||
|
||||
private void userAppend(string properties, DateTime dateTime)
|
||||
{
|
||||
instance.Call("user_append", getJSONObject(properties), getDate(dateTime));
|
||||
}
|
||||
|
||||
private void userDelete()
|
||||
{
|
||||
instance.Call("user_delete");
|
||||
}
|
||||
|
||||
private void userDelete(DateTime dateTime)
|
||||
{
|
||||
instance.Call("user_delete", getDate(dateTime));
|
||||
}
|
||||
|
||||
private void logout() {
|
||||
instance.Call("logout");
|
||||
}
|
||||
|
||||
private string getDeviceId()
|
||||
{
|
||||
return instance.Call<string>("getDeviceId");
|
||||
}
|
||||
|
||||
private void setNetworkType(DataEyeAnalyticsAPI.NetworkType networkType) {
|
||||
switch (networkType)
|
||||
{
|
||||
case DataEyeAnalyticsAPI.NetworkType.DEFAULT:
|
||||
instance.Call("setNetworkType", 0);
|
||||
break;
|
||||
case DataEyeAnalyticsAPI.NetworkType.WIFI:
|
||||
instance.Call("setNetworkType", 1);
|
||||
break;
|
||||
case DataEyeAnalyticsAPI.NetworkType.ALL:
|
||||
instance.Call("setNetworkType", 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void enableAutoTrack(AUTO_TRACK_EVENTS events)
|
||||
{
|
||||
instance.Call("enableAutoTrack", (int) events);
|
||||
}
|
||||
|
||||
private void optOutTracking()
|
||||
{
|
||||
instance.Call("optOutTracking");
|
||||
}
|
||||
|
||||
private void optOutTrackingAndDeleteUser()
|
||||
{
|
||||
instance.Call("optOutTrackingAndDeleteUser");
|
||||
}
|
||||
|
||||
private void optInTracking()
|
||||
{
|
||||
instance.Call("optInTracking");
|
||||
}
|
||||
|
||||
private void enableTracking(bool enabled)
|
||||
{
|
||||
instance.Call("enableTracking", enabled);
|
||||
}
|
||||
|
||||
private void setInstance(AndroidJavaObject anotherInstance)
|
||||
{
|
||||
this.instance = anotherInstance;
|
||||
}
|
||||
|
||||
private void enableEncrypt(bool enabled)
|
||||
{
|
||||
this.instance.Call("setEnableEncrypt", enabled);
|
||||
}
|
||||
|
||||
private DataEyeAnalyticsWrapper createLightInstance(DataEyeAnalyticsAPI.Token delegateToken)
|
||||
{
|
||||
DataEyeAnalyticsWrapper result = new DataEyeAnalyticsWrapper(delegateToken, false);
|
||||
AndroidJavaObject lightInstance = instance.Call<AndroidJavaObject>("createLightInstance");
|
||||
result.setInstance(lightInstance);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void calibrateTime(long timestamp)
|
||||
{
|
||||
sdkClass.CallStatic("calibrateTime", timestamp);
|
||||
}
|
||||
|
||||
private static void calibrateTimeWithNtp(string ntpServer)
|
||||
{
|
||||
sdkClass.CallStatic("calibrateTimeWithNtpForUnity", ntpServer);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7df398244984648ef9b2d6bd8d4c72ab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,213 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using DataEyeAnalytics.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace DataEyeAnalytics.Wrapper
|
||||
{
|
||||
public partial class DataEyeAnalyticsWrapper
|
||||
{
|
||||
#if (UNITY_STANDALONE || UNITY_EDITOR)
|
||||
private void init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void identify(string uniqueId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private string getDistinctId()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private void login(string accountId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void logout()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void flush()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private static void setVersionInfo(string lib_name, string lib_version) {
|
||||
|
||||
}
|
||||
|
||||
private void track(DataEyeAnalyticsEvent taEvent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void track(string eventName, string properties)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void track(string eventName, string properties, DateTime dateTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void setSuperProperties(string superProperties)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void unsetSuperProperty(string superPropertyName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void clearSuperProperty()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private Dictionary<string, object> getSuperProperties()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private void timeEvent(string eventName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void userSet(string properties)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void userSet(string properties, DateTime dateTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void userUnset(List<string> properties)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void userUnset(List<string> properties, DateTime dateTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void userSetOnce(string properties)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void userSetOnce(string properties, DateTime dateTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void userAdd(string properties)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void userAdd(string properties, DateTime dateTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void userDelete()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void userDelete(DateTime dateTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void userAppend(string properties)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void userAppend(string properties, DateTime dateTime)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void setNetworkType(DataEyeAnalyticsAPI.NetworkType networkType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private string getDeviceId()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private void optOutTracking()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void optOutTrackingAndDeleteUser()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void optInTracking()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void enableTracking(bool enabled)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void enableEncrypt(bool enabled)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private DataEyeAnalyticsWrapper createLightInstance(DataEyeAnalyticsAPI.Token delegateToken)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private string getTimeString(DateTime dateTime)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private void enableAutoTrack(AUTO_TRACK_EVENTS autoTrackEvents)
|
||||
{
|
||||
|
||||
}
|
||||
private static void enable_log(bool enableLog)
|
||||
{
|
||||
|
||||
}
|
||||
private static void calibrateTime(long timestamp)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private static void calibrateTimeWithNtp(string ntpServer)
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e59d0a3c993b4cc3aca983df234b3aa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,485 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DataEyeAnalytics.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DataEyeAnalytics.Wrapper
|
||||
{
|
||||
public partial class DataEyeAnalyticsWrapper
|
||||
{
|
||||
#if (!(UNITY_EDITOR || UNITY_IOS || UNITY_ANDROID|| UNITY_STANDALONE))
|
||||
private string uniqueId;
|
||||
private void init()
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - Thanks for using DataEyeAnalytics SDK for tracking data.");
|
||||
}
|
||||
private static void enable_log(bool enableLog)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper - calling enable_log with enableLog: " + enableLog);
|
||||
}
|
||||
|
||||
public static void setVersionInfo(string libName, string version) {
|
||||
|
||||
}
|
||||
|
||||
private void identify(string uniqueId)
|
||||
{
|
||||
this.uniqueId = uniqueId;
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling Identify with uniqueId: " + uniqueId);
|
||||
}
|
||||
private string getDistinctId()
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling GetDistinctId with return value: " + this.uniqueId);
|
||||
return this.uniqueId;
|
||||
}
|
||||
|
||||
private void login(string accountId)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling Login with accountId: " + accountId);
|
||||
}
|
||||
|
||||
private void logout()
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling Logout");
|
||||
}
|
||||
|
||||
private void track(string eventName, string properties)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling track with eventName: " + eventName + ", " +
|
||||
"properties: " + properties);
|
||||
}
|
||||
|
||||
private void track(string eventName, string properties, DateTime datetime)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling track with eventName: " + eventName + ", " +
|
||||
"properties: " + properties + ", " +
|
||||
"dateTime: " + datetime.ToString());
|
||||
}
|
||||
|
||||
private void track(DataEyeAnalyticsEvent analyticsEvent)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling track with eventName: " + analyticsEvent.EventName + ", " +
|
||||
"properties: " + getFinalEventProperties(analyticsEvent.Properties));
|
||||
|
||||
}
|
||||
|
||||
private void setSuperProperties(string superProperties)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling setSuperProperties with superProperties: " + DE_MiniJSON.Serialize(superProperties));
|
||||
}
|
||||
|
||||
private void unsetSuperProperty(string superPropertyName)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling unsetSuperProperties with superPropertyName: " + superPropertyName);
|
||||
|
||||
}
|
||||
private void clearSuperProperty()
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling clearSuperProperties");
|
||||
}
|
||||
|
||||
private Dictionary<string, object> getSuperProperties()
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling getSuperProperties");
|
||||
return null;
|
||||
}
|
||||
private void timeEvent(string eventName)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling timeEvent with eventName: " + eventName);
|
||||
}
|
||||
|
||||
private void userSet(string properties)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling userSet with properties: " + DE_MiniJSON.Serialize(properties));
|
||||
}
|
||||
|
||||
private void userSet(string properties, DateTime dateTime)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling userSet with properties: " + DE_MiniJSON.Serialize(properties)
|
||||
+ ", dateTime: " + dateTime.ToString("yyyy-MM-dd HH:mm:ss.fff"));
|
||||
}
|
||||
private void userSetOnce(string properties)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling userSetOnce with properties: " + DE_MiniJSON.Serialize(properties));
|
||||
}
|
||||
|
||||
private void userSetOnce(string properties, DateTime dateTime)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling userSetOnce with properties: " + DE_MiniJSON.Serialize(properties)
|
||||
+ ", dateTime: " + dateTime.ToString("yyyy-MM-dd HH:mm:ss.fff"));
|
||||
}
|
||||
|
||||
private void userUnset(List<string> properties)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling userUnset with properties: " + string.Join(", ", properties.ToArray()));
|
||||
}
|
||||
|
||||
private void userUnset(List<string> properties, DateTime dateTime)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling userUnset with properties: " + string.Join(", ", properties.ToArray())
|
||||
+ ", dateTime: " + dateTime.ToString("yyyy-MM-dd HH:mm:ss.fff"));
|
||||
}
|
||||
|
||||
private void userAdd(string properties)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling userAdd with properties: " + DE_MiniJSON.Serialize(properties));
|
||||
}
|
||||
|
||||
private void userAdd(string properties, DateTime dateTime)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling userAdd with properties: " + DE_MiniJSON.Serialize(properties)
|
||||
+ ", dateTime: " + dateTime.ToString("yyyy-MM-dd HH:mm:ss.fff"));
|
||||
}
|
||||
|
||||
private void userAppend(string properties)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling userAppend with properties: " + DE_MiniJSON.Serialize(properties));
|
||||
}
|
||||
|
||||
private void userAppend(string properties, DateTime dateTime)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling userAppend with properties: " + DE_MiniJSON.Serialize(properties)
|
||||
+ ", dateTime: " + dateTime.ToString("yyyy-MM-dd HH:mm:ss.fff"));
|
||||
}
|
||||
|
||||
private void userDelete()
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling userDelete");
|
||||
}
|
||||
|
||||
private void userDelete(DateTime dateTime)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling userDelete" + ", dateTime: " + dateTime.ToString("yyyy-MM-dd HH:mm:ss.fff"));
|
||||
}
|
||||
|
||||
private void flush()
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling flush.");
|
||||
}
|
||||
|
||||
private void enableAutoTrack(AUTO_TRACK_EVENTS events)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling enableAutoTrack: " + events.ToString());
|
||||
}
|
||||
private void setNetworkType(DataEyeAnalyticsAPI.NetworkType networkType)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling setNetworkType with networkType: " + (int)networkType);
|
||||
}
|
||||
|
||||
private string getDeviceId() {
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling getDeviceId()");
|
||||
return "editor device id";
|
||||
}
|
||||
|
||||
private void optOutTracking()
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling optOutTracking()");
|
||||
}
|
||||
|
||||
private void optOutTrackingAndDeleteUser()
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling optOutTrackingAndDeleteUser()");
|
||||
}
|
||||
|
||||
private void optInTracking()
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling optInTracking()");
|
||||
}
|
||||
|
||||
private void enableTracking(bool enabled)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling enableTracking() with enabled: " + enabled);
|
||||
}
|
||||
|
||||
private DataEyeAnalyticsWrapper createLightInstance(DataEyeAnalyticsAPI.Token delegateToken)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - calling createLightInstance()");
|
||||
return new DataEyeAnalyticsWrapper(delegateToken, false);
|
||||
}
|
||||
|
||||
private string getTimeString(DateTime dateTime) {
|
||||
return dateTime.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
}
|
||||
|
||||
private static void calibrateTime(long timestamp)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper: - calling calibrateTime() with: " + timestamp);
|
||||
}
|
||||
|
||||
private static void calibrateTimeWithNtp(string ntpServer)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper: - calling calibrateTimeWithNtp() with: " + ntpServer);
|
||||
}
|
||||
|
||||
private void EnableEncrypt(bool enabled)
|
||||
{
|
||||
DE_Log.d("TA.Wrapper: - calling setEnableEncrypt() with: " + enabled);
|
||||
}
|
||||
|
||||
#endif
|
||||
public readonly DataEyeAnalyticsAPI.Token token;
|
||||
private IDynamicSuperProperties dynamicSuperProperties;
|
||||
|
||||
private static System.Random rnd = new System.Random();
|
||||
|
||||
private string serilize<T>(Dictionary<string, T> data) {
|
||||
return DE_MiniJSON.Serialize(data, getTimeString);
|
||||
}
|
||||
|
||||
public DataEyeAnalyticsWrapper(DataEyeAnalyticsAPI.Token token, bool initRequired = true)
|
||||
{
|
||||
this.token = token;
|
||||
if (initRequired) init();
|
||||
}
|
||||
|
||||
public static void EnableLog(bool enableLog)
|
||||
{
|
||||
enable_log(enableLog);
|
||||
}
|
||||
|
||||
public static void SetVersionInfo(string version)
|
||||
{
|
||||
setVersionInfo("Unity", version);
|
||||
}
|
||||
|
||||
public void Identify(string uniqueId)
|
||||
{
|
||||
identify(uniqueId);
|
||||
}
|
||||
|
||||
public string GetDistinctId()
|
||||
{
|
||||
return getDistinctId();
|
||||
}
|
||||
|
||||
public void Login(string accountId)
|
||||
{
|
||||
login(accountId);
|
||||
}
|
||||
|
||||
public void Logout()
|
||||
{
|
||||
logout();
|
||||
}
|
||||
|
||||
public void EnableAutoTrack(AUTO_TRACK_EVENTS events)
|
||||
{
|
||||
enableAutoTrack(events);
|
||||
}
|
||||
|
||||
private string getFinalEventProperties(Dictionary<string, object> properties)
|
||||
{
|
||||
DE_PropertiesChecker.CheckProperties(properties);
|
||||
|
||||
if (null != dynamicSuperProperties)
|
||||
{
|
||||
Dictionary<string, object> finalProperties = new Dictionary<string, object>();
|
||||
DE_PropertiesChecker.MergeProperties(dynamicSuperProperties.GetDynamicSuperProperties(), finalProperties);
|
||||
DE_PropertiesChecker.MergeProperties(properties, finalProperties);
|
||||
return serilize(finalProperties);
|
||||
}
|
||||
else
|
||||
{
|
||||
return serilize(properties);
|
||||
}
|
||||
|
||||
}
|
||||
public void Track(string eventName, Dictionary<string, object> properties)
|
||||
{
|
||||
DE_PropertiesChecker.CheckString(eventName);
|
||||
track(eventName, getFinalEventProperties(properties));
|
||||
}
|
||||
|
||||
public void Track(string eventName, Dictionary<string, object> properties, DateTime datetime)
|
||||
{
|
||||
DE_PropertiesChecker.CheckString(eventName);
|
||||
track(eventName, getFinalEventProperties(properties), datetime);
|
||||
}
|
||||
|
||||
public void Track(DataEyeAnalyticsEvent taEvent)
|
||||
{
|
||||
if (null == taEvent || null == taEvent.EventType)
|
||||
{
|
||||
DE_Log.w("Ignoring invalid TA event");
|
||||
return;
|
||||
}
|
||||
|
||||
if (taEvent.EventTime == null)
|
||||
{
|
||||
DE_Log.w("ppp null...");
|
||||
}
|
||||
DE_PropertiesChecker.CheckString(taEvent.EventName);
|
||||
DE_PropertiesChecker.CheckProperties(taEvent.Properties);
|
||||
track(taEvent);
|
||||
}
|
||||
|
||||
public void SetSuperProperties(Dictionary<string, object> superProperties)
|
||||
{
|
||||
DE_PropertiesChecker.CheckProperties(superProperties);
|
||||
setSuperProperties(serilize(superProperties));
|
||||
}
|
||||
|
||||
public void UnsetSuperProperty(string superPropertyName)
|
||||
{
|
||||
DE_PropertiesChecker.CheckString(superPropertyName);
|
||||
unsetSuperProperty(superPropertyName);
|
||||
}
|
||||
|
||||
public void ClearSuperProperty()
|
||||
{
|
||||
clearSuperProperty();
|
||||
}
|
||||
|
||||
|
||||
public void TimeEvent(string eventName)
|
||||
{
|
||||
DE_PropertiesChecker.CheckString(eventName);
|
||||
timeEvent(eventName);
|
||||
}
|
||||
|
||||
public Dictionary<string, object> GetSuperProperties()
|
||||
{
|
||||
return getSuperProperties();
|
||||
}
|
||||
|
||||
public void UserSet(Dictionary<string, object> properties)
|
||||
{
|
||||
DE_PropertiesChecker.CheckProperties(properties);
|
||||
userSet(serilize(properties));
|
||||
}
|
||||
|
||||
public void UserSet(Dictionary<string, object> properties, DateTime dateTime)
|
||||
{
|
||||
DE_PropertiesChecker.CheckProperties(properties);
|
||||
userSet(serilize(properties), dateTime);
|
||||
}
|
||||
|
||||
public void UserSetOnce(Dictionary<string, object> properties)
|
||||
{
|
||||
DE_PropertiesChecker.CheckProperties(properties);
|
||||
userSetOnce(serilize(properties));
|
||||
}
|
||||
|
||||
public void UserSetOnce(Dictionary<string, object> properties, DateTime dateTime)
|
||||
{
|
||||
DE_PropertiesChecker.CheckProperties(properties);
|
||||
userSetOnce(serilize(properties), dateTime);
|
||||
}
|
||||
|
||||
public void UserUnset(List<string> properties)
|
||||
{
|
||||
DE_PropertiesChecker.CheckProperteis(properties);
|
||||
userUnset(properties);
|
||||
}
|
||||
|
||||
public void UserUnset(List<string> properties, DateTime dateTime)
|
||||
{
|
||||
DE_PropertiesChecker.CheckProperteis(properties);
|
||||
userUnset(properties, dateTime);
|
||||
}
|
||||
|
||||
public void UserAdd(Dictionary<string, object> properties)
|
||||
{
|
||||
DE_PropertiesChecker.CheckProperties(properties);
|
||||
userAdd(serilize(properties));
|
||||
}
|
||||
|
||||
public void UserAdd(Dictionary<string, object> properties, DateTime dateTime)
|
||||
{
|
||||
DE_PropertiesChecker.CheckProperties(properties);
|
||||
userAdd(serilize(properties), dateTime);
|
||||
}
|
||||
|
||||
public void UserAppend(Dictionary<string, object> properties)
|
||||
{
|
||||
DE_PropertiesChecker.CheckProperties(properties);
|
||||
userAppend(serilize(properties));
|
||||
}
|
||||
|
||||
public void UserAppend(Dictionary<string, object> properties, DateTime dateTime)
|
||||
{
|
||||
DE_PropertiesChecker.CheckProperties(properties);
|
||||
userAppend(serilize(properties), dateTime);
|
||||
}
|
||||
|
||||
public void UserDelete()
|
||||
{
|
||||
userDelete();
|
||||
}
|
||||
|
||||
public void UserDelete(DateTime dateTime)
|
||||
{
|
||||
userDelete(dateTime);
|
||||
}
|
||||
|
||||
public void Flush()
|
||||
{
|
||||
flush();
|
||||
}
|
||||
|
||||
public void SetNetworkType(DataEyeAnalyticsAPI.NetworkType networkType)
|
||||
{
|
||||
setNetworkType(networkType);
|
||||
}
|
||||
|
||||
public string GetDeviceId()
|
||||
{
|
||||
return getDeviceId();
|
||||
}
|
||||
|
||||
public void SetDynamicSuperProperties(IDynamicSuperProperties dynamicSuperProperties)
|
||||
{
|
||||
if (!DE_PropertiesChecker.CheckProperties(dynamicSuperProperties.GetDynamicSuperProperties()))
|
||||
{
|
||||
DE_Log.d("TA.Wrapper(" + token.appid + ") - Cannot set dynamic super properties due to invalid properties.");
|
||||
}
|
||||
this.dynamicSuperProperties = dynamicSuperProperties;
|
||||
}
|
||||
|
||||
public void OptOutTracking()
|
||||
{
|
||||
optOutTracking();
|
||||
}
|
||||
|
||||
public void OptOutTrackingAndDeleteUser()
|
||||
{
|
||||
optOutTrackingAndDeleteUser();
|
||||
}
|
||||
|
||||
public void OptInTracking()
|
||||
{
|
||||
optInTracking();
|
||||
}
|
||||
|
||||
public void EnableTracking(bool enabled)
|
||||
{
|
||||
enableTracking(enabled);
|
||||
}
|
||||
|
||||
public void EnableEncrypt(bool enabled)
|
||||
{
|
||||
enableEncrypt(enabled);
|
||||
}
|
||||
|
||||
public DataEyeAnalyticsWrapper CreateLightInstance()
|
||||
{
|
||||
return createLightInstance(new DataEyeAnalyticsAPI.Token(rnd.Next().ToString(), token.serverUrl, token.mode, token.timeZone, token.reyunAppID, token.timeZoneId));
|
||||
}
|
||||
|
||||
internal string GetAppId()
|
||||
{
|
||||
return token.appid;
|
||||
}
|
||||
|
||||
public static void CalibrateTime(long timestamp)
|
||||
{
|
||||
calibrateTime(timestamp);
|
||||
}
|
||||
|
||||
public static void CalibrateTimeWithNtp(string ntpServer)
|
||||
{
|
||||
calibrateTimeWithNtp(ntpServer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49eb9ec132b9c419a870fc8af51a60ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,381 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using DataEyeAnalytics.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DataEyeAnalytics.Wrapper
|
||||
{
|
||||
public partial class DataEyeAnalyticsWrapper
|
||||
{
|
||||
#if UNITY_IOS && !(UNITY_EDITOR)
|
||||
[DllImport("__Internal")]
|
||||
private static extern void start(string app_id, string server_url, int mode, string timeZoneId);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void identify(string app_id, string unique_id);
|
||||
[DllImport("__Internal")]
|
||||
private static extern string get_distinct_id(string app_id);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void login(string app_id, string account_id);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void logout(string app_id);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void track(string app_id, string event_name, string properties, long time_stamp_millis, string timezone);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void track_event(string app_id, string event_string);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void set_super_properties(string app_id, string properties);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void unset_super_property(string app_id, string property_name);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void clear_super_properties(string app_id);
|
||||
[DllImport("__Internal")]
|
||||
private static extern string get_super_properties(string app_id);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void time_event(string app_id, string event_name);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void user_set(string app_id, string properties);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void user_set_with_time(string app_id, string properties, long timestamp);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void user_unset(string app_id, string properties);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void user_unset_with_time(string app_id, string properties, long timestamp);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void user_set_once(string app_id, string properties);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void user_set_once_with_time(string app_id, string properties, long timestamp);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void user_add(string app_id, string properties);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void user_add_with_time(string app_id, string properties, long timestamp);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void user_delete(string app_id);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void user_delete_with_time(string app_id, long timestamp);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void user_append(string app_id, string properties);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void user_append_with_time(string app_id, string properties, long timestamp);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void flush(string app_id);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void set_network_type(int type);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void enable_log(bool is_enable);
|
||||
[DllImport("__Internal")]
|
||||
private static extern string get_device_id();
|
||||
[DllImport("__Internal")]
|
||||
private static extern void enable_tracking(string app_id, bool enabled);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void opt_out_tracking(string app_id);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void opt_out_tracking_and_delete_user(string app_id);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void opt_in_tracking(string app_id);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void create_light_instance(string app_id, string delegate_token);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void enable_autoTrack(string app_id, int events);
|
||||
[DllImport("__Internal")]
|
||||
private static extern string get_time_string(string app_id, long events);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void calibrate_time(long timestamp);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void calibrate_time_with_ntp(string ntpServer);
|
||||
[DllImport("__Internal")]
|
||||
private static extern void config_custom_lib_info(string lib_name, string lib_version);
|
||||
|
||||
private void init()
|
||||
{
|
||||
start(token.appid, token.serverUrl, (int)token.mode, token.getTimeZoneId());
|
||||
}
|
||||
|
||||
private void identify(string uniqueId)
|
||||
{
|
||||
identify(token.appid, uniqueId);
|
||||
}
|
||||
|
||||
private string getDistinctId()
|
||||
{
|
||||
return get_distinct_id(token.appid);
|
||||
}
|
||||
|
||||
private void login(string accountId)
|
||||
{
|
||||
login(token.appid, accountId);
|
||||
}
|
||||
|
||||
private void logout()
|
||||
{
|
||||
logout(token.appid);
|
||||
}
|
||||
|
||||
private void flush()
|
||||
{
|
||||
flush(token.appid);
|
||||
}
|
||||
|
||||
private static void setVersionInfo(string lib_name, string lib_version) {
|
||||
config_custom_lib_info(lib_name, lib_version);
|
||||
}
|
||||
|
||||
private void track(ThinkingAnalyticsEvent taEvent)
|
||||
{
|
||||
Dictionary<string, object> finalEvent = new Dictionary<string, object>();
|
||||
string extraId = taEvent.ExtraId;
|
||||
switch (taEvent.EventType)
|
||||
{
|
||||
case ThinkingAnalyticsEvent.Type.FIRST:
|
||||
finalEvent["event_type"] = "track_first";
|
||||
break;
|
||||
case ThinkingAnalyticsEvent.Type.UPDATABLE:
|
||||
finalEvent["event_type"] = "track_update";
|
||||
break;
|
||||
case ThinkingAnalyticsEvent.Type.OVERWRITABLE:
|
||||
finalEvent["event_type"] = "track_overwrite";
|
||||
break;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(extraId))
|
||||
{
|
||||
finalEvent["extra_id"] = extraId;
|
||||
}
|
||||
|
||||
finalEvent["event_name"] = taEvent.EventName;
|
||||
finalEvent["event_properties"] = taEvent.Properties;
|
||||
|
||||
if (taEvent.EventTime != DateTime.MinValue)
|
||||
{
|
||||
finalEvent["event_time"] = taEvent.EventTime;
|
||||
if (token.timeZone == ThinkingAnalyticsAPI.TATimeZone.Local)
|
||||
{
|
||||
switch (taEvent.EventTime.Kind)
|
||||
{
|
||||
case DateTimeKind.Local:
|
||||
finalEvent["event_timezone"] = "Local";
|
||||
break;
|
||||
case DateTimeKind.Utc:
|
||||
finalEvent["event_timezone"] = "UTC";
|
||||
break;
|
||||
case DateTimeKind.Unspecified:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
track_event(token.appid, serilize(finalEvent));
|
||||
}
|
||||
|
||||
private void track(string eventName, string properties)
|
||||
{
|
||||
track(token.appid, eventName, properties, 0, "");
|
||||
}
|
||||
|
||||
private void track(string eventName, string properties, DateTime dateTime)
|
||||
{
|
||||
long dateTimeTicksUTC = TimeZoneInfo.ConvertTimeToUtc(dateTime).Ticks;
|
||||
|
||||
DateTime dtFrom = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
long currentMillis = (dateTimeTicksUTC - dtFrom.Ticks) / 10000;
|
||||
|
||||
string tz = "";
|
||||
if (token.timeZone == ThinkingAnalyticsAPI.TATimeZone.Local)
|
||||
{
|
||||
switch(dateTime.Kind)
|
||||
{
|
||||
case DateTimeKind.Local:
|
||||
tz = "Local";
|
||||
break;
|
||||
case DateTimeKind.Utc:
|
||||
tz = "UTC";
|
||||
break;
|
||||
case DateTimeKind.Unspecified:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tz = token.getTimeZoneId();
|
||||
}
|
||||
|
||||
track(token.appid, eventName, properties, currentMillis, tz);
|
||||
}
|
||||
|
||||
private void setSuperProperties(string superProperties)
|
||||
{
|
||||
set_super_properties(token.appid, superProperties);
|
||||
}
|
||||
|
||||
private void unsetSuperProperty(string superPropertyName)
|
||||
{
|
||||
unset_super_property(token.appid, superPropertyName);
|
||||
}
|
||||
|
||||
private void clearSuperProperty()
|
||||
{
|
||||
clear_super_properties(token.appid);
|
||||
}
|
||||
|
||||
private Dictionary<string, object> getSuperProperties()
|
||||
{
|
||||
string superPropertiesString = get_super_properties(token.appid);
|
||||
return TD_MiniJSON.Deserialize(superPropertiesString);
|
||||
}
|
||||
|
||||
private void timeEvent(string eventName)
|
||||
{
|
||||
time_event(token.appid, eventName);
|
||||
}
|
||||
|
||||
private void userSet(string properties)
|
||||
{
|
||||
user_set(token.appid, properties);
|
||||
}
|
||||
|
||||
private void userSet(string properties, DateTime dateTime)
|
||||
{
|
||||
long dateTimeTicksUTC = TimeZoneInfo.ConvertTimeToUtc(dateTime).Ticks;
|
||||
DateTime dtFrom = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
long currentMillis = (dateTimeTicksUTC - dtFrom.Ticks) / 10000;
|
||||
user_set_with_time(token.appid, properties, currentMillis);
|
||||
}
|
||||
|
||||
private void userUnset(List<string> properties)
|
||||
{
|
||||
foreach (string property in properties)
|
||||
{
|
||||
user_unset(token.appid, property);
|
||||
}
|
||||
}
|
||||
|
||||
private void userUnset(List<string> properties, DateTime dateTime)
|
||||
{
|
||||
long dateTimeTicksUTC = TimeZoneInfo.ConvertTimeToUtc(dateTime).Ticks;
|
||||
DateTime dtFrom = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
long currentMillis = (dateTimeTicksUTC - dtFrom.Ticks) / 10000;
|
||||
foreach (string property in properties)
|
||||
{
|
||||
user_unset_with_time(token.appid, property, currentMillis);
|
||||
}
|
||||
}
|
||||
|
||||
private void userSetOnce(string properties)
|
||||
{
|
||||
user_set_once(token.appid, properties);
|
||||
}
|
||||
|
||||
private void userSetOnce(string properties, DateTime dateTime)
|
||||
{
|
||||
long dateTimeTicksUTC = TimeZoneInfo.ConvertTimeToUtc(dateTime).Ticks;
|
||||
DateTime dtFrom = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
long currentMillis = (dateTimeTicksUTC - dtFrom.Ticks) / 10000;
|
||||
user_set_once_with_time(token.appid, properties, currentMillis);
|
||||
}
|
||||
|
||||
private void userAdd(string properties)
|
||||
{
|
||||
user_add(token.appid, properties);
|
||||
}
|
||||
|
||||
private void userAdd(string properties, DateTime dateTime)
|
||||
{
|
||||
long dateTimeTicksUTC = TimeZoneInfo.ConvertTimeToUtc(dateTime).Ticks;
|
||||
DateTime dtFrom = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
long currentMillis = (dateTimeTicksUTC - dtFrom.Ticks) / 10000;
|
||||
user_add_with_time(token.appid, properties, currentMillis);
|
||||
}
|
||||
|
||||
private void userDelete()
|
||||
{
|
||||
user_delete(token.appid);
|
||||
}
|
||||
|
||||
private void userDelete(DateTime dateTime)
|
||||
{
|
||||
long dateTimeTicksUTC = TimeZoneInfo.ConvertTimeToUtc(dateTime).Ticks;
|
||||
DateTime dtFrom = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
long currentMillis = (dateTimeTicksUTC - dtFrom.Ticks) / 10000;
|
||||
user_delete_with_time(token.appid, currentMillis);
|
||||
}
|
||||
|
||||
private void userAppend(string properties)
|
||||
{
|
||||
user_append(token.appid, properties);
|
||||
}
|
||||
|
||||
private void userAppend(string properties, DateTime dateTime)
|
||||
{
|
||||
long dateTimeTicksUTC = TimeZoneInfo.ConvertTimeToUtc(dateTime).Ticks;
|
||||
DateTime dtFrom = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
long currentMillis = (dateTimeTicksUTC - dtFrom.Ticks) / 10000;
|
||||
user_append_with_time(token.appid, properties, currentMillis);
|
||||
}
|
||||
|
||||
private void setNetworkType(ThinkingAnalyticsAPI.NetworkType networkType)
|
||||
{
|
||||
set_network_type((int)networkType);
|
||||
}
|
||||
|
||||
private string getDeviceId()
|
||||
{
|
||||
return get_device_id();
|
||||
}
|
||||
|
||||
private void optOutTracking()
|
||||
{
|
||||
opt_out_tracking(token.appid);
|
||||
}
|
||||
|
||||
private void optOutTrackingAndDeleteUser()
|
||||
{
|
||||
opt_out_tracking_and_delete_user(token.appid);
|
||||
}
|
||||
|
||||
private void optInTracking()
|
||||
{
|
||||
opt_in_tracking(token.appid);
|
||||
}
|
||||
|
||||
private void enableTracking(bool enabled)
|
||||
{
|
||||
enable_tracking(token.appid, enabled);
|
||||
}
|
||||
|
||||
private void enableEncrypt(bool enabled)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private DataEyeAnalyticsWrapper createLightInstance(ThinkingAnalyticsAPI.Token delegateToken)
|
||||
{
|
||||
create_light_instance(token.appid, delegateToken.appid);
|
||||
return new DataEyeAnalyticsWrapper(delegateToken, false);
|
||||
}
|
||||
|
||||
private string getTimeString(DateTime dateTime)
|
||||
{
|
||||
long dateTimeTicksUTC = TimeZoneInfo.ConvertTimeToUtc(dateTime).Ticks;
|
||||
DateTime dtFrom = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
||||
long currentMillis = (dateTimeTicksUTC - dtFrom.Ticks) / 10000;
|
||||
return get_time_string(token.appid, currentMillis);
|
||||
}
|
||||
|
||||
private void enableAutoTrack(AUTO_TRACK_EVENTS autoTrackEvents)
|
||||
{
|
||||
enable_autoTrack(token.appid, (int)autoTrackEvents);
|
||||
}
|
||||
|
||||
private static void calibrateTime(long timestamp)
|
||||
{
|
||||
calibrate_time(timestamp);
|
||||
}
|
||||
|
||||
private static void calibrateTimeWithNtp(string ntpServer)
|
||||
{
|
||||
calibrate_time_with_ntp(ntpServer);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c2465b793e664be2b03c8a225455ca5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user