How to delete stored User Properties, Issue Properties etc. on Connect Addon Uninstall?

I tried to delete stored Issue properties using the “/uninstalled” lifecycle, and used app.post to inside my Index.js file. The following is the format of my request.

app.post(’/uninstalled’, addon.authenticate(), (req, res) => {

    let httpClient = addon.httpClient(req);
    let issue_key = ****;

    let options= {

        url: '/rest/api/3/issue/{issue_key}/properties/{property_key}',

        headers: {

            'X-Atlassian-Token': 'nocheck',

            'Accept' : 'application/json'

        }

    };

    httpClient.del(options,function(err, resp, body) {
        console.log(body);
    });

});

I’m getting the following error, after this request.
{“errorMessages”:[“Issue does not exist or you do not have permission to see it.”],“errors”:{}}

Similarly,
When I tried to delete stored User properties using the “/uninstalled” lifecycle, I’m getting the following error.
“{“message”:“Client must be authenticated to access this resource.”,“status-code”:401}”

I’m able to delete Addon Properties during /uninstall, but I’m not able to delete entity properties such as User, Issue, Project properties.
What is the actual way to delete stored entity-properties on uninstalling a connect-app??

Kindly help me with this! I’ve been stuck at this for a very long time! Any answers would be deeply appreciated!

Thanks in advance!

1 Like

Unfortunately, when you receive the uninstalled call, it’s already too late, your app doesn’t have access to Jira anymore.
Anyway, it’s not necessarily a good idea to delete data when an app is uninstalled, as it might be reinstalled right after and the customer is expecting to find existing data still present.

2 Likes

Thank you so much for your response @david2!

Can you suggest any other better ways to do this??

More Over, These data are app specific data! So ,If the user doesn’t install the app again. It would remain as a Junk data for a while in Jira.

Any suggestions on this??

Thank you in advance!

Nope. Sorry. My suggestion would be to either leave that data and not care, or store that data in your own database.

2 Likes

Thank you so much @david2 for taking your time to respond me. I appreciate it.

Data clean up is unfortunately a story that has not been solved yet. When should I be deleting a tenant's data?

3 Likes

Hi @BharathKumar,

I think @david2 and @danielwester have answered this well - thank you to both of you. If your app’s domain model is sound, then it should be reasonable for the data to remain attached to the various entities. That way, as @david2 indicates, if the app is re-installed then it can take advantage of data previously created. If, however, there is data that the app clearly needs to remove, then this may be an indication that you need to store the data somewhere that you will have access to after the uninstallation event is received.

Regards,
Dugald

2 Likes

I’d be interested to hear more on particular examples of scenarios where customers would expect that entity properties are deleted with the corresponding app. I’d imagine this wouldn’t always be the expected or desired behavior?

Would be helpful to know since as @dmorrow has called out, storing your data remotely is the workaround right now, but we’re also working on better hosted storage over the coming year and that team (@HeyJoe, @MichaelOates) may benefit from the info :slight_smile: