Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Bạn có thể gỡ lỗi cho Trình kết nối cộng đồng theo hai cách:
Bật thông báo lỗi mở rộng
Ghi nhật ký dữ liệu thực thi liên quan
Hướng dẫn này trình bày cách sử dụng hiệu quả những tính năng này.
Bật/tắt các tính năng gỡ lỗi
isAdminUser() sẽ trả về true nếu người dùng hiện tại thấy thông báo gỡ lỗi và dấu vết ngăn xếp. Nếu isAdminUser() trả về giá trị false (sai) hoặc không được xác định và xảy ra lỗi, người dùng sẽ thấy một thông báo lỗi chung.
Mẹo gỡ lỗi
Thiết kế isAdminUser() để luôn trả về true cho nhà phát triển.
Sử dụng getEffectiveUser() kết hợp với danh sách email an toàn gồm những người dùng đáng tin cậy để dễ dàng thêm hoặc xoá những người dùng sẽ thấy toàn bộ thông tin chi tiết về lỗi.
Điều này có thể đặc biệt hữu ích nếu người dùng gặp lỗi mà bạn gặp phải sự cố khi tái tạo.
Hãy sử dụng newDebugError() một cách thoải mái cho các biến bất biến cần phải giá trị đúng. Điều này có thể giúp thu hẹp các vấn đề trong tương lai.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[[["\u003cp\u003eCommunity Connectors can be debugged by enabling extended error messages or logging execution data.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eisAdminUser()\u003c/code\u003e function controls debug message visibility, returning \u003ccode\u003etrue\u003c/code\u003e for users who should see them and \u003ccode\u003efalse\u003c/code\u003e otherwise.\u003c/p\u003e\n"],["\u003cp\u003eLeverage Apps Script's logging mechanisms, such as the built-in Logger, Stackdriver, or even a Google Sheet, to proactively identify and resolve bugs while protecting user data privacy.\u003c/p\u003e\n"],["\u003cp\u003eDesigning \u003ccode\u003eisAdminUser()\u003c/code\u003e to always return \u003ccode\u003etrue\u003c/code\u003e for developers and using \u003ccode\u003egetEffectiveUser()\u003c/code\u003e with a safelist can aid in debugging and reproducing user errors.\u003c/p\u003e\n"]]],[],null,["You can debug your Community Connector in two ways:\n\n1. Enabling extended error messages\n2. Logging relevant execution data\n\nThis guide outlines how to make effective use of these capabilities.\n\nEnabling/disabling debug features\n\n`isAdminUser()` should return `true` if the current user should see debug\nmessages and stack traces. If `isAdminUser()` returns false, or is not defined,\nand an error occurs, the user will see a generic error message.\n| **Note:** Use `newUserError()` if users should see the error message regardless of the `isAdminUser()` response.\n\nDebugging Tips\n\n- Design `isAdminUser()` so it always returns `true` for developers.\n- Use [`getEffectiveUser()`](/apps-script/reference/base/session#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.\n- Make liberal use of [`newDebugError()`](/apps-script/reference/data-studio/community-connector#newDebugError()) for invariants that should hold true. This can help with narrowing down problems in the future.\n\nApps Script logging\n\nApps Script provides [different mechanisms for logging](/apps-script/guides/logging) including the built-in\n[Apps Script Logger](https://developers.google.com/apps-script/reference/base/logger), [Stackdriver Logging](https://developers.google.com/apps-script/guides/logging#stackdriver_logging), and [Stackdriver Error Reporting](https://developers.google.com/apps-script/guides/logging#stackdriver_error_reporting).\nYou can also try [logging to a Google Sheet](https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app). Proactive logging can help to\nquickly narrow in on the cause of bugs, though care should be taken to not log\nsensitive user data."]]