Device Storage
Last updated
if (!(await zw.deviceStorage.has("machine_id"))) {
await zw.deviceStorage.set("machine_id", "M1234");
}// @zw-run-locally
const credentials = {
username: await zw.deviceStorage.get("username_salesforce"),
password: await zw.deviceStorage.get("password_salesforce"),
};
// Get the active page and enter credentials programmatically
// Alternatively, use zw.deviceStorage.* directly in no-code blocks
const page = await zw.browserContext.getActivePage();
await page.goto("https://login.salesforce.com/");
await page.type("#username", credentials.username);
await page.type("#password", credentials.password);// Get an object mapping keys to string values
const all = await zw.deviceStorage.getAll();
await zw.log("deviceStorage keys", Object.keys(all));
const keys = Object.keys(all);
for (const key of keys) {
await zw.deviceStorage.remove(key);
}// Save an object (stringify on write)
const runMeta = {
machineId: "M1234",
lastRunAt: Date.now(),
lastProcessedInvoiceId: "INV-2026-00127",
};
await zw.deviceStorage.set("billing_bot_state", JSON.stringify(runMeta));
// Read it back (parse on read)
const raw = await zw.deviceStorage.get("billing_bot_state");
const parsed = raw ? JSON.parse(raw) : null;const secret = await zw.deviceStorage.get("some_secret");
// β
Good: Visible in live logs only (not saved to run reports)
await zw.logTemp(secret);
// π« Avoid: Saved to TaskBot run reports
await zw.log(secret);// π« Won't work
const someValue = zw.deviceStorage.get("someKey"); // missing await
// β
Works
const someValue = await zw.deviceStorage.get("someKey");