@mert sorry for the delay. Another option would be to use the Service that is injected into the context like this:
const dataSourceService = services.dataSourceService;
const ip = dataSourceService.get('xid');
Also here is a collection of example scripts for the new environment and a few for the legacy one:
https://github.com/infiniteautomation/script-examples