# Debug your Community Connector

You can debug your Community Connector in two ways:

1. Enabling extended error messages
2. Logging relevant execution data

This guide outlines how to make effective use of these capabilities.

## Enabling/disabling debug features

`isAdminUser()` should return `true` if the current user should see debug
messages and stack traces. If `isAdminUser()` returns false, or is not defined,
and an error occurs, the user will see a generic error message.

> [!NOTE]
> **Note:** Use `newUserError()` if users should see the error message regardless of the `isAdminUser()` response.

## Debugging Tips

- Design `isAdminUser()` so it always returns `true` for developers.
- Use [`getEffectiveUser()`](https://developers.google.com/apps-script/reference/base/session.md.txt#getEffectiveUser()) in combination with an email safelist of trusted users to easily add or remove users that should see the full error details. This can be especially useful if a user runs into an error that you have trouble reproducing.
- Make liberal use of [`newDebugError()`](https://developers.google.com/apps-script/reference/data-studio/community-connector.md.txt#newDebugError()) for invariants that should hold true. This can help with narrowing down problems in the future.

## Apps Script logging

Apps Script provides [different mechanisms for logging](https://developers.google.com/apps-script/guides/logging.md.txt) including the built-in
[Apps Script Logger](https://developers.google.com/apps-script/reference/base/logger.md.txt), [Stackdriver Logging](https://developers.google.com/apps-script/guides/logging.md.txt#stackdriver_logging), and [Stackdriver Error Reporting](https://developers.google.com/apps-script/guides/logging.md.txt#stackdriver_error_reporting).
You can also try [logging to a Google Sheet](https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app.md.txt). Proactive logging can help to
quickly narrow in on the cause of bugs, though care should be taken to not log
sensitive user data.