void PopulateAnalyticsEvent(AnalyticsValidatorEvent validatorEvent, VisualTreeAsset cloneableAsset, VisualElement targetContainer) { if (validatorEvent.GetTimeStamp() > provider.m_LastEventTime) { var eventBlock = cloneableAsset.CloneTree().contentContainer; ServicesUtils.TranslateStringsInTree(eventBlock); if (eventBlock != null) { //set core text eventBlock.Q <Label>(k_ValidatorUtcTimeLabel).text = validatorEvent.GetTimeStampText(); eventBlock.Q <Label>(k_ValidatorEventTypeLabel).text = validatorEvent.GetTypeText(); eventBlock.Q <Label>(k_ValidatorPlatformLabel).text = validatorEvent.GetPlatformText(); eventBlock.Q <Label>(k_ValidatorSdkVersionLabel).text = validatorEvent.GetSdkVersionText(); var specialTemplateBlock = eventBlock.Q(k_SpecialTemplatePlaceholder); if (specialTemplateBlock != null) { //special case text if (validatorEvent is CustomValidatorEvent) { var eventTemplate = EditorGUIUtility.Load(k_CustomEventsTemplatePath) as VisualTreeAsset; if (eventTemplate != null) { PopulateCustomEvent((CustomValidatorEvent)validatorEvent, eventTemplate, specialTemplateBlock); } } else if (validatorEvent is DeviceInfoValidatorEvent) { var eventTemplate = EditorGUIUtility.Load(k_DeviceInfoEventsTemplatePath) as VisualTreeAsset; if (eventTemplate != null) { PopulateDeviceInfoEvent((DeviceInfoValidatorEvent)validatorEvent, eventTemplate, specialTemplateBlock); } } else if (validatorEvent is TransactionValidatorEvent) { var eventTemplate = EditorGUIUtility.Load(k_TransactionEventsTemplatePath) as VisualTreeAsset; if (eventTemplate != null) { PopulateTransactionEvent((TransactionValidatorEvent)validatorEvent, eventTemplate, specialTemplateBlock); } } else { specialTemplateBlock.style.display = DisplayStyle.None; } } } 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(); } }