数数SDK
This commit is contained in:
parent
7a083da4fe
commit
8a11506a78
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1c3596aacf52e4dce91260e35b40c684
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,140 @@
|
|||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
|
||||
namespace ThinkingData.Analytics.Editors
|
||||
{
|
||||
[CustomEditor(typeof(TDAnalytics))]
|
||||
[CanEditMultipleObjects]
|
||||
public class TD_Inspectors : Editor
|
||||
{
|
||||
private ReorderableList _stringArray;
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
|
||||
var appId = this.serializedObject.FindProperty("configs");
|
||||
|
||||
_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);
|
||||
}
|
||||
}
|
||||
|
||||
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: 9e175a5169e2c4de78d15b28f2ce6520
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,124 @@
|
|||
#if UNITY_EDITOR && UNITY_IOS
|
||||
using System.IO;
|
||||
using ThinkingData.Analytics.Utils;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ThinkingData.Analytics.Editors
|
||||
{
|
||||
public class TD_PostProcessBuild
|
||||
{
|
||||
//Xcode Build Settings
|
||||
//[PostProcessBuild]
|
||||
[PostProcessBuildAttribute(88)]
|
||||
public static void OnPostProcessBuild(BuildTarget target, string targetPath)
|
||||
{
|
||||
if (target != BuildTarget.iOS)
|
||||
{
|
||||
Debug.LogWarning("[ThinkingData] Warning: Target is not iOS. XCodePostProcess will not run");
|
||||
return;
|
||||
}
|
||||
|
||||
string projPath = Path.GetFullPath(targetPath) + "/Unity-iPhone.xcodeproj/project.pbxproj";
|
||||
|
||||
PBXProject proj = new PBXProject();
|
||||
proj.ReadFromFile(projPath);
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
string targetGuid = proj.GetUnityFrameworkTargetGuid();
|
||||
#else
|
||||
string targetGuid = proj.TargetGuidByName(PBXProject.GetUnityTargetName());
|
||||
#endif
|
||||
|
||||
//Build Property
|
||||
proj.SetBuildProperty(targetGuid, "ENABLE_BITCODE", "NO");//BitCode NO
|
||||
proj.SetBuildProperty(targetGuid, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES");//Enable Objective-C Exceptions
|
||||
proj.AddBuildProperty(targetGuid, "OTHER_LDFLAGS", "-ObjC");
|
||||
|
||||
string[] headerSearchPathsToAdd = { "$(SRCROOT)/Libraries/Plugins/iOS/ThinkingSDK/Source/main", "$(SRCROOT)/Libraries/Plugins/iOS/ThinkingSDK/Source/common" };
|
||||
proj.UpdateBuildProperty(targetGuid, "HEADER_SEARCH_PATHS", headerSearchPathsToAdd, null);// Header Search Paths
|
||||
|
||||
//Add Frameworks
|
||||
proj.AddFrameworkToProject(targetGuid, "WebKit.framework", true);
|
||||
proj.AddFrameworkToProject(targetGuid, "CoreTelephony.framework", true);
|
||||
proj.AddFrameworkToProject(targetGuid, "SystemConfiguration.framework", true);
|
||||
proj.AddFrameworkToProject(targetGuid, "Security.framework", true);
|
||||
proj.AddFrameworkToProject(targetGuid, "UserNotifications.framework", true);
|
||||
|
||||
//Add Lib
|
||||
proj.AddFileToBuild(targetGuid, proj.AddFile("usr/lib/libsqlite3.tbd", "libsqlite3.tbd", PBXSourceTree.Sdk));
|
||||
proj.AddFileToBuild(targetGuid, proj.AddFile("usr/lib/libz.tbd", "libz.tbd", PBXSourceTree.Sdk));
|
||||
|
||||
proj.WriteToFile(projPath);
|
||||
|
||||
//Info.plist
|
||||
//Disable preset properties
|
||||
string plistPath = Path.Combine(targetPath, "Info.plist");
|
||||
PlistDocument plist = new PlistDocument();
|
||||
plist.ReadFromFile(plistPath);
|
||||
plist.root.CreateArray("TDDisPresetProperties");
|
||||
TDPublicConfig.GetPublicConfig();
|
||||
foreach (string item in TDPublicConfig.DisPresetProperties)
|
||||
{
|
||||
plist.root["TDDisPresetProperties"].AsArray().AddString(item);
|
||||
}
|
||||
plist.WriteToFile(plistPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UNITY_OPENHARMONY
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
|
||||
namespace ThinkingData.Analytics.Editors
|
||||
{
|
||||
public class TD_PostProcessBuild
|
||||
{
|
||||
[PostProcessBuildAttribute(88)]
|
||||
public static void OnPostProcessBuild(BuildTarget target, string targetPath)
|
||||
{
|
||||
string path = Path.Combine(targetPath, "entry/oh-package.json5");
|
||||
string jsonContent = File.ReadAllText(path);
|
||||
jsonContent = jsonContent.Replace("\"TDAnalytics\"", "\"@thinkingdata/analytics\"");
|
||||
File.WriteAllText(path, jsonContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UNITY_EDITOR && UNITY_ANDROID && UNITY_2019_1_OR_NEWER
|
||||
using UnityEditor;
|
||||
using UnityEditor.Android;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ThinkingData.Analytics.Editors
|
||||
{
|
||||
|
||||
class TD_PostProcessBuild : IPostGenerateGradleAndroidProject
|
||||
{
|
||||
// Copy configuration file ta_public_config.xml
|
||||
public int callbackOrder { get { return 0; } }
|
||||
public void OnPostGenerateGradleAndroidProject(string path)
|
||||
{
|
||||
// Copy configuration file 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: 75476b67117c64ab1a25a2b94db96dcb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6e99afc9a5a55e343b5eb579656b88d4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,22 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a187246822bbb47529482707f3e0eff8, type: 3}
|
||||
m_Name: GoogleMobileAdsSettings
|
||||
m_EditorClassIdentifier:
|
||||
adMobAndroidAppId:
|
||||
adMobIOSAppId:
|
||||
enableKotlinXCoroutinesPackagingOption: 1
|
||||
enableGradleBuildPreProcessor: 1
|
||||
disableOptimizeInitialization: 0
|
||||
disableOptimizeAdLoading: 0
|
||||
userTrackingUsageDescription:
|
||||
userLanguage: en
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7496f258105db1c44adb5eb28724b41f
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,32 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ac5dc49959b8d094ba069fb641fc914d
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.firebase.app.unity"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
</manifest>
|
|
@ -0,0 +1,2 @@
|
|||
target=android-9
|
||||
android.library=true
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools" tools:keep="@string/gcm_defaultSenderId,@string/google_storage_bucket,@string/project_id,@string/google_api_key,@string/google_crash_reporting_api_key,@string/google_app_id">
|
||||
<string name="gcm_defaultSenderId" translatable="false">601745472008</string>
|
||||
<string name="google_storage_bucket" translatable="false">ag787cd54047-e0ac1-gp.firebasestorage.app</string>
|
||||
<string name="project_id" translatable="false">ag787cd54047-e0ac1-gp</string>
|
||||
<string name="google_api_key" translatable="false">AIzaSyCbVg7dxQbatGTDomrKq4AkQAP4aH1vr4Y</string>
|
||||
<string name="google_crash_reporting_api_key" translatable="false">AIzaSyCbVg7dxQbatGTDomrKq4AkQAP4aH1vr4Y</string>
|
||||
<string name="google_app_id" translatable="false">1:601745472008:android:768b7c2f79e2e93725afbd</string>
|
||||
</resources>
|
|
@ -0,0 +1,32 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0126fce90148f434a8ead1dd4d008662
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.firebase.crashlytics.unity"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
</manifest>
|
|
@ -0,0 +1,2 @@
|
|||
target=android-9
|
||||
android.library=true
|
|
@ -0,0 +1 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><resources><string name="com.crashlytics.android.build_id" translatable="false">c1e37c92-6bd2-4451-a40c-88a57f3343f3</string></resources>
|
|
@ -0,0 +1 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><resources><string name="com.google.firebase.crashlytics.unity_version" translatable="false">2022.3.62f1</string></resources>
|
Binary file not shown.
|
@ -0,0 +1,32 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5f7f0ddaf71ac4a00a8d6e31e982eaed
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,32 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 640f04af2bfe244b69b495a42f69c4c6
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,411 @@
|
|||
/*
|
||||
* Copyright (C) 2024 ThinkingData
|
||||
*/
|
||||
package cn.thinkingdata.analytics;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import cn.thinkingdata.analytics.TDAnalytics;
|
||||
import cn.thinkingdata.analytics.TDAnalyticsAPI;
|
||||
import cn.thinkingdata.analytics.TDConfig;
|
||||
import cn.thinkingdata.analytics.TDFirstEvent;
|
||||
import cn.thinkingdata.analytics.TDOverWritableEvent;
|
||||
import cn.thinkingdata.analytics.TDUpdatableEvent;
|
||||
import cn.thinkingdata.analytics.ThinkingAnalyticsSDK;
|
||||
|
||||
public class ThinkingAnalyticsProxy {
|
||||
public static void setCustomerLibInfo(String libName, String libVersion) {
|
||||
TDAnalytics.setCustomerLibInfo(libName, libVersion);
|
||||
}
|
||||
|
||||
public static void enableTrackLog(boolean enableLog) {
|
||||
TDAnalytics.enableLog(enableLog);
|
||||
}
|
||||
|
||||
public static void calibrateTime(long timeStampMillis) {
|
||||
TDAnalytics.calibrateTime(timeStampMillis);
|
||||
}
|
||||
|
||||
public static void calibrateTimeWithNtp(String ntpServer) {
|
||||
TDAnalytics.calibrateTimeWithNtp(ntpServer);
|
||||
}
|
||||
|
||||
public static void init(Context context, String appId, String serverUrl, int mode, String name, String timeZone, int version, String publicKey) {
|
||||
try {
|
||||
if (context == null || TextUtils.isEmpty(appId) || TextUtils.isEmpty(serverUrl)) {
|
||||
return;
|
||||
}
|
||||
String instanceName = "";
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
instanceName = appId;
|
||||
} else {
|
||||
instanceName = name;
|
||||
}
|
||||
TDConfig tdConfig = TDConfig.getInstance(context, appId, serverUrl, instanceName);
|
||||
if (!TextUtils.isEmpty(timeZone)) {
|
||||
tdConfig.setDefaultTimeZone(TimeZone.getTimeZone(timeZone));
|
||||
}
|
||||
if (mode == 1 || mode == 2) {
|
||||
tdConfig.setMode(TDConfig.TDMode.values()[mode]);
|
||||
}
|
||||
if (version > 0 && !TextUtils.isEmpty(publicKey)) {
|
||||
tdConfig.enableEncrypt(version, publicKey);
|
||||
}
|
||||
TDAnalytics.init(tdConfig);
|
||||
} catch (Exception ignore) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void track(String eventName, String properties, long time, String timeZoneId, String appId) {
|
||||
try {
|
||||
ThinkingAnalyticsSDK instance = TDAnalyticsAPI.getInstance(appId);
|
||||
if (null != instance) {
|
||||
JSONObject pJson = null;
|
||||
try {
|
||||
pJson = new JSONObject(properties);
|
||||
} catch (JSONException ignore) {
|
||||
}
|
||||
if (time < 0 || TextUtils.isEmpty(timeZoneId)) {
|
||||
instance.track(eventName, pJson);
|
||||
} else {
|
||||
TimeZone timeZone = null;
|
||||
if (TextUtils.equals(timeZoneId, "Local")) {
|
||||
timeZone = TimeZone.getDefault();
|
||||
} else {
|
||||
timeZone = TimeZone.getTimeZone(timeZoneId);
|
||||
}
|
||||
instance.track(eventName, pJson, new Date(time), timeZone);
|
||||
}
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void trackEvent(int type, String eventName, String properties, String eventId, long time, String timeZoneId, String appId) {
|
||||
try {
|
||||
Date date = null;
|
||||
if (time > 0) {
|
||||
date = new Date(time);
|
||||
}
|
||||
TimeZone timeZone = null;
|
||||
if (TextUtils.equals(timeZoneId, "Local")) {
|
||||
timeZone = TimeZone.getDefault();
|
||||
} else {
|
||||
timeZone = TimeZone.getTimeZone(timeZoneId);
|
||||
}
|
||||
JSONObject pJson = null;
|
||||
try {
|
||||
pJson = new JSONObject(properties);
|
||||
} catch (JSONException ignore) {
|
||||
}
|
||||
if (type == 0) {
|
||||
TDFirstEvent firstEvent = new TDFirstEvent(eventName, pJson);
|
||||
firstEvent.setFirstCheckId(eventId);
|
||||
firstEvent.setEventTime(date, timeZone);
|
||||
TDAnalyticsAPI.track(firstEvent, appId);
|
||||
} else if (type == 1) {
|
||||
TDUpdatableEvent updatableEvent = new TDUpdatableEvent(eventName, pJson, eventId);
|
||||
updatableEvent.setEventTime(date, timeZone);
|
||||
TDAnalyticsAPI.track(updatableEvent, appId);
|
||||
} else if (type == 2) {
|
||||
TDOverWritableEvent overWritableEvent = new TDOverWritableEvent(eventName, pJson, eventId);
|
||||
overWritableEvent.setEventTime(date, timeZone);
|
||||
TDAnalyticsAPI.track(overWritableEvent, appId);
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void timeEvent(String eventName, String appId) {
|
||||
TDAnalyticsAPI.timeEvent(eventName, appId);
|
||||
}
|
||||
|
||||
public static void login(String accountId, String appId) {
|
||||
TDAnalyticsAPI.login(accountId, appId);
|
||||
}
|
||||
|
||||
public static void logout(String appId) {
|
||||
TDAnalyticsAPI.logout(appId);
|
||||
}
|
||||
|
||||
public static void identify(String distinctId, String appId) {
|
||||
TDAnalyticsAPI.setDistinctId(distinctId, appId);
|
||||
}
|
||||
|
||||
public static String getDistinctId(String appId) {
|
||||
return TDAnalyticsAPI.getDistinctId(appId);
|
||||
}
|
||||
|
||||
public static void userSet(String properties, long time, String appId) {
|
||||
try {
|
||||
ThinkingAnalyticsSDK instance = TDAnalyticsAPI.getInstance(appId);
|
||||
if (null != instance) {
|
||||
Date date = null;
|
||||
if (time > 0) {
|
||||
date = new Date(time);
|
||||
}
|
||||
instance.user_set(new JSONObject(properties), date);
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void userUnset(String properties, long time, String appId) {
|
||||
try {
|
||||
ThinkingAnalyticsSDK instance = TDAnalyticsAPI.getInstance(appId);
|
||||
if (null != instance) {
|
||||
Date date = null;
|
||||
if (time > 0) {
|
||||
date = new Date(time);
|
||||
}
|
||||
instance.user_unset(new JSONObject(properties), date);
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void userSetOnce(String properties, long time, String appId) {
|
||||
try {
|
||||
ThinkingAnalyticsSDK instance = TDAnalyticsAPI.getInstance(appId);
|
||||
if (null != instance) {
|
||||
Date date = null;
|
||||
if (time > 0) {
|
||||
date = new Date(time);
|
||||
}
|
||||
instance.user_setOnce(new JSONObject(properties), date);
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void userAdd(String properties, long time, String appId) {
|
||||
try {
|
||||
ThinkingAnalyticsSDK instance = TDAnalyticsAPI.getInstance(appId);
|
||||
if (null != instance) {
|
||||
Date date = null;
|
||||
if (time > 0) {
|
||||
date = new Date(time);
|
||||
}
|
||||
instance.user_add(new JSONObject(properties), date);
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void userDel(long time, String appId) {
|
||||
try {
|
||||
ThinkingAnalyticsSDK instance = TDAnalyticsAPI.getInstance(appId);
|
||||
if (null != instance) {
|
||||
Date date = null;
|
||||
if (time > 0) {
|
||||
date = new Date(time);
|
||||
}
|
||||
instance.user_delete(date);
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void userAppend(String properties, long time, String appId) {
|
||||
try {
|
||||
ThinkingAnalyticsSDK instance = TDAnalyticsAPI.getInstance(appId);
|
||||
if (null != instance) {
|
||||
Date date = null;
|
||||
if (time > 0) {
|
||||
date = new Date(time);
|
||||
}
|
||||
instance.user_append(new JSONObject(properties), date);
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void userUniqAppend(String properties, long time, String appId) {
|
||||
try {
|
||||
ThinkingAnalyticsSDK instance = TDAnalyticsAPI.getInstance(appId);
|
||||
if (null != instance) {
|
||||
Date date = null;
|
||||
if (time > 0) {
|
||||
date = new Date(time);
|
||||
}
|
||||
instance.user_uniqAppend(new JSONObject(properties), date);
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setSuperProperties(String properties, String appId) {
|
||||
try {
|
||||
TDAnalyticsAPI.setSuperProperties(new JSONObject(properties), appId);
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void unsetSuperProperty(String property, String appId) {
|
||||
TDAnalyticsAPI.unsetSuperProperty(property, appId);
|
||||
}
|
||||
|
||||
public static void clearSuperProperties(String appId) {
|
||||
TDAnalyticsAPI.clearSuperProperties(appId);
|
||||
}
|
||||
|
||||
public static String getSuperProperties(String appId) {
|
||||
return TDAnalyticsAPI.getSuperProperties(appId).toString();
|
||||
}
|
||||
|
||||
public static String getPresetProperties(String appId) {
|
||||
return TDAnalyticsAPI.getPresetProperties(appId).toEventPresetProperties().toString();
|
||||
}
|
||||
|
||||
public static void flush(String appId) {
|
||||
TDAnalyticsAPI.flush(appId);
|
||||
}
|
||||
|
||||
public static String getDeviceId() {
|
||||
return TDAnalytics.getDeviceId();
|
||||
}
|
||||
|
||||
public static void setTrackStatus(int status, String appId) {
|
||||
TDAnalytics.TDTrackStatus trackStatus = TDAnalytics.TDTrackStatus.NORMAL;
|
||||
if (status == 1) {
|
||||
trackStatus = TDAnalytics.TDTrackStatus.PAUSE;
|
||||
} else if (status == 2) {
|
||||
trackStatus = TDAnalytics.TDTrackStatus.STOP;
|
||||
} else if (status == 3) {
|
||||
trackStatus = TDAnalytics.TDTrackStatus.SAVE_ONLY;
|
||||
}
|
||||
TDAnalyticsAPI.setTrackStatus(trackStatus, appId);
|
||||
}
|
||||
|
||||
public static String createLightInstance(String appId) {
|
||||
return TDAnalyticsAPI.lightInstance(appId);
|
||||
}
|
||||
|
||||
public static void setNetworkType(int type, String appId) {
|
||||
if (type == 0 || type == 2) {
|
||||
TDAnalyticsAPI.setNetworkType(TDAnalytics.TDNetworkType.ALL, appId);
|
||||
} else if (type == 1) {
|
||||
TDAnalyticsAPI.setNetworkType(TDAnalytics.TDNetworkType.WIFI, appId);
|
||||
}
|
||||
}
|
||||
|
||||
public static void enableThirdPartySharing(int types, String params, String appId) {
|
||||
Map<String, Object> maps = new HashMap<>();
|
||||
try {
|
||||
JSONObject json = new JSONObject(params);
|
||||
for (Iterator<String> it = json.keys(); it.hasNext(); ) {
|
||||
String key = it.next();
|
||||
maps.put(key, json.opt(key));
|
||||
}
|
||||
} catch (JSONException ignore) {
|
||||
}
|
||||
if (maps.isEmpty()) {
|
||||
TDAnalyticsAPI.enableThirdPartySharing(types, appId);
|
||||
} else {
|
||||
TDAnalyticsAPI.enableThirdPartySharing(types, maps, appId);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setDynamicSuperPropertiesTrackerListener(String appId, DynamicSuperPropertiesTrackerListener listener) {
|
||||
ThinkingAnalyticsSDK ta = TDAnalyticsAPI.getInstance(appId);
|
||||
if (null == ta) return;
|
||||
ta.setAutoTrackDynamicProperties(new ThinkingAnalyticsSDK.AutoTrackDynamicProperties() {
|
||||
@Override
|
||||
public JSONObject getAutoTrackDynamicProperties() {
|
||||
try {
|
||||
String pStr = listener.getDynamicSuperPropertiesString();
|
||||
if (pStr != null) {
|
||||
return new JSONObject(pStr);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new JSONObject();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void enableAutoTrack(int types, String properties, String appId) {
|
||||
JSONObject json = null;
|
||||
try {
|
||||
json = new JSONObject(properties);
|
||||
} catch (JSONException ignore) {
|
||||
}
|
||||
TDAnalyticsAPI.enableAutoTrack(types, json, appId);
|
||||
}
|
||||
|
||||
public static void setAutoTrackProperties(int types, String properties, String appId) {
|
||||
JSONObject json = null;
|
||||
try {
|
||||
json = new JSONObject(properties);
|
||||
} catch (JSONException ignore) {
|
||||
}
|
||||
if (json == null) return;
|
||||
ThinkingAnalyticsSDK instance = TDAnalyticsAPI.getInstance(appId);
|
||||
List<ThinkingAnalyticsSDK.AutoTrackEventType> eventTypeList = new ArrayList<>();
|
||||
if ((types & TDAnalytics.TDAutoTrackEventType.APP_START) > 0) {
|
||||
eventTypeList.add(ThinkingAnalyticsSDK.AutoTrackEventType.APP_START);
|
||||
}
|
||||
if ((types & TDAnalytics.TDAutoTrackEventType.APP_END) > 0) {
|
||||
eventTypeList.add(ThinkingAnalyticsSDK.AutoTrackEventType.APP_END);
|
||||
}
|
||||
|
||||
if ((types & TDAnalytics.TDAutoTrackEventType.APP_INSTALL) > 0) {
|
||||
eventTypeList.add(ThinkingAnalyticsSDK.AutoTrackEventType.APP_INSTALL);
|
||||
}
|
||||
if ((types & TDAnalytics.TDAutoTrackEventType.APP_CRASH) > 0) {
|
||||
eventTypeList.add(ThinkingAnalyticsSDK.AutoTrackEventType.APP_CRASH);
|
||||
}
|
||||
instance.setAutoTrackProperties(eventTypeList, json);
|
||||
}
|
||||
|
||||
public static void enableAutoTrack(int types, AutoTrackEventTrackerListener listener, String appId) {
|
||||
TDAnalyticsAPI.enableAutoTrack(types, new TDAnalytics.TDAutoTrackEventHandler() {
|
||||
@Override
|
||||
public JSONObject getAutoTrackEventProperties(int i, JSONObject jsonObject) {
|
||||
try {
|
||||
String name = appId;
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
name = TDAnalytics.instance.mConfig.getName();
|
||||
}
|
||||
String eStr = listener.eventCallback(i, name, jsonObject.toString());
|
||||
if (eStr != null) {
|
||||
return new JSONObject(eStr);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new JSONObject();
|
||||
}
|
||||
}, appId);
|
||||
}
|
||||
|
||||
public interface DynamicSuperPropertiesTrackerListener {
|
||||
String getDynamicSuperPropertiesString();
|
||||
}
|
||||
|
||||
public interface AutoTrackEventTrackerListener {
|
||||
/**
|
||||
* Callback event name and current properties and get dynamic properties
|
||||
*
|
||||
* @return dynamic properties String
|
||||
*/
|
||||
String eventCallback(int type, String appId, String properties);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2eaec3210b47f473c8e023bc9410f6e2
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,32 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 04844570eb35e4807bd54a34a89619c0
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,10 @@
|
|||
org.gradle.jvmargs=-Xmx**JVM_HEAP_SIZE**M
|
||||
org.gradle.parallel=true
|
||||
unityStreamingAssets=**STREAMING_ASSETS**
|
||||
# Android Resolver Properties Start
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
# Android Resolver Properties End
|
||||
**ADDITIONAL_PROPERTIES**
|
||||
|
||||
android.jetifier.ignorelist=annotation-experimental-1.4.0.aar
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d19bf1415603c584ebc742afa3d23b8e
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,98 @@
|
|||
apply plugin: 'com.android.library'
|
||||
**APPLY_PLUGINS**
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
// Android Resolver Dependencies Start
|
||||
implementation 'androidx.annotation:annotation:1.2.0' // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/Editor/Dependencies.xml:8
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1' // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/Editor/Dependencies.xml:6
|
||||
implementation 'androidx.browser:browser:1.4.0' // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/Editor/Dependencies.xml:4
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:12
|
||||
implementation 'androidx.lifecycle:lifecycle-process:2.6.2' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:17
|
||||
implementation 'androidx.media3:media3-exoplayer:1.0.0-alpha01' // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/Editor/Dependencies.xml:5
|
||||
// implementation 'androidx.recyclerview:recyclerview:1.1.0' // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/Editor/Dependencies.xml:7
|
||||
implementation 'androidx.recyclerview:recyclerview:1.2.1' // Assets/MaxSdk/Mediation/Mintegral/Editor/Dependencies.xml:9
|
||||
implementation 'com.applovin.mediation:bigoads-adapter:5.5.1.2' // Assets/MaxSdk/Mediation/BigoAds/Editor/Dependencies.xml:4
|
||||
implementation 'com.applovin.mediation:bytedance-adapter:7.5.0.3.0' // Assets/MaxSdk/Mediation/ByteDance/Editor/Dependencies.xml:8
|
||||
implementation 'com.applovin.mediation:fyber-adapter:8.3.8.0' // Assets/MaxSdk/Mediation/Fyber/Editor/Dependencies.xml:4
|
||||
implementation 'com.applovin.mediation:google-adapter:[24.5.0.0]' // Assets/MaxSdk/Mediation/Google/Editor/Dependencies.xml:5
|
||||
implementation 'com.applovin.mediation:google-ad-manager-adapter:[24.5.0.0]' // Assets/MaxSdk/Mediation/GoogleAdManager/Editor/Dependencies.xml:5
|
||||
implementation 'com.applovin.mediation:mintegral-adapter:16.9.91.0' // Assets/MaxSdk/Mediation/Mintegral/Editor/Dependencies.xml:8
|
||||
implementation 'com.applovin.mediation:moloco-adapter:4.0.0.0' // Assets/MaxSdk/Mediation/Moloco/Editor/Dependencies.xml:4
|
||||
implementation 'com.applovin.mediation:unityads-adapter:4.16.1.0' // Assets/MaxSdk/Mediation/UnityAds/Editor/Dependencies.xml:4
|
||||
implementation 'com.applovin.mediation:vungle-adapter:7.5.1.0' // Assets/MaxSdk/Mediation/Vungle/Editor/Dependencies.xml:4
|
||||
implementation 'com.applovin:applovin-sdk:13.3.1' // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/applovin/Editor/Dependencies.xml:3
|
||||
// implementation 'com.bigossp:bigo-ads:5.0.0' // Assets/BigoSDK/Editor/Dependencies.xml:11
|
||||
implementation 'com.bigossp:bigo-ads:5.3.0' // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/bigo/Editor/Dependencies.xml:3
|
||||
implementation 'com.fyber:marketplace-sdk:8.3.7' // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/fyber/Editor/Dependencies.xml:3
|
||||
// implementation 'com.google.android.gms:play-services-ads:24.4.0' // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/admob/Editor/Dependencies.xml:3
|
||||
implementation 'com.google.android.gms:play-services-ads:24.5.0' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:7
|
||||
// implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1' // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/Editor/Dependencies.xml:5
|
||||
implementation 'com.google.android.gms:play-services-ads-identifier:18.2.0' // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/Editor/Dependencies.xml:7
|
||||
implementation 'com.google.android.gms:play-services-base:18.7.2' // Assets/rd3/Firebase/Editor/AppDependencies.xml:17
|
||||
implementation 'com.google.android.gms:play-services-basement:18.1.0' // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/Editor/Dependencies.xml:4
|
||||
implementation 'com.google.android.material:material:1.2.1' // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/Editor/Dependencies.xml:7
|
||||
implementation 'com.google.android.ump:user-messaging-platform:3.2.0' // Assets/GoogleMobileAds/Editor/GoogleUmpDependencies.xml:7
|
||||
implementation 'com.google.firebase:firebase-analytics:23.0.0' // Assets/rd3/Firebase/Editor/RemoteConfigDependencies.xml:15
|
||||
implementation 'com.google.firebase:firebase-analytics-unity:13.1.0' // Assets/rd3/Firebase/Editor/AnalyticsDependencies.xml:18
|
||||
implementation 'com.google.firebase:firebase-app-unity:13.1.0' // Assets/rd3/Firebase/Editor/AppDependencies.xml:22
|
||||
implementation 'com.google.firebase:firebase-common:22.0.0' // Assets/rd3/Firebase/Editor/AppDependencies.xml:13
|
||||
implementation 'com.google.firebase:firebase-config:23.0.0' // Assets/rd3/Firebase/Editor/RemoteConfigDependencies.xml:13
|
||||
implementation 'com.google.firebase:firebase-config-unity:13.1.0' // Assets/rd3/Firebase/Editor/RemoteConfigDependencies.xml:20
|
||||
implementation 'com.google.firebase:firebase-crashlytics-ndk:20.0.0' // Assets/rd3/Firebase/Editor/CrashlyticsDependencies.xml:13
|
||||
implementation 'com.google.firebase:firebase-crashlytics-unity:13.1.0' // Assets/rd3/Firebase/Editor/CrashlyticsDependencies.xml:20
|
||||
implementation 'com.mbridge.msdk.oversea:mbridge_android_sdk:16.9.71' // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/Editor/Dependencies.xml:6
|
||||
implementation 'com.pangle.global:pag-sdk:7.2.0.6' // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/Editor/Dependencies.xml:6
|
||||
implementation 'com.unity3d.ads:unity-ads:4.14.0' // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/unityads/Editor/Dependencies.xml:3
|
||||
implementation 'com.vungle:vungle-ads:7.5.0' // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/vungle/Editor/Dependencies.xml:3
|
||||
implementation 'io.github.kwainetwork:adApi:1.2.19' // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/Editor/Dependencies.xml:3
|
||||
implementation 'io.github.kwainetwork:adImpl:1.2.19' // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/Editor/Dependencies.xml:4
|
||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10' // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/kwai/Editor/Dependencies.xml:9
|
||||
// Android Resolver Dependencies End
|
||||
**DEPS**}
|
||||
|
||||
// Android Resolver Exclusions Start
|
||||
android {
|
||||
packagingOptions {
|
||||
exclude ('/lib/armeabi/*' + '*')
|
||||
exclude ('/lib/mips/*' + '*')
|
||||
exclude ('/lib/mips64/*' + '*')
|
||||
exclude ('/lib/x86/*' + '*')
|
||||
exclude ('/lib/x86_64/*' + '*')
|
||||
}
|
||||
}
|
||||
// Android Resolver Exclusions End
|
||||
android {
|
||||
namespace "com.unity3d.player"
|
||||
ndkPath "**NDKPATH**"
|
||||
compileSdkVersion **APIVERSION**
|
||||
buildToolsVersion '**BUILDTOOLS**'
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion **MINSDKVERSION**
|
||||
targetSdkVersion **TARGETSDKVERSION**
|
||||
ndk {
|
||||
abiFilters **ABIFILTERS**
|
||||
}
|
||||
versionCode **VERSIONCODE**
|
||||
versionName '**VERSIONNAME**'
|
||||
consumerProguardFiles 'proguard-unity.txt'**USER_PROGUARD**
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
|
||||
aaptOptions {
|
||||
noCompress = **BUILTIN_NOCOMPRESS** + unityStreamingAssets.tokenize(', ')
|
||||
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~"
|
||||
}**PACKAGING_OPTIONS**
|
||||
}
|
||||
**IL_CPP_BUILD_SETUP**
|
||||
**SOURCE_BUILD_SETUP**
|
||||
**EXTERNAL_SOURCES**
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d0ce803953bb6b144b9dced384d6d358
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,42 @@
|
|||
pluginManagement {
|
||||
repositories {
|
||||
**ARTIFACTORYREPOSITORY**
|
||||
gradlePluginPortal()
|
||||
google()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
include ':launcher', ':unityLibrary'
|
||||
**INCLUDES**
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
|
||||
repositories {
|
||||
**ARTIFACTORYREPOSITORY**
|
||||
google()
|
||||
mavenCentral()
|
||||
// Android Resolver Repos Start
|
||||
def unityProjectPath = $/file:///**DIR_UNITYPROJECT**/$.replace("\\", "/")
|
||||
maven {
|
||||
url "https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea" // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/gtm/Editor/Dependencies.xml:5, Assets/MaxSdk/Mediation/Mintegral/Editor/Dependencies.xml:8
|
||||
}
|
||||
maven {
|
||||
url "https://artifact.bytedance.com/repository/pangle" // Assets/ThinkupTpnPlugin/AnyThinkAds/Plugins/Android/NonChina/mediation/pangle/Editor/Dependencies.xml:5, Assets/MaxSdk/Mediation/ByteDance/Editor/Dependencies.xml:8
|
||||
}
|
||||
maven {
|
||||
url "https://repo1.maven.org/maven2/" // Assets/BigoSDK/Editor/Dependencies.xml:11
|
||||
}
|
||||
maven {
|
||||
url "https://maven.google.com/" // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:7, Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:12, Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:17, Assets/GoogleMobileAds/Editor/GoogleUmpDependencies.xml:7
|
||||
}
|
||||
maven {
|
||||
url (unityProjectPath + "/Assets/Firebase/m2repository") // Assets/rd3/Firebase/Editor/AnalyticsDependencies.xml:18, Assets/rd3/Firebase/Editor/AppDependencies.xml:22, Assets/rd3/Firebase/Editor/CrashlyticsDependencies.xml:20, Assets/rd3/Firebase/Editor/RemoteConfigDependencies.xml:20
|
||||
}
|
||||
mavenLocal()
|
||||
// Android Resolver Repos End
|
||||
flatDir {
|
||||
dirs "${project(':unityLibrary').projectDir}/libs"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b7bd8993c4f1e6242a9cfbe9355ae1d0
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 15e16f29589354e96963bf14c4beda9f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,6 @@
|
|||
import { TDOpenHarmonyProxy } from "./TDOpenHarmonyProxy.ts";
|
||||
export function RegisterNativeBridge(){
|
||||
var register = { }
|
||||
register["TDOpenHarmonyProxy"] = TDOpenHarmonyProxy;
|
||||
return register
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 15b10eae4ecca486aa372841269de824
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7bb46bcdc1562464698344aedabc6ad9
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,273 @@
|
|||
import { TDAnalytics, TDConfig, TDMode, TDNetworkType } from '@thinkingdata/analytics';
|
||||
import I18n from '@ohos.i18n';
|
||||
export class TDOpenHarmonyProxy {
|
||||
|
||||
static init(appId: string, serverUrl: string, mode: number, timeZone: string, version: number, publicKey: string) {
|
||||
let config = new TDConfig()
|
||||
config.appId = appId
|
||||
config.serverUrl = serverUrl
|
||||
if (mode == 1) {
|
||||
config.mode = TDMode.DEBUG
|
||||
} else if (mode == 2) {
|
||||
config.mode = TDMode.DEBUG_ONLY
|
||||
} else {
|
||||
config.mode = TDMode.NORMAL
|
||||
}
|
||||
if (timeZone) {
|
||||
config.defaultTimeZone = I18n.getTimeZone(timeZone)
|
||||
}
|
||||
if (publicKey && version > 0) {
|
||||
config.enableEncrypt(version, publicKey)
|
||||
}
|
||||
TDAnalytics.initWithConfig(globalThis.context, config)
|
||||
}
|
||||
|
||||
static enableLog(enable: boolean) {
|
||||
TDAnalytics.enableLog(enable)
|
||||
}
|
||||
|
||||
static setLibraryInfo(libName: string, libVersion: string) {
|
||||
TDAnalytics.setCustomerLibInfo(libName, libVersion)
|
||||
}
|
||||
|
||||
static setDistinctId(distinctId: string, appId: string) {
|
||||
TDAnalytics.setDistinctId(distinctId, appId)
|
||||
}
|
||||
|
||||
static getDistinctId(appId: string): string {
|
||||
return TDAnalytics.getDistinctId(appId)
|
||||
}
|
||||
|
||||
static login(accountId: string, appId: string) {
|
||||
TDAnalytics.login(accountId, appId)
|
||||
}
|
||||
|
||||
static logout(appId: string) {
|
||||
TDAnalytics.logout(appId)
|
||||
}
|
||||
|
||||
static track(eventName: string, properties: string, timeStamp: number, timeZoneId: string, appId: string) {
|
||||
try {
|
||||
let time: Date = null;
|
||||
let timeZone: I18n.TimeZone = null;
|
||||
if (timeStamp > 0) {
|
||||
time = new Date(timeStamp)
|
||||
if (timeZoneId) {
|
||||
if (timeZoneId === 'Local') {
|
||||
timeZone = I18n.getTimeZone()
|
||||
} else {
|
||||
timeZone = I18n.getTimeZone(timeZoneId)
|
||||
}
|
||||
}
|
||||
}
|
||||
TDAnalytics.track({
|
||||
eventName: eventName,
|
||||
properties: this.parseJsonStrict(properties),
|
||||
time: time,
|
||||
timeZone: timeZone
|
||||
}, appId)
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
static trackEvent(eventType: number, eventName: string, properties: string, eventId: string, timeStamp: number,
|
||||
timezoneId: string, appId: string) {
|
||||
try {
|
||||
let time: Date = null;
|
||||
let timeZone: I18n.TimeZone = null;
|
||||
if (timeStamp > 0) {
|
||||
time = new Date(timeStamp);
|
||||
if (timezoneId) {
|
||||
if (timezoneId == 'Local') {
|
||||
timeZone = I18n.getTimeZone()
|
||||
} else {
|
||||
timeZone = I18n.getTimeZone(timezoneId)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (eventType == 1) {
|
||||
TDAnalytics.trackFirst({
|
||||
eventName: eventName,
|
||||
properties: this.parseJsonStrict(properties),
|
||||
firstCheckId: eventId,
|
||||
time: time,
|
||||
timeZone: timeZone
|
||||
}, appId)
|
||||
} else if (eventType == 2) {
|
||||
TDAnalytics.trackUpdate({
|
||||
eventName: eventName,
|
||||
properties: this.parseJsonStrict(properties),
|
||||
eventId: eventId,
|
||||
time: time,
|
||||
timeZone: timeZone
|
||||
}, appId)
|
||||
} else if (eventType == 3) {
|
||||
TDAnalytics.trackOverwrite({
|
||||
eventName: eventName,
|
||||
properties: this.parseJsonStrict(properties),
|
||||
eventId: eventId,
|
||||
time: time,
|
||||
timeZone: timeZone
|
||||
}, appId)
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static setSuperProperties(superProperties: string, appId: string) {
|
||||
try {
|
||||
TDAnalytics.setSuperProperties(this.parseJsonStrict(superProperties), appId)
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
static unsetSuperProperty(property: string, appId: string) {
|
||||
TDAnalytics.unsetSuperProperty(property, appId)
|
||||
}
|
||||
|
||||
static clearSuperProperties(appId: string) {
|
||||
TDAnalytics.clearSuperProperties(appId)
|
||||
}
|
||||
|
||||
static getSuperProperties(appId: string): string {
|
||||
return TDAnalytics.getSuperProperties(appId)
|
||||
}
|
||||
|
||||
static getPresetProperties(appId: string): string {
|
||||
return TDAnalytics.getPresetProperties(appId)
|
||||
}
|
||||
|
||||
static flush(appId: string) {
|
||||
TDAnalytics.flush(appId)
|
||||
}
|
||||
|
||||
static userSet(properties: string, timeStamp: number, appId: string) {
|
||||
try {
|
||||
let time: Date = null;
|
||||
if (timeStamp > 0) {
|
||||
time = new Date(timeStamp)
|
||||
}
|
||||
TDAnalytics.userSet({
|
||||
properties: this.parseJsonStrict(properties),
|
||||
time: time
|
||||
}, appId)
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
static userSetOnce(properties: string, timeStamp: number, appId: string) {
|
||||
try {
|
||||
let time: Date = null;
|
||||
if (timeStamp > 0) {
|
||||
time = new Date(timeStamp)
|
||||
}
|
||||
TDAnalytics.userSetOnce({
|
||||
properties: this.parseJsonStrict(properties),
|
||||
time: time
|
||||
}, appId)
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
static userUnset(property: string, timeStamp: number, appId: string) {
|
||||
let time: Date = null;
|
||||
if (timeStamp > 0) {
|
||||
time = new Date(timeStamp)
|
||||
}
|
||||
TDAnalytics.userUnset({
|
||||
property: property,
|
||||
time: time
|
||||
}, appId)
|
||||
}
|
||||
|
||||
static userAdd(properties: string, timeStamp: number, appId: string) {
|
||||
try {
|
||||
let time: Date = null;
|
||||
if (timeStamp > 0) {
|
||||
time = new Date(timeStamp)
|
||||
}
|
||||
TDAnalytics.userAdd({
|
||||
properties: this.parseJsonStrict(properties),
|
||||
time: time
|
||||
}, appId)
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
static userAppend(properties: string, timeStamp: number, appId: string) {
|
||||
try {
|
||||
let time: Date = null;
|
||||
if (timeStamp > 0) {
|
||||
time = new Date(timeStamp)
|
||||
}
|
||||
TDAnalytics.userAppend({
|
||||
properties: this.parseJsonStrict(properties),
|
||||
time: time
|
||||
}, appId)
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
static userUniqAppend(properties: string, timeStamp: number, appId: string) {
|
||||
try {
|
||||
let time: Date = null;
|
||||
if (timeStamp > 0) {
|
||||
time = new Date(timeStamp)
|
||||
}
|
||||
TDAnalytics.userUniqAppend({
|
||||
properties: this.parseJsonStrict(properties),
|
||||
time: time
|
||||
}, appId)
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static userDelete(timeStamp: number, appId: string) {
|
||||
let time: Date = null;
|
||||
if (timeStamp > 0) {
|
||||
time = new Date(timeStamp)
|
||||
}
|
||||
TDAnalytics.userDelete({
|
||||
time: time
|
||||
}, appId)
|
||||
}
|
||||
|
||||
static getDeviceId(): string {
|
||||
return TDAnalytics.getDeviceId()
|
||||
}
|
||||
|
||||
static setNetWorkType(type: number) {
|
||||
if (type == 2) {
|
||||
TDAnalytics.setNetworkType(TDNetworkType.WIFI)
|
||||
} else {
|
||||
TDAnalytics.setNetworkType(TDNetworkType.ALL)
|
||||
}
|
||||
}
|
||||
|
||||
static enableAutoTrack(autoTypes: number, appId: string) {
|
||||
TDAnalytics.enableAutoTrack(globalThis.context, autoTypes, null, appId)
|
||||
}
|
||||
|
||||
static timeEvent(eventName: string, appId: string) {
|
||||
TDAnalytics.timeEvent(eventName, appId)
|
||||
}
|
||||
|
||||
static calibrateTime(timestamp: number) {
|
||||
TDAnalytics.calibrateTime(timestamp)
|
||||
}
|
||||
|
||||
private static parseJsonStrict(jsonString: string): object {
|
||||
try {
|
||||
const parsed = JSON.parse(jsonString);
|
||||
if (typeof parsed !== 'object' || parsed === null) {
|
||||
return {};
|
||||
}
|
||||
return parsed;
|
||||
} catch (error) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c7ac184e05351426197404368d11c8d2
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b5e64871c9af447029fea9ebb8a01507
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: eefcaefb9c6534ae78d8e6d4345a9531
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,213 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using ThinkingSDK.PC.Main;
|
||||
using ThinkingSDK.PC.Storage;
|
||||
using ThinkingSDK.PC.Utils;
|
||||
using ThinkingSDK.PC.Constant;
|
||||
public class ThinkingSDKAutoTrack : MonoBehaviour
|
||||
{
|
||||
private string mAppId;
|
||||
private TDAutoTrackEventType mAutoTrackEvents = TDAutoTrackEventType.None;
|
||||
private Dictionary<string, Dictionary<string, object>> mAutoTrackProperties = new Dictionary<string, Dictionary<string, object>>();
|
||||
private bool mStarted = false;
|
||||
private TDAutoTrackEventHandler_PC mEventCallback_PC;
|
||||
|
||||
private static string TDAutoTrackEventType_APP_START = "AppStart";
|
||||
private static string TDAutoTrackEventType_APP_END = "AppEnd";
|
||||
private static string TDAutoTrackEventType_APP_CRASH = "AppCrash";
|
||||
private static string TDAutoTrackEventType_APP_INSTALL = "AppInstall";
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
}
|
||||
void OnApplicationFocus(bool hasFocus)
|
||||
{
|
||||
if (hasFocus)
|
||||
{
|
||||
if ((mAutoTrackEvents & TDAutoTrackEventType.AppStart) != 0)
|
||||
{
|
||||
Dictionary<string, object> properties = new Dictionary<string, object>();
|
||||
if (mAutoTrackProperties.ContainsKey(TDAutoTrackEventType_APP_START))
|
||||
{
|
||||
ThinkingSDKUtil.AddDictionary(properties, mAutoTrackProperties[TDAutoTrackEventType_APP_START]);
|
||||
}
|
||||
if (mEventCallback_PC != null)
|
||||
{
|
||||
ThinkingSDKUtil.AddDictionary(properties, mEventCallback_PC.AutoTrackEventCallback_PC((int) TDAutoTrackEventType.AppStart, properties));
|
||||
}
|
||||
ThinkingPCSDK.Track(ThinkingSDKConstant.START_EVENT, properties, this.mAppId);
|
||||
}
|
||||
if ((mAutoTrackEvents & TDAutoTrackEventType.AppEnd) != 0)
|
||||
{
|
||||
ThinkingPCSDK.TimeEvent(ThinkingSDKConstant.END_EVENT, this.mAppId);
|
||||
}
|
||||
|
||||
ThinkingPCSDK.PauseTimeEvent(false, appId: this.mAppId);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((mAutoTrackEvents & TDAutoTrackEventType.AppEnd) != 0)
|
||||
{
|
||||
Dictionary<string, object> properties = new Dictionary<string, object>();
|
||||
if (mAutoTrackProperties.ContainsKey(TDAutoTrackEventType_APP_END))
|
||||
{
|
||||
ThinkingSDKUtil.AddDictionary(properties, mAutoTrackProperties[TDAutoTrackEventType_APP_END]);
|
||||
}
|
||||
if (mEventCallback_PC != null)
|
||||
{
|
||||
ThinkingSDKUtil.AddDictionary(properties, mEventCallback_PC.AutoTrackEventCallback_PC((int) TDAutoTrackEventType.AppEnd, properties));
|
||||
}
|
||||
ThinkingPCSDK.Track(ThinkingSDKConstant.END_EVENT, properties, this.mAppId);
|
||||
}
|
||||
ThinkingPCSDK.Flush(this.mAppId);
|
||||
|
||||
ThinkingPCSDK.PauseTimeEvent(true, appId: this.mAppId);
|
||||
}
|
||||
}
|
||||
|
||||
void OnApplicationQuit()
|
||||
{
|
||||
if (Application.isFocused == true)
|
||||
{
|
||||
OnApplicationFocus(false);
|
||||
}
|
||||
//ThinkingPCSDK.FlushImmediately(this.mAppId);
|
||||
}
|
||||
|
||||
public void SetAppId(string appId)
|
||||
{
|
||||
this.mAppId = appId;
|
||||
}
|
||||
|
||||
public void EnableAutoTrack(TDAutoTrackEventType events, Dictionary<string, object> properties, string appId)
|
||||
{
|
||||
SetAutoTrackProperties(events, properties);
|
||||
if ((events & TDAutoTrackEventType.AppInstall) != 0)
|
||||
{
|
||||
object result = ThinkingSDKFile.GetData(appId, ThinkingSDKConstant.IS_INSTALL, typeof(int));
|
||||
if (result == null)
|
||||
{
|
||||
Dictionary<string, object> mProperties = new Dictionary<string, object>(properties);
|
||||
ThinkingSDKFile.SaveData(appId, ThinkingSDKConstant.IS_INSTALL, 1);
|
||||
if (mAutoTrackProperties.ContainsKey(TDAutoTrackEventType_APP_INSTALL))
|
||||
{
|
||||
ThinkingSDKUtil.AddDictionary(mProperties, mAutoTrackProperties[TDAutoTrackEventType_APP_INSTALL]);
|
||||
}
|
||||
ThinkingPCSDK.Track(ThinkingSDKConstant.INSTALL_EVENT, mProperties, this.mAppId);
|
||||
ThinkingPCSDK.Flush(this.mAppId);
|
||||
}
|
||||
}
|
||||
if ((events & TDAutoTrackEventType.AppStart) != 0 && mStarted == false)
|
||||
{
|
||||
Dictionary<string, object> mProperties = new Dictionary<string, object>(properties);
|
||||
if (mAutoTrackProperties.ContainsKey(TDAutoTrackEventType_APP_START))
|
||||
{
|
||||
ThinkingSDKUtil.AddDictionary(mProperties, mAutoTrackProperties[TDAutoTrackEventType_APP_START]);
|
||||
}
|
||||
ThinkingPCSDK.Track(ThinkingSDKConstant.START_EVENT, mProperties, this.mAppId);
|
||||
ThinkingPCSDK.Flush(this.mAppId);
|
||||
}
|
||||
if ((events & TDAutoTrackEventType.AppEnd) != 0 && mStarted == false)
|
||||
{
|
||||
ThinkingPCSDK.TimeEvent(ThinkingSDKConstant.END_EVENT, this.mAppId);
|
||||
}
|
||||
|
||||
mStarted = true;
|
||||
}
|
||||
|
||||
public void EnableAutoTrack(TDAutoTrackEventType events, TDAutoTrackEventHandler_PC eventCallback, string appId)
|
||||
{
|
||||
mAutoTrackEvents = events;
|
||||
mEventCallback_PC = eventCallback;
|
||||
if ((events & TDAutoTrackEventType.AppInstall) != 0)
|
||||
{
|
||||
object result = ThinkingSDKFile.GetData(appId, ThinkingSDKConstant.IS_INSTALL, typeof(int));
|
||||
if (result == null)
|
||||
{
|
||||
ThinkingSDKFile.SaveData(appId, ThinkingSDKConstant.IS_INSTALL, 1);
|
||||
Dictionary<string, object> properties = null;
|
||||
if (mAutoTrackProperties.ContainsKey(TDAutoTrackEventType_APP_INSTALL))
|
||||
{
|
||||
properties = mAutoTrackProperties[TDAutoTrackEventType_APP_INSTALL];
|
||||
}
|
||||
else
|
||||
{
|
||||
properties = new Dictionary<string, object>();
|
||||
}
|
||||
if (mEventCallback_PC != null)
|
||||
{
|
||||
ThinkingSDKUtil.AddDictionary(properties, mEventCallback_PC.AutoTrackEventCallback_PC((int)TDAutoTrackEventType.AppInstall, properties));
|
||||
}
|
||||
ThinkingPCSDK.Track(ThinkingSDKConstant.INSTALL_EVENT, properties, this.mAppId);
|
||||
ThinkingPCSDK.Flush(this.mAppId);
|
||||
}
|
||||
}
|
||||
if ((events & TDAutoTrackEventType.AppStart) != 0 && mStarted == false)
|
||||
{
|
||||
Dictionary<string, object> properties = null;
|
||||
if (mAutoTrackProperties.ContainsKey(TDAutoTrackEventType_APP_START))
|
||||
{
|
||||
properties = mAutoTrackProperties[TDAutoTrackEventType_APP_START];
|
||||
}
|
||||
else
|
||||
{
|
||||
properties = new Dictionary<string, object>();
|
||||
}
|
||||
if (mEventCallback_PC != null)
|
||||
{
|
||||
ThinkingSDKUtil.AddDictionary(properties, mEventCallback_PC.AutoTrackEventCallback_PC((int) TDAutoTrackEventType.AppStart, properties));
|
||||
}
|
||||
ThinkingPCSDK.Track(ThinkingSDKConstant.START_EVENT, properties, this.mAppId);
|
||||
ThinkingPCSDK.Flush(this.mAppId);
|
||||
}
|
||||
if ((events & TDAutoTrackEventType.AppEnd) != 0 && mStarted == false)
|
||||
{
|
||||
ThinkingPCSDK.TimeEvent(ThinkingSDKConstant.END_EVENT, this.mAppId);
|
||||
}
|
||||
|
||||
mStarted = true;
|
||||
}
|
||||
|
||||
public void SetAutoTrackProperties(TDAutoTrackEventType events, Dictionary<string, object> properties)
|
||||
{
|
||||
mAutoTrackEvents = events;
|
||||
if ((events & TDAutoTrackEventType.AppInstall) != 0)
|
||||
{
|
||||
if (mAutoTrackProperties.ContainsKey(TDAutoTrackEventType_APP_INSTALL))
|
||||
{
|
||||
ThinkingSDKUtil.AddDictionary(mAutoTrackProperties[TDAutoTrackEventType_APP_INSTALL], properties);
|
||||
}
|
||||
else
|
||||
mAutoTrackProperties[TDAutoTrackEventType_APP_INSTALL] = properties;
|
||||
}
|
||||
if ((events & TDAutoTrackEventType.AppStart) != 0)
|
||||
{
|
||||
if (mAutoTrackProperties.ContainsKey(TDAutoTrackEventType_APP_START))
|
||||
{
|
||||
ThinkingSDKUtil.AddDictionary(mAutoTrackProperties[TDAutoTrackEventType_APP_START], properties);
|
||||
}
|
||||
else
|
||||
mAutoTrackProperties[TDAutoTrackEventType_APP_START] = properties;
|
||||
}
|
||||
if ((events & TDAutoTrackEventType.AppEnd) != 0)
|
||||
{
|
||||
if (mAutoTrackProperties.ContainsKey(TDAutoTrackEventType_APP_END))
|
||||
{
|
||||
ThinkingSDKUtil.AddDictionary(mAutoTrackProperties[TDAutoTrackEventType_APP_END], properties);
|
||||
}
|
||||
else
|
||||
mAutoTrackProperties[TDAutoTrackEventType_APP_END] = properties;
|
||||
}
|
||||
if ((events & TDAutoTrackEventType.AppCrash) != 0)
|
||||
{
|
||||
if (mAutoTrackProperties.ContainsKey(TDAutoTrackEventType_APP_CRASH))
|
||||
{
|
||||
ThinkingSDKUtil.AddDictionary(mAutoTrackProperties[TDAutoTrackEventType_APP_CRASH], properties);
|
||||
}
|
||||
else
|
||||
mAutoTrackProperties[TDAutoTrackEventType_APP_CRASH] = properties;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0ac1f96dfbfb046e79d0e2f5c3d94261
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 255aaff7c590d43c0893234eb5279770
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,192 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ThinkingSDK.PC.Utils;
|
||||
using ThinkingSDK.PC.Request;
|
||||
using ThinkingSDK.PC.Constant;
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace ThinkingSDK.PC.Config
|
||||
{
|
||||
public enum Mode
|
||||
{
|
||||
/* normal mode, the data will be stored in the cache and reported in batches */
|
||||
NORMAL,
|
||||
/* debug mode, the data will be reported one by one */
|
||||
DEBUG,
|
||||
/* debug only mode, only verify the data, and will not store it */
|
||||
DEBUG_ONLY
|
||||
}
|
||||
public class ThinkingSDKConfig
|
||||
{
|
||||
private string mToken;
|
||||
private string mServerUrl;
|
||||
private string mNormalUrl;
|
||||
private string mDebugUrl;
|
||||
private string mConfigUrl;
|
||||
private string mInstanceName;
|
||||
private Mode mMode = Mode.NORMAL;
|
||||
private TimeZoneInfo mTimeZone;
|
||||
public int mUploadInterval = 30;
|
||||
public int mUploadSize = 30;
|
||||
private List<string> mDisableEvents = new List<string>();
|
||||
private static Dictionary<string, ThinkingSDKConfig> sInstances = new Dictionary<string, ThinkingSDKConfig>();
|
||||
private ResponseHandle mCallback;
|
||||
private ThinkingSDKConfig(string token,string serverUrl, string instanceName)
|
||||
{
|
||||
//verify server url
|
||||
serverUrl = this.VerifyUrl(serverUrl);
|
||||
this.mServerUrl = serverUrl;
|
||||
this.mNormalUrl = serverUrl + "/sync";
|
||||
this.mDebugUrl = serverUrl + "/data_debug";
|
||||
this.mConfigUrl = serverUrl + "/config";
|
||||
this.mToken = token;
|
||||
this.mInstanceName = instanceName;
|
||||
try
|
||||
{
|
||||
this.mTimeZone = TimeZoneInfo.Local;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("TimeZoneInfo initial failed :" + e.Message);
|
||||
}
|
||||
}
|
||||
private string VerifyUrl(string serverUrl)
|
||||
{
|
||||
Uri uri = new Uri(serverUrl);
|
||||
serverUrl = uri.Scheme + "://" + uri.Host + ":" + uri.Port;
|
||||
return serverUrl;
|
||||
}
|
||||
public void SetMode(Mode mode)
|
||||
{
|
||||
this.mMode = mode;
|
||||
}
|
||||
public Mode GetMode()
|
||||
{
|
||||
return this.mMode;
|
||||
}
|
||||
public string DebugURL()
|
||||
{
|
||||
return this.mDebugUrl;
|
||||
}
|
||||
public string NormalURL()
|
||||
{
|
||||
return this.mNormalUrl;
|
||||
}
|
||||
public string ConfigURL()
|
||||
{
|
||||
return this.mConfigUrl;
|
||||
}
|
||||
public string Server()
|
||||
{
|
||||
return this.mServerUrl;
|
||||
}
|
||||
public string InstanceName()
|
||||
{
|
||||
return this.mInstanceName;
|
||||
}
|
||||
public static ThinkingSDKConfig GetInstance(string token, string server, string instanceName)
|
||||
{
|
||||
ThinkingSDKConfig config = null;
|
||||
if (!string.IsNullOrEmpty(instanceName))
|
||||
{
|
||||
if (sInstances.ContainsKey(instanceName))
|
||||
{
|
||||
config = sInstances[instanceName];
|
||||
}
|
||||
else
|
||||
{
|
||||
config = new ThinkingSDKConfig(token, server, instanceName);
|
||||
sInstances.Add(instanceName, config);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sInstances.ContainsKey(token))
|
||||
{
|
||||
config = sInstances[token];
|
||||
}
|
||||
else
|
||||
{
|
||||
config = new ThinkingSDKConfig(token, server, null);
|
||||
sInstances.Add(token, config);
|
||||
}
|
||||
}
|
||||
return config;
|
||||
}
|
||||
public void SetTimeZone(TimeZoneInfo timeZoneInfo)
|
||||
{
|
||||
this.mTimeZone = timeZoneInfo;
|
||||
}
|
||||
public TimeZoneInfo TimeZone()
|
||||
{
|
||||
return this.mTimeZone;
|
||||
}
|
||||
public List<string> DisableEvents() {
|
||||
return this.mDisableEvents;
|
||||
}
|
||||
public bool IsDisabledEvent(string eventName)
|
||||
{
|
||||
if (this.mDisableEvents == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.mDisableEvents.Contains(eventName);
|
||||
}
|
||||
}
|
||||
public void UpdateConfig(MonoBehaviour mono, ResponseHandle callback = null)
|
||||
{
|
||||
mCallback = callback;
|
||||
mono.StartCoroutine(this.GetWithFORM(this.mConfigUrl,this.mToken,null, ConfigResponseHandle));
|
||||
}
|
||||
|
||||
private void ConfigResponseHandle(Dictionary<string, object> result)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (result != null && result["code"] != null
|
||||
&& int.Parse(result["code"].ToString()) == 0)
|
||||
{
|
||||
Dictionary<string, object> data = (Dictionary<string, object>)result["data"];
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Get remote config success: " + ThinkingSDKJSON.Serialize(data));
|
||||
foreach (KeyValuePair<string, object> kv in data)
|
||||
{
|
||||
if (kv.Key == "sync_interval")
|
||||
{
|
||||
this.mUploadInterval = int.Parse(kv.Value.ToString());
|
||||
}
|
||||
else if (kv.Key == "sync_batch_size")
|
||||
{
|
||||
this.mUploadSize = int.Parse(kv.Value.ToString());
|
||||
}
|
||||
else if (kv.Key == "disable_event_list")
|
||||
{
|
||||
foreach (var item in (List<object>)kv.Value)
|
||||
{
|
||||
this.mDisableEvents.Add((string)item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Get remote config failed: " + ThinkingSDKJSON.Serialize(result));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Get remote config failed: " + ex.Message);
|
||||
}
|
||||
if (mCallback != null)
|
||||
{
|
||||
mCallback();
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator GetWithFORM (string url, string appId, Dictionary<string, object> param, ResponseHandle responseHandle) {
|
||||
yield return ThinkingSDKBaseRequest.GetWithFORM_2(this.mConfigUrl,this.mToken,param,responseHandle);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 472854a90c78a4dd4a16616ba3d3437d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,52 @@
|
|||
namespace ThinkingSDK.PC.Config
|
||||
{
|
||||
public class ThinkingSDKPublicConfig
|
||||
{
|
||||
// Whether to print log
|
||||
bool isPrintLog;
|
||||
// sdk version
|
||||
string version = "1.0";
|
||||
// sdk name
|
||||
string name = "Unity";
|
||||
private static readonly ThinkingSDKPublicConfig config = null;
|
||||
|
||||
static ThinkingSDKPublicConfig()
|
||||
{
|
||||
config = new ThinkingSDKPublicConfig();
|
||||
}
|
||||
|
||||
private static ThinkingSDKPublicConfig GetConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
public ThinkingSDKPublicConfig()
|
||||
{
|
||||
isPrintLog = false;
|
||||
}
|
||||
public static void SetIsPrintLog(bool isPrint)
|
||||
{
|
||||
GetConfig().isPrintLog = isPrint;
|
||||
}
|
||||
public static bool IsPrintLog()
|
||||
{
|
||||
return GetConfig().isPrintLog;
|
||||
}
|
||||
public static void SetVersion(string libVersion)
|
||||
{
|
||||
GetConfig().version = libVersion;
|
||||
}
|
||||
public static void SetName(string libName)
|
||||
{
|
||||
GetConfig().name = libName;
|
||||
}
|
||||
public static string Version()
|
||||
{
|
||||
return GetConfig().version;
|
||||
}
|
||||
public static string Name()
|
||||
{
|
||||
return GetConfig().name;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 47e9c09a25d664062bd8264d072b2f34
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e5cb18d25c15d4fca82ba5c10c117b9e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,116 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace ThinkingSDK.PC.Constant
|
||||
{
|
||||
public delegate void ResponseHandle(Dictionary<string,object> result = null);
|
||||
public class ThinkingSDKConstant
|
||||
{
|
||||
|
||||
// current platform
|
||||
public static readonly string PLATFORM = "PC";
|
||||
// date format style
|
||||
public static readonly string TIME_PATTERN = "{0:yyyy-MM-dd HH:mm:ss.fff}";
|
||||
|
||||
// event type
|
||||
public static readonly string TYPE = "#type";
|
||||
// event time
|
||||
public static readonly string TIME = "#time";
|
||||
// distinct ID
|
||||
public static readonly string DISTINCT_ID = "#distinct_id";
|
||||
// event name
|
||||
public static readonly string EVENT_NAME = "#event_name";
|
||||
// account ID
|
||||
public static readonly string ACCOUNT_ID = "#account_id";
|
||||
// event properties
|
||||
public static readonly string PROPERTIES = "properties";
|
||||
// network type
|
||||
public static readonly string NETWORK_TYPE = "#network_type";
|
||||
// sdk version
|
||||
public static readonly string LIB_VERSION = "#lib_version";
|
||||
// carrier name
|
||||
public static readonly string CARRIER = "#carrier";
|
||||
// sdk name
|
||||
public static readonly string LIB = "#lib";
|
||||
// os name
|
||||
public static readonly string OS = "#os";
|
||||
// device ID
|
||||
public static readonly string DEVICE_ID = "#device_id";
|
||||
// device screen height
|
||||
public static readonly string SCREEN_HEIGHT = "#screen_height";
|
||||
//device screen width
|
||||
public static readonly string SCREEN_WIDTH = "#screen_width";
|
||||
// device manufacturer
|
||||
public static readonly string MANUFACTURE = "#manufacturer";
|
||||
// device model
|
||||
public static readonly string DEVICE_MODEL = "#device_model";
|
||||
// device system language
|
||||
public static readonly string SYSTEM_LANGUAGE = "#system_language";
|
||||
// os version
|
||||
public static readonly string OS_VERSION = "#os_version";
|
||||
// app version
|
||||
public static readonly string APP_VERSION = "#app_version";
|
||||
// app bundle ID
|
||||
public static readonly string APP_BUNDLEID = "#bundle_id";
|
||||
// zone offset
|
||||
public static readonly string ZONE_OFFSET = "#zone_offset";
|
||||
// project ID
|
||||
public static readonly string APPID = "#app_id";
|
||||
// unique ID for the event
|
||||
public static readonly string UUID = "#uuid";
|
||||
// first event ID
|
||||
public static readonly string FIRST_CHECK_ID = "#first_check_id";
|
||||
// special event ID
|
||||
public static readonly string EVENT_ID = "#event_id";
|
||||
// random ID
|
||||
public static readonly string RANDOM_ID = "RANDDOM_ID";
|
||||
// random ID(WebGL)
|
||||
public static readonly string RANDOM_DEVICE_ID = "RANDOM_DEVICE_ID";
|
||||
// event duration
|
||||
public static readonly string DURATION = "#duration";
|
||||
// flush time
|
||||
public static readonly string FLUSH_TIME = "#flush_time";
|
||||
// request data
|
||||
public static readonly string REQUEST_DATA = "data";
|
||||
|
||||
// super properties
|
||||
public static readonly string SUPER_PROPERTY = "super_properties";
|
||||
|
||||
// user properties action
|
||||
public static readonly string USER_ADD = "user_add";
|
||||
public static readonly string USER_SET = "user_set";
|
||||
public static readonly string USER_SETONCE = "user_setOnce";
|
||||
public static readonly string USER_UNSET = "user_unset";
|
||||
public static readonly string USER_DEL = "user_del";
|
||||
public static readonly string USER_APPEND = "user_append";
|
||||
public static readonly string USER_UNIQ_APPEND = "user_uniq_append";
|
||||
|
||||
// Whether to pause data reporting
|
||||
public static readonly string ENABLE_TRACK = "enable_track";
|
||||
// Whether to stop data reporting
|
||||
public static readonly string OPT_TRACK = "opt_track";
|
||||
// Whether the installation is recorded
|
||||
public static readonly string IS_INSTALL = "is_install";
|
||||
|
||||
// app install event
|
||||
public static readonly string INSTALL_EVENT = "ta_app_install";
|
||||
// app start event
|
||||
public static readonly string START_EVENT = "ta_app_start";
|
||||
// app end event
|
||||
public static readonly string END_EVENT = "ta_app_end";
|
||||
// app crash event
|
||||
public static readonly string CRASH_EVENT = "ta_app_crash";
|
||||
// app crash reason
|
||||
public static readonly string CRASH_REASON = "#app_crashed_reason";
|
||||
// scene load
|
||||
public static readonly string APP_SCENE_LOAD = "ta_scene_loaded";
|
||||
// scene unload
|
||||
public static readonly string APP_SCENE_UNLOAD = "ta_scene_unloaded";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 361e81159859b41d797fc238c8f55f17
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a138ac43e601b433093a111aff909263
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,125 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ThinkingSDK.PC.Time;
|
||||
|
||||
namespace ThinkingSDK.PC.DataModel
|
||||
{
|
||||
public abstract class ThinkingSDKBaseData
|
||||
{
|
||||
// event type
|
||||
private string mType;
|
||||
// event time
|
||||
private ThinkingSDKTimeInter mTime;
|
||||
// distinct ID
|
||||
private string mDistinctID;
|
||||
// event name
|
||||
private string mEventName;
|
||||
// account ID
|
||||
private string mAccountID;
|
||||
|
||||
// unique ID for the event
|
||||
private string mUUID;
|
||||
private Dictionary<string, object> mProperties = new Dictionary<string, object>();
|
||||
public Dictionary<string, object> Properties()
|
||||
{
|
||||
return mProperties;
|
||||
}
|
||||
public void SetEventName(string eventName)
|
||||
{
|
||||
this.mEventName = eventName;
|
||||
}
|
||||
public void SetEventType(string eventType)
|
||||
{
|
||||
this.mType = eventType;
|
||||
}
|
||||
public string EventName()
|
||||
{
|
||||
return this.mEventName;
|
||||
}
|
||||
public void SetTime(ThinkingSDKTimeInter time)
|
||||
{
|
||||
this.mTime = time;
|
||||
}
|
||||
public ThinkingSDKTimeInter EventTime()
|
||||
{
|
||||
return this.mTime;
|
||||
}
|
||||
public void SetDataType(string type)
|
||||
{
|
||||
this.mType = type;
|
||||
}
|
||||
virtual public String GetDataType()
|
||||
{
|
||||
return this.mType;
|
||||
}
|
||||
public string AccountID()
|
||||
{
|
||||
return this.mAccountID;
|
||||
}
|
||||
public string DistinctID()
|
||||
{
|
||||
return this.mDistinctID;
|
||||
}
|
||||
public void SetAccountID(string accuntID)
|
||||
{
|
||||
this.mAccountID = accuntID;
|
||||
}
|
||||
public void SetDistinctID(string distinctID)
|
||||
{
|
||||
this.mDistinctID = distinctID;
|
||||
}
|
||||
public string UUID()
|
||||
{
|
||||
return this.mUUID;
|
||||
}
|
||||
public ThinkingSDKBaseData() { }
|
||||
public ThinkingSDKBaseData(ThinkingSDKTimeInter time,string eventName)
|
||||
{
|
||||
this.SetBaseData(eventName);
|
||||
this.SetTime(time);
|
||||
}
|
||||
public ThinkingSDKBaseData(string eventName)
|
||||
{
|
||||
this.SetBaseData(eventName);
|
||||
}
|
||||
public void SetBaseData(string eventName)
|
||||
{
|
||||
this.mEventName = eventName;
|
||||
this.mUUID = System.Guid.NewGuid().ToString();
|
||||
}
|
||||
|
||||
public ThinkingSDKBaseData(ThinkingSDKTimeInter time, string eventName, Dictionary<string, object> properties):this(time,eventName)
|
||||
{
|
||||
if (properties != null)
|
||||
{
|
||||
this.SetProperties(properties);
|
||||
}
|
||||
}
|
||||
|
||||
abstract public Dictionary<string, object> ToDictionary();
|
||||
public void SetProperties(Dictionary<string, object> properties,bool isOverwrite = true)
|
||||
{
|
||||
if (isOverwrite)
|
||||
{
|
||||
foreach (KeyValuePair<string, object> kv in properties)
|
||||
{
|
||||
mProperties[kv.Key] = kv.Value;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (KeyValuePair<string, object> kv in properties)
|
||||
{
|
||||
if (!mProperties.ContainsKey(kv.Key))
|
||||
{
|
||||
mProperties[kv.Key] = kv.Value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 69b1ae68ce0724b4290b99fb1920ffca
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,82 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ThinkingSDK.PC.Constant;
|
||||
using ThinkingSDK.PC.Time;
|
||||
|
||||
namespace ThinkingSDK.PC.DataModel
|
||||
{
|
||||
public class ThinkingSDKEventData:ThinkingSDKBaseData
|
||||
{
|
||||
private DateTime mEventTime;
|
||||
private TimeZoneInfo mTimeZone;
|
||||
private float mDuration;
|
||||
private static Dictionary<string, object> mData;
|
||||
public void SetEventTime(DateTime dateTime)
|
||||
{
|
||||
this.mEventTime = dateTime;
|
||||
}
|
||||
public void SetTimeZone(TimeZoneInfo timeZone)
|
||||
{
|
||||
this.mTimeZone = timeZone;
|
||||
}
|
||||
//public DateTime EventTime()
|
||||
//{
|
||||
// return this.mEventTime;
|
||||
//}
|
||||
public DateTime Time()
|
||||
{
|
||||
return mEventTime;
|
||||
}
|
||||
public ThinkingSDKEventData(string eventName) : base(eventName)
|
||||
{
|
||||
}
|
||||
|
||||
public ThinkingSDKEventData(ThinkingSDKTimeInter time, string eventName):base(time,eventName)
|
||||
{
|
||||
}
|
||||
public ThinkingSDKEventData(ThinkingSDKTimeInter time, string eventName, Dictionary<string, object> properties):base(time,eventName,properties)
|
||||
{
|
||||
}
|
||||
public override string GetDataType()
|
||||
{
|
||||
return "track";
|
||||
}
|
||||
public void SetDuration(float duration)
|
||||
{
|
||||
this.mDuration = duration;
|
||||
}
|
||||
|
||||
public override Dictionary<string, object> ToDictionary()
|
||||
{
|
||||
if (mData == null)
|
||||
{
|
||||
mData = new Dictionary<string, object>();
|
||||
}
|
||||
else
|
||||
{
|
||||
mData.Clear();
|
||||
}
|
||||
mData[ThinkingSDKConstant.TYPE] = GetDataType();
|
||||
mData[ThinkingSDKConstant.TIME] = this.EventTime().GetTime(this.mTimeZone);
|
||||
mData[ThinkingSDKConstant.DISTINCT_ID] = this.DistinctID();
|
||||
if (!string.IsNullOrEmpty(this.EventName()))
|
||||
{
|
||||
mData[ThinkingSDKConstant.EVENT_NAME] = this.EventName();
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.AccountID()))
|
||||
{
|
||||
mData[ThinkingSDKConstant.ACCOUNT_ID] = this.AccountID();
|
||||
}
|
||||
mData[ThinkingSDKConstant.UUID] = this.UUID();
|
||||
Dictionary<string, object> properties = this.Properties();
|
||||
properties[ThinkingSDKConstant.ZONE_OFFSET] = this.EventTime().GetZoneOffset(this.mTimeZone);
|
||||
if (mDuration != 0)
|
||||
{
|
||||
properties[ThinkingSDKConstant.DURATION] = mDuration;
|
||||
}
|
||||
mData[ThinkingSDKConstant.PROPERTIES] = properties;
|
||||
|
||||
return mData;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3d815c0c9730f473387bb0c0cd83098c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,35 @@
|
|||
using System.Collections.Generic;
|
||||
using ThinkingSDK.PC.Constant;
|
||||
using ThinkingSDK.PC.Utils;
|
||||
namespace ThinkingSDK.PC.DataModel
|
||||
{
|
||||
public class ThinkingSDKFirstEvent:ThinkingSDKEventData
|
||||
{
|
||||
private string mFirstCheckId;
|
||||
public ThinkingSDKFirstEvent(string eventName):base(eventName)
|
||||
{
|
||||
|
||||
}
|
||||
public void SetFirstCheckId(string firstCheckId)
|
||||
{
|
||||
mFirstCheckId = firstCheckId;
|
||||
}
|
||||
public string FirstCheckId()
|
||||
{
|
||||
if (string.IsNullOrEmpty(mFirstCheckId))
|
||||
{
|
||||
return ThinkingSDKDeviceInfo.DeviceID();
|
||||
}
|
||||
else
|
||||
{
|
||||
return mFirstCheckId;
|
||||
}
|
||||
}
|
||||
override public Dictionary<string, object> ToDictionary()
|
||||
{
|
||||
Dictionary<string,object> dictionary = base.ToDictionary();
|
||||
dictionary[ThinkingSDKConstant.FIRST_CHECK_ID] = FirstCheckId();
|
||||
return dictionary;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 285f00076791947c8a99103da1a2653d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,24 @@
|
|||
using System.Collections.Generic;
|
||||
using ThinkingSDK.PC.Constant;
|
||||
|
||||
namespace ThinkingSDK.PC.DataModel
|
||||
{
|
||||
public class ThinkingSDKOverWritableEvent:ThinkingSDKEventData
|
||||
{
|
||||
private string mEventID;
|
||||
public ThinkingSDKOverWritableEvent(string eventName,string eventID) : base(eventName)
|
||||
{
|
||||
this.mEventID = eventID;
|
||||
}
|
||||
public override string GetDataType()
|
||||
{
|
||||
return "track_overwrite";
|
||||
}
|
||||
override public Dictionary<string, object> ToDictionary()
|
||||
{
|
||||
Dictionary<string, object> dictionary = base.ToDictionary();
|
||||
dictionary[ThinkingSDKConstant.EVENT_ID] = mEventID;
|
||||
return dictionary;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9609b6c1610254c6795e60fe0ce7a92b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,25 @@
|
|||
using System.Collections.Generic;
|
||||
using ThinkingSDK.PC.Constant;
|
||||
|
||||
namespace ThinkingSDK.PC.DataModel
|
||||
{
|
||||
public class ThinkingSDKUpdateEvent:ThinkingSDKEventData
|
||||
{
|
||||
|
||||
private string mEventID;
|
||||
public ThinkingSDKUpdateEvent(string eventName, string eventID) : base(eventName)
|
||||
{
|
||||
this.mEventID = eventID;
|
||||
}
|
||||
public override string GetDataType()
|
||||
{
|
||||
return "track_update";
|
||||
}
|
||||
override public Dictionary<string, object> ToDictionary()
|
||||
{
|
||||
Dictionary<string, object> dictionary = base.ToDictionary();
|
||||
dictionary[ThinkingSDKConstant.EVENT_ID] = mEventID;
|
||||
return dictionary;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 25db2db9cd0d24311b5c5db04b42a604
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,31 @@
|
|||
using System.Collections.Generic;
|
||||
using ThinkingSDK.PC.Constant;
|
||||
using ThinkingSDK.PC.Time;
|
||||
|
||||
namespace ThinkingSDK.PC.DataModel
|
||||
{
|
||||
public class ThinkingSDKUserData:ThinkingSDKBaseData
|
||||
{
|
||||
public ThinkingSDKUserData(ThinkingSDKTimeInter time,string eventType, Dictionary<string,object> properties)
|
||||
{
|
||||
this.SetEventType(eventType);
|
||||
this.SetTime(time);
|
||||
this.SetBaseData(null);
|
||||
this.SetProperties(properties);
|
||||
}
|
||||
override public Dictionary<string, object> ToDictionary()
|
||||
{
|
||||
Dictionary<string, object> data = new Dictionary<string, object>();
|
||||
data[ThinkingSDKConstant.TYPE] = GetDataType();
|
||||
data[ThinkingSDKConstant.TIME] = EventTime().GetTime(null);
|
||||
data[ThinkingSDKConstant.DISTINCT_ID] = DistinctID();
|
||||
if (!string.IsNullOrEmpty(AccountID()))
|
||||
{
|
||||
data[ThinkingSDKConstant.ACCOUNT_ID] = AccountID();
|
||||
}
|
||||
data[ThinkingSDKConstant.UUID] = UUID();
|
||||
data[ThinkingSDKConstant.PROPERTIES] = Properties();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 890bcbb20acb741689b72692aaf6f60a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3166be662c1c1445387662fcb7118be5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,97 @@
|
|||
using ThinkingSDK.PC.Config;
|
||||
using System.Collections.Generic;
|
||||
using ThinkingSDK.PC.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ThinkingSDK.PC.Main
|
||||
{
|
||||
public class LightThinkingSDKInstance : ThinkingSDKInstance
|
||||
{
|
||||
public LightThinkingSDKInstance(string appId, string server, ThinkingSDKConfig config, MonoBehaviour mono = null) : base(appId, server, null, config, mono)
|
||||
{
|
||||
}
|
||||
public override void Identifiy(string distinctID)
|
||||
{
|
||||
if (IsPaused())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(distinctID))
|
||||
{
|
||||
this.mDistinctID = distinctID;
|
||||
}
|
||||
}
|
||||
public override string DistinctId()
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.mDistinctID))
|
||||
{
|
||||
this.mDistinctID = ThinkingSDKUtil.RandomID(false);
|
||||
}
|
||||
return this.mDistinctID;
|
||||
}
|
||||
public override void Login(string accountID)
|
||||
{
|
||||
if (IsPaused())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(accountID))
|
||||
{
|
||||
this.mAccountID = accountID;
|
||||
}
|
||||
}
|
||||
public override string AccountID()
|
||||
{
|
||||
return this.mAccountID;
|
||||
}
|
||||
public override void Logout()
|
||||
{
|
||||
if (IsPaused())
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.mAccountID = "";
|
||||
}
|
||||
public override void SetSuperProperties(Dictionary<string, object> superProperties)
|
||||
{
|
||||
if (IsPaused())
|
||||
{
|
||||
return;
|
||||
}
|
||||
ThinkingSDKUtil.AddDictionary(this.mSupperProperties, superProperties);
|
||||
}
|
||||
public override void UnsetSuperProperty(string propertyKey)
|
||||
{
|
||||
if (IsPaused())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this.mSupperProperties.ContainsKey(propertyKey))
|
||||
{
|
||||
this.mSupperProperties.Remove(propertyKey);
|
||||
}
|
||||
}
|
||||
public override Dictionary<string, object> SuperProperties()
|
||||
{
|
||||
return this.mSupperProperties;
|
||||
}
|
||||
public override void ClearSuperProperties()
|
||||
{
|
||||
if (IsPaused())
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.mSupperProperties.Clear();
|
||||
}
|
||||
public override void EnableAutoTrack(TDAutoTrackEventType events, Dictionary<string, object> properties)
|
||||
{
|
||||
}
|
||||
public override void SetAutoTrackProperties(TDAutoTrackEventType events, Dictionary<string, object> properties)
|
||||
{
|
||||
}
|
||||
public override void Flush()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7bff4ee40c5ed4a0cb4e4afe060d03c2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,362 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ThinkingSDK.PC.Config;
|
||||
using ThinkingSDK.PC.DataModel;
|
||||
using ThinkingSDK.PC.Time;
|
||||
using ThinkingSDK.PC.Utils;
|
||||
using UnityEngine;
|
||||
namespace ThinkingSDK.PC.Main
|
||||
{
|
||||
public class ThinkingPCSDK
|
||||
{
|
||||
private ThinkingPCSDK()
|
||||
{
|
||||
|
||||
}
|
||||
private static readonly Dictionary<string, ThinkingSDKInstance> Instances = new Dictionary<string, ThinkingSDKInstance>();
|
||||
private static readonly Dictionary<string, ThinkingSDKInstance> LightInstances = new Dictionary<string, ThinkingSDKInstance>();
|
||||
private static string CurrentAppid;
|
||||
|
||||
private static ThinkingSDKInstance GetInstance(string appId)
|
||||
{
|
||||
ThinkingSDKInstance instance = null;
|
||||
if (!string.IsNullOrEmpty(appId))
|
||||
{
|
||||
appId = appId.Replace(" ", "");
|
||||
if (LightInstances.ContainsKey(appId))
|
||||
{
|
||||
instance = LightInstances[appId];
|
||||
}
|
||||
else if (Instances.ContainsKey(appId))
|
||||
{
|
||||
instance = Instances[appId];
|
||||
}
|
||||
}
|
||||
if (instance == null)
|
||||
{
|
||||
instance = Instances[CurrentAppid];
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static ThinkingSDKInstance CurrentInstance()
|
||||
{
|
||||
ThinkingSDKInstance instance = Instances[CurrentAppid];
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static ThinkingSDKInstance Init(string appId, string server, string instanceName, ThinkingSDKConfig config = null, MonoBehaviour mono = null)
|
||||
{
|
||||
if (ThinkingSDKUtil.IsEmptyString(appId))
|
||||
{
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("appId is empty");
|
||||
return null;
|
||||
}
|
||||
ThinkingSDKInstance instance = null;
|
||||
if (!string.IsNullOrEmpty(instanceName))
|
||||
{
|
||||
if (Instances.ContainsKey(instanceName))
|
||||
{
|
||||
instance = Instances[instanceName];
|
||||
}
|
||||
else
|
||||
{
|
||||
instance = new ThinkingSDKInstance(appId, server, instanceName, config, mono);
|
||||
if (string.IsNullOrEmpty(CurrentAppid))
|
||||
{
|
||||
CurrentAppid = instanceName;
|
||||
}
|
||||
Instances[instanceName] = instance;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Instances.ContainsKey(appId))
|
||||
{
|
||||
instance = Instances[appId];
|
||||
}
|
||||
else
|
||||
{
|
||||
instance = new ThinkingSDKInstance(appId, server, null, config, mono);
|
||||
if (string.IsNullOrEmpty(CurrentAppid))
|
||||
{
|
||||
CurrentAppid = appId;
|
||||
}
|
||||
Instances[appId] = instance;
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
/// <summary>
|
||||
/// Sets distinct ID
|
||||
/// </summary>
|
||||
/// <param name="distinctID"></param>
|
||||
/// <param name="appId"></param>
|
||||
public static void Identifiy(string distinctID, string appId = "")
|
||||
{
|
||||
GetInstance(appId).Identifiy(distinctID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets distinct ID
|
||||
/// </summary>
|
||||
/// <param name="appId"></param>
|
||||
/// <returns></returns>
|
||||
public static string DistinctId(string appId = "")
|
||||
{
|
||||
return GetInstance(appId).DistinctId();
|
||||
}
|
||||
/// <summary>
|
||||
/// Sets account ID
|
||||
/// </summary>
|
||||
/// <param name="accountID"></param>
|
||||
/// <param name="appId"></param>
|
||||
public static void Login(string accountID,string appId = "")
|
||||
{
|
||||
GetInstance(appId).Login(accountID);
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets account ID
|
||||
/// </summary>
|
||||
/// <param name="appId"></param>
|
||||
/// <returns></returns>
|
||||
public static string AccountID(string appId = "")
|
||||
{
|
||||
return GetInstance(appId).AccountID();
|
||||
}
|
||||
/// <summary>
|
||||
/// Clear account ID
|
||||
/// </summary>
|
||||
public static void Logout(string appId = "")
|
||||
{
|
||||
GetInstance(appId).Logout();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable Auto-tracking Events
|
||||
/// </summary>
|
||||
/// <param name="events"></param>
|
||||
/// <param name="appId"></param>
|
||||
public static void EnableAutoTrack(TDAutoTrackEventType events, Dictionary<string, object> properties, string appId = "")
|
||||
{
|
||||
GetInstance(appId).EnableAutoTrack(events, properties);
|
||||
}
|
||||
|
||||
public static void EnableAutoTrack(TDAutoTrackEventType events, TDAutoTrackEventHandler_PC eventCallback, string appId = "")
|
||||
{
|
||||
GetInstance(appId).EnableAutoTrack(events, eventCallback);
|
||||
}
|
||||
|
||||
public static void SetAutoTrackProperties(TDAutoTrackEventType events, Dictionary<string, object> properties, string appId = "")
|
||||
{
|
||||
GetInstance(appId).SetAutoTrackProperties(events, properties);
|
||||
}
|
||||
|
||||
public static void Track(string eventName,string appId = "")
|
||||
{
|
||||
GetInstance(appId).Track(eventName);
|
||||
}
|
||||
public static void Track(string eventName, Dictionary<string, object> properties, string appId = "")
|
||||
{
|
||||
GetInstance(appId).Track(eventName,properties);
|
||||
}
|
||||
public static void Track(string eventName, Dictionary<string, object> properties, DateTime date, string appId = "")
|
||||
{
|
||||
GetInstance(appId).Track(eventName, properties, date);
|
||||
}
|
||||
public static void Track(string eventName, Dictionary<string, object> properties, DateTime date, TimeZoneInfo timeZone, string appId = "")
|
||||
{
|
||||
GetInstance(appId).Track(eventName, properties, date, timeZone);
|
||||
}
|
||||
public static void TrackForAll(string eventName, Dictionary<string, object> properties)
|
||||
{
|
||||
foreach (string appId in Instances.Keys)
|
||||
{
|
||||
GetInstance(appId).Track(eventName, properties);
|
||||
}
|
||||
}
|
||||
public static void Track(ThinkingSDKEventData eventModel,string appId = "")
|
||||
{
|
||||
GetInstance(appId).Track(eventModel);
|
||||
}
|
||||
|
||||
public static void Flush (string appId = "")
|
||||
{
|
||||
GetInstance(appId).Flush();
|
||||
}
|
||||
//public static void FlushImmediately (string appId = "")
|
||||
//{
|
||||
// GetInstance(appId).FlushImmediately();
|
||||
//}
|
||||
public static void SetSuperProperties(Dictionary<string, object> superProperties,string appId = "")
|
||||
{
|
||||
GetInstance(appId).SetSuperProperties(superProperties);
|
||||
}
|
||||
public static void UnsetSuperProperty(string propertyKey, string appId = "")
|
||||
{
|
||||
GetInstance(appId).UnsetSuperProperty(propertyKey);
|
||||
}
|
||||
public static Dictionary<string, object> SuperProperties(string appId="")
|
||||
{
|
||||
return GetInstance(appId).SuperProperties();
|
||||
}
|
||||
|
||||
public static Dictionary<string, object> PresetProperties(string appId="")
|
||||
{
|
||||
return GetInstance(appId).PresetProperties();
|
||||
}
|
||||
|
||||
public static void ClearSuperProperties(string appId= "")
|
||||
{
|
||||
GetInstance(appId).ClearSuperProperties();
|
||||
}
|
||||
|
||||
public static void TimeEvent(string eventName,string appId="")
|
||||
{
|
||||
GetInstance(appId).TimeEvent(eventName);
|
||||
}
|
||||
public static void TimeEventForAll(string eventName)
|
||||
{
|
||||
foreach (string appId in Instances.Keys)
|
||||
{
|
||||
GetInstance(appId).TimeEvent(eventName);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Pause Event timing
|
||||
/// </summary>
|
||||
/// <param name="status">ture: puase timing, false: resume timing</param>
|
||||
/// <param name="eventName">event name (null or empty is for all event)</param>
|
||||
public static void PauseTimeEvent(bool status, string eventName = "", string appId = "")
|
||||
{
|
||||
GetInstance(appId).PauseTimeEvent(status, eventName);
|
||||
}
|
||||
public static void UserSet(Dictionary<string, object> properties, string appId = "")
|
||||
{
|
||||
GetInstance(appId).UserSet(properties);
|
||||
}
|
||||
public static void UserSet(Dictionary<string, object> properties, DateTime dateTime,string appId = "")
|
||||
{
|
||||
GetInstance(appId).UserSet(properties, dateTime);
|
||||
}
|
||||
public static void UserUnset(string propertyKey,string appId = "")
|
||||
{
|
||||
GetInstance(appId).UserUnset(propertyKey);
|
||||
}
|
||||
public static void UserUnset(string propertyKey, DateTime dateTime,string appId = "")
|
||||
{
|
||||
GetInstance(appId).UserUnset(propertyKey,dateTime);
|
||||
}
|
||||
public static void UserUnset(List<string> propertyKeys, string appId = "")
|
||||
{
|
||||
GetInstance(appId).UserUnset(propertyKeys);
|
||||
}
|
||||
public static void UserUnset(List<string> propertyKeys, DateTime dateTime, string appId = "")
|
||||
{
|
||||
GetInstance(appId).UserUnset(propertyKeys,dateTime);
|
||||
}
|
||||
public static void UserSetOnce(Dictionary<string, object> properties,string appId = "")
|
||||
{
|
||||
GetInstance(appId).UserSetOnce(properties);
|
||||
}
|
||||
public static void UserSetOnce(Dictionary<string, object> properties, DateTime dateTime, string appId = "")
|
||||
{
|
||||
GetInstance(appId).UserSetOnce(properties,dateTime);
|
||||
}
|
||||
public static void UserAdd(Dictionary<string, object> properties, string appId = "")
|
||||
{
|
||||
GetInstance(appId).UserAdd(properties);
|
||||
}
|
||||
public static void UserAdd(Dictionary<string, object> properties, DateTime dateTime, string appId = "")
|
||||
{
|
||||
GetInstance(appId).UserAdd(properties,dateTime);
|
||||
}
|
||||
public static void UserAppend(Dictionary<string, object> properties, string appId = "")
|
||||
{
|
||||
GetInstance(appId).UserAppend(properties);
|
||||
}
|
||||
public static void UserAppend(Dictionary<string, object> properties, DateTime dateTime, string appId = "")
|
||||
{
|
||||
GetInstance(appId).UserAppend(properties,dateTime);
|
||||
}
|
||||
public static void UserUniqAppend(Dictionary<string, object> properties, string appId = "")
|
||||
{
|
||||
GetInstance(appId).UserUniqAppend(properties);
|
||||
}
|
||||
public static void UserUniqAppend(Dictionary<string, object> properties, DateTime dateTime, string appId = "")
|
||||
{
|
||||
GetInstance(appId).UserUniqAppend(properties,dateTime);
|
||||
}
|
||||
public static void UserDelete(string appId="")
|
||||
{
|
||||
GetInstance(appId).UserDelete();
|
||||
}
|
||||
public static void UserDelete(DateTime dateTime,string appId = "")
|
||||
{
|
||||
GetInstance(appId).UserDelete(dateTime);
|
||||
}
|
||||
public static void SetDynamicSuperProperties(TDDynamicSuperPropertiesHandler_PC dynamicSuperProperties, string appId = "")
|
||||
{
|
||||
GetInstance(appId).SetDynamicSuperProperties(dynamicSuperProperties);
|
||||
}
|
||||
public static void SetTrackStatus(TDTrackStatus status, string appId = "")
|
||||
{
|
||||
GetInstance(appId).SetTrackStatus(status);
|
||||
}
|
||||
public static void OptTracking(bool optTracking,string appId = "")
|
||||
{
|
||||
GetInstance(appId).OptTracking(optTracking);
|
||||
}
|
||||
public static void EnableTracking(bool isEnable, string appId = "")
|
||||
{
|
||||
GetInstance(appId).EnableTracking(isEnable);
|
||||
}
|
||||
public static void OptTrackingAndDeleteUser(string appId = "")
|
||||
{
|
||||
GetInstance(appId).OptTrackingAndDeleteUser();
|
||||
}
|
||||
public static string CreateLightInstance()
|
||||
{
|
||||
string randomID = System.Guid.NewGuid().ToString("N");
|
||||
ThinkingSDKInstance lightInstance = ThinkingSDKInstance.CreateLightInstance();
|
||||
LightInstances[randomID] = lightInstance;
|
||||
return randomID;
|
||||
}
|
||||
public static void CalibrateTime(long timestamp)
|
||||
{
|
||||
ThinkingSDKTimestampCalibration timestampCalibration = new ThinkingSDKTimestampCalibration(timestamp);
|
||||
ThinkingSDKInstance.SetTimeCalibratieton(timestampCalibration);
|
||||
}
|
||||
public static void CalibrateTimeWithNtp(string ntpServer)
|
||||
{
|
||||
ThinkingSDKNTPCalibration ntpCalibration = new ThinkingSDKNTPCalibration(ntpServer);
|
||||
ThinkingSDKInstance.SetNtpTimeCalibratieton(ntpCalibration);
|
||||
}
|
||||
|
||||
public static void OnDestory() {
|
||||
Instances.Clear();
|
||||
LightInstances.Clear();
|
||||
}
|
||||
|
||||
public static string GetDeviceId()
|
||||
{
|
||||
return ThinkingSDKDeviceInfo.DeviceID();
|
||||
}
|
||||
public static void EnableLog(bool isEnable)
|
||||
{
|
||||
ThinkingSDKPublicConfig.SetIsPrintLog(isEnable);
|
||||
}
|
||||
public static void SetLibName(string name)
|
||||
{
|
||||
ThinkingSDKPublicConfig.SetName(name);
|
||||
}
|
||||
public static void SetLibVersion(string versionCode)
|
||||
{
|
||||
ThinkingSDKPublicConfig.SetVersion(versionCode);
|
||||
}
|
||||
public static string TimeString(DateTime dateTime, string appId = "")
|
||||
{
|
||||
return GetInstance(appId).TimeString(dateTime);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ee46cd65b236c4202a800c812df46325
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,786 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using ThinkingSDK.PC.Config;
|
||||
using ThinkingSDK.PC.Constant;
|
||||
using ThinkingSDK.PC.DataModel;
|
||||
using ThinkingSDK.PC.Request;
|
||||
using ThinkingSDK.PC.Storage;
|
||||
using ThinkingSDK.PC.TaskManager;
|
||||
using ThinkingSDK.PC.Time;
|
||||
using ThinkingSDK.PC.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ThinkingSDK.PC.Main
|
||||
{
|
||||
[Flags]
|
||||
// Auto-tracking Events Type
|
||||
public enum TDAutoTrackEventType
|
||||
{
|
||||
None = 0,
|
||||
AppStart = 1 << 0, // reporting when the app enters the foreground (ta_app_start)
|
||||
AppEnd = 1 << 1, // reporting when the app enters the background (ta_app_end)
|
||||
AppCrash = 1 << 4, // reporting when an uncaught exception occurs (ta_app_crash)
|
||||
AppInstall = 1 << 5, // reporting when the app is opened for the first time after installation (ta_app_install)
|
||||
AppSceneLoad = 1 << 6, // reporting when the scene is loaded in the app (ta_scene_loaded)
|
||||
AppSceneUnload = 1 << 7, // reporting when the scene is unloaded in the app (ta_scene_loaded)
|
||||
All = AppStart | AppEnd | AppInstall | AppCrash | AppSceneLoad | AppSceneUnload
|
||||
}
|
||||
// Data Reporting Status
|
||||
public enum TDTrackStatus
|
||||
{
|
||||
Pause = 1, // pause data reporting
|
||||
Stop = 2, // stop data reporting, and clear caches
|
||||
SaveOnly = 3, // data stores in the cache, but not be reported
|
||||
Normal = 4 // resume data reporting
|
||||
}
|
||||
|
||||
public interface TDDynamicSuperPropertiesHandler_PC
|
||||
{
|
||||
Dictionary<string, object> GetDynamicSuperProperties_PC();
|
||||
}
|
||||
public interface TDAutoTrackEventHandler_PC
|
||||
{
|
||||
Dictionary<string, object> AutoTrackEventCallback_PC(int type, Dictionary<string, object>properties);
|
||||
}
|
||||
public class ThinkingSDKInstance
|
||||
{
|
||||
private string mAppid;
|
||||
private string mServer;
|
||||
protected string mDistinctID;
|
||||
protected string mAccountID;
|
||||
private bool mOptTracking = true;
|
||||
private Dictionary<string, object> mTimeEvents = new Dictionary<string, object>();
|
||||
private Dictionary<string, object> mTimeEventsBefore = new Dictionary<string, object>();
|
||||
private bool mEnableTracking = true;
|
||||
private bool mEventSaveOnly = false; //data stores in the cache, but not be reported
|
||||
protected Dictionary<string, object> mSupperProperties = new Dictionary<string, object>();
|
||||
protected Dictionary<string, Dictionary<string, object>> mAutoTrackProperties = new Dictionary<string, Dictionary<string, object>>();
|
||||
private ThinkingSDKConfig mConfig;
|
||||
private ThinkingSDKBaseRequest mRequest;
|
||||
private static ThinkingSDKTimeCalibration mTimeCalibration;
|
||||
private static ThinkingSDKTimeCalibration mNtpTimeCalibration;
|
||||
private TDDynamicSuperPropertiesHandler_PC mDynamicProperties;
|
||||
private ThinkingSDKTask mTask {
|
||||
get {
|
||||
return ThinkingSDKTask.SingleTask();
|
||||
}
|
||||
set {
|
||||
this.mTask = value;
|
||||
}
|
||||
}
|
||||
private static ThinkingSDKInstance mCurrentInstance;
|
||||
private MonoBehaviour mMono;
|
||||
private static MonoBehaviour sMono;
|
||||
private ThinkingSDKAutoTrack mAutoTrack;
|
||||
|
||||
WaitForSeconds flushDelay;
|
||||
public static void SetTimeCalibratieton(ThinkingSDKTimeCalibration timeCalibration)
|
||||
{
|
||||
mTimeCalibration = timeCalibration;
|
||||
}
|
||||
public static void SetNtpTimeCalibratieton(ThinkingSDKTimeCalibration timeCalibration)
|
||||
{
|
||||
mNtpTimeCalibration = timeCalibration;
|
||||
}
|
||||
private ThinkingSDKInstance()
|
||||
{
|
||||
|
||||
}
|
||||
private void DefaultData()
|
||||
{
|
||||
DistinctId();
|
||||
AccountID();
|
||||
SuperProperties();
|
||||
DefaultTrackState();
|
||||
}
|
||||
public ThinkingSDKInstance(string appId,string server):this(appId,server,null,null)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
public ThinkingSDKInstance(string appId, string server, string instanceName, ThinkingSDKConfig config, MonoBehaviour mono = null)
|
||||
{
|
||||
this.mMono = mono;
|
||||
sMono = mono;
|
||||
if (config == null)
|
||||
{
|
||||
this.mConfig = ThinkingSDKConfig.GetInstance(appId, server, instanceName);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.mConfig = config;
|
||||
}
|
||||
this.mConfig.UpdateConfig(mono, ConfigResponseHandle);
|
||||
this.mAppid = appId;
|
||||
this.mServer = server;
|
||||
if (this.mConfig.GetMode() == Mode.NORMAL)
|
||||
{
|
||||
this.mRequest = new ThinkingSDKNormalRequest(appId, this.mConfig.NormalURL());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.mRequest = new ThinkingSDKDebugRequest(appId,this.mConfig.DebugURL());
|
||||
if (this.mConfig.GetMode() == Mode.DEBUG_ONLY)
|
||||
{
|
||||
((ThinkingSDKDebugRequest)this.mRequest).SetDryRun(1);
|
||||
}
|
||||
}
|
||||
DefaultData();
|
||||
mCurrentInstance = this;
|
||||
// dynamic loading ThinkingSDKTask ThinkingSDKAutoTrack
|
||||
GameObject mThinkingSDKTask = new GameObject("ThinkingSDKTask", typeof(ThinkingSDKTask));
|
||||
UnityEngine.Object.DontDestroyOnLoad(mThinkingSDKTask);
|
||||
|
||||
GameObject mThinkingSDKAutoTrack = new GameObject("ThinkingSDKAutoTrack", typeof(ThinkingSDKAutoTrack));
|
||||
this.mAutoTrack = (ThinkingSDKAutoTrack) mThinkingSDKAutoTrack.GetComponent(typeof(ThinkingSDKAutoTrack));
|
||||
if (!string.IsNullOrEmpty(instanceName))
|
||||
{
|
||||
this.mAutoTrack.SetAppId(instanceName);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.mAutoTrack.SetAppId(this.mAppid);
|
||||
}
|
||||
UnityEngine.Object.DontDestroyOnLoad(mThinkingSDKAutoTrack);
|
||||
}
|
||||
private void EventResponseHandle(Dictionary<string, object> result)
|
||||
{
|
||||
int eventCount = 0;
|
||||
if (result != null)
|
||||
{
|
||||
int flushCount = 0;
|
||||
if (result.ContainsKey("flush_count"))
|
||||
{
|
||||
flushCount = (int)result["flush_count"];
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.mConfig.InstanceName()))
|
||||
{
|
||||
eventCount = ThinkingSDKFileJson.DeleteBatchTrackingData(flushCount, this.mConfig.InstanceName());
|
||||
}
|
||||
else
|
||||
{
|
||||
eventCount = ThinkingSDKFileJson.DeleteBatchTrackingData(flushCount, this.mAppid);
|
||||
}
|
||||
}
|
||||
mTask.Release();
|
||||
if (eventCount > 0)
|
||||
{
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Flush automatically (" + this.mAppid + ")");
|
||||
Flush();
|
||||
}
|
||||
}
|
||||
private void ConfigResponseHandle(Dictionary<string, object> result)
|
||||
{
|
||||
if (this.mConfig.GetMode() == Mode.NORMAL)
|
||||
{
|
||||
flushDelay = new WaitForSeconds(mConfig.mUploadInterval);
|
||||
sMono.StartCoroutine(WaitAndFlush());
|
||||
}
|
||||
}
|
||||
public static ThinkingSDKInstance CreateLightInstance()
|
||||
{
|
||||
ThinkingSDKInstance lightInstance = new LightThinkingSDKInstance(mCurrentInstance.mAppid, mCurrentInstance.mServer, mCurrentInstance.mConfig, sMono);
|
||||
return lightInstance;
|
||||
}
|
||||
public ThinkingSDKTimeInter GetTime(DateTime dateTime)
|
||||
{
|
||||
ThinkingSDKTimeInter time = null;
|
||||
|
||||
if ( dateTime == DateTime.MinValue || dateTime == null)
|
||||
{
|
||||
if (mNtpTimeCalibration != null)// check if time calibrated
|
||||
{
|
||||
time = new ThinkingSDKCalibratedTime(mNtpTimeCalibration, mConfig.TimeZone());
|
||||
}
|
||||
else if (mTimeCalibration != null)// check if time calibrated
|
||||
{
|
||||
time = new ThinkingSDKCalibratedTime(mTimeCalibration, mConfig.TimeZone());
|
||||
}
|
||||
else
|
||||
{
|
||||
time = new ThinkingSDKTime(mConfig.TimeZone(), DateTime.Now);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
time = new ThinkingSDKTime(mConfig.TimeZone(), dateTime);
|
||||
}
|
||||
|
||||
return time;
|
||||
}
|
||||
// sets distisct ID
|
||||
public virtual void Identifiy(string distinctID)
|
||||
{
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Setting distinct ID, DistinctId = " + distinctID);
|
||||
if (IsPaused())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(distinctID))
|
||||
{
|
||||
this.mDistinctID = distinctID;
|
||||
ThinkingSDKFile.SaveData(mAppid, ThinkingSDKConstant.DISTINCT_ID,distinctID);
|
||||
}
|
||||
}
|
||||
public virtual string DistinctId()
|
||||
{
|
||||
this.mDistinctID = (string)ThinkingSDKFile.GetData(this.mAppid,ThinkingSDKConstant.DISTINCT_ID, typeof(string));
|
||||
if (string.IsNullOrEmpty(this.mDistinctID))
|
||||
{
|
||||
this.mDistinctID = ThinkingSDKUtil.RandomID();
|
||||
ThinkingSDKFile.SaveData(this.mAppid, ThinkingSDKConstant.DISTINCT_ID, this.mDistinctID);
|
||||
}
|
||||
|
||||
return this.mDistinctID;
|
||||
}
|
||||
|
||||
public virtual void Login(string accountID)
|
||||
{
|
||||
if (IsPaused())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Login SDK, AccountId = " + accountID);
|
||||
if (!string.IsNullOrEmpty(accountID))
|
||||
{
|
||||
this.mAccountID = accountID;
|
||||
ThinkingSDKFile.SaveData(mAppid, ThinkingSDKConstant.ACCOUNT_ID, accountID);
|
||||
}
|
||||
}
|
||||
public virtual string AccountID()
|
||||
{
|
||||
this.mAccountID = (string)ThinkingSDKFile.GetData(this.mAppid,ThinkingSDKConstant.ACCOUNT_ID, typeof(string));
|
||||
return this.mAccountID;
|
||||
}
|
||||
public virtual void Logout()
|
||||
{
|
||||
if (IsPaused())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Logout SDK");
|
||||
this.mAccountID = "";
|
||||
ThinkingSDKFile.DeleteData(this.mAppid,ThinkingSDKConstant.ACCOUNT_ID);
|
||||
}
|
||||
//TODO
|
||||
public virtual void EnableAutoTrack(TDAutoTrackEventType events, Dictionary<string, object> properties)
|
||||
{
|
||||
this.mAutoTrack.EnableAutoTrack(events, properties, mAppid);
|
||||
}
|
||||
public virtual void EnableAutoTrack(TDAutoTrackEventType events, TDAutoTrackEventHandler_PC eventCallback)
|
||||
{
|
||||
this.mAutoTrack.EnableAutoTrack(events, eventCallback, mAppid);
|
||||
}
|
||||
// sets auto-tracking events properties
|
||||
public virtual void SetAutoTrackProperties(TDAutoTrackEventType events, Dictionary<string, object> properties)
|
||||
{
|
||||
this.mAutoTrack.SetAutoTrackProperties(events, properties);
|
||||
}
|
||||
public void Track(string eventName)
|
||||
{
|
||||
Track(eventName, null, DateTime.MinValue);
|
||||
}
|
||||
public void Track(string eventName, Dictionary<string, object> properties)
|
||||
{
|
||||
Track(eventName, properties, DateTime.MinValue);
|
||||
}
|
||||
public void Track(string eventName, Dictionary<string, object> properties, DateTime date)
|
||||
{
|
||||
Track(eventName, properties, date, null, false);
|
||||
}
|
||||
public void Track(string eventName, Dictionary<string, object> properties, DateTime date, TimeZoneInfo timeZone)
|
||||
{
|
||||
Track(eventName, properties, date, timeZone, false);
|
||||
}
|
||||
public void Track(string eventName, Dictionary<string, object> properties, DateTime date, TimeZoneInfo timeZone, bool immediately)
|
||||
{
|
||||
ThinkingSDKTimeInter time = GetTime(date);
|
||||
ThinkingSDKEventData data = new ThinkingSDKEventData(time, eventName, properties);
|
||||
if (timeZone != null)
|
||||
{
|
||||
data.SetTimeZone(timeZone);
|
||||
}
|
||||
SendData(data, immediately);
|
||||
}
|
||||
private void SendData(ThinkingSDKEventData data)
|
||||
{
|
||||
SendData(data, false);
|
||||
}
|
||||
private void SendData(ThinkingSDKEventData data, bool immediately)
|
||||
{
|
||||
if (this.mDynamicProperties != null)
|
||||
{
|
||||
data.SetProperties(this.mDynamicProperties.GetDynamicSuperProperties_PC(),false);
|
||||
}
|
||||
if (this.mSupperProperties != null && this.mSupperProperties.Count > 0)
|
||||
{
|
||||
data.SetProperties(this.mSupperProperties,false);
|
||||
}
|
||||
Dictionary<string, object> deviceInfo = ThinkingSDKUtil.DeviceInfo();
|
||||
foreach (string item in ThinkingSDKUtil.DisPresetProperties)
|
||||
{
|
||||
if (deviceInfo.ContainsKey(item))
|
||||
{
|
||||
deviceInfo.Remove(item);
|
||||
}
|
||||
}
|
||||
data.SetProperties(deviceInfo, false);
|
||||
|
||||
float duration = 0;
|
||||
if (mTimeEvents.ContainsKey(data.EventName()))
|
||||
{
|
||||
int beginTime = (int)mTimeEvents[data.EventName()];
|
||||
int nowTime = Environment.TickCount;
|
||||
duration = (float)((nowTime - beginTime) / 1000.0);
|
||||
mTimeEvents.Remove(data.EventName());
|
||||
if (mTimeEventsBefore.ContainsKey(data.EventName()))
|
||||
{
|
||||
int beforeTime = (int)mTimeEventsBefore[data.EventName()];
|
||||
duration = duration + (float)(beforeTime / 1000.0);
|
||||
mTimeEventsBefore.Remove(data.EventName());
|
||||
}
|
||||
}
|
||||
if (duration != 0)
|
||||
{
|
||||
data.SetDuration(duration);
|
||||
}
|
||||
|
||||
SendData((ThinkingSDKBaseData)data, immediately);
|
||||
}
|
||||
private void SendData(ThinkingSDKBaseData data)
|
||||
{
|
||||
SendData(data, false);
|
||||
}
|
||||
private void SendData(ThinkingSDKBaseData data, bool immediately)
|
||||
{
|
||||
if (IsPaused())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.mAccountID))
|
||||
{
|
||||
data.SetAccountID(this.mAccountID);
|
||||
}
|
||||
if (string.IsNullOrEmpty(this.mDistinctID))
|
||||
{
|
||||
DistinctId();
|
||||
}
|
||||
data.SetDistinctID(this.mDistinctID);
|
||||
|
||||
if (this.mConfig.IsDisabledEvent(data.EventName()))
|
||||
{
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Disabled Event: " + data.EventName());
|
||||
return;
|
||||
}
|
||||
if (this.mConfig.GetMode() == Mode.NORMAL && this.mRequest.GetType() != typeof(ThinkingSDKNormalRequest))
|
||||
{
|
||||
this.mRequest = new ThinkingSDKNormalRequest(this.mAppid, this.mConfig.NormalURL());
|
||||
}
|
||||
|
||||
if (immediately)
|
||||
{
|
||||
Dictionary<string, object> dataDic = data.ToDictionary();
|
||||
this.mMono.StartCoroutine(mRequest.SendData_2(null, ThinkingSDKJSON.Serialize(dataDic), 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary<string, object> dataDic = data.ToDictionary();
|
||||
int count = 0;
|
||||
if (!string.IsNullOrEmpty(this.mConfig.InstanceName()))
|
||||
{
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Enqueue data: \n" + ThinkingSDKJSON.Serialize(dataDic) + "\n AppId: " + this.mAppid);
|
||||
count = ThinkingSDKFileJson.EnqueueTrackingData(dataDic, this.mConfig.InstanceName());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Enqueue data: \n" + ThinkingSDKJSON.Serialize(dataDic) + "\n AppId: " + this.mAppid);
|
||||
count = ThinkingSDKFileJson.EnqueueTrackingData(dataDic, this.mAppid);
|
||||
}
|
||||
if (this.mConfig.GetMode() != Mode.NORMAL || count >= this.mConfig.mUploadSize)
|
||||
{
|
||||
if (count >= this.mConfig.mUploadSize)
|
||||
{
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Flush automatically (" + this.mAppid + ")");
|
||||
}
|
||||
Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator WaitAndFlush()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
yield return flushDelay;
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Flush automatically (" + this.mAppid + ")");
|
||||
Flush();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// flush events data
|
||||
/// </summary>
|
||||
public virtual void Flush()
|
||||
{
|
||||
if (mEventSaveOnly == false) {
|
||||
mTask.SyncInvokeAllTask();
|
||||
|
||||
int batchSize = (this.mConfig.GetMode() != Mode.NORMAL) ? 1 : mConfig.mUploadSize;
|
||||
if (!string.IsNullOrEmpty(this.mConfig.InstanceName()))
|
||||
{
|
||||
mTask.StartRequest(mRequest, EventResponseHandle, batchSize, this.mConfig.InstanceName());
|
||||
}
|
||||
else
|
||||
{
|
||||
mTask.StartRequest(mRequest, EventResponseHandle, batchSize, this.mAppid);
|
||||
}
|
||||
}
|
||||
}
|
||||
//public void FlushImmediately()
|
||||
//{
|
||||
// if (mEventSaveOnly == false)
|
||||
// {
|
||||
// mTask.SyncInvokeAllTask();
|
||||
|
||||
// int batchSize = (this.mConfig.GetMode() != Mode.NORMAL) ? 1 : mConfig.mUploadSize;
|
||||
// string list;
|
||||
// int eventCount = 0;
|
||||
// if (!string.IsNullOrEmpty(this.mConfig.InstanceName()))
|
||||
// {
|
||||
// list = ThinkingSDKFileJson.DequeueBatchTrackingData(batchSize, this.mConfig.InstanceName(), out eventCount);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// list = ThinkingSDKFileJson.DequeueBatchTrackingData(batchSize, this.mAppid, out eventCount);
|
||||
// }
|
||||
// if (eventCount > 0)
|
||||
// {
|
||||
// this.mMono.StartCoroutine(mRequest.SendData_2(EventResponseHandle, list, eventCount));
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
public void Track(ThinkingSDKEventData eventModel)
|
||||
{
|
||||
ThinkingSDKTimeInter time = GetTime(eventModel.Time());
|
||||
eventModel.SetTime(time);
|
||||
SendData(eventModel);
|
||||
}
|
||||
|
||||
public virtual void SetSuperProperties(Dictionary<string, object> superProperties)
|
||||
{
|
||||
if (IsPaused())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Dictionary<string, object> properties = new Dictionary<string, object>();
|
||||
string propertiesStr = (string)ThinkingSDKFile.GetData(this.mAppid, ThinkingSDKConstant.SUPER_PROPERTY, typeof(string));
|
||||
if (!string.IsNullOrEmpty(propertiesStr))
|
||||
{
|
||||
properties = ThinkingSDKJSON.Deserialize(propertiesStr);
|
||||
}
|
||||
ThinkingSDKUtil.AddDictionary(properties, superProperties);
|
||||
this.mSupperProperties = properties;
|
||||
ThinkingSDKFile.SaveData(this.mAppid, ThinkingSDKConstant.SUPER_PROPERTY, ThinkingSDKJSON.Serialize(this.mSupperProperties));
|
||||
}
|
||||
public virtual void UnsetSuperProperty(string propertyKey)
|
||||
{
|
||||
if (IsPaused())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Dictionary<string, object> properties = new Dictionary<string, object>();
|
||||
string propertiesStr = (string)ThinkingSDKFile.GetData(this.mAppid, ThinkingSDKConstant.SUPER_PROPERTY, typeof(string));
|
||||
if (!string.IsNullOrEmpty(propertiesStr))
|
||||
{
|
||||
properties = ThinkingSDKJSON.Deserialize(propertiesStr);
|
||||
}
|
||||
if (properties.ContainsKey(propertyKey))
|
||||
{
|
||||
properties.Remove(propertyKey);
|
||||
}
|
||||
this.mSupperProperties = properties;
|
||||
ThinkingSDKFile.SaveData(this.mAppid, ThinkingSDKConstant.SUPER_PROPERTY, ThinkingSDKJSON.Serialize(this.mSupperProperties));
|
||||
}
|
||||
public virtual Dictionary<string, object> SuperProperties()
|
||||
{
|
||||
string propertiesStr = (string)ThinkingSDKFile.GetData(this.mAppid, ThinkingSDKConstant.SUPER_PROPERTY, typeof(string));
|
||||
if (!string.IsNullOrEmpty(propertiesStr))
|
||||
{
|
||||
this.mSupperProperties = ThinkingSDKJSON.Deserialize(propertiesStr);
|
||||
}
|
||||
return this.mSupperProperties;
|
||||
}
|
||||
public Dictionary<string, object> PresetProperties()
|
||||
{
|
||||
Dictionary<string, object> presetProperties = new Dictionary<string, object>();
|
||||
presetProperties[ThinkingSDKConstant.DEVICE_ID] = ThinkingSDKDeviceInfo.DeviceID();
|
||||
presetProperties[ThinkingSDKConstant.CARRIER] = ThinkingSDKDeviceInfo.Carrier();
|
||||
presetProperties[ThinkingSDKConstant.OS] = ThinkingSDKDeviceInfo.OS();
|
||||
presetProperties[ThinkingSDKConstant.SCREEN_HEIGHT] = ThinkingSDKDeviceInfo.ScreenHeight();
|
||||
presetProperties[ThinkingSDKConstant.SCREEN_WIDTH] = ThinkingSDKDeviceInfo.ScreenWidth();
|
||||
presetProperties[ThinkingSDKConstant.MANUFACTURE] = ThinkingSDKDeviceInfo.Manufacture();
|
||||
presetProperties[ThinkingSDKConstant.DEVICE_MODEL] = ThinkingSDKDeviceInfo.DeviceModel();
|
||||
presetProperties[ThinkingSDKConstant.SYSTEM_LANGUAGE] = ThinkingSDKDeviceInfo.MachineLanguage();
|
||||
presetProperties[ThinkingSDKConstant.OS_VERSION] = ThinkingSDKDeviceInfo.OSVersion();
|
||||
presetProperties[ThinkingSDKConstant.NETWORK_TYPE] = ThinkingSDKDeviceInfo.NetworkType();
|
||||
presetProperties[ThinkingSDKConstant.APP_BUNDLEID] = ThinkingSDKAppInfo.AppIdentifier();
|
||||
presetProperties[ThinkingSDKConstant.APP_VERSION] = ThinkingSDKAppInfo.AppVersion();
|
||||
presetProperties[ThinkingSDKConstant.ZONE_OFFSET] = ThinkingSDKUtil.ZoneOffset(DateTime.Now, this.mConfig.TimeZone());
|
||||
|
||||
return presetProperties;
|
||||
}
|
||||
public virtual void ClearSuperProperties()
|
||||
{
|
||||
if (IsPaused())
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.mSupperProperties.Clear();
|
||||
ThinkingSDKFile.DeleteData(this.mAppid,ThinkingSDKConstant.SUPER_PROPERTY);
|
||||
}
|
||||
|
||||
public void TimeEvent(string eventName)
|
||||
{
|
||||
if (!mTimeEvents.ContainsKey(eventName))
|
||||
{
|
||||
mTimeEvents.Add(eventName, Environment.TickCount);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Pause Event timing
|
||||
/// </summary>
|
||||
/// <param name="status">ture: puase timing, false: resume timing</param>
|
||||
/// <param name="eventName">event name (null or empty is for all event)</param>
|
||||
public void PauseTimeEvent(bool status, string eventName = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(eventName))
|
||||
{
|
||||
string[] eventNames = new string[mTimeEvents.Keys.Count];
|
||||
mTimeEvents.Keys.CopyTo(eventNames, 0);
|
||||
for (int i=0; i< eventNames.Length; i++)
|
||||
{
|
||||
string key = eventNames[i];
|
||||
if (status == true)
|
||||
{
|
||||
int startTime = int.Parse(mTimeEvents[key].ToString());
|
||||
int pauseTime = Environment.TickCount;
|
||||
int duration = pauseTime - startTime;
|
||||
if (mTimeEventsBefore.ContainsKey(key))
|
||||
{
|
||||
duration = duration + int.Parse(mTimeEventsBefore[key].ToString());
|
||||
}
|
||||
mTimeEventsBefore[key] = duration;
|
||||
}
|
||||
else
|
||||
{
|
||||
mTimeEvents[key] = Environment.TickCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (status == true)
|
||||
{
|
||||
int startTime = int.Parse(mTimeEvents[eventName].ToString());
|
||||
int pauseTime = Environment.TickCount;
|
||||
int duration = pauseTime - startTime;
|
||||
mTimeEventsBefore[eventName] = duration;
|
||||
}
|
||||
else
|
||||
{
|
||||
mTimeEvents[eventName] = Environment.TickCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void UserSet(Dictionary<string, object> properties)
|
||||
{
|
||||
UserSet(properties, DateTime.MinValue);
|
||||
}
|
||||
public void UserSet(Dictionary<string, object> properties,DateTime dateTime)
|
||||
{
|
||||
ThinkingSDKTimeInter time = GetTime(dateTime);
|
||||
ThinkingSDKUserData data = new ThinkingSDKUserData(time, ThinkingSDKConstant.USER_SET, properties);
|
||||
SendData(data);
|
||||
}
|
||||
public void UserUnset(string propertyKey)
|
||||
{
|
||||
UserUnset(propertyKey, DateTime.MinValue);
|
||||
}
|
||||
public void UserUnset(string propertyKey, DateTime dateTime)
|
||||
{
|
||||
ThinkingSDKTimeInter time = GetTime(dateTime);
|
||||
Dictionary<string, object> properties = new Dictionary<string, object>();
|
||||
properties[propertyKey] = 0;
|
||||
ThinkingSDKUserData data = new ThinkingSDKUserData(time, ThinkingSDKConstant.USER_UNSET, properties);
|
||||
SendData(data);
|
||||
}
|
||||
public void UserUnset(List<string> propertyKeys)
|
||||
{
|
||||
UserUnset(propertyKeys,DateTime.MinValue);
|
||||
}
|
||||
public void UserUnset(List<string> propertyKeys, DateTime dateTime)
|
||||
{
|
||||
ThinkingSDKTimeInter time = GetTime(dateTime);
|
||||
Dictionary<string, object> properties = new Dictionary<string, object>();
|
||||
foreach (string key in propertyKeys)
|
||||
{
|
||||
properties[key] = 0;
|
||||
}
|
||||
ThinkingSDKUserData data = new ThinkingSDKUserData(time, ThinkingSDKConstant.USER_UNSET, properties);
|
||||
SendData(data);
|
||||
}
|
||||
public void UserSetOnce(Dictionary<string, object> properties)
|
||||
{
|
||||
UserSetOnce(properties, DateTime.MinValue);
|
||||
}
|
||||
public void UserSetOnce(Dictionary<string, object> properties, DateTime dateTime)
|
||||
{
|
||||
ThinkingSDKTimeInter time = GetTime(dateTime);
|
||||
ThinkingSDKUserData data = new ThinkingSDKUserData(time, ThinkingSDKConstant.USER_SETONCE, properties);
|
||||
SendData(data);
|
||||
}
|
||||
public void UserAdd(Dictionary<string, object> properties)
|
||||
{
|
||||
UserAdd(properties, DateTime.MinValue);
|
||||
}
|
||||
public void UserAdd(Dictionary<string, object> properties, DateTime dateTime)
|
||||
{
|
||||
ThinkingSDKTimeInter time = GetTime(dateTime);
|
||||
ThinkingSDKUserData data = new ThinkingSDKUserData(time, ThinkingSDKConstant.USER_ADD, properties);
|
||||
SendData(data);
|
||||
}
|
||||
public void UserAppend(Dictionary<string, object> properties)
|
||||
{
|
||||
UserAppend(properties, DateTime.MinValue);
|
||||
}
|
||||
public void UserAppend(Dictionary<string, object> properties, DateTime dateTime)
|
||||
{
|
||||
ThinkingSDKTimeInter time = GetTime(dateTime);
|
||||
ThinkingSDKUserData data = new ThinkingSDKUserData(time, ThinkingSDKConstant.USER_APPEND, properties);
|
||||
SendData(data);
|
||||
}
|
||||
public void UserUniqAppend(Dictionary<string, object> properties)
|
||||
{
|
||||
UserUniqAppend(properties, DateTime.MinValue);
|
||||
}
|
||||
public void UserUniqAppend(Dictionary<string, object> properties, DateTime dateTime)
|
||||
{
|
||||
ThinkingSDKTimeInter time = GetTime(dateTime);
|
||||
ThinkingSDKUserData data = new ThinkingSDKUserData(time, ThinkingSDKConstant.USER_UNIQ_APPEND, properties);
|
||||
SendData(data);
|
||||
}
|
||||
public void UserDelete()
|
||||
{
|
||||
UserDelete(DateTime.MinValue);
|
||||
}
|
||||
public void UserDelete(DateTime dateTime)
|
||||
{
|
||||
ThinkingSDKTimeInter time = GetTime(dateTime);
|
||||
Dictionary<string, object> properties = new Dictionary<string, object>();
|
||||
ThinkingSDKUserData data = new ThinkingSDKUserData(time, ThinkingSDKConstant.USER_DEL,properties);
|
||||
SendData(data);
|
||||
}
|
||||
public void SetDynamicSuperProperties(TDDynamicSuperPropertiesHandler_PC dynamicSuperProperties)
|
||||
{
|
||||
if (IsPaused())
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.mDynamicProperties = dynamicSuperProperties;
|
||||
}
|
||||
protected bool IsPaused()
|
||||
{
|
||||
bool mIsPaused = !mEnableTracking || !mOptTracking;
|
||||
if (mIsPaused)
|
||||
{
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("SDK Track status is Pause or Stop");
|
||||
}
|
||||
return mIsPaused;
|
||||
}
|
||||
|
||||
public void SetTrackStatus(TDTrackStatus status)
|
||||
{
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Change Status to " + status);
|
||||
switch (status)
|
||||
{
|
||||
case TDTrackStatus.Pause:
|
||||
mEventSaveOnly = false;
|
||||
OptTracking(true);
|
||||
EnableTracking(false);
|
||||
break;
|
||||
case TDTrackStatus.Stop:
|
||||
mEventSaveOnly = false;
|
||||
EnableTracking(true);
|
||||
OptTracking(false);
|
||||
break;
|
||||
case TDTrackStatus.SaveOnly:
|
||||
mEventSaveOnly = true;
|
||||
EnableTracking(true);
|
||||
OptTracking(true);
|
||||
break;
|
||||
case TDTrackStatus.Normal:
|
||||
default:
|
||||
mEventSaveOnly = false;
|
||||
OptTracking(true);
|
||||
EnableTracking(true);
|
||||
Flush();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void OptTracking(bool optTracking)
|
||||
{
|
||||
mOptTracking = optTracking;
|
||||
int opt = optTracking ? 1 : 0;
|
||||
ThinkingSDKFile.SaveData(mAppid, ThinkingSDKConstant.OPT_TRACK, opt);
|
||||
if (!optTracking)
|
||||
{
|
||||
ThinkingSDKFile.DeleteData(mAppid, ThinkingSDKConstant.ACCOUNT_ID);
|
||||
ThinkingSDKFile.DeleteData(mAppid, ThinkingSDKConstant.DISTINCT_ID);
|
||||
ThinkingSDKFile.DeleteData(mAppid, ThinkingSDKConstant.SUPER_PROPERTY);
|
||||
this.mAccountID = null;
|
||||
this.mDistinctID = null;
|
||||
this.mSupperProperties = new Dictionary<string, object>();
|
||||
ThinkingSDKFileJson.DeleteAllTrackingData(mAppid);
|
||||
}
|
||||
}
|
||||
public void EnableTracking(bool isEnable)
|
||||
{
|
||||
mEnableTracking = isEnable;
|
||||
int enable = isEnable ? 1 : 0;
|
||||
ThinkingSDKFile.SaveData(mAppid, ThinkingSDKConstant.ENABLE_TRACK,enable);
|
||||
}
|
||||
private void DefaultTrackState()
|
||||
{
|
||||
object enableTrack = ThinkingSDKFile.GetData(mAppid, ThinkingSDKConstant.ENABLE_TRACK, typeof(int));
|
||||
object optTrack = ThinkingSDKFile.GetData(mAppid, ThinkingSDKConstant.OPT_TRACK, typeof(int));
|
||||
if (enableTrack != null)
|
||||
{
|
||||
this.mEnableTracking = ((int)enableTrack) == 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.mEnableTracking = true;
|
||||
}
|
||||
if (optTrack != null)
|
||||
{
|
||||
this.mOptTracking = ((int)optTrack) == 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.mOptTracking = true;
|
||||
}
|
||||
}
|
||||
public void OptTrackingAndDeleteUser()
|
||||
{
|
||||
UserDelete();
|
||||
OptTracking(false);
|
||||
}
|
||||
public string TimeString(DateTime dateTime)
|
||||
{
|
||||
return ThinkingSDKUtil.FormatDate(dateTime, mConfig.TimeZone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8287bb3311be54f52be240639203175f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: db5e3ec02eff54121adead1f781264b7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,155 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Security;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Collections.Generic;
|
||||
using ThinkingSDK.PC.Constant;
|
||||
using ThinkingSDK.PC.Utils;
|
||||
using System.IO;
|
||||
using UnityEngine.Networking;
|
||||
using System.Collections;
|
||||
using ThinkingSDK.PC.Config;
|
||||
|
||||
namespace ThinkingSDK.PC.Request
|
||||
{
|
||||
/*
|
||||
* Enumerate the form of data reported by post, and the enumeration value represents json and form forms
|
||||
*/
|
||||
enum POST_TYPE { JSON, FORM };
|
||||
public abstract class ThinkingSDKBaseRequest
|
||||
{
|
||||
private string mAppid;
|
||||
private string mURL;
|
||||
private string mData;
|
||||
public ThinkingSDKBaseRequest(string appId, string url, string data)
|
||||
{
|
||||
mAppid = appId;
|
||||
mURL = url;
|
||||
mData = data;
|
||||
}
|
||||
public ThinkingSDKBaseRequest(string appId, string url)
|
||||
{
|
||||
mAppid = appId;
|
||||
mURL = url;
|
||||
}
|
||||
public void SetData(string data)
|
||||
{
|
||||
this.mData = data;
|
||||
}
|
||||
public string APPID() {
|
||||
return mAppid;
|
||||
}
|
||||
public string URL()
|
||||
{
|
||||
return mURL;
|
||||
}
|
||||
public string Data()
|
||||
{
|
||||
return mData;
|
||||
}
|
||||
/**
|
||||
* initialization interface
|
||||
*/
|
||||
public static void GetConfig(string url,ResponseHandle responseHandle)
|
||||
{
|
||||
if (!ThinkingSDKUtil.IsValiadURL(url))
|
||||
{
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Invalid Url:\n" + url);
|
||||
}
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||
request.Method = "GET";
|
||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||
var responseResult = new StreamReader(response.GetResponseStream()).ReadToEnd();
|
||||
if (responseResult != null)
|
||||
{
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Request URL:\n"+url);
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Response:\n"+responseResult);
|
||||
}
|
||||
}
|
||||
|
||||
public bool MyRemoteCertificateValidationCallback(System.Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
|
||||
{
|
||||
bool isOk = true;
|
||||
// If there are errors in the certificate chain,
|
||||
// look at each error to determine the cause.
|
||||
if (sslPolicyErrors != SslPolicyErrors.None) {
|
||||
for (int i=0; i<chain.ChainStatus.Length; i++) {
|
||||
if (chain.ChainStatus[i].Status == X509ChainStatusFlags.RevocationStatusUnknown) {
|
||||
continue;
|
||||
}
|
||||
chain.ChainPolicy.RevocationFlag = X509RevocationFlag.EntireChain;
|
||||
chain.ChainPolicy.RevocationMode = X509RevocationMode.Online;
|
||||
chain.ChainPolicy.UrlRetrievalTimeout = new TimeSpan (0, 1, 0);
|
||||
chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllFlags;
|
||||
bool chainIsValid = chain.Build ((X509Certificate2)certificate);
|
||||
if (!chainIsValid) {
|
||||
isOk = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
|
||||
abstract public IEnumerator SendData_2(ResponseHandle responseHandle, string data, int eventCount);
|
||||
|
||||
public static IEnumerator GetWithFORM_2(string url, string appId, Dictionary<string, object> param, ResponseHandle responseHandle)
|
||||
{
|
||||
string uri = url + "?appid=" + appId;
|
||||
if (param != null)
|
||||
{
|
||||
uri = uri + "&data=" + ThinkingSDKJSON.Serialize(param);
|
||||
}
|
||||
|
||||
using (UnityWebRequest webRequest = UnityWebRequest.Get(uri))
|
||||
{
|
||||
webRequest.timeout = 30;
|
||||
webRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
|
||||
//if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Request URL: \n" + uri);
|
||||
|
||||
// Request and wait for the desired page.
|
||||
yield return webRequest.SendWebRequest();
|
||||
|
||||
Dictionary<string,object> resultDict = null;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
switch (webRequest.result)
|
||||
{
|
||||
case UnityWebRequest.Result.ConnectionError:
|
||||
case UnityWebRequest.Result.DataProcessingError:
|
||||
case UnityWebRequest.Result.ProtocolError:
|
||||
//if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Error response: \n" + webRequest.error);
|
||||
break;
|
||||
case UnityWebRequest.Result.Success:
|
||||
string resultText = webRequest.downloadHandler.text;
|
||||
//if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Response: \n" + resultText);
|
||||
if (!string.IsNullOrEmpty(resultText))
|
||||
{
|
||||
resultDict = ThinkingSDKJSON.Deserialize(resultText);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#else
|
||||
if (webRequest.isHttpError || webRequest.isNetworkError)
|
||||
{
|
||||
//if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Error response: \n" + webRequest.error);
|
||||
}
|
||||
else
|
||||
{
|
||||
string resultText = webRequest.downloadHandler.text;
|
||||
//if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Response: \n" + resultText);
|
||||
if (!string.IsNullOrEmpty(resultText))
|
||||
{
|
||||
resultDict = ThinkingSDKJSON.Deserialize(resultText);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (responseHandle != null)
|
||||
{
|
||||
responseHandle(resultDict);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3b31966af44764a508681ee9d6e24f7a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,95 @@
|
|||
using System.Collections.Generic;
|
||||
using ThinkingSDK.PC.Config;
|
||||
using ThinkingSDK.PC.Constant;
|
||||
using ThinkingSDK.PC.Utils;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using System.Collections;
|
||||
|
||||
namespace ThinkingSDK.PC.Request
|
||||
{
|
||||
public class ThinkingSDKDebugRequest:ThinkingSDKBaseRequest
|
||||
{
|
||||
private int mDryRun = 0;
|
||||
private string mDeviceID = ThinkingSDKDeviceInfo.DeviceID();
|
||||
public void SetDryRun(int dryRun)
|
||||
{
|
||||
mDryRun = dryRun;
|
||||
}
|
||||
public ThinkingSDKDebugRequest(string appId, string url, string data):base(appId,url,data)
|
||||
{
|
||||
|
||||
}
|
||||
public ThinkingSDKDebugRequest(string appId, string url) : base(appId, url)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEnumerator SendData_2(ResponseHandle responseHandle, string data, int eventCount)
|
||||
{
|
||||
this.SetData(data);
|
||||
string uri = this.URL();
|
||||
//string content = ThinkingSDKJSON.Serialize(this.Data()[0]);
|
||||
string content = data.Substring(1,data.Length-2);
|
||||
|
||||
WWWForm form = new WWWForm();
|
||||
form.AddField("appid", this.APPID());
|
||||
form.AddField("source", "client");
|
||||
form.AddField("dryRun", mDryRun);
|
||||
form.AddField("deviceId", mDeviceID);
|
||||
form.AddField("data", content);
|
||||
|
||||
using (UnityWebRequest webRequest = UnityWebRequest.Post(uri, form))
|
||||
{
|
||||
webRequest.timeout = 30;
|
||||
webRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Send event Request:\n " + content + "\n URL = " + uri);
|
||||
|
||||
// Request and wait for the desired page.
|
||||
yield return webRequest.SendWebRequest();
|
||||
|
||||
Dictionary<string,object> resultDict = null;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
switch (webRequest.result)
|
||||
{
|
||||
case UnityWebRequest.Result.ConnectionError:
|
||||
case UnityWebRequest.Result.DataProcessingError:
|
||||
case UnityWebRequest.Result.ProtocolError:
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Send event Response Error:\n " + webRequest.error);
|
||||
break;
|
||||
case UnityWebRequest.Result.Success:
|
||||
string resultText = webRequest.downloadHandler.text;
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Send event Response:\n " + resultText);
|
||||
if (!string.IsNullOrEmpty(resultText))
|
||||
{
|
||||
resultDict = ThinkingSDKJSON.Deserialize(resultText);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#else
|
||||
if (webRequest.isHttpError || webRequest.isNetworkError)
|
||||
{
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Send event Response Error:\n " + webRequest.error);
|
||||
}
|
||||
else
|
||||
{
|
||||
string resultText = webRequest.downloadHandler.text;
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Send event Response:\n " + resultText);
|
||||
if (!string.IsNullOrEmpty(resultText))
|
||||
{
|
||||
resultDict = ThinkingSDKJSON.Deserialize(resultText);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (responseHandle != null)
|
||||
{
|
||||
if (resultDict != null)
|
||||
{
|
||||
resultDict.Add("flush_count", eventCount);
|
||||
}
|
||||
responseHandle(resultDict);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7849691904f3c426e81a91572a027863
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,106 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Text;
|
||||
using ThinkingSDK.PC.Constant;
|
||||
using ThinkingSDK.PC.Utils;
|
||||
using UnityEngine.Networking;
|
||||
using System.Collections;
|
||||
using ThinkingSDK.PC.Config;
|
||||
|
||||
namespace ThinkingSDK.PC.Request
|
||||
{
|
||||
public class ThinkingSDKNormalRequest:ThinkingSDKBaseRequest
|
||||
{
|
||||
public ThinkingSDKNormalRequest(string appId, string url, string data) :base(appId, url, data)
|
||||
{
|
||||
}
|
||||
public ThinkingSDKNormalRequest(string appId, string url) : base(appId, url)
|
||||
{
|
||||
}
|
||||
|
||||
public override IEnumerator SendData_2(ResponseHandle responseHandle, string data, int eventCount)
|
||||
{
|
||||
this.SetData(data);
|
||||
string uri = this.URL();
|
||||
var flush_time = ThinkingSDKUtil.GetTimeStamp();
|
||||
|
||||
string content = "{\"#app_id\":\"" + this.APPID() + "\",\"data\":" + data + ",\"#flush_time\":" + flush_time + "}";
|
||||
string encodeContent = Encode(content);
|
||||
byte[] contentCompressed = Encoding.UTF8.GetBytes(encodeContent);
|
||||
|
||||
using (UnityWebRequest webRequest = new UnityWebRequest(uri, "POST"))
|
||||
{
|
||||
webRequest.timeout = 30;
|
||||
webRequest.SetRequestHeader("Content-Type", "text/plain");
|
||||
webRequest.SetRequestHeader("appid", this.APPID());
|
||||
webRequest.SetRequestHeader("TA-Integration-Type", "PC");
|
||||
webRequest.SetRequestHeader("TA-Integration-Version", ThinkingSDKPublicConfig.Version());
|
||||
webRequest.SetRequestHeader("TA-Integration-Count", "1");
|
||||
webRequest.SetRequestHeader("TA-Integration-Extra", "PC");
|
||||
webRequest.uploadHandler = (UploadHandler)new UploadHandlerRaw(contentCompressed);
|
||||
webRequest.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
|
||||
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Send event Request:\n " + content + "\n URL = " + uri);
|
||||
|
||||
// Request and wait for the desired page.
|
||||
yield return webRequest.SendWebRequest();
|
||||
|
||||
Dictionary<string, object> resultDict = null;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
switch (webRequest.result)
|
||||
{
|
||||
case UnityWebRequest.Result.ConnectionError:
|
||||
case UnityWebRequest.Result.DataProcessingError:
|
||||
case UnityWebRequest.Result.ProtocolError:
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Send event Response Error:\n " + webRequest.error);
|
||||
break;
|
||||
case UnityWebRequest.Result.Success:
|
||||
string resultText = webRequest.downloadHandler.text;
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Send event Response:\n " + resultText);
|
||||
if (!string.IsNullOrEmpty(resultText))
|
||||
{
|
||||
resultDict = ThinkingSDKJSON.Deserialize(resultText);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#else
|
||||
if (webRequest.isHttpError || webRequest.isNetworkError)
|
||||
{
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Send event Response Error:\n " + webRequest.error);
|
||||
}
|
||||
else
|
||||
{
|
||||
string resultText = webRequest.downloadHandler.text;
|
||||
if (ThinkingSDKPublicConfig.IsPrintLog()) ThinkingSDKLogger.Print("Send event Response:\n " + resultText);
|
||||
if (!string.IsNullOrEmpty(resultText))
|
||||
{
|
||||
resultDict = ThinkingSDKJSON.Deserialize(resultText);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (responseHandle != null)
|
||||
{
|
||||
if (resultDict != null)
|
||||
{
|
||||
resultDict.Add("flush_count", eventCount);
|
||||
}
|
||||
responseHandle(resultDict);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static string Encode(string inputStr)
|
||||
{
|
||||
byte[] inputBytes = Encoding.UTF8.GetBytes(inputStr);
|
||||
using (var outputStream = new MemoryStream())
|
||||
{
|
||||
using (var gzipStream = new GZipStream(outputStream, CompressionMode.Compress))
|
||||
gzipStream.Write(inputBytes, 0, inputBytes.Length);
|
||||
byte[] output = outputStream.ToArray();
|
||||
return Convert.ToBase64String(output);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 992a71ad5ae554eb98a712f6a65b3a7f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 21f73e209611b40d3a1c87e9418529b2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,80 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ThinkingSDK.PC.Storage
|
||||
{
|
||||
public class ThinkingSDKFile
|
||||
{
|
||||
private static string connectorKey = "_";
|
||||
public static string GetKey(string prefix,string key)
|
||||
{
|
||||
return prefix + connectorKey + key;
|
||||
}
|
||||
public static void SaveData(string prefix, string key, object value)
|
||||
{
|
||||
SaveData(GetKey(prefix, key), value);
|
||||
}
|
||||
public static void SaveData(string key, object value)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(key))
|
||||
{
|
||||
if (value.GetType() == typeof(int))
|
||||
{
|
||||
PlayerPrefs.SetInt(key, (int)value);
|
||||
}
|
||||
else if (value.GetType() == typeof(float))
|
||||
{
|
||||
PlayerPrefs.SetFloat(key, (float)value);
|
||||
}
|
||||
else if (value.GetType() == typeof(string))
|
||||
{
|
||||
PlayerPrefs.SetString(key, (string)value);
|
||||
}
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
}
|
||||
public static object GetData(string key, Type type)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(key) && PlayerPrefs.HasKey(key))
|
||||
{
|
||||
if (type == typeof(int))
|
||||
{
|
||||
return PlayerPrefs.GetInt(key);
|
||||
}
|
||||
else if (type == typeof(float))
|
||||
{
|
||||
return PlayerPrefs.GetFloat(key);
|
||||
}
|
||||
else if (type == typeof(string))
|
||||
{
|
||||
return PlayerPrefs.GetString(key);
|
||||
}
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
public static object GetData(string prefix,string key, Type type)
|
||||
{
|
||||
key = GetKey(prefix, key);
|
||||
return GetData(key, type);
|
||||
}
|
||||
|
||||
public static void DeleteData(string key)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(key))
|
||||
{
|
||||
if (PlayerPrefs.HasKey(key))
|
||||
{
|
||||
PlayerPrefs.DeleteKey(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void DeleteData(string prefix,string key)
|
||||
{
|
||||
key = GetKey(prefix, key);
|
||||
DeleteData(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: be6ada75d19854acca2314015d2c6376
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,188 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using ThinkingSDK.PC.Utils;
|
||||
|
||||
namespace ThinkingSDK.PC.Storage
|
||||
{
|
||||
public class ThinkingSDKFileJson
|
||||
{
|
||||
// Save the event, return the number of cached events
|
||||
internal static int EnqueueTrackingData(Dictionary<string, object> data, string prefix)
|
||||
{
|
||||
int eventId = EventAutoIncrementingID(prefix);
|
||||
string trackingKey = GetEventKeysPrefix(prefix, eventId);
|
||||
|
||||
var dataJson = ThinkingSDKJSON.Serialize(data);
|
||||
PlayerPrefs.SetString(trackingKey, dataJson);
|
||||
IncreaseTrackingDataID(prefix);
|
||||
int eventCount = EventAutoIncrementingID(prefix) - EventIndexID(prefix);
|
||||
return eventCount;
|
||||
}
|
||||
|
||||
// Get event end ID
|
||||
internal static int EventAutoIncrementingID(string prefix)
|
||||
{
|
||||
string mEventAutoIncrementingID = GetEventAutoIncrementingIDKey(prefix);
|
||||
return PlayerPrefs.HasKey(mEventAutoIncrementingID) ? PlayerPrefs.GetInt(mEventAutoIncrementingID) : 0;
|
||||
}
|
||||
|
||||
// Auto increment event end ID
|
||||
private static void IncreaseTrackingDataID(string prefix)
|
||||
{
|
||||
int id = EventAutoIncrementingID(prefix);
|
||||
id += 1;
|
||||
PlayerPrefs.SetInt(GetEventAutoIncrementingIDKey(prefix), id);
|
||||
}
|
||||
|
||||
// Reset event end ID
|
||||
private static void ResetTrackingDataID(string prefix)
|
||||
{
|
||||
int id = 0;
|
||||
PlayerPrefs.SetInt(GetEventAutoIncrementingIDKey(prefix), id);
|
||||
}
|
||||
|
||||
// Get event start ID
|
||||
internal static int EventIndexID(string prefix)
|
||||
{
|
||||
string eventIndexID = GetEventIndexIDKey(prefix);
|
||||
return PlayerPrefs.HasKey(eventIndexID) ? PlayerPrefs.GetInt(eventIndexID) : 0;
|
||||
}
|
||||
|
||||
// Save time start ID
|
||||
private static void SaveEventIndexID(int indexID, string prefix)
|
||||
{
|
||||
string eventIndexID = GetEventIndexIDKey(prefix);
|
||||
PlayerPrefs.SetInt(eventIndexID, indexID);
|
||||
}
|
||||
|
||||
// Fetch a specified number of events in batches
|
||||
internal static string DequeueBatchTrackingData(int batchSize, string prefix, out int eventCount)
|
||||
{
|
||||
string batchData = eventBatchPrefix;
|
||||
List<Dictionary<string, object>> tempDataList = new List<Dictionary<string, object>>();
|
||||
int dataIndex = EventIndexID(prefix);
|
||||
int maxIndex = EventAutoIncrementingID(prefix) - 1;
|
||||
eventCount = 0;
|
||||
while (eventCount < batchSize && dataIndex <= maxIndex) {
|
||||
string trackingKey = GetEventKeysPrefix(prefix, dataIndex);
|
||||
if (PlayerPrefs.HasKey(trackingKey)) {
|
||||
string dataJson = PlayerPrefs.GetString(trackingKey);
|
||||
if (eventCount < batchSize - 1 && dataIndex < maxIndex)
|
||||
{
|
||||
batchData = batchData + dataJson + eventBatchInfix;
|
||||
}
|
||||
else
|
||||
{
|
||||
batchData = batchData + dataJson;
|
||||
}
|
||||
eventCount++;
|
||||
}
|
||||
dataIndex++;
|
||||
}
|
||||
|
||||
if (eventCount > 0)
|
||||
{
|
||||
batchData = batchData + eventBatchSuffix;
|
||||
return batchData;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Batch delete the specified number of events and return the remaining number of events
|
||||
internal static int DeleteBatchTrackingData(int batchSize, string prefix)
|
||||
{
|
||||
int deletedCount = 0;
|
||||
int dataIndex = EventIndexID(prefix);
|
||||
int maxIndex = EventAutoIncrementingID(prefix) - 1;
|
||||
while (deletedCount < batchSize && dataIndex <= maxIndex) {
|
||||
string trackingKey = GetEventKeysPrefix(prefix, dataIndex);
|
||||
if (PlayerPrefs.HasKey(trackingKey)) {
|
||||
PlayerPrefs.DeleteKey(trackingKey);
|
||||
deletedCount++;
|
||||
}
|
||||
dataIndex++;
|
||||
}
|
||||
SaveEventIndexID(dataIndex, prefix);
|
||||
|
||||
int eventCount = EventAutoIncrementingID(prefix) - EventIndexID(prefix);
|
||||
return eventCount;
|
||||
}
|
||||
|
||||
// Batch delete specified events
|
||||
// internal static void DeleteBatchTrackingData(List<Dictionary<string, object>> batch, string prefix) {
|
||||
// foreach(Dictionary<string, object> data in batch) {
|
||||
// String id = data["id"].ToString();
|
||||
// if (id != null && PlayerPrefs.HasKey(id)) {
|
||||
// PlayerPrefs.DeleteKey(id);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// Batch delete all events
|
||||
internal static int DeleteAllTrackingData(string prefix)
|
||||
{
|
||||
DeleteBatchTrackingData(int.MaxValue, prefix);
|
||||
SaveEventIndexID(0, prefix);
|
||||
ResetTrackingDataID(prefix);
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static string eventKeyInfix = "Event";
|
||||
private static string eventIndexIDSuffix = "EventIndexID";
|
||||
private static string eventAutoIncrementingIDSuffix = "EventAutoIncrementingID";
|
||||
|
||||
private static string eventBatchPrefix = "[";
|
||||
private static string eventBatchInfix = ",";
|
||||
private static string eventBatchSuffix = "]";
|
||||
|
||||
private static Dictionary<string, string> eventKeysPrefix = new Dictionary<string, string>() { };
|
||||
private static Dictionary<string, string> eventIndexIDKeys = new Dictionary<string, string>() { };
|
||||
private static Dictionary<string, string> eventAutoIncrementingIDKeys = new Dictionary<string, string>() { };
|
||||
|
||||
private static string GetEventKeysPrefix(string prefix, int index)
|
||||
{
|
||||
if (eventKeysPrefix.ContainsKey(prefix))
|
||||
{
|
||||
return eventKeysPrefix[prefix] + index;
|
||||
}
|
||||
else
|
||||
{
|
||||
string eventKey = prefix + eventKeyInfix;
|
||||
eventKeysPrefix[prefix] = eventKey;
|
||||
return eventKey + index;
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetEventIndexIDKey(string prefix)
|
||||
{
|
||||
if (eventIndexIDKeys.ContainsKey(prefix))
|
||||
{
|
||||
return eventIndexIDKeys[prefix];
|
||||
}
|
||||
else
|
||||
{
|
||||
string eventKey = prefix + eventIndexIDSuffix;
|
||||
eventIndexIDKeys[prefix] = eventKey;
|
||||
return eventKey;
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetEventAutoIncrementingIDKey(string prefix)
|
||||
{
|
||||
if (eventAutoIncrementingIDKeys.ContainsKey(prefix))
|
||||
{
|
||||
return eventAutoIncrementingIDKeys[prefix];
|
||||
}
|
||||
else
|
||||
{
|
||||
string eventKey = prefix + eventAutoIncrementingIDSuffix;
|
||||
eventAutoIncrementingIDKeys[prefix] = eventKey;
|
||||
return eventKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d4bedacbe272d46bda26db9388665562
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 372921461f6fe4648827f1a91a1759e1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,130 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using ThinkingSDK.PC.Request;
|
||||
using ThinkingSDK.PC.Constant;
|
||||
using ThinkingSDK.PC.Storage;
|
||||
using ThinkingSDK.PC.Main;
|
||||
|
||||
namespace ThinkingSDK.PC.TaskManager
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public class ThinkingSDKTask : MonoBehaviour
|
||||
{
|
||||
private readonly static object _locker = new object();
|
||||
|
||||
private List<ThinkingSDKBaseRequest> requestList = new List<ThinkingSDKBaseRequest>();
|
||||
private List<ResponseHandle> responseHandleList = new List<ResponseHandle>();
|
||||
private List<int> batchSizeList = new List<int>();
|
||||
private List<string> appIdList = new List<string>();
|
||||
|
||||
|
||||
private static ThinkingSDKTask mSingleTask;
|
||||
|
||||
private bool isWaiting = false;
|
||||
private float updateInterval = 0;
|
||||
|
||||
public static ThinkingSDKTask SingleTask()
|
||||
{
|
||||
return mSingleTask;
|
||||
}
|
||||
|
||||
private void Awake() {
|
||||
mSingleTask = this;
|
||||
}
|
||||
|
||||
private void Start() {
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
updateInterval += UnityEngine.Time.deltaTime;
|
||||
if (updateInterval > 0.2)
|
||||
{
|
||||
updateInterval = 0;
|
||||
if (!isWaiting && requestList.Count > 0)
|
||||
{
|
||||
WaitOne();
|
||||
StartRequestSendData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//private void OnDestroy()
|
||||
//{
|
||||
// ThinkingPCSDK.OnDestory();
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// hold signal
|
||||
/// </summary>
|
||||
public void WaitOne()
|
||||
{
|
||||
isWaiting = true;
|
||||
}
|
||||
/// <summary>
|
||||
/// release signal
|
||||
/// </summary>
|
||||
public void Release()
|
||||
{
|
||||
isWaiting = false;
|
||||
}
|
||||
public void SyncInvokeAllTask()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void StartRequest(ThinkingSDKBaseRequest mRequest, ResponseHandle responseHandle, int batchSize, string appId)
|
||||
{
|
||||
lock(_locker)
|
||||
{
|
||||
requestList.Add(mRequest);
|
||||
responseHandleList.Add(responseHandle);
|
||||
batchSizeList.Add(batchSize);
|
||||
appIdList.Add(appId);
|
||||
}
|
||||
}
|
||||
|
||||
private void StartRequestSendData()
|
||||
{
|
||||
if (requestList.Count > 0)
|
||||
{
|
||||
ThinkingSDKBaseRequest mRequest;
|
||||
ResponseHandle responseHandle;
|
||||
string list;
|
||||
int eventCount = 0;
|
||||
lock (_locker)
|
||||
{
|
||||
mRequest = requestList[0];
|
||||
responseHandle = responseHandleList[0];
|
||||
list = ThinkingSDKFileJson.DequeueBatchTrackingData(batchSizeList[0], appIdList[0], out eventCount);
|
||||
}
|
||||
if (mRequest != null)
|
||||
{
|
||||
if (eventCount > 0 && list.Length > 0)
|
||||
{
|
||||
this.StartCoroutine(this.SendData(mRequest, responseHandle, list, eventCount));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (responseHandle != null)
|
||||
{
|
||||
responseHandle(null);
|
||||
}
|
||||
}
|
||||
lock(_locker)
|
||||
{
|
||||
requestList.RemoveAt(0);
|
||||
responseHandleList.RemoveAt(0);
|
||||
batchSizeList.RemoveAt(0);
|
||||
appIdList.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
private IEnumerator SendData(ThinkingSDKBaseRequest mRequest, ResponseHandle responseHandle, string list, int eventCount) {
|
||||
yield return mRequest.SendData_2(responseHandle, list, eventCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: eb96ead89c0c544608be4e0ad781de78
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"name": "ThinkingSDK"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0a958a7eb80a248e1b8bc4553787c209
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c859b53e53b824a2aa36430c980862cf
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,44 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace ThinkingSDK.PC.Time
|
||||
{
|
||||
public class TDTimeout : MonoBehaviour
|
||||
{
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void SetTimeout(int timeout, Action<object> action, object obj)
|
||||
{
|
||||
GameObject gameObject = new GameObject("TDTimeout");
|
||||
var tdTimeout = gameObject.AddComponent<TDTimeout>();
|
||||
tdTimeout._setTimeout(timeout, action, obj);
|
||||
}
|
||||
|
||||
private void _setTimeout(int timeout, Action<object> action, object obj)
|
||||
{
|
||||
StartCoroutine(_wait(timeout, action, obj));
|
||||
}
|
||||
|
||||
private IEnumerator _wait(int timeout, Action<object> action, object obj)
|
||||
{
|
||||
yield return new WaitForSeconds(timeout);
|
||||
if (action != null)
|
||||
{
|
||||
action(obj);
|
||||
}
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4c4b6a31edd864c43a12c23d11ac6ddd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using ThinkingSDK.PC.Utils;
|
||||
|
||||
namespace ThinkingSDK.PC.Time
|
||||
{
|
||||
public class ThinkingSDKCalibratedTime : ThinkingSDKTimeInter
|
||||
{
|
||||
private ThinkingSDKTimeCalibration mCalibratedTime;
|
||||
private long mSystemElapsedRealtime;
|
||||
private TimeZoneInfo mTimeZone;
|
||||
private DateTime mDate;
|
||||
public ThinkingSDKCalibratedTime(ThinkingSDKTimeCalibration calibrateTimeInter,TimeZoneInfo timeZoneInfo)
|
||||
{
|
||||
this.mCalibratedTime = calibrateTimeInter;
|
||||
this.mTimeZone = timeZoneInfo;
|
||||
this.mDate = mCalibratedTime.NowDate();
|
||||
}
|
||||
public string GetTime(TimeZoneInfo timeZone)
|
||||
{
|
||||
if (timeZone == null)
|
||||
{
|
||||
return ThinkingSDKUtil.FormatDate(mDate, mTimeZone);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ThinkingSDKUtil.FormatDate(mDate, timeZone);
|
||||
}
|
||||
}
|
||||
|
||||
public double GetZoneOffset(TimeZoneInfo timeZone)
|
||||
{
|
||||
if (timeZone == null)
|
||||
{
|
||||
return ThinkingSDKUtil.ZoneOffset(mDate, mTimeZone);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ThinkingSDKUtil.ZoneOffset(mDate, timeZone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 46014ab35934a4a90b8329f357801cdf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
|
||||
namespace ThinkingSDK.PC.Time
|
||||
{
|
||||
public class ThinkingSDKDefinedTime : ThinkingSDKTimeInter
|
||||
{
|
||||
private string mTime;
|
||||
private double mZoneOffset;
|
||||
public ThinkingSDKDefinedTime(string time,double zoneOffset)
|
||||
{
|
||||
this.mTime = time;
|
||||
this.mZoneOffset = zoneOffset;
|
||||
}
|
||||
public string GetTime(TimeZoneInfo timeZone)
|
||||
{
|
||||
return this.mTime;
|
||||
}
|
||||
|
||||
public double GetZoneOffset(TimeZoneInfo timeZone)
|
||||
{
|
||||
return this.mZoneOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 86eabc3f1cff146f89092cd516702db9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,131 @@
|
|||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Linq;
|
||||
|
||||
namespace ThinkingSDK.PC.Time
|
||||
{
|
||||
public class ThinkingSDKNTPCalibration : ThinkingSDKTimeCalibration
|
||||
{
|
||||
public ThinkingSDKNTPCalibration(string ntpServer) {
|
||||
double totalMilliseconds = ConvertDateTimeInt(DateTime.UtcNow);
|
||||
this.mStartTime = (long)totalMilliseconds;
|
||||
this.mSystemElapsedRealtime = Environment.TickCount;
|
||||
|
||||
// request scoket time
|
||||
Socket socket = GetNetworkTimeSync(ntpServer, this);
|
||||
// set scoket timeout
|
||||
TDTimeout.SetTimeout(3, new Action<object>(ScoketTimeout), (object)socket);
|
||||
}
|
||||
|
||||
private void ScoketTimeout(object obj)
|
||||
{
|
||||
if (obj is Socket)
|
||||
{
|
||||
Socket socket = (Socket)obj;
|
||||
if (socket.Connected == true)
|
||||
{
|
||||
socket.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static new double ConvertDateTimeInt(System.DateTime time)
|
||||
{
|
||||
DateTime startTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
return (double)(time - startTime).TotalMilliseconds;
|
||||
}
|
||||
|
||||
private static Socket GetNetworkTimeSync(string ntpServer, ThinkingSDKTimeCalibration timeCalibration)
|
||||
{
|
||||
// NTP message size - 16 bytes of the digest (RFC 2030)
|
||||
var ntpData = new byte[48];
|
||||
|
||||
//Setting the Leap Indicator, Version Number and Mode values
|
||||
ntpData[0] = 0x1B; //LI = 0 (no warning), VN = 3 (IPv4 only), Mode = 3 (Client Mode)
|
||||
|
||||
var addresses = Dns.GetHostEntry(ntpServer).AddressList;
|
||||
var addressFirst = addresses.First(e => e.AddressFamily == AddressFamily.InterNetwork);
|
||||
if (addressFirst == null)
|
||||
{
|
||||
addressFirst = addresses[0];
|
||||
}
|
||||
|
||||
//The UDP port number assigned to NTP is 123
|
||||
var ipEndPoint = new IPEndPoint(addressFirst, 123);
|
||||
//NTP uses UDP
|
||||
var socket = new Socket(ipEndPoint.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
|
||||
|
||||
socket.Connect(ipEndPoint);
|
||||
|
||||
SocketAsyncEventArgs socketAsyncEventArgs = new SocketAsyncEventArgs();
|
||||
socketAsyncEventArgs.SetBuffer(ntpData, 0, ntpData.Length);
|
||||
socketAsyncEventArgs.UserToken = timeCalibration;
|
||||
socketAsyncEventArgs.RemoteEndPoint = ipEndPoint;
|
||||
socketAsyncEventArgs.Completed += SocketAsyncEventArgs_Completed;
|
||||
// send socket request
|
||||
socket.SendAsync(socketAsyncEventArgs);
|
||||
|
||||
return socket;
|
||||
}
|
||||
|
||||
private static void SocketAsyncEventArgs_Completed(object sender, SocketAsyncEventArgs eventArgs)
|
||||
{
|
||||
Socket socket = (Socket)sender;
|
||||
if (eventArgs.SocketError == SocketError.Success)
|
||||
{
|
||||
if (eventArgs.LastOperation == SocketAsyncOperation.Send)
|
||||
{
|
||||
socket.ReceiveAsync(eventArgs);
|
||||
}
|
||||
else if (eventArgs.LastOperation == SocketAsyncOperation.Receive)
|
||||
{
|
||||
if (eventArgs.SocketError == SocketError.Success && eventArgs.Buffer.Length > 0)
|
||||
{
|
||||
DateTime ntpTime = ParseDateTimeWithNTPData(eventArgs.Buffer);
|
||||
double totalMilliseconds = ConvertDateTimeInt(ntpTime);
|
||||
ThinkingSDKTimeCalibration timeCalibration = (ThinkingSDKTimeCalibration)eventArgs.UserToken;
|
||||
timeCalibration.mStartTime = (long)totalMilliseconds;
|
||||
}
|
||||
socket.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
socket.Close();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
socket.Close();
|
||||
}
|
||||
}
|
||||
|
||||
static uint SwapEndianness(ulong x)
|
||||
{
|
||||
return (uint)(((x & 0x000000ff) << 24) + ((x & 0x0000ff00) << 8) + ((x & 0x00ff0000) >> 8) + ((x & 0xff000000) >> 24));
|
||||
}
|
||||
|
||||
private static DateTime ParseDateTimeWithNTPData(byte[] ntpData)
|
||||
{
|
||||
//Offset to get to the "Transmit Timestamp" field (time at which the reply
|
||||
//departed the server for the client, in 64-bit timestamp format."
|
||||
const byte serverReplyTime = 40;
|
||||
|
||||
//Get the seconds part
|
||||
ulong intPart = BitConverter.ToUInt32(ntpData, serverReplyTime);
|
||||
|
||||
//Get the seconds fraction
|
||||
ulong fractPart = BitConverter.ToUInt32(ntpData, serverReplyTime + 4);
|
||||
|
||||
//Convert From big-endian to little-endian
|
||||
intPart = SwapEndianness(intPart);
|
||||
fractPart = SwapEndianness(fractPart);
|
||||
|
||||
var milliseconds = (intPart * 1000) + ((fractPart * 1000) / 0x100000000L);
|
||||
|
||||
//**UTC** time
|
||||
var networkDateTime = (new DateTime(1900, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddMilliseconds((long)milliseconds);
|
||||
return networkDateTime;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 610a0d13d17714116b2d436c4daf69a9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using ThinkingSDK.PC.Utils;
|
||||
|
||||
namespace ThinkingSDK.PC.Time
|
||||
{
|
||||
public class ThinkingSDKTime : ThinkingSDKTimeInter
|
||||
{
|
||||
private TimeZoneInfo mTimeZone;
|
||||
private DateTime mDate;
|
||||
|
||||
public ThinkingSDKTime(TimeZoneInfo timezone, DateTime date)
|
||||
{
|
||||
this.mTimeZone = timezone;
|
||||
this.mDate = date;
|
||||
}
|
||||
|
||||
public string GetTime(TimeZoneInfo timeZone)
|
||||
{
|
||||
if (timeZone == null)
|
||||
{
|
||||
return ThinkingSDKUtil.FormatDate(mDate, mTimeZone);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ThinkingSDKUtil.FormatDate(mDate, timeZone);
|
||||
}
|
||||
}
|
||||
|
||||
public double GetZoneOffset(TimeZoneInfo timeZone)
|
||||
{
|
||||
if (timeZone == null)
|
||||
{
|
||||
return ThinkingSDKUtil.ZoneOffset(mDate, mTimeZone);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ThinkingSDKUtil.ZoneOffset(mDate, timeZone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 482ba0db5b92b4f9e9475acfda6e496c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
|
||||
namespace ThinkingSDK.PC.Time
|
||||
{
|
||||
public class ThinkingSDKTimeCalibration
|
||||
{
|
||||
/// <summary>
|
||||
/// Timestamp when time was calibrated
|
||||
/// </summary>
|
||||
public long mStartTime;
|
||||
/// <summary>
|
||||
/// System boot time when calibrating time
|
||||
/// </summary>
|
||||
public long mSystemElapsedRealtime;
|
||||
public DateTime NowDate()
|
||||
{
|
||||
long nowTime = Environment.TickCount;
|
||||
long timestamp = nowTime - this.mSystemElapsedRealtime + this.mStartTime;
|
||||
// DateTime dt = DateTimeOffset.FromUnixTimeMilliseconds(timestamp).LocalDateTime;
|
||||
// return dt;
|
||||
|
||||
DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
return dt.AddMilliseconds(timestamp);
|
||||
}
|
||||
|
||||
protected static double ConvertDateTimeInt(System.DateTime time)
|
||||
{
|
||||
DateTime startTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
return (double)(time - startTime).TotalMilliseconds;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b9bb8b764cd4d47bd91702ea2c9a5ad5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue