Using Storage API with uiKit APP

Hello Community,

I’m discovering the confluence integration, and I need to build an app that combines 3 elements:

  • confluence:globalSettings to store some app params using Storage API.
  • macro and its MacroConfig.

I have created a uiKit application as the MacroConfig is not supported by the CustomUI apps, in the other side I can’t implement resolver to load and save parameters.

when deploying I have this issue.

Error: Error thrown in the snapshot context.

App code snapshot error: Snapshot error occurred: Error: window is not defined
Learn more about the snapshot context at https://go.atlassian.com/forge-snapshot-context.

Can you please advise ?

Welcome to the Atlassian Developer Community, @MarouaneMAJID!

In order to get better context, can you share a code snippet on how you implemented your resolver as well as the relevant manifest sections?

I’ve seen a similar error in the past when I called @forge/bridge’s requestConfluence inside my resolver – do let us know if this is indeed the case.

To help you build your Macro UI Kit app and ensure that it is all set up correctly, you can reference this tutorial.

Cheers,
Ian

1 Like

Hi Ian,
Thanks you for the reply, sure Here is the resolver code

import Resolver from "@forge/resolver";
import { storage } from '@forge/api';

const resolver = new Resolver();

resolver.define("saveSetting", (payload) => {
    storage.set('config', payload);
    return { status: `config Saved!` };
});


resolver.define("loadSetting", ({}) => {
    var config = storage.get('config').then( (r)=> {return r})
    return config;
});


export const handler = resolver.getDefinitions();

the manifest

modules:
  macro:
    - key: mmd-test-hello-world
      function: main
      title: MMD_Test
      description: Inserts Hello world!
      config:
        function: config
  confluence:globalSettings:
    - key: mmd-test-global-settings-hello-world
      function: settings
      title: MMD_Test
      description: A hello world global settings.
      resolver:
        function: storage
  function:
    - key: main
      handler: index.run
    - key: config
      handler: index.config
    - key: settings
      handler: settings.run
    - key: storage
      handler: storage.handler
app:
  id: ari:cloud:ecosystem::app/332f7699-ec0c-4949-9b23-73f0d37b6fa4
  runtime:
    snapshots: false
permissions:
  scopes:
    - storage:app

Hi @MarouaneMAJID,

I tried following the same approach you did wherein I called the Storage APIs in a resolver and it is working as intended. How did you isolate the issue with Storage API?

Cheers,
Ian

Hi @ianRagudo,
thanks for the reply, We have solved the issue by creating a new customUI app rather than uiKit, I’ll mark your answer as Solution maybe updating forge resolved the problem.