How do I track errors or send custom metrics in my UI Kit app (solution inside)

Hi, Forge developers!

Firstly, this is not an official announcement but rather a knowledge sharing blog post. Our team is now actively working on monitoring and metrics for Forge apps. However, there’s not much you can do right now if you want to track errors or send custom metrics if your app is built using UI Kit. I faced the same problem when I tried to build a simple Forge app to display if any changes have been made since I visited the page last time.

I am a big fan of Sentry. On top of this, we use Sentry in Atlassian for our products so the solution came naturally: I should just add Sentry SDK for Node.JS to my app code and things will “just work”. However, it wasn’t so smooth: Sentry code was failing because its SDK expects standard Node.JS environment whereas functions in UI Kit are executed in a special sandbox which doesn’t support all Node.JS features.

I started looking into this direction and found a solution: Sentry supports “transports” which are essentially a way to specify how the data is sent to Sentry. So I built a custom Forge transport for Sentry. It was a rocky path but this transport is now published and you can use it in your UI Kit apps!

Of course, there are some other restrictions so your Sentry setup should be a bit special. I have made the code for my app Confluence recent edits overview public so you can see how I do this in my app - check out the repo.

I will work with Sentry developers to put the documentation about using this custom transport to Sentry docs but in the meantime, feel free to use this transport for your UI Kit apps. And feel free to report any bugs in this thread.

7 Likes