/installed under index.js

Hi,

I would like to add some custom tracking code when someone installs my addon. I tried placing code on the app get installed and it doesn’t show anything. Seems this route is there but not actually used?

// Add route for installed response! I think it is native this one is not used
app.get('/installed', function(req, res) {
    res.status(200);
});

How can I add code when the /installed runs?

Thanks
Joao

Hello @joao.correia1,

The lifecycle events are POST requests to the registered URLs. Can you try the code snippet below if it suits your use case?

app.post('/installed', function(req, res) {
    console.log("Installed lifecycle");
    console.log(req);
    res.send(200);
});

Cheers,
Ian

1 Like

Thank you @iragudo this worked perfectly!

Well it works but it breaks the registration. I get:

Failed to register with host https://xxxxxx@xxxxxx-dev.atlassian.net/wiki
Add-on installation timed out
Add-on not registered; no compatible hosts detected

Any ideas?

Thanks
Joao

I have not experienced that error, can you paste the code snippet on how you handled the POST to the installed URL? Also, were there any other stack trace / details aside from Add-on installation timed out?

Well it works but it breaks the registration

When in doubt, you can read atlassian-connect-express (ACE) source code to see how the /installed endpoint should be handled:
https://bitbucket.org/atlassian/atlassian-connect-express/src/f7867a013d3ca034b1962bae8990bd8496e6ded0/lib/index.js#lines-135

2 Likes