Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×So the problem here is that i want tp capture the useragent String value when i open the issue in the browser , let alone make any changes .For it i have created the scripted field which captures the value
According to my understanding the value of the user agent is only captured from the HTTP request which is sent to the server when any changes are made to it . But is it possible to get the user agent value only by opening the issue on the browser or when just refreshing the browser , If possible can you please how to do it
Hi @acc1211
You can try with HttpContext.getRequest() to capture the browser user agent. For example, using the following script on the scripted field to display the user agent when user view the issue on different web browsers:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.sal.api.web.context.HttpContext
def httpContext = ComponentAccessor.getComponent(HttpContext)
def request = httpContext.getRequest()
if (request) {
return request.getHeader("user-agent")
}
Google Chrome:
Firefox:
I hope this helps.
Hi @acc1211
You can capture request with com.atlassian.sal.api.web.context.HttpContext package. For example, test this script via Script Console:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.sal.api.web.context.HttpContext
def httpContext = ComponentAccessor.getComponent(HttpContext)
def request = httpContext.getRequest()
if (request) {
log.warn request.getHeader("user-agent")
}
You will get the user agent information from the Logs tab. Its the same apply in the scripted field. I hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.