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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,556,729
Community Members
 
Community Events
184
Community Groups

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.
Mar 02, 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

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.
Mar 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.
Mar 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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events