diff --git a/CHANGELOG.md b/CHANGELOG.md index e1af7ee..30b4c26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ # CHANGELOG All notable changes to this project will be documented in this file. +## [3.1.2] - 2023/03/16 +### Fix + - `nrUpdateConfig` bug. + - Documentation errata. +### Update + - Remove unused field in NRAgent. + ## [3.1.1] - 2022/10/04 ### Fix - Crash happening when using a playlist. diff --git a/README.md b/README.md index 97ce99d..ba1c423 100644 --- a/README.md +++ b/README.md @@ -651,8 +651,8 @@ Return: Nothing Example: - config = { networkProxy: "http://example.com:8888/;" } - nrUpdateConig(m.nr, config) + config = { proxyUrl: "http://example.com:8888/;" } + nrUpdateConfig(m.nr, config) ``` **nrSendLog** diff --git a/components/NewRelicAgent/NRAgent.brs b/components/NewRelicAgent/NRAgent.brs index 4e3e426..c427aaf 100644 --- a/components/NewRelicAgent/NRAgent.brs +++ b/components/NewRelicAgent/NRAgent.brs @@ -12,6 +12,7 @@ sub init() m.logApiUrl = "" m.metricApiUrl = "" m.nrRegion = "US" + m.testServer = "http://my.test.server:8888" print "************************************************************" print " New Relic Agent for Roku v" + m.nrAgentVersion print " Copyright 2019-2022 New Relic Inc. All Rights Reserved." @@ -116,7 +117,7 @@ function NewRelicInit(account as String, apikey as String, region as String) as 'Create and configure tasks (metrics) m.bgTaskMetrics = m.top.findNode("NRTaskMetrics") m.bgTaskMetrics.setField("apiKey", m.nrInsightsApiKey) - m.metricApiUrl = box(nrMetricsApiUrl()) + m.metricApiUrl = box(nrMetricApiUrl()) m.bgTaskMetrics.setField("metricApiUrl", m.metricApiUrl) m.bgTaskMetrics.sampleType = "metric" @@ -201,10 +202,13 @@ end function function nrUpdateConfig(config as object) as void if config = invalid then return if config.proxyUrl <> invalid + nrLog("------------> Set Proxy Url " + config.proxyUrl) m.eventApiUrl = box(nrEventApiUrl()) m.logApiUrl = box(nrLogApiUrl()) - m.bgTask.setField("eventApiUrl", config.proxyUrl + m.eventApiUrl) - m.bgTask.setField("logApiUrl", config.proxyUrl + m.logApiUrl) + m.metricApiUrl = box(nrMetricApiUrl()) + m.bgTaskEvents.setField("eventApiUrl", config.proxyUrl + m.eventApiUrl) + m.bgTaskLogs.setField("logApiUrl", config.proxyUrl + m.logApiUrl) + m.bgTaskMetrics.setField("metricApiUrl", config.proxyUrl + m.logApiUrl) end if end function @@ -828,7 +832,7 @@ function nrEventApiUrl() as String return "https://insights-collector.eu01.nr-data.net/v1/accounts/" + m.nrAccountNumber + "/events" else if m.nrRegion = "TEST" 'NOTE: set address hosting the test server - return "http://x.x.x.x:5000/event" + return m.testServer + "/event" end if end function @@ -839,18 +843,18 @@ function nrLogApiUrl() as String return "https://log-api.eu.newrelic.com/log/v1" else if m.nrRegion = "TEST" 'NOTE: set address hosting the test server - return "http://x.x.x.x:5000/log" + return m.testServer + "/log" end if end function -function nrMetricsApiUrl() as String +function nrMetricApiUrl() as String if m.nrRegion = "US" return "https://metric-api.newrelic.com/metric/v1" else if m.nrRegion = "EU" return "https://metric-api.eu.newrelic.com/metric/v1" else if m.nrRegion = "TEST" 'NOTE: set address hosting the test server - return "http://x.x.x.x:5000/metric" + return m.testServer + "/metric" end if end function diff --git a/components/NewRelicAgent/NRAgent.xml b/components/NewRelicAgent/NRAgent.xml index 504067d..62f5320 100644 --- a/components/NewRelicAgent/NRAgent.xml +++ b/components/NewRelicAgent/NRAgent.xml @@ -13,7 +13,7 @@ - + diff --git a/components/NewRelicAgent/NRTask.brs b/components/NewRelicAgent/NRTask.brs index 411015c..19f026e 100644 --- a/components/NewRelicAgent/NRTask.brs +++ b/components/NewRelicAgent/NRTask.brs @@ -44,17 +44,17 @@ function nrPushSamples(samples as Object, endpoint as String, sampleType as Stri end function function nrEventProcessor() as Void - m.nr.callFunc("nrLog", "-- nrEventProcessor --") + m.nr.callFunc("nrLog", "-- nrEventProcessor at URL " + m.eventApiUrl) nrSampleProcessor("event", m.eventApiUrl) end function function nrLogProcessor() as Void - m.nr.callFunc("nrLog", "-- nrLogProcessor --") + m.nr.callFunc("nrLog", "-- nrLogProcessor at URL " + m.logApiUrl) nrSampleProcessor("log", m.logApiUrl) end function function nrMetricProcessor() as Void - m.nr.callFunc("nrLog", "-- nrMetricProcessor --") + m.nr.callFunc("nrLog", "-- nrMetricProcessor at URL " + m.metricApiUrl) nrSampleProcessor("metric", m.metricApiUrl) end function @@ -89,10 +89,10 @@ function nrTaskMain() as Void 'Assuming that parent node is com.newrelic.NRAgent m.nr = m.top.getParent() m.apiKey = m.top.apiKey - m.eventApiUrl = m.top.eventApiUrl - m.logApiUrl = m.top.logApiUrl - m.metricApiUrl = m.top.metricApiUrl m.sampleType = m.top.sampleType + if m.eventApiUrl = "" then m.eventApiUrl = m.top.eventApiUrl + if m.logApiUrl = "" then m.logApiUrl = m.top.logApiUrl + if m.metricApiUrl = "" then m.metricApiUrl = m.top.metricApiUrl end if m.nr.callFunc("nrLog", "---- Running NRTask ---- " + m.sampleType) if m.sampleType = "event" @@ -103,4 +103,10 @@ function nrTaskMain() as Void nrMetricProcessor() end if m.nr.callFunc("nrLog", "---- Ended running NRTask ---- " + m.sampleType) +end function + +function onConfigUpdate() as Void + m.eventApiUrl = m.top.eventApiUrl + m.logApiUrl = m.top.logApiUrl + m.metricApiUrl = m.top.metricApiUrl end function \ No newline at end of file diff --git a/components/NewRelicAgent/NRTask.xml b/components/NewRelicAgent/NRTask.xml index 78a7c35..0508963 100644 --- a/components/NewRelicAgent/NRTask.xml +++ b/components/NewRelicAgent/NRTask.xml @@ -12,9 +12,9 @@ - - - + + + diff --git a/components/SearchTask.brs b/components/SearchTask.brs index a1479c8..5e5702b 100644 --- a/components/SearchTask.brs +++ b/components/SearchTask.brs @@ -22,7 +22,7 @@ function searchTaskMain() _url = box("https://www.google.com/search?source=hp&q=" + m.top.searchString) if Rnd(5) = 4 ' Generates an error - _url = box("https://www.google.com/shitrequest") + _url = box("https://www.google.com/wrongrequest") end if urlReq = CreateObject("roUrlTransfer") urlReq.SetUrl(_url)