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.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Opening Issue in Browser

acc1211
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 2, 2021

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

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
John Chin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 22, 2021

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.

1 vote
John Chin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 22, 2021

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.

TAGS
AUG Leaders

Atlassian Community Events