15
DEBUGGING LIGHTNING COMPONENTS Mohith Shrivastava Salesforce Engineer @ CodeScience Salesforce MVP @Salesforce

Debugging lightning components-SEDreamin17

Embed Size (px)

Citation preview

Page 1: Debugging lightning components-SEDreamin17

DEBUGGING LIGHTNING COMPONENTSMohith ShrivastavaSalesforce Engineer @ CodeScienceSalesforce MVP @Salesforce

Page 2: Debugging lightning components-SEDreamin17

THANK YOU TO OUR PLATINUM SPONSORS!

Page 3: Debugging lightning components-SEDreamin17

SIX STAGES OF DEBUGGING1.That can’t Happen2.That does not happen on my Instance or Developer org3.That shouldn’t happen4.Why does that happen ?5.Oh I see6.How did that ever work ??

Page 4: Debugging lightning components-SEDreamin17

INTRODUCTION TO LIGHTNING COMPONENTS

Page 5: Debugging lightning components-SEDreamin17

INTRODUCTION TO LIGHTNING COMPONENTS1. JavaScript Framework that lets you build Single page Applications

2. On Backend uses salesforce apex (Object Oriented Language like Java )

3. On Frontend uses ES5 JavaScript (Functional Programming ) for DOM manipulation and client side business logic and uses two way data binding via attributes

4. Components use Event Driven pattern (pub-sub) model to communicate with each other

Page 6: Debugging lightning components-SEDreamin17
Page 7: Debugging lightning components-SEDreamin17

ENABLING LOGS

1. Enabling Salesforce Debug Logs For Apex Logging

2. Enabling Debug Mode For Lightning Component Debugging for un minifying JavaScript

Page 8: Debugging lightning components-SEDreamin17

LIGHTNING CHROME INSPECTOR USEFUL COMMANDS

Installation Link

$auraTemp+""Returns the component descriptor.

$auraTemp.get("v.attributeName")Returns the value for the attributeName attribute.

$auraTemp.getElement()Returns the corresponding DOM element.

inspect($auraTemp.getElement())Opens the Elements tab and inspects the DOM element for the component.

Page 9: Debugging lightning components-SEDreamin17

PERFORMANCE PROFILING

Page 10: Debugging lightning components-SEDreamin17

EVENTS LOGGING1. This tab shows all the events fired. The event graph helps you to understand

the sequence of events and handlers for one or more actions.

2. You can inspect standard and custom application events , component events

3. Use this to inspect the Tree and debug event variables

The graph is color coded.

Black—The current eventMaroon—A controller actionBlue—Another event fired before or after the current event

Page 11: Debugging lightning components-SEDreamin17

ACTIONS LOGGING

1. Actions are various types like storable, cached,Success,Error,Aborted

2. Actions logging help to see the action responses and override the behaviour to build more robust error handling

3. You can override the server actions

Page 12: Debugging lightning components-SEDreamin17

1. Using console.log to inspect objects2. Setting Breakpoints3. Using debugger keyword (debugger)

JAVASCRIPT DEBUGS

Page 13: Debugging lightning components-SEDreamin17

➢ Prevents Components from causing XSS and similar security issues

➢ Prevents Components from reading other component’s rendered data without any restrictions

➢ Prevents Components from calling undocumented/private APIs

➢ Managed Package Apps going through the security review process has to adhere to security best practices .

➢ Use lightning CLI to discover potential issues .

➢ Read this blogpost for more info

LOCKER SERVICE

Page 14: Debugging lightning components-SEDreamin17

https://github.com/msrivastav13/SEDreamin17

References

Page 15: Debugging lightning components-SEDreamin17

Thank you!