Пример #1
0
    private void InitializePlugin()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);

        try {
            if (agentInstance == null)
            {
                                #if UNITY_IPHONE
                UnityEngine.Debug.Log("Initializing New Relic iOS agent.");
                agentInstance = new NewRelicIos(this);
                                #elif UNITY_ANDROID
                UnityEngine.Debug.Log("Initializing New Relic Android agent.");
                agentInstance = new NewRelicAndroid(this);
                                #endif  // UNITY_ANDROID
            }
        } catch (Exception e) {
            UnityEngine.Debug.LogException(e);
        }
    }
Пример #2
0
        public void Initialize(IPipelines pipelines)
        {
            pipelines.BeforeRequest.AddItemToStartOfPipeline(
                context =>
            {
                var route = routeResolver.Resolve(context);

                if (route == null || route.Route == null || route.Route.Description == null) // probably not necessary but don't want the chance of losing visibility on anything
                {
                    NewRelicAgent.SetTransactionName(
                        context.Request.Method,
                        context.Request.Url.ToString());
                }
                else
                {
                    NewRelicAgent.SetTransactionName(
                        route.Route.Description.Method,
                        route.Route.Description.Path);
                }
                return(null);
            });
            pipelines.OnError.AddItemToEndOfPipeline(
                (context, ex) =>
            {
                NewRelicAgent.NoticeError(
                    ex);
                return(null);
            });
        }
Пример #3
0
    public NewRelicAndroid(NewRelicAgent plugin) : base(plugin)
    {
        using (AndroidJavaClass activityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
            activityContext = activityClass.GetStatic <AndroidJavaObject> ("currentActivity");
            if (activityContext == null)
            {
                UnityEngine.Debug.LogError("NewRelicAndroid: Could not load activity context.");
            }

            pluginInstance = new AndroidJavaClass("com.newrelic.agent.android.NewRelic");
            if (pluginInstance == null)
            {
                UnityEngine.Debug.LogError("NewRelicAndroid: Could not instantiate NewRelic plugin class.");
            }

            unityApiClass = new AndroidJavaClass("com.newrelic.agent.android.unity.NewRelicUnity");
            if (unityApiClass == null)
            {
                UnityEngine.Debug.LogError("NewRelicAndroid: unable to instantiate a NewRelicUnity class.");
            }
        }
    }
Пример #4
0
 public NewRelic(NewRelicAgent plugin)
 {
     this.plugin = plugin;
 }
Пример #5
0
    public NewRelicIos(NewRelicAgent plugin) : base(plugin)
    {
        useSSL(plugin.usingSSL);

        if (plugin.applicationBuild != null && plugin.applicationBuild.Length > 0)
        {
            setApplicationBuild(plugin.applicationBuild);
        }

        if (plugin.applicationVersion != null && plugin.applicationVersion.Length > 0)
        {
            setApplicationVersion(plugin.applicationVersion);
        }

        logLevel((int)plugin.logLevel);

        enableCrashReporting(plugin.crashReporting);

        if (plugin.interactionTracing)
        {
            enableFeatures((int)NewRelicAgent.FeatureFlag.InteractionTracing);
        }
        else
        {
            disableFeatures((int)NewRelicAgent.FeatureFlag.InteractionTracing);
        }

        if (plugin.swiftInteractionTracing)
        {
            enableFeatures((int)NewRelicAgent.FeatureFlag.SwiftInteractionTracing);
        }
        else
        {
            disableFeatures((int)NewRelicAgent.FeatureFlag.SwiftInteractionTracing);
        }

        if (plugin.URLSessionInstrumentation)
        {
            enableFeatures((int)NewRelicAgent.FeatureFlag.URLSessionInstrumentation);
        }
        else
        {
            disableFeatures((int)NewRelicAgent.FeatureFlag.URLSessionInstrumentation);
        }


        if (plugin.httpResponseBodyCapture)
        {
            enableFeatures((int)NewRelicAgent.FeatureFlag.HttpResponseBodyCapture);
        }
        else
        {
            disableFeatures((int)NewRelicAgent.FeatureFlag.HttpResponseBodyCapture);
        }

        if (plugin.experimentalNetworkingInstrumentation)
        {
            enableFeatures((int)NewRelicAgent.FeatureFlag.ExperimentalNetworkingInstrumentation);
        }
        else
        {
            disableFeatures((int)NewRelicAgent.FeatureFlag.ExperimentalNetworkingInstrumentation);
        }

        if (plugin.analyticsEvents)
        {
            enableFeatures((int)NewRelicAgent.FeatureFlag.AnalyticsEvents);
        }
        else
        {
            disableFeatures((int)NewRelicAgent.FeatureFlag.AnalyticsEvents);
        }
    }