Deploy functionality to your app quickly
Designed to increase productivity, Firebase Extensions provide extended functionality to your apps without the need to research, write, or debug code on your own.
Firebase extension are new services offered by a firebase platform. services like
5. Export collections to BigQuery
6. Shorten URLs
Use this extension to create resized versions of an image uploaded to a Cloud Storage bucket.
When you upload an image file to your specified Cloud Storage bucket, this extension:
Creates a resized image with your specified dimensions. Stores the resized image in the same Storage bucket as the original uploaded image.Names the resized image using the same name as the original uploaded image, but suffixed with your specified width and height.
You can even configure the extension to create resized images of different dimensions for each original image upload. For example, you might want images that are 200x200, 400x400, and 680x680 - this extension can create these three resized images then store them in your bucket.
Another optional feature of this extension is to specify a Cache-Control header for your resized image files.
Use this extension to translate strings (for example, text messages) written to a Cloud Firestore collection.
This extension listens to your specified Cloud Firestore collection. If you add a string to a specified field in any document within that collection, this extension:
Translates the string into your specified target language(s); the source language of the string is automatically detected. Adds the translation(s) of the string to a separate specified field in the same document.
You specify the desired target languages using ISO-639-1 codes. You can find a list of valid languages and their corresponding codes in the Cloud Translate API documentation.
If the original non-translated field of the document is updated, then the translations will be automatically updated, as well.
Use this extension to add new users to an existing MailChimp audience.
This extension adds the email address of each new user to your specified MailChimp audience. Also, if the user deletes their user account for your app, this extension removes the user from the MailChimp audience.
Note: To use this extension, you need to manage your users with Firebase Authentication.
This extension uses Mailchimp, so you'll need to supply your MailChimp API Key and Audience ID when installing this extension.
Use this extension to render and send emails that contain the information from documents added to a specified Cloud Firestore collection.
Adding a document triggers this extension to send an email built from the document's fields. The document's top-level fields specify the email sender and recipients, including to, cc, and bcc options (each supporting UIDs). The document's message field specifies the other email elements, like subject line and email body (either plaintext or HTML)
Here's a basic example document write that would trigger this extension:
admin.firestore().collection('mail').add({
to: 'someone@example.com',
message: {
subject: 'Hello from Firebase!',
html: 'This is an <code>HTML</code> email body.',
},
})
You can also optionally configure this extension to render emails using Handlebar templates. Each template is a document stored in a Cloud Firestore collection.
When you configure this extension, you'll need to supply your SMTP credentials for mail delivery.
5. Export collections to BigQuery
Use this extension to export the documents in a Cloud Firestore collection to BigQuery. Exports are realtime and incremental, so the data in BigQuery is a mirror of your content in Cloud Firestore.
The extension creates and updates a dataset containing the following two BigQuery resources:
A table of raw data that stores a full change history of the documents within your collection. This table includes a number of metadata fields so that BigQuery can display the current state of your data. The principle metadata fields are timestamp, document_name, and the operation for the document change. A view which represents the current state of the data within your collection. It also shows a log of the latest operation for each document (CREATE, UPDATE, or IMPORT).
If you create, update, delete, or import a document in the specified collection, this extension sends that update to BigQuery. You can then run queries on this mirrored dataset.
Note that this extension only listens for document changes in the collection, but no changes in any subcollection. You can, though, install additional instances of this extension to specifically listen to a subcollection or other collections in your database. Or if you have the same subcollection across documents in a given collection, you can use {wildcard} notation to listen to all those subcollections (for example : chats/{chatid}/posts).
6. Shorten URLs
Use this extension to create shortened URLs from URLs written to Cloud Firestore. These shortened URLs are useful as display URLs.
This extension listens to your specified Cloud Firestore collection. If you add a URL to a specified field in any document within that collection, this extension:
Shortens the URL. Saves the shortened URL in a new specified field in the same document.
If the original URL in a document is updated, then the shortened URL will be automatically updated, too.
This extension uses Bitly to shorten URLs, so you'll need to supply your Bitly access token as part of this extension's installation. You can generate this access token using Bitly.
Use this extension to add a highly scalable counter service to your app. This is ideal for applications that count viral actions or any very high-velocity action such as views, likes, or shares.
Since Cloud Firestore has a limit of one sustained write per second, per document, this extension instead shards your writes across documents in a _counter_shards_ subcollection. Each client only increments their own unique shard while the background workers (provided by this extension) monitor and aggregate these shards into a main document.
Here are some features of this extension:
Scales from 0 updates per second to at least 10,000 per second. Supports an arbitrary number of counters in your app. Works offline and provides latency compensation for the main counter.
Note that this extension is currently fully resourced for use with JavaScript apps (we provide the required JS SDK). You can, however, use this extension on other platforms if you'd like to develop your own API based on the provided JS SDK.
Use this extension to control the maximum number of nodes stored in a Firebase Realtime Database path.
If the number of nodes in your specified Realtime Database path exceeds the specified max count, this extension deletes the oldest nodes first until there are the max count number of nodes remaining.
Use this extension to automatically delete a user's data if the user is deleted from your authenticated users.
You can configure this extension to delete user data from any or all of the following: Cloud Firestore, Realtime Database, or Cloud Storage. Each trigger of the extension to delete data is keyed to the user's UserId.
Note: To use this extension, you need to manage your users with Firebase Authentication.
This extension is useful in respecting user privacy and fulfilling compliance requirements. However, using this extension does not guarantee compliance with government and industry regulations.
In the upcoming weeks, we will see how we can install these extensions in the firebase platform.
Commentaires