Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,362,135
Community Members
 
Community Events
168
Community Groups

Opening Issue in Browser

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 

2 answers

1 accepted

0 votes
Answer accepted

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:

Screenshot 2021-03-22 at 4.20.11 PM.png

Firefox:

Screenshot 2021-03-22 at 4.20.45 PM.png
I hope this helps.

0 votes

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.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events