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); }
internal DDNAImpl(DDNA ddna) : base(ddna) { string eventStorePath = null; if (Settings.UseEventStore) { eventStorePath = Settings.EVENT_STORAGE_PATH .Replace("{persistent_path}", Application.persistentDataPath); if (!Utils.IsDirectoryWritable(eventStorePath)) { Logger.LogWarning("Event store path unwritable, event caching disabled."); Settings.UseEventStore = false; } } eventStore = new EventStore(eventStorePath); if (Settings.UseEventStore && !eventStore.IsInitialised) { // failed to access files for some reason Logger.LogWarning("Failed to access event store path, event caching disabled."); Settings.UseEventStore = false; eventStore = new EventStore(eventStorePath); } engageCache = new EngageCache(Settings); actionStore = new ActionStore(Settings.ACTIONS_STORAGE_PATH .Replace("{persistent_path}", Application.persistentDataPath)); ImageMessageStore = new ImageMessageStore(ddna); executionCountManager = new ExecutionCountManager(); EngageFactory = new EngageFactory(this); }
internal DDNAImpl(DDNA ddna) : base(ddna) { string eventStorePath = null; if (Settings.UseEventStore) { eventStorePath = Settings.EVENT_STORAGE_PATH .Replace("{persistent_path}", Application.persistentDataPath); if (!Utils.IsDirectoryWritable(eventStorePath)) { Logger.LogWarning("Event store path unwritable, event caching disabled."); Settings.UseEventStore = false; } } eventStore = new EventStore(eventStorePath); if (Settings.UseEventStore && !eventStore.IsInitialised) { // failed to access files for some reason Logger.LogWarning("Failed to access event store path, event caching disabled."); Settings.UseEventStore = false; eventStore = new EventStore(eventStorePath); } engageCache = new EngageCache(Settings); actionStore = new ActionStore(Settings.ACTIONS_STORAGE_PATH .Replace("{persistent_path}", Application.persistentDataPath)); ImageMessageStore = new ImageMessageStore(ddna); executionCountManager = new ExecutionCountManager(); #if DDNA_SMARTADS // initialise SmartAds so it can register for events var smartAds = SmartAds.Instance.Config(engageCache); smartAds.transform.parent = gameObject.transform; EngageFactory = new EngageFactory(this, smartAds); Application.RequestAdvertisingIdentifierAsync( (string advertisingId, bool trackingEnabled, string error) => { if (trackingEnabled) { PlayerPrefs.SetString(DDNA.PF_KEY_ADVERTISING_ID, advertisingId); } } ); #else EngageFactory = new EngageFactory(this, null); #endif }
public List <TriggerCondition> parseConditions(ExecutionCountManager executionCountManager) { List <TriggerCondition> limitations = new List <TriggerCondition>(); if (campaignLimitsConfig.ContainsKey("showConditions")) { JSONObject[] showConditions = (campaignLimitsConfig["showConditions"] as List <object>).Select(e => e as JSONObject).ToArray(); foreach (var showCondition in showConditions) { TriggerCondition limitation = parseCondition(showCondition, executionCountManager); if (limitation != null) { limitations.Add(limitation); } } } return(limitations); }
public TriggerCondition parseCondition(JSONObject showCondition, ExecutionCountManager executionCountManager) { if (showCondition.ContainsKey("executionsRequiredCount")) { long executionsRequired = long.Parse(showCondition.GetOrDefault("executionsRequiredCount", "0")); return(new ExecutionCountTriggerCondition(executionsRequired, executionCountManager, variantId)); } if (showCondition.ContainsKey("executionsRepeat")) { long executionsRepeat = long.Parse(showCondition.GetOrDefault("executionsRepeat", "1")); var limit = new ExecutionRepeatTriggerCondition(executionsRepeat, executionCountManager, variantId); if (showCondition.ContainsKey("executionsRepeatLimit")) { long executionsRepeatLimit = long.Parse(showCondition.GetOrDefault("executionsRepeatLimit", "-1")); limit.setExecutionLimit(executionsRepeatLimit); } return(limit); } return(null); }