コード例 #1
0
        public static void SendBuildEvent(GUID guid, BuildTarget buildTarget, BuildTargetGroup buildTargetGroup, IEnumerable <XRLoader> loaders)
        {
#if UNITY_ANALYTICS && ENABLE_CLOUD_SERVICES_ANALYTICS
            if (!s_Initialized && !Initialize())
            {
                return;
            }

            List <string> loaderTypeNames = new List <string>();
            foreach (var loader in loaders)
            {
                loaderTypeNames.Add(loader.GetType().Name);
            }

            var data = new BuildEvent
            {
                buildGuid        = guid.ToString(),
                buildTarget      = buildTarget.ToString(),
                buildTargetGroup = buildTargetGroup.ToString(),
                assigned_loaders = loaderTypeNames.ToArray(),
            };

            EditorAnalytics.SendEventWithLimit(kEventBuild, data);
#endif //UNITY_ANALYTICS && ENABLE_CLOUD_SERVICES_ANALYTICS
        }
コード例 #2
0
ファイル: OpenXRAnalytics.cs プロジェクト: BotsOP/RythmVRGAME
        private static bool Initialize()
        {
#if ENABLE_TEST_SUPPORT || !UNITY_ANALYTICS
            return(false);
#else
            if (s_Initialized)
            {
                return(true);
            }

#if UNITY_EDITOR
            if (!EditorAnalytics.enabled)
            {
                return(false);
            }

            if (AnalyticsResult.Ok != EditorAnalytics.RegisterEventWithLimit(kEventInitialize, kMaxEventsPerHour, kMaxNumberOfElements, kVendorKey))
#else
            if (AnalyticsResult.Ok != Analytics.Analytics.RegisterEvent(kEventInitialize, kMaxEventsPerHour, kMaxNumberOfElements, kVendorKey))
#endif
            { return(false); }

            s_Initialized = true;

            return(true);
#endif
        }
        private static bool RegisterEvent(string eventName)
        {
            const string vendorKey = "unity.scene-template";
            var          result    = EditorAnalytics.RegisterEventWithLimit(eventName, 100, 1000, vendorKey);

            switch (result)
            {
            case AnalyticsResult.Ok:
            {
#if PERFORMANCE_TRACKING_ANALYTICS_LOGGING
                Debug.Log($"SceneTemplate: Registered event: {eventName}");
#endif
                return(true);
            }

            case AnalyticsResult.TooManyRequests:
                // this is fine - event registration survives domain reload (native)
                return(true);

            default:
            {
                Console.WriteLine($"[ST] Failed to register analytics event '{eventName}'. Result: '{result}'");
                return(false);
            }
            }
        }
コード例 #4
0
        static bool EnableAnalytics()
        {
            var res = EditorAnalytics.RegisterEventWithLimit(k_EventName, k_MaxEventsPerHour, k_MaxNumberOfElements, k_VendorKey);

            s_EventRegistered = res == AnalyticsResult.Ok;
            return(s_EventRegistered);
        }
コード例 #5
0
        public static void SendEvent(string action, string packageId = null)
        {
            // remove sensitive part of the id: file path or url is not tracked
            if (!string.IsNullOrEmpty(packageId))
            {
                packageId = Regex.Replace(packageId, "(?<package>[^@]+)@(?<protocol>[^:]+):.+", "${package}@${protocol}");
            }

            var packageFiltering    = ServicesContainer.instance.Resolve <PackageFiltering>();
            var packageManagerPrefs = ServicesContainer.instance.Resolve <PackageManagerPrefs>();
            var settingsProxy       = ServicesContainer.instance.Resolve <PackageManagerProjectSettingsProxy>();

            var parameters = new PackageManagerWindowAnalytics
            {
                action               = action,
                package_id           = packageId ?? string.Empty,
                search_text          = packageFiltering.currentSearchText,
                filter_name          = packageFiltering.currentFilterTab.ToString(),
                window_docked        = EditorWindow.GetWindowDontShow <PackageManagerWindow>()?.docked ?? false,
                dependencies_visible = packageManagerPrefs.showPackageDependencies,
                preview_visible      = settingsProxy.enablePreviewPackages,
                t_since_start        = (long)(EditorApplication.timeSinceStartup * 1E6),
                ts = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond
            };

            EditorAnalytics.SendEventWithLimit("packageManagerWindowUserAction", parameters);
        }
コード例 #6
0
        private static void Send()
        {
            if (!EditorAnalytics.enabled)
            {
                return;
            }

            if (!RegisterEvent())
            {
                return;
            }

            // Because dicts aren't serializable, convert it to a list right before we send
            foreach (var count in _collectedData.HotkeyUsageCountDict)
            {
                var c = new HotkeyStringUsageCount();
                c.hotkey = count.Key;
                c.count  = count.Value;
                _collectedData.hotkeyUsageCount.Add(c);
            }

            EditorAnalytics.SendEventWithLimit(EventName, _collectedData);

            ResetCollectedData();
        }
コード例 #7
0
        static bool EnableAnalytics()
        {
            if (s_EventRegistered)
            {
                return(true);
            }

#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE
            AnalyticsResult result = EditorAnalytics.RegisterEventWithLimit(k_EventName, k_MaxEventsPerHour, k_MaxNumberOfElements, k_VendorKey, k_EventVersion);
            if (result == AnalyticsResult.Ok)
            {
                s_EventRegistered = true;
            }
#elif MLA_UNITY_ANALYTICS_MODULE
            AnalyticsResult result = AnalyticsResult.UnsupportedPlatform;
            if (result == AnalyticsResult.Ok)
            {
                s_EventRegistered = true;
            }
#endif
            if (s_EventRegistered && s_SentModels == null)
            {
                s_SentModels = new HashSet <NNModel>();
            }

            return(s_EventRegistered);
        }
コード例 #8
0
        public static void SendBarracudaImportEvent(object originalModel, Model importedModel)
        {
            //The event shouldn't be able to report if this is disabled but if we know we're not going to report
            //Lets early out and not waste time gathering all the data
            if (!EditorAnalytics.enabled)
            {
                return;
            }

            if (!EnableAnalytics())
            {
                return;
            }


            var data = new BarracudaImportAnalyticsData();

            try
            {
                data.original_layers = AnalyzeONNXModel(originalModel);
                data.imported_layers = AnalyzeNNModel(importedModel);
                data.model_type      = string.IsNullOrEmpty(data.original_layers) ? "NN" : "ONNX";
                data.import_warnings = AnalyzeWarnings(importedModel);
            }
            catch (Exception e)
            {
                D.LogError($"Failed collecting Barracuda analytics: {e}");
            }

            EditorAnalytics.SendEventWithLimit(k_ImportEventName, data);
        }
コード例 #9
0
ファイル: SearchAnalytics.cs プロジェクト: yhn531/AMS
 private static void Send(EventName eventName, object eventData)
 {
     if (!RegisterEvents())
     {
         #if QUICKSEARCH_ANALYTICS_LOGGING
         Console.WriteLine($"[QS] Analytics disabled: event='{eventName}', time='{DateTime.Now:HH:mm:ss}', payload={EditorJsonUtility.ToJson(eventData, true)}");
         #endif
         return;
     }
     try
     {
         var result = EditorAnalytics.SendEventWithLimit(eventName.ToString(), eventData);
         if (result == AnalyticsResult.Ok)
         {
             #if QUICKSEARCH_ANALYTICS_LOGGING
             Console.WriteLine($"[QS] Event='{eventName}', time='{DateTime.Now:HH:mm:ss}', payload={EditorJsonUtility.ToJson(eventData, true)}");
             #endif
         }
         else
         {
             Console.WriteLine($"[QS] Failed to send event {eventName}. Result: {result}");
         }
     }
     catch (Exception)
     {
         // ignored
     }
 }
コード例 #10
0
 public static void SendEvent <T>(T eventData) where T : IMemoryProfilerAnalyticsEvent
 {
     if (s_EnableAnalytics)
     {
         EditorAnalytics.SendEventWithLimit(k_EventTopicName, eventData);
     }
 }
コード例 #11
0
        static bool EnableAnalytics()
        {
#if MLA_UNITY_ANALYTICS_MODULE_ENABLED
            if (s_EventsRegistered)
            {
                return(true);
            }
            foreach (var eventName in s_EventNames)
            {
#if UNITY_EDITOR
                AnalyticsResult result = EditorAnalytics.RegisterEventWithLimit(eventName, k_MaxEventsPerHour, k_MaxNumberOfElements, k_VendorKey);
                if (result != AnalyticsResult.Ok)
                {
                    return(false);
                }
#else
                return(false);
#endif // UNITY_EDITOR
            }
            s_EventsRegistered = true;

            if (s_SentRemotePolicyInitialized == null)
            {
                s_SentRemotePolicyInitialized     = new HashSet <string>();
                s_SentTrainingBehaviorInitialized = new HashSet <string>();
                s_TrainingSessionGuid             = Guid.NewGuid();
            }

            return(s_EventsRegistered);
#else
            return(false);
#endif // MLA_UNITY_ANALYTICS_MODULE_ENABLED
        }
        private void Send(EventName eventName, object eventData)
        {
            if (!RegisterEvents())
            {
#if COVERAGE_ANALYTICS_LOGGING
                Console.WriteLine($"[{CoverageSettings.PackageName}] Analytics disabled: event='{eventName}', time='{DateTime.Now:HH:mm:ss}', payload={EditorJsonUtility.ToJson(eventData, true)}");
#endif
                return;
            }
            try
            {
                var result = EditorAnalytics.SendEventWithLimit(eventName.ToString(), eventData);
                if (result == AnalyticsResult.Ok)
                {
#if COVERAGE_ANALYTICS_LOGGING
                    ResultsLogger.LogSessionItem($"Event={eventName}, time={DateTime.Now:HH:mm:ss}, payload={EditorJsonUtility.ToJson(eventData, true)}", LogVerbosityLevel.Info);
#endif
                }
                else
                {
                    ResultsLogger.LogSessionItem($"Failed to send analytics event {eventName}. Result: {result}", LogVerbosityLevel.Error);
                }
            }
            catch (Exception)
            {
                // ignored
            }
        }
コード例 #13
0
        public static void TrainingBehaviorInitialized(TrainingBehaviorInitializedEvent rawTbiEvent)
        {
#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE && ENABLE_CLOUD_SERVICES_ANALYTICS
            if (!IsAnalyticsEnabled())
            {
                return;
            }

            if (!EnableAnalytics())
            {
                return;
            }

            var tbiEvent     = SanitizeTrainingBehaviorInitializedEvent(rawTbiEvent);
            var behaviorName = tbiEvent.BehaviorName;
            var added        = s_SentTrainingBehaviorInitialized.Add(behaviorName);

            if (!added)
            {
                // We previously added this model. Exit so we don't resend.
                return;
            }

            tbiEvent.TrainingSessionGuid = s_TrainingSessionGuid.ToString();

            // Note - to debug, use JsonUtility.ToJson on the event.
            // Debug.Log(
            //     $"Would send event {k_TrainingBehaviorInitializedEventName} with body {JsonUtility.ToJson(tbiEvent, true)}"
            // );
            if (AnalyticsUtils.s_SendEditorAnalytics)
            {
                EditorAnalytics.SendEventWithLimit(k_TrainingBehaviorInitializedEventName, tbiEvent);
            }
#endif
        }
コード例 #14
0
        private static bool RegisterEvent(string eventName)
        {
            const string vendorKey = "unity.tiny.editor";
            var          result    = EditorAnalytics.RegisterEventWithLimit(eventName, 100, 1000, vendorKey);

            switch (result)
            {
            case AnalyticsResult.Ok:
            {
                    #if UTINY_INTERNAL
                Debug.Log($"Tiny: Registered event: {eventName}");
                    #endif
                return(true);
            }

            case AnalyticsResult.TooManyRequests:
                // this is fine - event registration survives domain reload (native)
                return(true);

            default:
            {
                TraceError($"failed to register analytics event '{eventName}'. Result: '{result}'");
                return(false);
            }
            }
        }
        private bool RegisterEvent(string eventName)
        {
            const string vendorKey = "unity.testtools.codecoverage";
            var          result    = EditorAnalytics.RegisterEventWithLimit(eventName, 100, 1000, vendorKey);

            switch (result)
            {
            case AnalyticsResult.Ok:
            {
#if COVERAGE_ANALYTICS_LOGGING
                ResultsLogger.LogSessionItem($"Registered analytics event: {eventName}", LogVerbosityLevel.Info);
#endif
                return(true);
            }

            case AnalyticsResult.TooManyRequests:
                // this is fine - event registration survives domain reload (native)
                return(true);

            default:
            {
                ResultsLogger.LogSessionItem($"Failed to register analytics event {eventName}. Result: {result}", LogVerbosityLevel.Error);
                return(false);
            }
            }
        }
コード例 #16
0
        /// <summary>
        /// Download and install the Unity IAP Package.
        /// </summary>
        public void InstallUnityPackage(Action onImport)
        {
            if (m_InstallInProgress)
            {
                return;
            }

            var originalCallback = ServicePointManager.ServerCertificateValidationCallback;

            // Only OSX supports SSL certificate validation, disable checking on other platforms.
            // TODO - fix when a Unity Web framework supports SSL.
            if (Application.platform != RuntimePlatform.OSXEditor)
            {
                ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => true;
            }

            m_InstallInProgress = true;
            var location = FileUtil.GetUniqueTempPathInProject();

            // Extension is required for correct Windows import.
            location = Path.ChangeExtension(location, ".unitypackage");

            UnityWebRequest request = new UnityWebRequest(k_PackageUri, UnityWebRequest.kHttpVerbGET);

            request.downloadHandler = new DownloadHandlerFile(location);
            var operation = request.SendWebRequest();

            operation.completed += (asyncOp) =>
            {
                // Installation must be done on the main thread.
                EditorApplication.CallbackFunction handler = null;
                handler = () =>
                {
                    ServicePointManager.ServerCertificateValidationCallback = originalCallback;
                    EditorApplication.update -= handler;
                    m_InstallInProgress       = false;
                    if ((request.result != UnityWebRequest.Result.ProtocolError) && (request.result != UnityWebRequest.Result.ConnectionError))
                    {
                        string etag = request.GetResponseHeaders()[k_ETagHeader];
                        SaveETag(etag);

                        AssetDatabase.ImportPackage(location, false);

                        EditorAnalytics.SendImportServicePackageEvent(new ImportPackageInfo()
                        {
                            packageName = Path.GetFileName(k_PackageUri.ToString()), eTag = etag
                        });

                        //TODO: ImportPackage is a delayeed operation with no callback. See if we can get a confirmation of successful installation
                        //      before firing our callback, or even before Saving the ETag.
                        onImport();
                    }
                    else
                    {
                        UnityEngine.Debug.LogError(L10n.Tr("Failed to download IAP package. Please check connectivity and retry. Web request Error: ") + request.error);
                    }
                };
                EditorApplication.update += handler;
            };
        }
コード例 #17
0
        static bool EnableAnalytics()
        {
            if (s_EventsRegistered)
            {
                return(true);
            }


#if UNITY_EDITOR
            AnalyticsResult result = EditorAnalytics.RegisterEventWithLimit(k_RemotePolicyInitializedEventName, k_MaxEventsPerHour, k_MaxNumberOfElements, k_VendorKey);
#else
            AnalyticsResult result = AnalyticsResult.UnsupportedPlatform;
#endif
            if (result != AnalyticsResult.Ok)
            {
                return(false);
            }

            s_EventsRegistered = true;

            if (s_SentRemotePolicyInitialized == null)
            {
                s_SentRemotePolicyInitialized = new HashSet <string>();
                s_TrainingSessionGuid         = Guid.NewGuid();
            }

            return(s_EventsRegistered);
        }
コード例 #18
0
ファイル: HDAnalytics.cs プロジェクト: GeorgeYarwood/Deeper
        public static void SendEvent()
        {
            if (!EditorAnalytics.enabled)
            {
                return;
            }

            var hdrpAsset = HDRenderPipeline.currentAsset;

            if (hdrpAsset == null)
            {
                return;
            }

            if (EditorAnalytics.RegisterEventWithLimit(k_EventName, k_MaxEventsPerHour, k_MaxNumberOfElements, k_VendorKey) != AnalyticsResult.Ok)
            {
                return;
            }

            RenderPipelineSettings settings = hdrpAsset.currentPlatformRenderPipelineSettings;
            RenderPipelineSettings defaults = RenderPipelineSettings.NewDefault();

            var data = new EventData(DiffSettings(settings, defaults));

            EditorAnalytics.SendEventWithLimit(k_EventName, data);
        }
コード例 #19
0
ファイル: SearchAnalytics.cs プロジェクト: yhn531/AMS
        private static bool RegisterEvent(string eventName)
        {
            const string vendorKey = "unity.quicksearch";
            var          result    = EditorAnalytics.RegisterEventWithLimit(eventName, 100, 1000, vendorKey);

            switch (result)
            {
            case AnalyticsResult.Ok:
            {
#if QUICKSEARCH_ANALYTICS_LOGGING
                Debug.Log($"QuickSearch: Registered event: {eventName}");
#endif
                return(true);
            }

            case AnalyticsResult.TooManyRequests:

                // this is fine - event registration survives domain reload (native)
                return(true);

            default:
            {
                Console.WriteLine($"[QS] Failed to register analytics event '{eventName}'. Result: '{result}'");
                return(false);
            }
            }
        }
コード例 #20
0
        private static void ReportImpl(AddressableAssetSettings currentSettings)
        {
            if (!_eventRegistered)
            {
                //If the event isn't registered, attempt to register it.  If unsuccessful, return.
                if (!RegisterEvent())
                {
                    return;
                }
            }

            //Gather how many addressable assets we have
            int numberOfAddressableAssets = 0;

            foreach (var group in currentSettings.groups)
            {
                numberOfAddressableAssets += group.entries.Count;
            }

            string buildScriptName = currentSettings.ActivePlayerDataBuilder.Name;

            AnalyticsData data = new AnalyticsData()
            {
                BuildScriptName           = builtInBuildScriptNames.Contains(buildScriptName) ? buildScriptName : "Custom Build Script",
                NumberOfAddressableAssets = numberOfAddressableAssets,
            };

            //Report
            EditorAnalytics.SendEventWithLimit(EventName, data);
        }
コード例 #21
0
ファイル: HDAnalytics.cs プロジェクト: vault51/Graphics
        public static void SendEvent()
        {
            if (!EditorAnalytics.enabled)
            {
                return;
            }

            var activeBuildTarget = EditorUserBuildSettings.activeBuildTarget;

            var qualityLevelCount = QualitySettings.names.Length;

            for (int i = 0; i < QualitySettings.names.Length; ++i)
            {
                var hdrpAsset = QualitySettings.GetRenderPipelineAssetAt(i) as HDRenderPipelineAsset;
                if (hdrpAsset != null)
                {
                    if (EditorAnalytics.RegisterEventWithLimit(k_UsageEventName, k_MaxEventsPerHour, k_MaxNumberOfElements, k_VendorKey, k_UsageCurrentVersion) != AnalyticsResult.Ok)
                    {
                        continue;
                    }

                    RenderPipelineSettings settings = hdrpAsset.currentPlatformRenderPipelineSettings;
                    RenderPipelineSettings defaults = RenderPipelineSettings.NewDefault();

                    var guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(hdrpAsset.GetInstanceID()));
                    var data = new UsageEventData(activeBuildTarget, guid, DiffSettings(settings, defaults));

                    EditorAnalytics.SendEventWithLimit(k_UsageEventName, data, k_UsageCurrentVersion);
                }
            }
        }
コード例 #22
0
 public static void SendUserAction(string category, string action)
 {
     EditorAnalytics.SendCollabUserAction(new CollabUserActionAnalyticsEvent()
     {
         category = category, action = action
     });
 }
コード例 #23
0
        public static void TrainingEnvironmentInitialized(TrainingEnvironmentInitializedEvent tbiEvent)
        {
            if (!IsAnalyticsEnabled())
            {
                return;
            }

            if (!EnableAnalytics())
            {
                return;
            }

            if (s_SentEnvironmentInitialized)
            {
                // We already sent an TrainingEnvironmentInitializedEvent. Exit so we don't resend.
                return;
            }

            s_SentEnvironmentInitialized = true;
            tbiEvent.TrainingSessionGuid = s_TrainingSessionGuid.ToString();

            // Note - to debug, use JsonUtility.ToJson on the event.
            // Debug.Log(
            //     $"Would send event {k_TrainingEnvironmentInitializedEventName} with body {JsonUtility.ToJson(tbiEvent, true)}"
            // );
#if UNITY_EDITOR && MLA_UNITY_ANALYTICS_MODULE_ENABLED
            if (AnalyticsUtils.s_SendEditorAnalytics)
            {
                EditorAnalytics.SendEventWithLimit(k_TrainingEnvironmentInitializedEventName, tbiEvent);
            }
#endif
        }
コード例 #24
0
            void SetupTroubleShootingBlock()
            {
                m_TroubleshootingBlock = provider.rootVisualElement.Q(k_TroubleshootingBlock);

                if (m_TroubleshootingBlock != null)
                {
                    m_TroubleshootingBlock.Q <Button>(k_TroubleToggle).clicked += ToggleTroubleshooting;

                    var accessDashboard = m_TroubleshootingBlock.Q(k_AccessAnalyticsDashboardLink);
                    if (accessDashboard != null)
                    {
                        var clickable = new Clickable(() =>
                        {
                            var dashboardUrl = string.Format(AnalyticsConfiguration.instance.dashboardUrl, Connect.UnityConnect.instance.projectInfo.projectGUID);
                            EditorAnalytics.SendOpenDashboardForService(new OpenDashboardForService()
                            {
                                serviceName = AnalyticsService.instance.name, url = dashboardUrl
                            });
                            Application.OpenURL(dashboardUrl);
                        });
                        accessDashboard.AddManipulator(clickable);
                    }
                    var supportLink = m_TroubleshootingBlock.Q(k_SupportLink);
                    if (supportLink != null)
                    {
                        var clickable = new Clickable(() =>
                        {
                            Application.OpenURL(AnalyticsConfiguration.instance.supportUrl);
                        });
                        supportLink.AddManipulator(clickable);
                    }
                    CheckTroubleshootingModeVisibility(m_TroubleshootingBlock);
                }
            }
コード例 #25
0
        private static void ReportRunFinished(ITestResultAdaptor testResult)
        {
            SetUpIfNeeded();

            var activeRuns = TestJobDataHolder.instance.TestRuns;

            if (activeRuns.Count == 0)
            {
                return;
            }

            var executionSettings = activeRuns[0].executionSettings;
            var filter            = executionSettings.filters.First();
            var runFinishedData   = new RunFinishedData()
            {
                totalTests           = testResult.Test.TestCaseCount,
                numPassedTests       = testResult.PassCount,
                numFailedTests       = testResult.FailCount,
                numInconclusiveTests = testResult.InconclusiveCount,
                numSkippedTests      = testResult.SkipCount,
                testModeFilter       = (int)filter.testMode,
                targetPlatform       = executionSettings.targetPlatform != null?executionSettings.targetPlatform.ToString() : "editor",
                                           runSynchronously  = executionSettings.runSynchronously,
                                           isCustomRunner    = false,
                                           isFiltering       = executionSettings.filters.Any(f => f.HasAny()),
                                           isAutomated       = IsCommandLineArgSet("-automated"),
                                           isFromCommandLine = IsCommandLineArgSet("-runTests"),
                                           totalTestDuration = testResult.Duration,
                                           totalRunDuration  = (DateTime.Now - Convert.ToDateTime(activeRuns[0].startTime)).TotalSeconds
            };

            EditorAnalytics.SendEventWithLimit(RunFinishedEventName, runFinishedData, 1);
        }
コード例 #26
0
 void OnDestroy()
 {
     EditorAnalytics.SendEventCloseServiceWindow(new CloseServiceWindowState()
     {
         availableServices = m_StatusLabelByServiceName.Count
     });
 }
コード例 #27
0
        static void SendUniversalEvent()
        {
            //The event shouldn't be able to report if this is disabled but if we know we're not going to report
            //Lets early out and not waste time gathering all the data
            if (!EditorAnalytics.enabled)
            {
                return;
            }

            if (!EnableAnalytics())
            {
                return;
            }

            // Needd to check if this isn't null
            UniversalRenderPipelineAsset rendererAsset = GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset;

            if (rendererAsset != null)
            {
                ScriptableRendererData[] rendererDataList = rendererAsset.m_RendererDataList;

                string mainLightMode       = rendererAsset.mainLightRenderingMode.ToString();
                string additionalLightMode = rendererAsset.additionalLightsRenderingMode.ToString();

                HashSet <string> rendererDatas  = new HashSet <string>();
                HashSet <string> renderFeatures = new HashSet <string>();
                int rendererDataAmount          = 0;
                int rendererFeaturesAmount      = 0;

                foreach (ScriptableRendererData rendererData in rendererDataList)
                {
                    if (rendererData != null)
                    {
                        rendererDataAmount++;
                        rendererDatas.Add(rendererData.GetType().ToString());
                        foreach (ScriptableRendererFeature rendererFeature in rendererData.rendererFeatures)
                        {
                            if (rendererFeature != null)
                            {
                                rendererFeaturesAmount++;
                                renderFeatures.Add(rendererFeature.GetType().ToString());
                            }
                        }
                    }
                }

                var data = new AnalyticsData()
                {
                    renderer_data                   = rendererDatas.ToArray(),
                    renderer_data_amount            = rendererDataAmount,
                    renderer_features               = renderFeatures.ToArray(),
                    renderer_features_amount        = rendererFeaturesAmount,
                    main_light_rendering_mode       = mainLightMode,
                    additional_light_rendering_mode = additionalLightMode,
                };

                EditorAnalytics.SendEventWithLimit(k_EventName, data);
            }
        }
コード例 #28
0
        /// <summary>
        /// Registers and attempts to send a VSP Attribution event.
        /// </summary>
        /// <param name="actionName">Name of the action, identifying a place this event was called from.</param>
        /// <param name="partnerName">Identifiable Verified Solutions Partner name.</param>
        /// <param name="customerUid">Unique identifier of the customer using Partner's Verified Solution.</param>
        public static AnalyticsResult SendAttributionEvent(string actionName, string partnerName, string customerUid)
        {
            try
            {
#if UNITY_EDITOR
                // Are Editor Analytics enabled ? (Preferences)
                // The event shouldn't be able to report if this is disabled but if we know we're not going to report
                // lets early out and not spend time gathering all the data
                bool isEditorAnalyticsEnabled = EditorAnalytics.enabled;

                if (!isEditorAnalyticsEnabled)
                {
                    return(AnalyticsResult.AnalyticsDisabled);
                }
#else // IF !UNITY_EDITOR
                bool isRuntimeAnalyticsEnabled = Analytics.enabled;

                if (!isRuntimeAnalyticsEnabled)
                {
                    return(AnalyticsResult.AnalyticsDisabled);
                }

                if (!Debug.isDebugBuild)
                {
                    return(AnalyticsResult.UnsupportedPlatform);
                }
#endif

                // Can an event be registered?
                bool isEventRegistered = RegisterEvent();

                if (!isEventRegistered)
                {
                    return(AnalyticsResult.InvalidData);
                }

                // Create an expected data object
                var eventData = new VspAttributionData
                {
                    actionName  = actionName,
                    partnerName = partnerName,
                    customerUid = customerUid,
                    extra       = "{}"
                };

#if UNITY_EDITOR
                // Send the Attribution Event
                var eventResult = EditorAnalytics.SendEventWithLimit(k_EventName, eventData, k_VersionId);
#else // IF !UNITY_EDITOR
                var eventResult = Analytics.SendEvent(k_EventName, eventData, k_VersionId);
#endif
                return(eventResult);
            }
            catch
            {
                // Fail silently
                return(AnalyticsResult.AnalyticsDisabled);
            }
        }
コード例 #29
0
 public void SendAnalyticsEvent(string name, object data)
 {
     #if UNITY_EDITOR
     EditorAnalytics.SendEventWithLimit(name, data);
     #else
     Analytics.Analytics.SendEvent(name, data);
     #endif
 }
コード例 #30
0
        public long     ts;            // in milliseconds

        public static void Setup()
        {
            int    maxEventsPerHour           = 1000;
            int    maxNumberOfElementInStruct = 100;
            string vendorKey = "unity.package-manager-ui";

            EditorAnalytics.RegisterEventWithLimit("packageManagerWindowUserAction", maxEventsPerHour, maxNumberOfElementInStruct, vendorKey);
        }