SDAPI Breakpoints 2.0
A breakpoint represents a location in a script file. When the script engine is evaluating a script file, the engine queries the script debugger to determine if the current location represents a breakpoint. If it does represent a breakpoint, the engine halts the script thread at the breakpoint location; otherwise, the engine continues. For each line in the script file, the engine queries the script debugger to determine if the current location represents a breakpoint.
When you create breakpoints, you must specify the full path to the script file in the context of the containing cartridge module.
You can optionally set a 'condition expression' when creating a breakpoint. When evaluating a breakpoint, the engine honors the breakpoint if the 'condition expression' evaluates to 'true'.
The following examples show how you can create breakpoints, get breakpoints, and remove breakpoints.
Example 1: Create Breakpoints
REQUEST:
POST /s/-/dw/debugger/v1_0/breakpoints
{
"breakpoints":
[
{
"line_number":18,
"script_path":"/app_storefront_controllers/cartridge/controllers/Cart.js"
},
{
"line_number":25,
"script_path":"/app_storefront_controllers/cartridge/scripts/models/CartModel.js"
}
]
}
RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"_v":"2.0"
"breakpoints":
[
{
"id":1,
"line_number":18,
"script_path":"/app_storefront_controllers/cartridge/controllers/Cart.js"
},
{
"id":2,
"line_number":25,
"script_path":"/app_storefront_controllers/cartridge/scripts/models/CartModel.js"
}
]
}
Example 2: Create conditional Breakpoints
REQUEST:
POST /s/-/dw/debugger/v1_0/breakpoints
{
"breakpoints":
[
{
"condition":"product.isOnline() == true",
"line_number":18,
"script_path":"/app_storefront_controllers/cartridge/controllers/Cart.js"
},
{
"condition":"product.isOnline() == true",
"line_number":25,
"script_path":"/app_storefront_controllers/cartridge/scripts/models/CartModel.js"
}
]
}
RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"_v":"2.0"
"breakpoints":
[
{
"condition":"product.isOnline() == true",
"id":1,
"line_number":18,
"script_path":"/app_storefront_controllers/cartridge/controllers/Cart.js"
},
{
"condition":"product.isOnline() == true",
"id":2,
"line_number":25,
"script_path":"/app_storefront_controllers/cartridge/scripts/models/CartModel.js"
}
]
}
Example 3: Get breakpoints (no breakpoint identifer)
REQUEST:
GET /s/-/dw/debugger/v1_0/breakpoints
RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"_v":"2.0"
"breakpoints":
[
{
"id":1,
"line_number":18,
"script_path":"/app_storefront_controllers/cartridge/controllers/Cart.js"
},
{
"id":2,
"line_number":25,
"script_path":"/app_storefront_controllers/cartridge/scripts/models/CartModel.js"
}
]
}
Example 4: Get breakpoints with breakpoint identifer
REQUEST:
GET /s/-/dw/debugger/v1_0/breakpoints/1
RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"_v":"2.0"
"id":1,
"line_number":18,
"script_path":"/app_storefront_controllers/cartridge/controllers/Cart.js"
}
Example 5: Remove All Breakpoints
REQUEST:
DELETE /s/-/dw/debugger/v1_0/breakpoints/
RESPONSE:
HTTP/1.1 204 No Content
Content-Length: 0
Example 6: Remove a Single Breakpoint
REQUEST:
DELETE /s/-/dw/debugger/v1_0/breakpoints/1
RESPONSE:
HTTP/1.1 204 No Content
Content-Length: 0