void PopulateCustomEvent(CustomValidatorEvent validatorEvent, VisualTreeAsset cloneableAsset, VisualElement targetContainer) { var eventBlock = cloneableAsset.CloneTree().contentContainer; eventBlock.Q <Label>(k_CustomName).text = validatorEvent.GetNameText(); try { List <string> customStrings = validatorEvent.GetCustomParamsTexts(k_CustomDataFormat); bool hasParams = customStrings.Count > 0; var paramsBlock = eventBlock.Q(k_CustomParamBlock); if (paramsBlock != null) { paramsBlock.style.display = hasParams ? DisplayStyle.Flex : DisplayStyle.None; foreach (var customString in customStrings) { var customLabel = new Label(customString); customLabel.AddToClassList(k_BulletClass); paramsBlock.Add(customLabel); } } var noParamsBlock = eventBlock.Q(k_CustomNoParams); if (noParamsBlock != null) { noParamsBlock.style.display = hasParams ? DisplayStyle.None : DisplayStyle.Flex; } } catch (Exception ex) { NotificationManager.instance.Publish(provider.serviceInstance.notificationTopic, Notification.Severity.Warning, string.Format(L10n.Tr(k_CustomDataExceptionMessage), validatorEvent.GetNameText(), ex.Message)); Debug.LogException(ex); } targetContainer.Add(eventBlock); }
void OnGetValidationData(string downloadedData) { string basicStatus = null; string customStatus = null; string monetizationStatus = null; List <JSONValue> basicEvents = null; m_Events.Clear(); var jsonParser = new JSONParser(downloadedData); try { var json = jsonParser.Parse(); basicStatus = json.AsDict()[k_JsonKeyBasic].AsString(); customStatus = json.AsDict()[k_JsonKeyCustom].AsString(); monetizationStatus = json.AsDict()[k_JsonKeyMonetization].AsString(); basicEvents = json.AsDict()[k_JsonKeyBasicEvents].AsList(); } catch (Exception ex) { NotificationManager.instance.Publish(serviceInstance.notificationTopic, Notification.Severity.Error, string.Format(L10n.Tr(k_DataValidationExceptionMessage), Connect.UnityConnect.instance.projectInfo.projectName, ex.Message)); Debug.LogException(ex); } m_BasicDataValidated = (basicStatus == k_JsonValueCompleted); m_CustomDataIntegrated = (customStatus == k_JsonValueCompleted); m_MonetizationDataIntegrated = (monetizationStatus == k_JsonValueCompleted); foreach (var jsonEvent in basicEvents) { AnalyticsValidatorEvent parsedEvent; var type = jsonEvent.AsDict()[k_JsonKeyType].AsString(); if (type == k_JsonValueCustomType) { parsedEvent = new CustomValidatorEvent(jsonEvent); } else if (type == k_JsonValueDeviceInfoType) { parsedEvent = new DeviceInfoValidatorEvent(jsonEvent); } else if (type == k_JsonValueTransactionType) { parsedEvent = new TransactionValidatorEvent(jsonEvent); } else { parsedEvent = new AnalyticsValidatorEvent(jsonEvent); } if (parsedEvent.GetTimeStamp() > m_LastEventTime) { m_Events.Add(parsedEvent); } } if (m_BasicDataValidated && m_NotifyOnBasicValidate != null) { m_NotifyOnBasicValidate(); m_NotifyOnBasicValidate = null; } if (m_Events.Count > 0 && m_NotifyOnEventsUpdate != null) { m_NotifyOnEventsUpdate(); } }