Migrate to Firebase – Google I/O 2016

Hi Welcome So I’m very glad to be here today because I can finally share with you what we’ve been up to at Firebase Because today, more than ever, Firebase has the tools you need to build a successful app I’m also excited because I kind of came to I/O this year the long way around You see, I actually left a great job at Google four years ago I wanted to dive into this app development thing and change the world with a small startup This small startup how do unique vision we thought that we could empower developers by letting them focus on the user experience they wanted to create and not the back end that needed to support that And that startup of course was Parse So before I rejoined Google and teamed up with the Firebase team last year, I spent three years in the Parse team I’m most commonly known there as the lead developer for Parse push And also the type of person who was called in when there was reliability or scalability issues that tended to hit only the largest customers I worked a lot between the back end developers and the operations team And so I’ve been around the block a while and have done a number of back end services Now to be a little bit more somber for a second As a former team member, hearing about that shutdown hurt me physically And to anybody who is a Parse customer in this room, I want to express my sincerest apologies Nobody in Parse nor Firebase is happy with what’s happening here today We are not happy with the pain you’ve gone through And to my former teammates and Parse, I want to express how proud I am that they have responsibly handled this tragic event Because Firebase gave a year notice that they’re doing a shutdown They gave an open source implementation of their back end And they have dedicated themselves to spend the next year helping customers migrate And I think we should all say thank you for setting the bar for responsibility So the advice I’m going to give today is generic You don’t have to have been a Parse customer to benefit from it But I’ve decided to layout the content to help people who are like me coming from a Parse understand all of the new features that are available in Firebase We’re going to start today by looking at how Firebase fits in the Google ecosystem And why Firebase can help you even if you already have a back end Next we’re going to look at the set of products or products within Firebase that can help cover the feature gap between Parse.com Parse server Then we’re going to cover some novel features unique to Firebase that have no Parse alternative And finally dig deep into the internals of how you build your application To see how Firebase’s approach gives you some novel new tools So we welcome you to Google No matter where you are, no matter what you might already be running your application, even if it’s Parse server Because with Google, you can build just about anything When we look at a back end service, we typically compare it to one of four altitudes At the very bottom, we have an infrastructure as a service These give us the raw building blocks that we can use to build any back end, as long as we have the time and the expertise At Google, this traditionally means Google Compute Engine, where you have access to raw virtual machines or Google container engine, where you can scale up and down Docker instances If you’d like, you can go up the stack You can trade off some of the operational responsibility by using a platform as a service, like Google App Engine or the up and coming Google Cloud functions These types of products let you continue developing back end code while not needing to worry about which servers your back runs on Now just like you handed off some of the operational responsibility to build a platform as a service, you can go the next layer up and use a back end as a service, like Firebase, to hand off some of the developmental responsibilities Because a back end as a service provides a suite of integrated features that allow you to spend most or even all of your time

focused on the client code And we’re not going to spend time today covering the last level, software as a service But I list it here today to remind you that Google is fairly unique because we have powerful and successful products at all layers of the stack Which means when you choose to develop with Google you are not stuck at only one altitude You can branch out Imagine if you have a back end today that’s written on Google Compute Engine Odds are, if you are distributing files you’re using Google Cloud Storage to do so Now traditionally, if you wanted to give some of those users access to files, you’d have to create your own API server to control who has access to which files But starting today, you can use Firebase storage The back end is a service layer, on top of the infrastructure of Google Cloud Storage This will let you use a simple rules file to describe for your entire bucket who should have access And it saves you the need of needing to manage and scale a service between your storage and your users Similarly, you’ll also be able to go down the stack Today I’m announcing that the upcoming Google Cloud functions will fully integrate with Firebase And you’ll be able to react to changes that happen in the Firebase ecosystem as well So this means that if you already have a back end, that’s fine And if it’s at a different altitude from Firebase, that’s also fine If you’ve migrated from Parse.com to Parse Server, you’ve gone from a back end as a service to an infrastructure or platform as a service And if that’s the right choice for your team then I encourage you to stick with it Because Firebase can help you, no matter what your existing solution is today Almost [INAUDIBLE] First we have a series of features that cover the product gaps between Parse.com Parse Server These are Parse Crash Reporting, Parse Analytics, Parse Hosting and Parse Config Firebase has products in all of these areas so let’s take a quick look at how you can recover these product areas and do more than you ever could before First and foremost, you should check out Firebase Analytics This is the crown jewel of the new Firebase product line And it’s a great place to start because you don’t actually need to add any code to start using it And there is no charge, no matter how many API requests you send If you have complex analysis needs, Firebase Analytics will integrate with Google BigQuery, which will let you slice and dice your data as you see fit And analytics sets the stage for many other integrations with Firebase products So this is our new Analytics dashboard As you’ll see, the most important feature is right up at the top How many people are using your application We’ve sliced that down into the daily, weekly, and monthly active users in your app so you can understand the depth of engagement Next you can scroll down and see retention cohorts This is a fancy word for do your users keep using your app or do they get bored with it Retention cohorts lines up your user base based on which week they started using your app So you can look vertically down the line and see when do people stop using my app Now you’ll also notice that this dashboard is showing results for users aged 25 to 34 Now this application wasn’t actually providing that information to Firebase Because of Firebase, you automatically get powerful information without adding any code You understand where your new users are coming from, how many of them are coming back, how long they’re using your app when they do, and even demographic information, like their gender, age, country, and interests All in a free product And if you would like, you can add extra information for analytics as well You can describe custom attributes about your users or provide up to 500 custom types of events that you would like to send And you can use this information to dive deeper into your groups But if you need to compose that, you can do so in Audiences Audiences lets you describe a collection of users who meet certain characteristics and who have seen certain events

You can use that audience to dive deep into a demographic in your app and understand how they use it Or you can also use audiences to reengage customers in your application using Firebase notifications or remote config And like I said, you don’t need to add any code to use Firebase Analytics It’s part of the core SDK But if you’d like to add additional properties, you can say Set User properties string Or you can log additional events with log event with name parameters It’s that easy So if you are like me, you occasionally write imperfect software And one of the biggest problems I always face is tracking down what went wrong in the field Because the first time you get a bug report, it’s hard to translate what your user is describing to an actual crash tone And the second time you get a bug report, you need to triage Is this a new issue or should I save myself the time and not debug this because it’s already known When you get the third crash report, it seems familiar and you need to figure out whether or not this is a known issue that’s already been fixed or whether that bug has regressed And Crash Reporting can help you solve all three of these important problems So in the Crash Reporting dashboard, you can see at a glance how many crashes are happening in your application And there’s three important metrics here You can see the raw numbers of errors that we’re managing But we have groups them together into clusters Clusters are errors with a similar stack traces and likely have the same root cause This can greatly help you triage and dive into the individual reports that you see You can also triage by how many users are impacted by these crashes Now when we scroll down into clusters you can see that we have detailed information You see the stack trace, the latest version that this app is crashed for But you can also dive into every single error that was reported And these reports have detailed information You can understand what device was running this app You can understand whether that device was jailbroken You can understand how much memory was available in the app or what country the app was, in case you’re debugging maybe network issues You can understand whether it’s on Wi-Fi or cellular And one great feature for Android is that you can report non-fatal errors as well So you don’t have to wait for a crash to start improving your stability of your app So Crash Reporting also comes out code by default It’s part of the core SDK on Android And in IOS, you just have to crash reporting pod However you can make your life easier if you’d like to add a little bit of code First, FirebaseCrash.log will add a log line that only shows up in a crash report It doesn’t show up in log cats If you want to show up in both places, you can do that with FirebaseCrash.logcat And to report a non-fatal error, FirebaseCrash.report Now if you have an existing back end, odds are you already have a server that is able to host web content I still recommend that you check out a dedicated hosting service because it can make your life much easier With a Firebase hosting product, you can use a simple command line tool which is Firebase Deploy You deploy an entire copy of your static website If you’ve screwed up and there’s an issue, you can safely get back to a well known version using Firebase Rollback But you can deploy with more confidence because the Firebase command line tool lets you host your website locally with the same software that we use in our infrastructure And Firebase hosting is fast because it automatically integrates with content delivery networks to make sure your website is delivered quickly across the globe And it’s secure We are, as a cell first, we manage all of the certificates that you need to handle to serve secure content You just give us files and we give you a fast secure network Firebase hosting is so easy to use I actually struggled to come up with the follow up slide here So instead I decided to give an announcement Starting today, Firebase Hosting supports custom domains absolutely free Now our final product gap between Parse.com and Parse

Server was Parse Config And Firebase Remote Config is such a powerful product that I’m really happy to share it with you today Because sometimes you need dynamic content in your application but the database isn’t really the right place to put it Firebase Remote Config lets you store dynamic content just like Parse Config did, except you have the ability to target what you are sending according to the demographics of your user You can send different configs to different people So imagine you’ve written a newspaper app Newspapers of old had headlines And so we’re going to add one into our application Well that headline is meant to drive engagement and will do so with relevance With Firebase Remote Config, you can target national breaking news to users who are in a particular country If you have multiple headlines, you can do a tested roll out and use percent roll out to do AB testing to see whether or not the new headline is driving the engagement you expect If you’re a multilingual product, you can add translations in your remote config by providing a different config based on the language of the device that is accessing it And if you have particular interest groups within your newspaper, those will probably be in analytics You probably have an audience for people who love snowboarding or who love Google So you can post all of your I/O news headlines to people who are in the Google lovers audience and Firebase Analytics And using remote config is very easy There’s three things you need to do to get started First you want to provide offline defaults These will be used either before your initial request or any time the cache value is too old to be usable Next you can tell remote config to fetch or fetch with expiration duration And this will make sure you get a fresh copy of remote config if it has expired Now finally one config has access to the newest copy, it doesn’t automatically make it available because it would be pretty bad if you started configuring your app with one set of config values and then continued without knowing there was an update in between The line activateFetched helps you coordinate copies of remote config with how your application flows Once you have the latest copy remote config, you can use that same object just like you would a dictionary Use brackets syntax and access any property by name and you’ll get a wrapper object back where you can get strings and spools, whatever you’d like So these features helped us gain parity from Parse Server back to what we used to have in Parse.com Now before we go on to the things that are the core of your app where you might need to choose between one back or another, I want to give a brief shout out to some very novel features that are unique to Firebase First we have of dynamic links Dynamic links are like URLs for your application They can share the location of content deep within your app They work even for users who don’t have the app installed yet Shazam has been investing in time and dynamic links recently by partnering with Coca-Cola to print them on their bottles so you can get a warm welcome for users who want to try out the application Now in case you were not fortunate enough to be partnering with Coca-Cola, we have another product for you With Firebase invites, your users can send these dynamic links to their friends, regardless of whether or not they’re using your app And then you can improve organic growth in your application with app indexing App indexing allows the Google search engine to crawl the dynamic links in your app and provide deep links into your apps content in Google search results Now since like I said, I am fallible and many of you are probably as well, we have Firebase test lab for Android This will let you automate your app on many physical devices owned by Google So you can get a much broader test coverage without having to buy every device that comes out You can increase pay growth in your application by using the new integrations with Google AdWords So that once you’ve identified a group in Firebase analytics that is more likely to engage in your application,

you can target your ads to that demographic And you can earn money in your application by using Google AdMob, which will host advertisements in your application So now the meat of the talk Because the remaining products are more central to the way that you build an application Notifications, authentication, and data So they deserve a deeper look First and foremost, as I said, notifications have a special place in my heart And Firebase has two products in this area Google Cloud Messaging is now a Firebase Cloud Messaging This is the product that provides a low level service for sending content directly to an app For pushing data to it It is still freely available, accessible from the same APIs, and is the platform that other providers, like Parse or Urban Airship already use today to reach their devices for their push platforms Nothing in Firebase Cloud Messaging requires you to use other Firebase services On top of that, we’ve built Firebase Notifications This is the set of products that will help you use the information you’ve gained from Firebase to more accurately target your users and to create notifications for those users So let’s look at the new dashboard Obviously a notification composer should let you type in a notification You can also schedule the notification to be sent now or later You can schedule it either to be now, an exact time in the future, or a time relative to the user’s device If you have that news application, you can schedule the push to be sent every morning at 8:30 at the user’s time zone But the real power of Firebase Notifications comes from its targeting framework With Firebase notifications, you can use all of that rich knowledge you’ve learned in Firebase analytics to target your users however you’d like You can target your users with the audiences you’ve created If you’re more of a Parse Push to Channel person, then I recommend checking out Topics They’re the same general concept You subscribe to a topic and then you receive pushes sent to that topic The main difference between Push to Channel and using Topics is that Topics is about 50 times faster And then finally, if you’re testing an individual device, you can use this console to target just your device so that you can be confident you haven’t just sent hello world to your entire user base I have seen that happen actually It is not the greatest page to get Also Firebase Notifications integrates with Firebase Analytics in both directions You can use Analytics to decide who you want to engage And you can use Analytics to measure whether or not you successfully engaged that audience We automatically measure how many pushes were sent and how many were opened But we will also be able to measure a conversion event if you apply one In this example we have asked the users to look at a new talk Our goal here is that they will star that session, that they’ll add the talk to their favorites And if you do so, it will show up in our analytics panel To understand more about Firebase Notifications and Firebase Cloud Messaging, check out these two talks We have GCM is now FCM, which covers that foundational technology And on top of it, we have Firebase Notifications , Everything You Need to Know in 45 Minutes Now I am going to give a lot of shout outs to different talks I will post them on Spaces afterwards You don’t need to go take pictures of everything Firebase Off describes who is using your app, something we’re very familiar with But Firebase Off gives you the ability to connect with all the same authentication providers you used to expect and more More importantly, Firebase Off allows you to provide your own back end service to control your own authentication And it will be treated as a peer to our providers This means with Firebase Off, it is so powerful that you can actually implement login, where you log into Firebase using a Parse session token

Now for any service, if you have Parse Server, which is going to stay around, that might be a fine strategy If you are on Parse.com, I recommend that you use a migration from the client side When someone tries to log in, you’ll try to log in against Firebase If that doesn’t succeed, but does succeed against Parse, you know the user’s credentials that you still have in your app to create a new user and Firebase and then migrate the record from Parse user over to your Firebase database Now Firebase sessions how the same power of Parse sessions except we’ve used cryptography instead of a database Because the session token in Firebase includes all the things that you would have had in your PF session object Except it’s encoded and signed by your app’s private key This means you can know for sure that the session is valid, which user it applies to, when it’s supposed to expire, and any custom claims you have from your personal off service Rules like this particular session is from an IOT device and therefore should have restricted access These can all be verified directly on the session token, without having to make an extra API requests for every call that you make And Firebase Off integrates with Firebase rules See, in a system like Parse, every object describes its own axis control And as an app administrator, this can lead to uncertainty because you can’t actually audit the access control in your system unless you read through your entire app’s contents Even worse, if you need to update information or secure it in your application, if you need to give admins access, you would have to do a full data migration of your entire application for this to work Instead, Firebase off and Firebase security rules allow you to describe in one file the rules that should be applied to entire systems Your entire Firebase database or your entire storage bucket And you can know with confidence that these rules are applied everywhere So you can learn more about identity and authorization in Firebase with three key talks First there’s The Key to Firebase Security This will go over the languages that you’ll use to secure the real time database and Firebase storage Next, to focus on the actual log on experience, we have Best Practices for a Great Sign-in Experience And one talk I’ll pitch a few times is Zero to App, Develop with Firebase This talk combines off the database and storage to create three apps with live coding We’ll someone live coding all times for iOS, Android, and web So nobody is left out in the talk Now next– if we– there we go If you have large blobs of data, a database is not the right place to put it So for blobs of rich data, we have Firebase storage The Firebase layer on top of the petabyte scale Google Cloud Storage product Now if you look at our dashboard– the first thing you’ll see in our dashboard is that Firebase storage is actually a standalone product You can look at your files here You can modify them, upload them, and you don’t need to wrap your files inside other objects Also you’ll notice that we have a Rules tab Firebase files are secured themselves, not just objects that point to them This means that the data you store is secure, even if the URLs leak out And you can delete files directly There is no more garbage collection required And there’s no more 10 megabyte limit for the files that you use in Firebase storage Because Firebase allows you to download and upload resuming easily Now Parse has not yet decided the migration strategy for Parse.com and Parse Files But there is a Github Wikipedia page, which I’ll post in the spaces after this talk On the other hand, there’s very good news for Parse Server users because Parse Server already has a plug and play adapter for Parse files And you can use Google Cloud Storage There’s an official node module

And since Firebase was built on Google Cloud Storage, it’s reverse compatible with all of those same APIs Which means you can use one back end to have data that is both a Parse file and Firebase storage Now they say you save the best for last So let’s cover the Firebase real time database This is the original Firebase product and it’s why 470,000 developers trust us today The Firebase database started years ago by letting go of preconceptions of how a database needs to work We don’t need to have unstructured data just thrown in some collection We can lay our data to match the way we plan to present it in our application And we don’t need to restrict ourselves to just some RESTful interface REST is nice because it’s easy to think about so Firebase does support REST for the real time database However, we believe that being a drag to refresh just doesn’t cut it Dragging to refresh is going to be as old tomorrow as clicking Refresh to check your email is today So while on other systems you might have to save an object, have the cloud code trigger, send a push notification, have that show up in your device, issue a new query, update your UI Realize that not everybody has push notification enabled, so they’d also have a poll loop which damages your battery life and isn’t very responsive So add extra that allows you to override it with poll to refresh We thought we had a better idea at Firebase Let’s just make the data sync Describe the data you want and it pushes a device in milliseconds So the way we’ve done this is by restructuring how we show data Data in a Firebase database is built like a giant shared JSON document Or a giant tree And you can point to any node in that tree and say, I care about this Once you’ve said you like to listen to a point in the Firebase database, any changes to that will be intelligently streamed down to your device Now this requires us to have an unfamiliar structure But you can see some familiar concepts show up If we look at the first top level keys here, they’re presentations and presenters Now these are the names of collections, which should sound familiar Your first concept in most databases, your table or your clasp And it’s the same way in Firebase So next underneath the presentations collection, we’ll see some gibberish, some numbers More commonly you’ll see random strings This is how you have a list of objects in Firebase We have a tool called a Push ID, which will generate a random string based on the server’s time stamp This allows you to insert data into Firebase and insert data into a list while avoiding collisions With this type of layout though, you consider these to be the object IDs in our collection And underneath these object IDs you’ll see that all the next keys have the same structure These are our objects in our document object model Now some of these keys make sense Location, title, and time are just strings This last one is a little bit curious It’s a bit nested, it’s structured Well what is this The first key is that title, presenters Because if you remember, that was the name of our other namespace And remember how I said that list of numbers or garbage strings or arrays– this is the name of a namespace being mapped to an array inline Well if we scroll down, will notice that presenters has a child name inline This is how we can structure relational data in Firebase We have the name or value of one key pointing to basically a template parameter or the location inside the database somewhere else And that’s how you can use that one to reference do you have a list of pointers to objects elsewhere in the Firebase database So this is a new and novel approach

I know it might seem a little intimidating at first, so I wanted to share a case study from Skyscanner Skyscanner is a very popular travel app in Europe They have over 5 million monthly active customers And they had built a modern web mobile app and they wanted to know how they were doing So they had this feature here where they would ask the customer, how happy are you If the customer was happy, they would invite the user to share their feedback on the App Store or share the app with their friends If the feedback was negative, they asked for feedback directly So this was on another back end and they decided to try out Firebase They said it took them 10 hours to rewrite this whole feature using Firebase It took them two days to test all of their integrations with the new Firebase products And it took them two weeks to fully roll out their entire new code base What’d they say about it It was easy to switch from the legacy solution The web API is pretty mature for the time database and it’s incredibly easy to use So I’m going to lightning fast go through some strategies of migrating data Because these are fundamentally different They’re structured differently Typically we talk about a background sync You have your old app You build a new app in a clean room You might need some type of transformer logic, but you can use that to load and import You can use that to test your new app with a snapshot of old data You can drop that data if you want and restart Next you need to restart again and do syncing with your back to make sure that when you have these two copies, they don’t diverge This is a bit of a challenge, because you need to sync the same time as your imports so it can’t overwrite old data I have written some cloud code for you that I’ll share that can help you do these types of migrations But the other option you can do is just take your app and put it into a Read Only mode while doing your initial sync and then start your synchronization afterwards The other option is a double write You start your old app and you connect to a new database with an app that has access to both copies First you treat your old database with a source of truth And you might do a back fill of data in the background As features become available or fully migrated, you can change your source of truth to be the new back end Eventually your old app stops being used, you can clean up your dependency on the old back end, and then write your new app There’s two sessions to dive in deeper Deep Dive into the Realtime Database and Zero to App, Develop with Firebase So today we’ve shown you how Firebase is a suite of integrated products designed to help you develop your app, grow a user base, and earn money We’ve covered how Firebase fits into the Google ecosystem, how you could add some novel tools from Firebase, and how Firebase’s approach to building an app gives you novel advantages So remember migrating to Firebase doesn’t need to mean migrating away from something else We’ve shown you how the Firebase tools can help you solve problems in ways you haven’t been able to before What’s next? We have the rest at firebase.google.com Join online I’d love to hear what you’ve been doing, what you love about the new Firebase, and how we can improve So thank you very much on behalf of myself and my partner Silvano, who wrote the migration guide I will be spending the rest of my time out in the tent or I’ll be at all of the afternoon sessions at I/O. Thank you