04 Jul 2025 11:13 AM
Hi,
I am curious if it's possible to debug app functions with breakpoint pauses.
So far, when I try to fix something that's not working, either I deploy a test version of my app function to dyna could, then call it, and try to make sense of the logs, or run it locally with jest. But in the latter case, I can't call dynatrace callbacks, as when executed with yest, the client library is not initialized.
Ok, I can mock, but the whole point would be to debug with live data.
Any suggestions?
Thanks,
Zoltan
this is an example I want to call and step by step debug:
04 Jul 2025 12:07 PM
Hi Zoltan,
If you created the project through the dt-app CLI you should have a .vscode/launch.json file that includes debugging settings. By running that configuration you can debug your app function using breakpoints
11 Sep 2025 09:56 AM
Hi Dani,
Indeed, it works as you described (on a note - I had my project generated way back, where the launch.json generated didn't have this run config.
Also, what was confusing a bit was that the breakpoint is only shown as active during a request. When you set it, it appears as to be inactive - don't know why, perhaps it's my vs code setup...
While we are here one more question:
How do I pass the payload param to the function via a plain http request? Can't find an example in the docs.
Is the json post body what becomes the payload param of the function?
export default async function (payload: unknown = undefined)
Thanks,
Zoltan
15 Sep 2025 11:00 AM
Yes, it should be the body. Using the fetch command it's something like this
const method = options?.data ? 'POST' : 'GET';
const body = options?.data ? JSON.stringify(options.data) : undefined;
const response = await fetch(`/api/${functionName}`, { body, method });