internal EventTrigger(DDNABase ddna, int index, JSONObject json, ExecutionCountManager executionCountManager) { this.ddna = ddna; this.index = index; this.executionCountManager = executionCountManager; eventName = json.ContainsKey("eventName") ? json["eventName"] as string : ""; response = json.ContainsKey("response") ? json["response"] as JSONObject : new JSONObject(); priority = json.GetOrDefault("priority", 0L); limit = json.GetOrDefault("limit", -1L); condition = (json.ContainsKey("condition") ? json["condition"] as List <object> : new List <object>(0)) .Select(e => e as JSONObject) .ToArray(); campaignId = json.GetOrDefault("campaignID", -1L); variantId = json.GetOrDefault("variantID", -1L); var eventParams = response.GetOrDefault("eventParams", new JSONObject()); campaignName = eventParams.GetOrDefault <string, string>("responseEngagementName", null); variantName = eventParams.GetOrDefault <string, string>("responseVariantName", null); JSONObject campaignLimitsConfig = json.GetOrDefault("campaignExecutionConfig", new JSONObject()); TriggerConditionParser parser = new TriggerConditionParser(campaignLimitsConfig, variantId); this.campaignTriggerConditions = parser.parseConditions(executionCountManager); }
/// <summary> /// Clears the persistent data, such as user id. The SDK should be stopped /// before this method is called. /// /// Useful for testing purposes. /// </summary> public void ClearPersistentData() { if (HasStarted) { Logger.LogWarning("SDK has not been stopped before clearing persistent data"); } PlayerPrefs.DeleteKey(PF_KEY_USER_ID); PlayerPrefs.DeleteKey(PF_KEY_FIRST_SESSION); PlayerPrefs.DeleteKey(PF_KEY_LAST_SESSION); PlayerPrefs.DeleteKey(PF_KEY_CROSS_GAME_USER_ID); PlayerPrefs.DeleteKey(PF_KEY_ADVERTISING_ID); PlayerPrefs.DeleteKey(PF_KEY_FORGET_ME); PlayerPrefs.DeleteKey(PF_KEY_FORGOTTEN); PlayerPrefs.DeleteKey(PF_KEY_STOP_TRACKING_ME); PlayerPrefs.DeleteKey(PF_KEY_ACTIONS_SALT); delegated.ClearPersistentData(); lock (_lock) { if (delegated is DDNANonTracking) { delegated = new DDNAImpl(this); } } }
internal void Awake() { lock (_lock) { if (PlayerPrefs.HasKey(PF_KEY_FORGET_ME) || PlayerPrefs.HasKey(PF_KEY_FORGOTTEN) || PlayerPrefs.HasKey(PF_KEY_STOP_TRACKING_ME) ) { delegated = new DDNANonTracking(this); } else { delegated = new DDNAImpl(this); } // attach additional behaviours as children of this gameObject #if !DDNA_IOS_PUSH_NOTIFICATIONS_REMOVED GameObject iosNotificationsObject = new GameObject(); IosNotifications = iosNotificationsObject.AddComponent <IosNotifications>(); iosNotificationsObject.transform.parent = gameObject.transform; #endif GameObject androidNotificationsObject = new GameObject(); AndroidNotifications = androidNotificationsObject.AddComponent <AndroidNotifications>(); androidNotificationsObject.transform.parent = gameObject.transform; } }
internal EventTrigger(DDNABase ddna, int index, JSONObject json) { this.ddna = ddna; this.index = index; eventName = json.ContainsKey("eventName") ? json["eventName"] as string : ""; response = json.ContainsKey("response") ? json["response"] as JSONObject : new JSONObject(); priority = json.GetOrDefault("priority", 0L); limit = json.GetOrDefault("limit", -1L); condition = (json.ContainsKey("condition") ? json["condition"] as List <object> : new List <object>(0)) .Select(e => e as JSONObject) .ToArray(); campaignId = json.GetOrDefault("campaignID", -1L); variantId = json.GetOrDefault("variantID", -1L); var eventParams = response.GetOrDefault("eventParams", new JSONObject()); campaignName = eventParams.GetOrDefault <string, string>("responseEngagementName", null); variantName = eventParams.GetOrDefault <string, string>("responseVariantName", null); }
public void StopTrackingMe() { lock (_lock) { if (!PlayerPrefs.HasKey(PF_KEY_STOP_TRACKING_ME)) { var started = HasStarted; delegated.StopTrackingMe(); delegated = new DDNANonTracking(this); if (started) { delegated.StartSDK(false); } delegated.StopTrackingMe(); } } }
/// <summary> /// Forgets the current user and stops them from being tracked. /// /// Any subsequent calls on the SDK will succeed, but not send/request anything to/from /// the Platform. /// /// The status can be cleared by starting the SDK with a new use or clearing the persistent /// data. /// </summary> public void ForgetMe() { lock (_lock) { if (!PlayerPrefs.HasKey(PF_KEY_FORGET_ME)) { var started = HasStarted; delegated.ForgetMe(); delegated = new DDNANonTracking(this); if (started) { delegated.StartSDK(false); } delegated.ForgetMe(); } } }
/// <summary> /// Clears the persistent data, such as user id. The SDK should be stopped /// before this method is called. /// /// Useful for testing purposes. /// </summary> public void ClearPersistentData() { if (HasStarted) { Logger.LogWarning("SDK has not been stopped before clearing persistent data"); } PlayerPrefs.DeleteKey(PF_KEY_USER_ID); PlayerPrefs.DeleteKey(PF_KEY_FORGET_ME); PlayerPrefs.DeleteKey(PF_KEY_FORGOTTEN); delegated.ClearPersistentData(); lock (_lock) { if (delegated is DDNANonTracking) { delegated = new DDNAImpl(this); } } }
internal void Awake() { lock (_lock) { if (PlayerPrefs.HasKey(PF_KEY_FORGET_ME) || PlayerPrefs.HasKey(PF_KEY_FORGOTTEN)) { delegated = new DDNANonTracking(this); } else { delegated = new DDNAImpl(this); } // attach additional behaviours as children of this gameObject GameObject iosNotificationsObject = new GameObject(); IosNotifications = iosNotificationsObject.AddComponent <IosNotifications>(); iosNotificationsObject.transform.parent = gameObject.transform; GameObject androidNotificationsObject = new GameObject(); AndroidNotifications = androidNotificationsObject.AddComponent <AndroidNotifications>(); androidNotificationsObject.transform.parent = gameObject.transform; } }
internal EngageFactory(DDNABase ddna, SmartAds smartads) { this.ddna = ddna; this.smartads = smartads; }
public void PreTest() { ddna = Substitute.For <DDNABase>(null); store = Substitute.For <ActionStore>(Settings.ACTIONS_STORAGE_PATH .Replace("{persistent_path}", Application.persistentDataPath)); }
/// <summary> /// Starts the SDK. Call before sending events or making engagements. This method /// can be used if the game configuration needs to be provided in the code as opposed /// to using the configuration UI. /// </summary> /// <param name="config">The game configuration for the SDK.</param> /// <param name="userID">The user id for the player, if set to null we create one for you.</param> public void StartSDK(Configuration config, string userID) { lock (_lock) { bool newPlayer = false; if (String.IsNullOrEmpty(UserID)) // first time! { newPlayer = true; if (String.IsNullOrEmpty(userID)) // generate a user id { userID = GenerateUserID(); } } else if (!String.IsNullOrEmpty(userID)) // use offered user id { if (UserID != userID) { newPlayer = true; } } UserID = userID; if (newPlayer) { Logger.LogInfo("Starting DDNA SDK with new user " + UserID); } else { Logger.LogInfo("Starting DDNA SDK with existing user " + UserID); } EnvironmentKey = (config.environmentKey == 0) ? config.environmentKeyDev : config.environmentKeyLive; CollectURL = config.collectUrl; EngageURL = config.engageUrl; if (Platform == null) { Platform = ClientInfo.Platform; } if (!string.IsNullOrEmpty(config.hashSecret)) { HashSecret = config.hashSecret; } if (config.useApplicationVersion) { ClientVersion = Application.version; } else if (!string.IsNullOrEmpty(config.clientVersion)) { ClientVersion = config.clientVersion; } if (newPlayer) { PlayerPrefs.DeleteKey(PF_KEY_FIRST_SESSION); PlayerPrefs.DeleteKey(PF_KEY_LAST_SESSION); PlayerPrefs.DeleteKey(PF_KEY_CROSS_GAME_USER_ID); if (delegated is DDNANonTracking) { PlayerPrefs.DeleteKey(PF_KEY_FORGET_ME); PlayerPrefs.DeleteKey(PF_KEY_FORGOTTEN); PlayerPrefs.DeleteKey(PF_KEY_STOP_TRACKING_ME); delegated = new DDNAImpl(this); } } delegated.StartSDK(newPlayer); if (Settings.SendGameRunningEveryMinute) { gameRunningEventCoroutine = GameHeartbeat(gameRunningEventInterval); StartCoroutine(gameRunningEventCoroutine); } } }
internal EngageFactory(DDNABase ddna) { this.ddna = ddna; }
public void PreTest() { ddna = Substitute.For <DDNABase>(null); }
/// <summary> /// Starts the SDK. Call before sending events or making engagements. This method /// can be used if the game configuration needs to be provided in the code as opposed /// to using the configuration UI. /// </summary> /// <param name="config">The game configuration for the SDK.</param> /// <param name="userID">The user id for the player, if set to null we create one for you.</param> public void StartSDK(Configuration config, string userID) { lock (_lock) { bool newPlayer = false; if (String.IsNullOrEmpty(UserID)) // first time! { newPlayer = true; if (String.IsNullOrEmpty(userID)) // generate a user id { userID = GenerateUserID(); } } else if (!String.IsNullOrEmpty(userID)) // use offered user id { if (UserID != userID) { newPlayer = true; } } UserID = userID; if (newPlayer) { Logger.LogInfo("Starting DDNA SDK with new user " + UserID); } else { Logger.LogInfo("Starting DDNA SDK with existing user " + UserID); } EnvironmentKey = (config.environmentKey == 0) ? config.environmentKeyDev : config.environmentKeyLive; CollectURL = config.collectUrl; EngageURL = config.engageUrl; if (Platform == null) { Platform = ClientInfo.Platform; } if (!string.IsNullOrEmpty(config.hashSecret)) { HashSecret = config.hashSecret; } if (config.useApplicationVersion) { ClientVersion = Application.version; } else if (!string.IsNullOrEmpty(config.clientVersion)) { ClientVersion = config.clientVersion; } if (newPlayer && delegated is DDNANonTracking) { PlayerPrefs.DeleteKey(PF_KEY_FORGET_ME); PlayerPrefs.DeleteKey(PF_KEY_FORGOTTEN); delegated = new DDNAImpl(this); } delegated.StartSDK(newPlayer); } }