Overview
ThedebugLog function provides conditional console logging for debugging purposes. It only outputs logs when running in HubSpot environments or when explicitly enabled via sessionStorage.
Location
Function Signature
Parameters
Variable number of arguments to be logged to the console. Can be any JavaScript value (strings, objects, arrays, etc.).
Returns
Type:void
This function does not return any value.
Behavior
The function logs messages to the console only when:- The hostname matches HubSpot patterns (
.hs-sitesor.hubspot), OR - The
juicekey exists insessionStorage
Implementation
Usage Examples
Basic Logging
Logging Multiple Values
In Alpine.data Components
Enabling Debug Logs
To enable debug logging in any environment, set thejuice key in sessionStorage:
Via Browser Console
Via Alpine.data xDOM Component
Automatic Activation
Debug logs are automatically enabled when:- Local HubSpot Development: Hostname contains
.hs-sites - HubSpot Platform: Hostname contains
.hubspot
Disabling Debug Logs
To disable debug logging:Best Practices
- Use
debugLoginstead ofconsole.logfor development-only messages - Leave debug statements in production code - they won’t execute unless explicitly enabled
- Log meaningful context, not just values (e.g., include labels with your data)
Related
- main.js - Main entry point that imports debugLog
- Alpine.data (xDOM) - Exposes debugLog in Alpine components