App lifecycle methods
Rocketlane exposes lifecycle hooks that allow your app to respond to key events during its installation and removal. These methods enable you to handle setup tasks, perform cleanups, or trigger workflows when a user installs or uninstalls your app.
Information pointThese lifecycle methods should be defined in the
eventHandlers
object inside your app’s index.js file.
Available Lifecycle Events
onAppInstall
Triggered immediately after a user installs your app from the Marketplace.
Use cases:
- Initialize default settings
- Register webhooks
- Sync starter data
- Log install metrics
Signature:
onAppInstall: {
run: async (r, args) => { ... }
}
Parameters:
r
– Rocketlane SDK runtime contextargs
– contains:installationId
: unique ID for the installed appconfig
: user-provided installation config valuescontext
: metadata like account ID, user ID, etc.
onAppUninstall
Triggered when the app is removed from a workspace.
Use cases:
- Cleanup data or revoke access
- Deregister webhooks
- Clear background jobs
- Log uninstall analytics
Signature:
onAppUninstall: {
run: (r, args) => { ... }
}
Parameters:
r
– Rocketlane SDK runtime contextargs
– contains:installationId
: the app instance being uninstalledcontext
: metadata related to the uninstalling user/account
Example
eventHandlers: {
onAppInstall: {
run: async (r, args) => {
const { installationId, config, context } = args;
console.log("App installed:", installationId);
// Setup logic goes here
}
},
onAppUninstall: {
run: (r, args) => {
const { installationId, context } = args;
console.log("App uninstalled:", installationId);
// Cleanup logic goes here
}
}
}
Updated about 1 month ago
What’s Next