Building a Connect Add-on: Lessons Learned

Dmitry Pashkevich

Lucidchart for JIRA Cloud

Tip #1: Blend in

Blend in

Blend in

AUI

  • Dialogs
  • Notifications
  • Forms
  • Icons
  • ...

  • Keyboard shortcuts




  • Helper functions


  • Use your own front-end template engine
AJS.whenIType('ze').execute(function () {
    alert('I have executed.');
});
AJS.whenIType('c').click('#create');
AJS.whenIType('gh').or('gd').goTo('http://example.com/');
AJS.whenIType('n').moveToNextItem('.selector');
AJS.whenIType('p').moveToPrevItem('.selector');
AJS.log("Panel initialized.");
AJS.format("Have a {0} day", "good"); 
AJS.$('#confirmPrompt').hide();

Tip #2: You're not the boss

You are a user

Test with non-admin users

Handle non-200 responses

lucidAc.jira.listAttachments(
    ISSUE_ID
).done(function(responseText) {
    // got a successful response,
    // render diagram attachments panel...    
}).fail(function(xhr, message, error) {
    // show error message to the user
    apMessages.error(
        'Lucidchart Diagrams',
        'Failed to load attachments. Error thrown: ' + error
    );

    // log extra details in the console
    AJS.error(
        "Lucidchart",
        "Failed to load attachments at " + attachmentsUrl,
        message,
        error,
        xhr.responseText
    );
});

Add-on is also a user

Server-side calls also fail

val attachmentEither = client.addAttachment(/* ... */)

attachmentEither.fold(
  errorResponse => {
    val statusCode = errorResponse.statusCode
    
    logger.error(
      "Failed to create attachment. Response from JIRA server (consumerKey=%s, status='%d'): "
        .format(consumerKey, statusCode)
    )

    if(statusCode == 401 || statusCode == 403) { 
      // Unauthorized - most likely problems with addon user permissions
      InternalServerError("Failed to create attachment, check add-on user permissions...")
    } else if (errorResponse.body.contains("exceeds its maximum permitted size")) {
        // Hit attachment size limit...
        InternalServerError("Unable to create attachment. Size limit is exceeded, ...")
    } else {
      InternalServerError("Unknown error. Please try again")
    }
  },
  attachmentList => {
    Ok(/* ... */).as("text/json")
  }
)

Proactively check for permissions

Tip #3: Be the community

Thanks!

Q: Permissions cocktail

Building a Connect Add-on: Lessons Learned

By dpashkevich

Building a Connect Add-on: Lessons Learned

In this presentation I shared the lessons I learned while building a successful Atlassian Connect add-on.

  • 1,225