Function Store
  • Home
  • Getting started
    • Introduction
    • Installing a function
    • Reconfiguring a function
    • Uninstalling a function
    • FAQs
  • Reference
    • Requirements
      • Assign Roles
        • User permissions
      • Link a Billing account to your project
      • Enable the APIs
    • Projects
      • How to add a project
      • How to set up a project
    • Functions
      • Benefits
      • Use cases
      • Authentication when installing
      • Runtime configuration
      • Deploying with a ZIP file
    • Policies
      • How to add a Policy
      • How to remove a Policy
    • Authentication
      • Users
      • Roles
      • Permissions
    • Secrets
      • Creating a Secret
      • Using a Secret
      • Changing the value for a Secret
      • Deactivating a Secret
  • developers
    • Overview
    • Getting Started
    • Set up
    • Workspaces
      • Create a workspace
      • Workspace boilerplate
      • Node engines
    • Writing Functions
      • Function Anatomy
      • Configuration file
      • Function Triggers
      • Environment Variables
        • Type "text"
        • Type "number"
        • Type "email"
        • Type "url"
        • Type "json"
        • Type "boolean"
        • Type "select"
        • Type "multiselect"
        • Type "firestoreDocumentPath"
        • Type "firestoreCollectionPath"
        • Type "color"
      • Documentation
    • Push/Update your functions in the cloud
    • Continuous Integration
    • Publish functions in the Marketplace
    • Emulators
      • Initialize emulators in your workspace
      • Environment variables
      • Starting emulators
      • Testing your functions in the emulator
      • Importing existing data into local emulators
        • Exporting data from Cloud Firestore to local emulator
        • Exporting user accounts from Firebase to local emulator
    • Visual Studio Code Extension
      • Installing the extension
      • Extension UI
      • Functions list
      • Creating and editing functions
      • Emulators
      • Extension settings
      • Troubleshooting
        • "Command not found" error when executing a command
  • Billing
    • Understanding Billing
  • Security
    • Security
  • Resources
    • Events and Triggers
    • Best Practices
      • How to log events in functions?
    • Document your Functions
    • Editorial guidelines
    • Our Processes
      • Use Cases Analysis
  • Use cases
    • Custom Stripe Checkout
Powered by GitBook
On this page
  • Events
  • Cloud Firestore triggers:
  • Realtime Database triggers
  • Remote Config triggers
  • Firebase Authentication triggers
  • Google Analytics triggers
  • Cloud Storage triggers
  • Pub/Sub triggers
  • Firebase Test Lab triggers
  • Cloud functions. EventContext

Was this helpful?

  1. Resources

Events and Triggers

These are the basic Firebase and Google Cloud Platform events and triggers.

PreviousSecurityNextBest Practices

Last updated 4 years ago

Was this helpful?

Events

Events are things that happen within your cloud environment that you might want to take action on. These might be changes to data in a database, files added to a storage system, or a new virtual machine instance is created. Currently, Cloud Functions supports events from the following providers:

  • Firebase (, Storage, , )

  • —forward log entries to a Pub/Sub topic by . You can then .

For more information about Events, check .

Cloud Firestore triggers:

Events:

  • onCreate: triggered when a document is written to for the first time.

  • onUpdate: triggered when a document already exists and has any value changed.

  • onDelete: triggered when a document with data is deleted.

  • onWrite: triggered when onCreate, onUpdate or onDelete is triggered.

Realtime Database triggers

Events:

  • onWrite(): triggered when data is created, updated, or deleted in the Realtime Database.

  • onCreate(): which triggered when new data is created in the Realtime Database.

  • onUpdate():which triggered when data is updated in the Realtime Database.

  • onDelete(): which triggered when data is deleted from the Realtime Database.

Remote Config triggers

You can trigger a function in response to Firebase Remote Config events, including the publication of a new config version or the rollback to an older version.

Firebase Authentication triggers

Firebase accounts will trigger user creation events for Cloud Functions when:

  • A user creates an email account and password.

  • A user signs in for the first time using a federated identity provider.

  • The developer creates an account using the Firebase Admin SDK.

  • A user signs in to a new anonymous auth session for the first time.

Google Analytics triggers

Cloud Storage triggers

Events:

  • onFinalize: Sent when a new object (or a new generation of an existing object) is successfully created in the bucket. This includes copying or rewriting an existing object. A failed upload does not trigger this event.

  • onMetadataUpdate: Sent when the metadata of an existing object changes.

Pub/Sub triggers

Firebase Test Lab triggers

Create a new function that triggers when a TestMatrix completes with the event handler functions.testLab.testMatrix().onComplete().

Cloud functions. EventContext

Type of event. Possible values are:

  • 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

For more information about Firestore events check , and for Cloud Firestore over .

For more information about Realtime Database triggers, check .

For more information about Remote Config triggers, check .

For more information about Firebase Authentication triggers, check .

Cloud Functions supports the Google Analytics . This event is triggered whenever user activity generates a conversion event. For example, you could write a function that triggers when the in_app_purchase event is generated, indicating that an in-app purchase has occurred. You must specify the Analytics event that you want to trigger your function using the method, and handle the event within the event handler.

For more information about Google Analytics triggers, check .

onArchive: Only sent when a bucket has enabled . This event indicates that the live version of an object has become an archived version, either because it was archived or because it was overwritten by the upload of an object of the same name.

onDelete: Sent when an object has been permanently deleted. This includes objects that are overwritten or are deleted as part of the bucket's . For buckets with enabled, this is not sent when an object is archived (see onArchive), even if archival occurs via the storage.objects.delete method.

For more information about Cloud Storage triggers, check .

You can trigger a function whenever a new Pub/Sub message is sent to a specific topic. You must specify the Pub/Sub topic name that you want to trigger your function, and set the event within the event handler.

For more information about Pub/Sub triggers, check .

For more information about Pub/Sub triggers, check .

For more information about Cloud functions-EventContext, check and over .

HTTP
Cloud Storage
Cloud Pub/Sub
Cloud Firestore
Realtime Database
Analytics
Auth
Cloud Logging
creating a sink
trigger the function
here
here
here
here
here
here
AnalyticsEvent
functions.analytics.event()
onLog()
here
object versioning
lifecycle configuration
object versioning
here
onPublish()
here
here
here
here