Building Atlassian Connect add-ons with client-server frameworks like Express.JS and Play produces powerful add-ons, but requires hosting and database consideration. In contrast, "static" Connect add-ons are easier to write and far simpler to deploy. A static Connect add-on is simply a set of files (including an atlassian-connect.json descriptor) that are web accessible, either through a web server or via deployment to a CDN. Static add-ons have several advantages. First, infinite scalability. Why pay for CPU when you can let the user agent do the work? Second, simple persistence. Why pay for disk when you have local storage and JIRA & Confluence's persistence REST APIs? Third, extreme performance. Let a worldwide CDN serve your files from the nearest edge - it's literally impossible to compete with a static add-on when it comes to performance! Finally, easy caching. Why bother serving requests when your unchanged static files can be cached indefinitely with simple HTTP caching? In this talk I'll highlight the benefits and restrictions of static add-on architecture, and discuss the nuts and bolts of implementing a static add-on. I'll also show off the static add-on skeleton that will get your static add-on development off to a flying start.
34. include-all.js
function includeAll(callback) {!
// parse query parameters from web-panel iframe URL!
var host = getQueryParam(“xdm_e”);!
var contextPath = getQueryParam(“cp”);!
!
// construct URL targeting host application!
var allUrl = host + contextPath + “/atlassian-connect/all.js";!
!
// retrieve script asynchronously!
jQuery.getScript(allUrl, function () {!
// window.AP is now available !
// can now launch pop-ups, use REST APIs and interact with host UI!
callback(window.AP);!
});!
}
35. AP API
includeAll(function(AP) {!
! // use the REST API!
! AP.request({!
! ! url: “/rest/prototype/1/space/" + spaceKey + ".json?expand=rootpages”,!
! ! type: “GET”,!
! ! success: function(spaceJson) {!
! ! ! // parse root pages from space object!
! ! }!
! });!
! !
! // display messages!
! AP.messages.info(“Space Graph”, “Initializing Space Graph for ” + spaceKey);!
!
! // plus AP.events, AP.dialog, AP.cookie, etc.!
}
46. Storage Options
AP.cookie
Very fast (local)!
Scoped to the browser!
Size limited!
Temporary storage!
Use for user
preference, recent
history, etc.
Entity storage
Slower (ajax roundtrip)!
Scoped to the entity!
Size limited!
Permanent storage !
Use for annotating
issues or pages with
data
Backend
!
?
52. Hybrid Add-Ons
Browser HTML
CSS
JS
CDN
GET /resource
X-Domain
JavaScript API
Service A
Service B
?
?
• Persistence
• Authentication
• Email / IM
• 3rd party web services
• Other server-side stuff
53. Hybrid Add-Ons
Browser
• Real-time storage & sync
• Authentication
• Generous free dev plan (50 connections)
• Now with hosting / CDN
• Real-time storage & sync
• Authentication
• Self-hosted
• FOSS
• Real-time storage & sync
• Integration with 3rd party services:
Mailgun, Mandrill, SendGrid, Stripe,
Twilio
• Generous free dev plan (30 req / sec)