nicolasgarnier Upgrade all firebase-admin imports to 5.11.0
Change-Id: Ib3f6a5f57d3fdd0dbc2ee3d27efbd3cf00966257
Latest commit 849ab0b Mar 26, 2018

README.md

Send a survey when users update your app

This sample shows how to send a survey to your users who have updated your app. App Update is detected using a Firebase Analytics event.

Functions Code

See file functions/index.js for the trigger and the email sending code.

Sending emails is performed using nodemailer a node based Email client with comprehensive EMail server setup. For simplicity, in this sample we're showing how to send email through SMTP using a Gmail account. Be aware that Gmail has an email sending quota. If you are planning on sending a large number of emails you should use a professional email sending platform such as Sendgrid, Mailjet or Mailgun.

The dependencies are listed in functions/package.json.

Trigger rules

The function triggers on changes to app_update Firebase Analytics events. For other automatically logged events see: https://support.google.com/firebase/answer/6317485

Setting up the sample

Set the gmail.email and gmail.password Google Cloud environment variables to match the email and password of the Gmail account used to send emails. For this use:

firebase functions:config:set gmail.email="myusername@gmail.com" gmail.password="secretpassword"

Deploy and test

This sample can be tested on your Android and iOS app. To test it out:

  • Make sure you set the app_update events as being a Conversion event in your project. You can do this on the Analytics section > Events tab.
  • Set the project to your Firebase project using firebase use --add then select your projec tin the list.
  • Deploy your project using firebase deploy
  • Have users update your app, for instance through the play store.
  • Within a few hours the emails to the survey will be sent.