How to get uninstalled event fired when uninstalling the atlassian connect addon ?

Diso Dev January 23, 2017

 

Hi

Based on this Blog i implemented in my index.js the following code see below.

https://developer.atlassian.com/hipchat/tutorials/getting-started-with-atlassian-connect-express-node-js

 

addon.on('host_settings_saved', function (clientKey, settings) {
    console.log('host_settings_saved');  //<-- OK
});

addon.on('installed', function(clientKey, clientInfo, req){
    console.log('installed');  //<-- NOT OK
});

addon.on('uninstalled', function(clientKey, clientInfo, req){
    console.log('uninstalled'); //<-- NOT OK
});

 

The Connect Addon Descriptor looks like that:

"lifecycle": {
    "installed": "/installed",
    "uninstalled": "/uninstalled"
},

 

After the installation of the addon i get this terminal log with http status code 204:

POST /installed?user_key=12345 204 45.760 ms

 

But during the uninstall-process i get a terminal log with http status code 404:

POST /uninstalled?user_key=12345 404 23.576 ms

 

Why the eventlistener doesn't work for the uninstall eventType?

 

Thank you & Regards

 

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
James Hazelwood
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 23, 2017

Hi Lutz,

addon.on registers listeners for events raised by the addon object. It doesn't emit any events called uninstalled or installed. The installed / uninstalled lifecycle webhooks are a completely different mechanism, and you hook into those by registering routes on the app. The atlassian-connect-express library does this for /installed which is why you can see a 204 for that one. To register your own:

app.post('/uninstalled', addon.authenticate(), function (req, res) {
	...
});

Hope that helps,

James

Diso Dev January 23, 2017

Thank you. Works perfect!

TAGS
AUG Leaders

Atlassian Community Events