Dashboard background scripts not loading with Atlassian Connect

I’m trying to get background scripts to work for Jira Dashboards with Atlassian Connect.

I’ve set a permitted location.type as documented here.

I have the following atlassian-connect.json

{
    ...
    "jiraBackgroundScripts": [
      {
        "url": "/background/issue_view", 
        "location": {
          "type": "issue_view",
          "shouldReloadOnRefresh": true
        },
        "key": "background-script-issue-view"
      },
      {
        "url": "/background/dashboard", 
        "location": {
          "type": "dashboard",
          "shouldReloadOnRefresh": true
        },
        "key": "background-script-dashboard"
      }
    ],
    ...
}

Both locations should render this rather imaginative cachable HTML:

<html>
<body>
  You can't see me. I'm in the background.
  <script>
    console.log("🔥 background script fired", location.pathname);
  </script>
</body>
</html>

The issue_view backgroundScript loads whenever I view an issue, but the dashboard one does not load when I view a dashboard.

Whats the secret magic that I am missing here?

I know that adding request parameters onto the url prevents things from working. Am I missing something here? Can anyone show me an example that works?

Cc: @mszpyra @dmorrow

Hi @david ,

I can’t see anything wrong with your code. I’ve created this Glitch app which reproduces the issue. I’ve also contacted an engineering team to investigate and I’ll get back to you when there is something to report.

Regards,
Dugald

1 Like

@dmorrow Thank you. I look forward to a response from the engineering team :upside_down_face:

@dmorrow talking with other marketplace partners, it seems that if your app contains dashboards, then the background script is only loaded for the dashboards within your app.
It is not loaded for other dashboards.

Whereas, background scripts for the issue_view location will load for all issue views as there is no inclusion criteria.

This means that the behaviour of the background script is very different for the dashboard location compared with the issue_view location.

My intention and assumption was for the background script to load on every single dashboard view.

It seems that the extension point has not been designed in that manner. :cry:

Also, if the dashboard is part of the app anyway, likely it wouldn’t even need a background script because the dashboard could just contain the logic instead. :thinking:

Thanks for the update @david. That behaviour / limitation isn’t described in the documentation either. The team I contacted are still looking into this, so I will let them know of this discovery and ask them what it would take to enable background scripts to run on any dashboard.

1 Like

Hi @david ,

The engineering team have raised an issue for this. Unfortunately the issue isn’t publicly visible, but I’ll share it here so it can be referenced anyway;- ARKEN-1061: Let dashboard background scripts to render without a need to have a gadget present.

Regards,
Dugald

3 Likes

Thanks for the update @dmorrow. It’s great that this is seen as an issue.

Will there be any public visibility on this? Maybe an issue in each of the AC & Forge projects that links to the ARKEN-1061?

How can others vote on this?

2 Likes

Hi @david we have created background scripts on dashboards help gadgets to communicate to each other. What is the issue you are trying to solve, could you share more context and use case?

1 Like

Hi @JakubMierzewski

We currently have a feature request from some customers of our Google Analytics in Jira & JSM app where they want to be able to assess the validity and usefulness of each dashboard used within their Jira instance. The dashboard background script would therefore be the perfect way for us to achieve this if it was implemented as the documentation suggests.

We already use background scripts on issues to track usage of all the issues screens within Jira, so adding analytics of dashboards seems to be a natural extension of functionality for our app.

Ideally, we would love to be able to use a atl.footer location just like in Confluence, but this location was removed for cloud, so we are grabbing hold of any locations we can, hence the need for the dashboard background script to work whether our app has a dashboard, or not.

This request isn’t just for us. Other vendors are already using the dashboard background script location but without knowing that it’s only loaded when their app also has a dashboard present.

Further, I’d say that the logic for loading background scripts is currently inconsistent between the issue_view and dashboard locations and therefore the approach should be standardised. It is likely trivial for an app vendor to check whether the current dashboard is part of their app, so the change in behaviour would not cause major problems for existing apps.

2 Likes

Thanks, @david. It all makes sense. We will analyze it and come back to you

Hey @JakubMierzewski, any news on this?

Hey @JakubMierzewski, any news on this?

Hey @JakubMierzewski, any news on this?

Hey @JakubMierzewski, any news on this?

Cc: @dmorrow

@david, please accept my apologies. I forgot to get back to you and overlooked your multiple requests for an update. The target solution is to have background scripts on all pages. Please vote for this ticket. We are gathering interest here.

Maybe we can do a simpler Fix for Forge for your specific case. I can’t prioritize it and add it to the roadmap. But I have added it to the list of ideas for Innovation Week, and I will try to convince one or two developers to engage. I will let you know if we start development. I can’t promise any date.

@JakubMierzewski thanks for getting back to me :raised_hands:

The app I really want to use this in is based on Atlassian Connect. Is there an issue for that too?