10 KiB
SAC Debugging and Browser Tools Reference
Complete guide for debugging Analytics Designer scripts using browser developer tools.
Table of Contents
- Console Logging
- Browser Debugging
- Debug Mode
- Breakpoints
- Script Editor Tools
- R Visualization Debugging
- Performance Logging
- Common Issues
Console Logging
The primary debugging method using console.log().
Basic Usage
var nth = 1;
console.log("Hello World, " + nth.toString());
// Output: Hello World, 1
Logging Objects
// Log complex objects
var selections = Chart_1.getSelections();
console.log(selections);
// Log data source variables
var ds = Chart_1.getDataSource();
console.log(ds.getVariables());
// Log member info
var members = ds.getMembers("Location", 5);
console.log(members);
Viewing Console Output
- Run the analytic application
- Press F12 or Ctrl+Shift+J to open Developer Tools
- Go to Console tab
- Filter by "Info" type if needed
- Expand
sandbox.worker.main.*.jsentries for your logs
Note: Scripts are stored as minified variables and aren't directly debuggable in the console. Use console.log() to inspect values.
Browser Debugging
Detailed steps for debugging Analytics Designer scripts in Chrome browser.
Note: Analytics Designer supports debugging only in Chrome browser.
Note: Scripts are transformed before execution, so they won't look exactly like the code in the script editor.
Note: Scripts must run at least once in the current session to appear in dev tools.
Script Naming Convention
Analytics Designer scripts follow a specific naming pattern:
- Folder:
<APPLICATION_NAME> - Script:
<WIDGET_NAME>.<FUNCTION_NAME>.js
Example:
- Application:
My Demo Application - Widget:
Button_1withonClickevent - Script name:
Button_1.onClick.js - Folder:
My_Demo_Application
Note: Special characters (except - and .) are replaced with underscore (_).
Find Script by Name (Quick Method)
- Press F12 to open Developer Tools
- Press Ctrl+P
- Start typing part of the script name (e.g.,
Button_1.on) - Select from the list
Find Script by File Tree
- Press F12 to open Developer Tools
- Select Sources tab
- Open node starting with
sandbox.worker.main - Open AnalyticApplication node
- Find folder with your application name
- Scripts executed in current session appear here
File Tree Structure:
sandbox.worker.main.js
└── AnalyticApplication
└── My_Demo_Application
├── Application.onInitialization.js
├── Button_1.onClick.js
└── ScriptObject_1.returnText.js
Debug Mode
Enable enhanced debugging features with debug mode.
Enabling Debug Mode
Append ;debug=true to the application URL:
[https://your-tenant.sapanalytics.cloud/app.html?story=STORY_ID;debug=true](https://your-tenant.sapanalytics.cloud/app.html?story=STORY_ID;debug=true)
Debug Mode Features
- debugger; statement support: Pause execution at specific lines
- Comment preservation: Comments in scripts are kept in transformed code
- Script name suffix: Scripts get
-dbgsuffix (e.g.,Button_1.onClick-dbg.js)
Using debugger; Statement
With debug mode enabled, add debugger; to pause execution:
/*
* This is a block comment
*/
// Debug point
debugger;
// This is a comment
return Text_1.getPlainText();
Advantages over breakpoints:
- Define pause location while writing code
- Don't need to find script in dev tools first
- Persists across sessions
Breakpoints
Set breakpoints to pause script execution at specific lines.
Setting a Breakpoint
- Open Developer Tools (F12)
- Navigate to your script in Sources tab
- Click on the line number where you want to pause
- A blue marker appears on that line
Multiple Breakpoints
Add several breakpoints to pause at different points:
- Each clicked line number gets a blue marker
- Script pauses at each breakpoint when executed
Removing a Breakpoint
Click on the blue marker to remove it.
Execution Controls
When paused at a breakpoint:
| Button | Action |
|---|---|
| Resume (F8) | Continue execution |
| Step Over (F10) | Execute current line, move to next |
| Step Into (F11) | Enter function call |
| Step Out (Shift+F11) | Exit current function |
Inspecting Variables
While paused:
- Hover over variables to see values
- Use Scope panel to see all variables
- Use Watch panel to track specific expressions
- Use Console to evaluate expressions
Script Editor Tools
Built-in debugging features in the Analytics Designer script editor.
Errors and Warnings
The Info panel displays validation results:
- Open Info panel at bottom of designer
- Click Errors tab
- Search or filter (errors only, warnings only, both)
- Double-click error to open script and jump to location
Visual Indicators:
- Red underline: Error
- Orange underline: Warning
- Red marker: Error at line number
- Orange marker: Warning at line number
Find References
Find all places where a widget or scripting object is used:
- Right-click object in Outline
- Select Find References
- Results appear in Reference list tab of Info panel
Renaming with Refactoring
When you rename objects, all references update automatically:
Renamable Objects:
- Widgets
- Gadgets
- Script variables
- Script objects
- Script object functions
- Function arguments
Renaming Methods:
-
Via Outline:
- Select object in Outline
- Click ... (More) button
- Select Rename
- Enter new name
-
Via Styling Panel:
- Select object in Outline
- Enter new name in Name field
- Click Done (for script objects)
-
Function Arguments:
- Select script object function
- Click Edit button for argument
- Enter new name
- Click Done
R Visualization Debugging
Debug R scripts and their JavaScript integration.
R Widget Runtime Environments
R widgets have two separate environments:
- R environment: Server-side, in R engine
- JavaScript environment: Browser-side, with other widget scripts
Execution Order
On Startup:
- R script runs
onResultChangedJavaScript event does NOT run (initial state)
On Data Change:
- R script runs first
onResultChangedJavaScript event runs
Reading R Environment from JavaScript
// R script creates: gmCorrelation <- cor(grossMargin, grossMarginPlan)
// JavaScript reads the value
var nCor = this.getEnvironmentValues().getNumber("gmCorrelation");
var sCor = nCor.toString();
console.log("Margin Correlation: " + sCor);
Writing to R Environment from JavaScript
// Set R environment variable from JavaScript
RVisualization_1.getInputParameters().setNumber("userSelection", 0);
Available Methods
Reading:
getEnvironmentValues().getNumber(variableName)getEnvironmentValues().getString(variableName)
Writing:
getInputParameters().setNumber(variableName, value)getInputParameters().setString(variableName, value)
Performance Logging
Enable detailed performance tracking for optimization.
Enabling Performance Logging
Add URL parameter:
?APP_PERFORMANCE_LOGGING=true
Viewing Performance Data
In browser console:
// Get all performance entries for the application
window.sap.raptr.getEntriesByMarker("(Application)")
.filter(e => e.entryType === 'measure')
.sort((a,b) => (a.startTime + a.duration) - (b.startTime + b.duration));
Performance Entry Properties
| Property | Description |
|---|---|
name |
Operation name |
entryType |
Entry type (measure, mark) |
startTime |
Start timestamp |
duration |
Execution time in ms |
Common Issues
Script Not Appearing in Dev Tools
Problem: Can't find script in Sources tab.
Solution: Script must run at least once. Trigger the event (click button, select chart, etc.) then refresh dev tools.
Breakpoint Not Hit
Problem: Breakpoint set but execution doesn't pause.
Solution:
- Ensure script is for the correct event
- Check if the event actually triggers
- Try using
debugger;statement instead
debugger; Statement Ignored
Problem: debugger; doesn't pause execution.
Solution: Enable debug mode by adding ;debug=true to URL.
Console.log Not Showing
Problem: console.log() output not visible.
Solution:
- Open correct browser (Chrome)
- Check Console tab
- Clear filters that might hide output
- Look in
sandbox.worker.main.*.jsentries
Variables Show as undefined
Problem: Variables appear undefined when inspected.
Solution: Scripts are transformed before execution. Variable names may differ. Use console.log() to inspect actual values.
Script Looks Different in Debugger
Problem: Code in debugger doesn't match script editor.
This is expected: Analytics Designer transforms scripts before browser execution. The logic is the same, but syntax may differ.
Debugging Checklist
Before debugging:
- Using Chrome browser
- Developer Tools open (F12)
- Script has been executed at least once
- For
debugger;, debug mode enabled (;debug=true) - Console tab open for
console.log()output - Sources tab open for breakpoints
During debugging:
- Start with simple
console.log()to verify code runs - Check Info panel for script errors first
- Use Find References to understand dependencies
- Test incrementally (every 5-10 lines)
- Check variable types match expected
Keyboard Shortcuts Summary
| Shortcut | Action |
|---|---|
| F12 | Open Developer Tools |
| Ctrl+Shift+J | Open Console directly |
| Ctrl+P | Quick file search (in Sources) |
| F8 | Resume execution |
| F10 | Step over |
| F11 | Step into |
| Shift+F11 | Step out |
For script editor shortcuts, see: https://help.sap.com/doc/00f68c2e08b941f081002fd3691d86a7/release/en-US/68dfa2fd057c4d13ad2772825e83b491.html
Source: SAP Analytics Designer Development Guide - Chapter 4: Scripting in Analytics Designer Last Updated: 2025-11-23