事件發生的上下文。
EventContext 描述: - 事件發生的時間。 - 事件的唯一識別碼。 - 發生事件的資源(如果適用)。 - 觸發事件的請求的授權(如果適用且可用)。
簽名:
export interface EventContext<Params = Record<string, string>>
特性
財產 | 類型 | 描述 |
---|---|---|
授權 | { 令牌:對象; uid:字串; } | 觸發該功能的使用者的身份驗證資訊。 |
授權類型 | “管理員” | “用戶” | “未經驗證” | 使用者的權限等級。 |
事件ID | 細繩 | 事件的唯一識別碼。 |
事件類型 | 細繩 | 事件類型。 |
參數 | 參數 | 一個對象,其中包含提供給即時資料庫觸發器方法的path 參數中的通配符值。 |
資源 | 資源 | 發出事件的資源。 |
時間戳 | 細繩 | RFC 3339字串形式的事件時間戳記。 |
事件上下文.auth
觸發該功能的使用者的身份驗證資訊。
該物件包含經過身份驗證的使用者的uid
和token
屬性。有關包括令牌密鑰在內的更多詳細信息,請參閱安全規則參考。
僅針對即時資料庫觸發器和可呼叫函數填入此欄位。對於未經身份驗證的用戶,此欄位為空。對於 Firebase 管理員使用者和不提供使用者資訊的事件類型,此欄位不存在。
簽名:
auth?: {
token: object;
uid: string;
};
EventContext.authType
使用者的權限等級。
有效值為:
ADMIN
:開發者使用者或透過服務帳戶進行身份驗證的使用者。USER
:已知使用者。UNAUTHENTICATED
:未經驗證的操作null
:適用於不提供使用者資訊的事件類型(即時資料庫除外)。
簽名:
authType?: "ADMIN" | "USER" | "UNAUTHENTICATED";
事件上下文.eventId
事件的唯一識別碼。
簽名:
eventId: string;
EventContext.eventType
事件類型。
可能的值為:
google.analytics.event.log
google.firebase.auth.user.create
google.firebase.auth.user.delete
google.firebase.database.ref.write
google.firebase.database.ref.create
google.firebase.database.ref.update
google.firebase.database.ref.delete
google.firestore.document.write
google.firestore.document.create
google.firestore.document.update
google.firestore.document.delete
google.pubsub.topic.publish
google.firebase.remoteconfig.update
google.storage.object.finalize
google.storage.object.archive
google.storage.object.delete
google.storage.object.metadataUpdate
google.testing.testMatrix.complete
簽名:
eventType: string;
EventContext.params
一個對象,其中包含提供給即時資料庫觸發器方法的path
參數中的通配符值。
簽名:
params: Params;
EventContext.資源
發出事件的資源。
有效值為:
分析: projects/<projectId>/events/<analyticsEventType>
即時資料庫: projects/_/instances/<databaseInstance>/refs/<databasePath>
儲存: projects/_/buckets/<bucketName>/objects/<fileName>#<generation>
驗證: projects/<projectId>
發佈/訂閱: projects/<projectId>/topics/<topicName>
由於即時資料庫實例和 Cloud Storage 儲存分區是全域唯一的且與專案無關,因此它們的資源以projects/_
開頭。下劃線不是有效的項目名稱。
簽名:
resource: Resource;
EventContext.時間戳
RFC 3339字串形式的事件時間戳記。
簽名:
timestamp: string;