sentry-electron: Can't configure Sentry for a Figma plugin code (running inside an Electron isolated context)
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Electron SDK Version
Unknown, I’m using Figma 116.9.6
Electron Version
22.3.5
What platform are you using?
MacOS
Link to Sentry event
No response
Steps to Reproduce
I’m not that familiar with Electron, but simply importing a sentry package on the code side of my Figma plugin breaks Figma itself.
This documentation page has an explanation on how plugins run inside of Figma.
I had no problems setting up Sentry on the UI part of the plugin which runs inside an iframe.
Here’s my rollup config that builds the code that runs on the ssandbox:
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "@rollup/plugin-typescript";
import { sentryRollupPlugin } from "@sentry/rollup-plugin";
export default [
// CODE.JS
// The part that communicates with Figma directly
// Runs in a sandboxed environment (isolated context in electron)
// with no access to Node, the DOM, or any of the node/browser APIs
{
input: "src/code/init.ts",
output: {
file: "dist/code.js",
format: "iife",
name: "code",
sourcemap: true,
},
plugins: [
typescript(),
resolve({
browser: true,
moduleDirectories: ["node_modules"],
}),
commonjs({ transformMixedEsModules: true, typescript: true }),
// production && terser(),
// Put the Sentry rollup plugin after all other plugins
sentryRollupPlugin({
org: "toki-labs",
project: "cva-code",
// Auth tokens can be obtained from https://sentry.io/settings/account/api/auth-tokens/
// and need `project:releases` and `org:read` scopes
authToken: "xxxxxxxxxxxx",
})
],
}
]
Expected Result
Figma does not crash and errors are sent to Sentry
Actual Result
Here’s the error I’m getting:
00:24:17.803 figma_app.min.js.br:5 Error: Syntax error on line 2380: Unexpected token ...
at sHo (figma_app.min.js.br:1628:98)
at async figma_app.min.js.br:1758:6222
(anonymous) @ figma_app.min.js.br:5
vef @ figma_app.min.js.br:1758
await in vef (async)
(anonymous) @ figma_app.min.js.br:1758
(anonymous) @ figma_app.min.js.br:1758
runLastPlugin @ figma_app.min.js.br:2409
_FigmaApp_runLastPlugin @ compiled_wasm.js.br:2
$wasm-function[12721] @ compiled_wasm.wasm.br:0xa5d952
$wasm-function[19997] @ compiled_wasm.wasm.br:0xc1b6a8
$wasm-function[1022] @ compiled_wasm.wasm.br:0x21a75
$wasm-function[18831] @ compiled_wasm.wasm.br:0xbfea0a
$wasm-function[8628] @ compiled_wasm.wasm.br:0x662bca
$wasm-function[29734] @ compiled_wasm.wasm.br:0xfd09e1
$wasm-function[3412] @ compiled_wasm.wasm.br:0x1a2cc7
$wasm-function[26663] @ compiled_wasm.wasm.br:0xd6f638
(anonymous) @ compiled_wasm.js.br:2
wrappedCallback @ compiled_wasm.js.br:2
r @ figma_app.min.js.br:16
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 19 (6 by maintainers)
Here you go @iamtekeste
what was missing:
sourcemapshould be set to"inline"keepNames: trueto show original function names when minifying (optional)Some extras (just for fun):
--show-configoption you can pass tobuild-figma-pluginto show build configesbuild.base.configto share common config options among main and uiesbuild.mergeConfigs.jsto merge all config objects (CFP <|-- base.config <|--build-figma-plugin.(main|ui).js)--esb-*CLI options so any esbuild option in the root level can be overridden via command linebuild,build:with-maps,build:show-config, andwatchRemember to enable the Developer VM!
Here’s the PR with the changes
And if you want to debug in VS Code navigating through the original code, read this article I wrote a while ago
Hey @iamtekeste,
This is a wild guess, but looking at the result you are getting from stacktracify, I think you are missing source maps. Here’s why:
Method
ewas correctly unminified torender, so the source maps for your code is there. But methods from packages were not. You may want to check what’s in your source map using thesource-mappackage or by modifying thestacktracifycode to log some stuff, e.g. by uncommenting this line to show the source content.There are too many variables to list. E.g. what bundler are you using, are you using IIFE, are the source maps embedded in the files, etc. So, if you want (and can) to create a repo and share your files (or some demo files) all take a look at it. I’ve already created a Figma test runner and an RPC lib that will be part of @figma-plugin-sdk, and I think adding production debug helpers would be an awesome addition.
Btw, If Sentry wants to sponsor it, I can make a
sentry-figma-pluginpackage instead of a generic one XD@svallory amazing work, this going to improve my debugging workflow by a lot! Hit me up whenever you setup your sponsorship page so I can contribute a little bit.
Hey, @iamtekeste! I’m so sorry. I don’t know how I missed your response. Are you still having issues with the sourcemaps? I’ll take a look at your repo now
@AbhiPrasad I never pinged you because the monitoring got sent back to backlog and launching v2 was more important. We’ll launch it this week though, so I’ll ping you now
Subscribing to this thread, as I’d also like to see a sentry package for Figma plugins.
We should try to see if we can get someone from figma to help here. @iamtekeste I’m fairly certain the issue is also with sourcemaps. Sentry has a guide for verifying if sourcemaps are working, you can follow this part of the Sentry docs for it.
@svallory were you able to get the discord going okay? still available there to chat!
As an aside:
We do offer sponsorships for open source projects (gave away 500k recently)!
Happy to ask to get your name/GH org added to our yearly fund for the extra help here!