<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Life360 Engineering - Medium]]></title>
        <description><![CDATA[Musings of Life360&#39;s talented engineers - Medium]]></description>
        <link>https://medium.com/life360-engineering?source=rss----7d698da22bc9---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Life360 Engineering - Medium</title>
            <link>https://medium.com/life360-engineering?source=rss----7d698da22bc9---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 08:16:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/life360-engineering" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Android CI Build Performance — Faster I/O, Faster Builds]]></title>
            <link>https://medium.com/life360-engineering/android-ci-build-performance-faster-i-o-faster-builds-0cf2e4718e6a?source=rss----7d698da22bc9---4</link>
            <guid isPermaLink="false">https://medium.com/p/0cf2e4718e6a</guid>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[android-gradle]]></category>
            <category><![CDATA[android-build-system]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Pablo Baxter]]></dc:creator>
            <pubDate>Mon, 09 Feb 2026 22:43:44 GMT</pubDate>
            <atom:updated>2026-02-09T22:43:37.374Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Android CI Build Performance — Faster I/O, Faster Builds</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2fMbCOwRLfXKU-P9" /><figcaption>Photo by <a href="https://unsplash.com/@abject?utm_source=medium&amp;utm_medium=referral">benjamin lehman</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>It’s not always easy maintaining and improving Android builds, especially as projects continue to grow over time. At Life360, we were looking at our continuous integration (CI) run times, which were averaging ~24 minutes on every pull request. There was an effort to try and reduce this by optimizing JVM flags, optimizing dependency downloads, re-writing the Gradle build-logic, and bringing in Develocity to identify other areas of improvement. Eventually we found that one of the biggest bottlenecks in our Android build was I/O.</p><h3>Identifying the Bottleneck</h3><p>To better explain why I/O is such a bottleneck, let’s dive a little bit into how Android builds APKs and AARs. When an Android binary is built using Gradle, plugins can use process annotations, generate code, bundle assets and resources, transform libraries, and compile Kotlin/Java code. Many of these tasks are cacheable in Gradle, however the Android Gradle Plugin disables caching for tasks that perform I/O only work. Caching I/O only work can have worse performance impact than just re-running the tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*PL2sihSMMYFcL7XqxN5WMA.png" /><figcaption>Before optimizing CI for I/O</figcaption></figure><p>One thing we noticed was that these tasks took a significant amount of time to run, mainly because there were so many. The image above shows an example of two tasks that correlate to the <a href="https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:build-system/gradle-core/src/main/java/com/android/build/gradle/internal/tasks/BundleLibraryClasses.kt?q=BundleLibraryClassesDir">BundleLibraryClassesDir</a> task and the <a href="https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:build-system/gradle-core/src/main/java/com/android/build/gradle/internal/tasks/databinding/DataBindingMergeDependencyArtifactsTask.kt?q=DataBindingMergeDependencyArtifactsTask">DataBindingMergeDependencyArtifact</a> task, both of which only perform I/O with hardly any computational work. Yet they each take a non-significant amount of time to run. These tasks are also the longest of these non-cacheable I/O only tasks, with the rest of the 600+ tasks taking 3+ seconds each.</p><h3>Testing a Hypothesis</h3><p><strong>If I/O was faster, our builds should be faster.</strong> Obviously increasing memory or processing power won’t improve I/O performance, so we looked at using a different storage medium. Currently, we use AWS instances for our CI pipeline, which we are able to swap for other instances with relative ease. We identified two instances we wanted to test against, one being memory optimized and the other being storage optimized. Due to Android builds being memory hungry, we wanted to prioritize memory over processing power in our benchmarks. We also didn’t want to incur a greater AWS cost, so we chose instances that were about the same price as those we currently used.</p><p>As for our setup, we used a simple <a href="https://github.com/gradle/gradle-profiler">Gradle Profiler</a> scenario that only ran the debug APK assemble task for our Android project. Each run was done in a pipeline we created that allowed us to easily swap out the AWS instance types. We ran five iterations for each instance, with only one warm up run.</p><p>We first established the baseline of the current instance that ran our build task, which was the m8i.4xlarge instance type. This instance type doesn’t have an SSD, and was using an EBS volume.</p><h4><a href="https://instances.vantage.sh/aws/ec2/m8i.4xlarge?currency=USD">m8i.4xlarge</a> Results</h4><p>Average time: 514,685.43 ms (~8.6 minutes)</p><p>This result aligned with what we had seen in our current CI pipelines. Next, we tested the r6idn.2xlarge instance, which is a memory optimized instance that contains a SSD and provided the same amount of memory as the m8i, but had half the number of vCPUs. Although we didn’t want to lose processing power, the cost of the r6idn.4xlarge was almost double of the m8i.4xlarge, so we opted for the reduced number of vCPUs.</p><h4><a href="https://instances.vantage.sh/aws/ec2/r6idn.2xlarge?currency=USD">r6idn.2xlarge</a> Results</h4><p>Average time: 393,328.13 ms (~6.6 minutes)</p><p>Even with half the number of vCPUs, we saw a 24% improvement over the m8i instance! These I/O only tasks seemed to cause a significant negative impact on our build times. The next instance we tested was the i7i.2xlarge instance, which is a storage optimized instance that had the same amount of vCPUs and memory as the r6idn and was about the same price as well.</p><h4><a href="https://instances.vantage.sh/aws/ec2/i7i.2xlarge?currency=USD">i7i.2xlarge</a> Results</h4><p>Average time: 289,587.15 ms (~4.8 minutes)</p><p>The result of the first benchmark was fantastic, however this one was phenomenal! This had a 26% improvement in build performance over the last benchmark, and a &gt;40% improvement over our baseline. When the results were reconfirmed in another round of tests, it was clear the i7i instances were going to run our Android CI pipelines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5R2PSLgob3Js0Os2Gv8TZA.png" /><figcaption>Gradle Profiler benchmark results</figcaption></figure><h3>Measuring the Actual Improvements</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WHF3HcaI9XBQhjY8FGjt3Q.png" /><figcaption>Before and after swapping to i7i</figcaption></figure><p>The graphs on the left represent the state of our CI times before deploying the i7i instances. The numbers are the average time for each phase of our CI. They range about 6 months before we swapped to the i7i instances, and were actually trending towards a positive improvement at the time due to some of the work mentioned earlier (JVM flag fine-tuning and Gradle build-logic re-write).</p><p>The right side of the graphs capture of CI run times from just before the i7i deployment, up until the end of January. Not only were the improvements clearly visible in these charts, the Android team at Life360 noticed them in their day to day almost immediately as well.</p><p>In summary, just as the <a href="https://youtu.be/Er_goz33q7c?si=TicThO8z5Y_PXBVv&amp;t=1257">Block</a> and <a href="https://youtu.be/o5ERrt53RIs?si=hvzZtCZ1okxAsXC4&amp;t=666">Peloton</a> teams have also found, it is clear that I/O is a significant bottleneck with Android builds on CI. Whether the AWS i7i instances are the best choice for Android builds isn’t as clear though. Additional investigations, analysis, and benchmarking would be necessary to answer that.</p><h3>Come join us</h3><p>Life360 is creating the largest membership service for families by developing technology that helps managing family life easier and safer. There is so much more to do as we get there and we’re looking for talented people to join the team: check out our <a href="http://www.life360.com/jobs">jobs page</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0cf2e4718e6a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/life360-engineering/android-ci-build-performance-faster-i-o-faster-builds-0cf2e4718e6a">Android CI Build Performance — Faster I/O, Faster Builds</a> was originally published in <a href="https://medium.com/life360-engineering">Life360 Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Email Deliverability@Life360]]></title>
            <link>https://medium.com/life360-engineering/email-deliverability-life360-915585ea6f61?source=rss----7d698da22bc9---4</link>
            <guid isPermaLink="false">https://medium.com/p/915585ea6f61</guid>
            <category><![CDATA[spf]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[email-deliverability]]></category>
            <category><![CDATA[dns]]></category>
            <category><![CDATA[life360]]></category>
            <dc:creator><![CDATA[Asha Kasinath]]></dc:creator>
            <pubDate>Tue, 22 Jul 2025 19:35:08 GMT</pubDate>
            <atom:updated>2025-07-22T19:35:08.881Z</atom:updated>
            <content:encoded><![CDATA[<h3>We Fixed Our Email Deliverability @Life360 (So You Can Too)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MTQkkTClr1Y-iuo3MI1zVg.png" /><figcaption>**Why did the email get sunburnt at the beach party?**</figcaption></figure><p><strong>Spoiler: That sunburn? It was our deliverability problem. Read on to find out more.</strong></p><h3>📭 Emails Weren’t Landing — and No One Knew Why</h3><p>It all began with a login problem.</p><p>Some users weren’t getting their One-Time Passcodes (OTPs) by email. No OTP meant no access.</p><p>OTPs are a key part of the Life360 login flow, designed to give users a fast, frictionless way to sign in without needing to remember a password. Just enter your phone number or email, get a temporary code, and you’re in. It’s simple, secure, and there’s no “Forgot Password?” drama.</p><p>But when those emails didn’t arrive, our sleek login flow ground to a halt.</p><p>We assumed it was a simple deliverability hiccup. But the deeper we dug, the more we found. Our legacy email system, dating back to 2008, had no clear owner, limited visibility, and critical misconfigurations.</p><p>Behind the scenes, we had:</p><ul><li>Domain authentication quietly failing</li><li>Shared IP addresses hurting our reputation</li><li>Test automation sending garbage traffic</li><li>Some of our IPs on blacklists</li></ul><p>Fixing OTPs led us to rethink how we handle email, and we ended up building a better, more transparent, and reliable system.</p><h3>🗺️ Lost in Legacy: The Email Infrastructure Expedition</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*1zl4vlJq55_dNupH2YXQyg.png" /><figcaption>A person opens a door to reveal a dusty, cobweb-filled server room with old hardware racks. A monitor displays a mail icon, symbolizing outdated or neglected email infrastructure. The scene conveys legacy tech that’s been left untouched for years.</figcaption></figure><p>Our email system was a relic from Life360’s early days. Many teams used it. Few understood it.</p><p>Critical emails like OTPs, password resets, and account activations were all tangled together. There was no separation of concerns, no clear monitoring, and no obvious way to know if things were working.</p><h3>🔍 OTP Debugging Adventures</h3><p>Put yourself in a developer’s shoes:</p><ul><li>You trigger the OTP flow. The email never arrives.</li><li>You check logs, yes, the email request went out.</li><li>You try to find the dashboard for email delivery. But where is it?</li><li>Days go by as you hunt down how to gain access to this elusive dashboard.</li><li>Finally, you get in. You see charts, but nothing helpful.</li><li>You look for OTP metrics. It’s all too broad, too delayed.</li><li>And still, you can’t tell if the user ever got the email.</li></ul><h3>🎭 Deliverability Drama Uncovered</h3><p>We audited the system and found several root causes:</p><p><strong>🧨Misconfigurations</strong></p><ul><li>Missing or malformed <strong>SPF</strong>, <strong>DKIM</strong>, and <strong>DMARC</strong> records.<br>Domain authentication was failing silently.</li></ul><p><strong>📉 IP Reputation Woes</strong></p><ul><li>QA and Production environments shared a single IP.</li><li>Microsoft had blacklisted our IPs due to bounce rates and suspicious patterns.</li></ul><p><strong>🤖 Automation Misfires</strong></p><ul><li>Test emails were being sent to invalid domains like life360-automations.com.</li><li>These invalid targets were contributing to spikes in hard bounce and blocks.</li></ul><h3>How We Cleaned House</h3><h4>✅ Step 1: Domain Authentication</h4><p>We properly configured SPF, DKIM, and DMARC using the email provider’s out-of-the-box tools and deployed everything using Terraform. This provided a consistent, trackable infrastructure.</p><h4>✅ Step 2: IP Pool Isolation</h4><p>We segmented traffic into function-specific IP pools:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*t7ZON7VZVgFxWhPTMl-nGg.png" /><figcaption>Diagram showing Life360 email sending architecture. A Life360-branded envelope icon branches into two email types: “OTP Emails” and “Password Reset Emails.” Each type is associated with two dedicated IP addresses—IP1 and IP2 for OTP and IP3 and IP4 for Password Reset—illustrating IP pool isolation by function.</figcaption></figure><ul><li><strong>OTP emails</strong> → 1–2 IPs</li><li><strong>Forgot password</strong> → 1–2 IPs</li><li>Also,<strong> </strong>separate IPs for <strong>QA</strong> and <strong>Prod</strong></li></ul><p>This allowed us to monitor and preserve IP reputation by flow.</p><h4>✅ Step 3: Aligning rDNS with Sending Domains</h4><p>We configured reverse DNS (rDNS) to match our sending domains. This step ensures that the IP address used to send email properly resolves back to the authenticated domain — a key deliverability signal for many mailbox providers. Misaligned or missing rDNS records can lead to lower trust and increase the chance of emails getting filtered or blocked.</p><h4>✅ Step 4: Monitoring IP Reputation via Microsoft SNDS</h4><p>Mailbox providers don’t always tell you directly when things go wrong. Tools like SNDS and Google Postmaster give senders a behind-the-scenes look into how their infrastructure is performing from the inbox provider’s perspective. We enrolled our IPs in Microsoft’s Smart Network Data Services (SNDS), a tool that provides visibility into how Microsoft sees your email traffic. It surfaces insights like:</p><ul><li>Volume of email sent</li><li>Spam complaint rates</li><li>IP reputation and trap activity</li></ul><h4>✅ Step 5: Stopping Automation-Generated Noise</h4><p>We introduced a logic change to prevent automation-generated test emails from hitting email providers’ APIs, especially those targeting fake or invalid domains used during QA. This significantly reduced the volume of invalid email traffic, protected our sender reputation, and helped ensure production deliverability remained healthy.</p><p>This means we can debug issues faster and stop sending to known-bad addresses immediately.</p><h4>✅ Step 6: SPF Cleanup — Because Silent Fails Are the Worst</h4><p>SPF records have a DNS lookup limit of 10. We were dangerously close to hitting it, thanks to years of accumulating “includes” for third-party tools. We pruned it down with the help of Life360 ITOPS, preserving necessary includes and ditching the legacy bloat, ensuring reliable authentication without the risk of silent failure.</p><h3>🧠 OTP: Our Accidental Deliverability Hero</h3><p>When we launched Email OTP for frictionless login and settings, we also opened the door to a powerful deliverability advantage, whether we intended to or not.</p><p>Every OTP email acts as a mini signal of email validity.</p><ul><li>If it’s delivered and used, the address is likely healthy.</li><li>If it bounces or goes ignored, it may be fake, mistyped, or inactive.</li></ul><p><strong>The potential outcome:</strong></p><p>→ A naturally cleaner database over time</p><p>→ Improved inbox placement rates</p><p>→ A healthier, more responsive email ecosystem</p><p>We’re just beginning to explore how OTP signals can inform our broader deliverability strategy.</p><h3>📉 What Was Failing (And Why It Mattered)</h3><p>Here’s what 120,000+ bounce events taught us:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*rjZK6rnUmPGj0xmvYN3u-Q.png" /><figcaption>Donut chart showing email bounce reasons. The largest segments are “Mailbox unavailable” at 60.2% (orange-yellow) and “Invalid address” at 29.4% (orange). Smaller segments include “Unclassified” at 9.2%, “Technical” at 0.8%, “Reputation” at 0.4%, “Content” at 0.02%, and “Frequency/volume too high” at 0.01%. Legend with corresponding colors is shown below the chart.</figcaption></figure><ul><li><strong>60.2%</strong> → Mailbox unavailable (deactivated inboxes, full mailboxes)</li><li><strong>29.4%</strong> → Invalid addresses (typos, temp domains)</li><li><strong>9.2%</strong> → Unclassified/transient issues</li><li><strong>&lt;1.2%</strong> → Technical errors or reputation-based rejections</li></ul><p>This data helped us prioritize smart validation tools and observability upgrades.</p><h3>🔮 The Road Ahead</h3><h4>🛡 Smart Email Validation at Input</h4><p>We’re evaluating various<strong> Email Validation tools</strong> to catch malformed, fake, or disposable addresses <strong>before</strong> sending.</p><h4>🛰 Enhanced Real-Time Monitoring</h4><p>Integrating more webhook-based insights with client behavior to proactively guide users when emails fail, not after the fact.</p><h3>🛠 Building a New Email Path? Here’s the Playbook</h3><p>If you’re setting up a new email stream, whether it’s for OTPs, password resets, or user notifications, here’s a general playbook we’ve found helpful for building a strong, deliverability-friendly setup:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v5JKQV_Sb5X8N7g1zNQ1FQ.png" /><figcaption>Blueprint-style visual titled “New Email Flow” with a checklist of steps: Create subuser account, create API keys, add sending domain with authentication, create link branding to match sender domain, get dedicated IPs (no sharing), apply reverse DNS (rDNS), and a final note saying “And you’re done. Start sending” with a paper airplane icon.</figcaption></figure><p><strong>Use different domains/accounts for Segregation:</strong> Each email flow (like marketing, OTP, or support) should ideally live in its own domain/account. This keeps traffic isolated and makes metrics easier to monitor.</p><ul><li><strong>Set Up Domain Authentication per account:</strong> Authenticate your sending domain with SPF, DKIM, and DMARC. This helps mailbox providers verify that your emails are legit.</li><li><strong>Create account-specific API Keys:</strong> Generate API keys scoped only to the subaccount’s needs. This keeps access secure and controlled.</li><li><strong>Add Link Branding for Your Domain:</strong> Configure link branding to ensure that any click-tracked links match your domain, a key signal for trust and inbox placement.</li><li><strong>Use Dedicated IPs Where Appropriate:</strong> Dedicated IPs give you more control over your sending reputation. Group IPs by email type to protect critical flows (like OTPs) from less predictable ones.</li><li><strong>Set Up Reverse DNS (rDNS) Records:</strong> Once IPs are assigned, configure reverse DNS to match your sending domain. This closes the loop and signals to receiving servers that your infrastructure is authenticated and well-managed.</li></ul><p>All these steps, from domain auth to rDNS, work together to establish trust with mailbox providers. They reduce the risk of your emails being flagged as spam and improve the chances of reaching the inbox reliably.</p><h3>💌 Final Thoughts</h3><p>Email deliverability isn’t just an ops problem,</p><p>It’s a <strong>product experience</strong> issue.</p><p>If you ever spot a similar issue in your own systems — users not receiving key emails, mysterious login failures — here’s what helped us:</p><ul><li>Traced the problem end-to-end, from user reports to email infrastructure</li><li>Audited domain authentication (SPF, DKIM, DMARC).</li><li>Moved from shared to dedicated IPs.</li><li>Cleaned up noisy, unnecessary traffic.</li><li>Prioritized clear ownership and monitoring for the existing flow.</li></ul><p>When we got all that right, everyone won: engineering, support, and most importantly, the end user.</p><h3><strong>😂 📧 </strong>And before we go, here’s the punchline to that email joke…</h3><h3>🥁 *Drum roll please…* 🥁</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D1V2PfZRQWtpB-hKu3D1oA.png" /><figcaption><em>Did you get it? SPF isn’t just sunscreen — your domain’s Sender Policy Framework is just as important. 😉</em></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=915585ea6f61" width="1" height="1" alt=""><hr><p><a href="https://medium.com/life360-engineering/email-deliverability-life360-915585ea6f61">Email Deliverability@Life360</a> was originally published in <a href="https://medium.com/life360-engineering">Life360 Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Don’t just shift left with AWS cloud security, you might miss something!]]></title>
            <link>https://medium.com/life360-engineering/dont-just-shift-left-with-aws-cloud-security-you-might-miss-something-8487f999c07?source=rss----7d698da22bc9---4</link>
            <guid isPermaLink="false">https://medium.com/p/8487f999c07</guid>
            <dc:creator><![CDATA[Alex Farhadi]]></dc:creator>
            <pubDate>Thu, 07 Jul 2022 17:52:55 GMT</pubDate>
            <atom:updated>2022-07-07T17:52:55.143Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*vTOwU9c3HShRs-pVL-WhOg.png" /></figure><p>Life360 uses AWS to host its application and related services. AWS presents new security challenges as the DevOps paradigm has shifted how and who controls various facets of a technology stack. The DevOps philosophy has enabled teams to become more independent and efficient by breaking down barriers and silos. In the days before DevOps, there was a centralized team who managed networks, deployments, servers, or other components of the technology stack; now that line is a bit more blurred. There are now more engineers, with a variety of different skills and expertise all changing things at lightning speed vs what may have taken a specialized team days or weeks to complete. The key benefits of the DevOps philosophy such as speed and agility are likely here to stay. The impact of high-speed releases is not all rainbows and unicorns since now security issues can make it to production with the same speed. In this article, I’ll go into how Life360 balances enabling high-speed DevOps style workflows and maintaining a high security bar by not always just shifting left.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/0*RFCnr-OTN6FF3LO3" /><figcaption>Credit: Pete Cheslock for the meme.</figcaption></figure><p>AWS security issues can come in all shapes and sizes; this article is focused on AWS service and component configuration. Some of the most notable issues that people may be familiar with from the news are things like an open S3 bucket that contained customer data, or a database that was left wide open to the world that contained other sensitive information. These are all things that without proper scanning and auditing, can happen to your organization.</p><p>Many times, companies prefer the shift left strategy when it comes to identifying vulnerabilities. Shift left is a strategy in which you try to identify and stop vulnerabilities as early on in the development process as possible. This is a great approach that reduces the costs associated with remediating security issues as it is typically less expensive to change something within a code review vs changing something in production. Shift left is a great strategy for things that are defined in code, but what about everything else that was created before IaC (infrastructure as code) was started within the company? Or that one account that was supposed to be used purely for development purposes where IaC is not enforced? This is where a combination of shifting left and right comes into play, or scanning things across the entire SDLC spectrum. In terms security practitioners would recognize, this is a modern version of “defense in depth” applied to the cloud native model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2Qli2Nww6WMgNC6K" /></figure><p>Life360 uses a continuous spectrum approach for AWS security issues, meaning we want to detect and prevent new issues as quickly as possible within the SDLC, but we also want to find things that already exist within production, have been created without code, or somehow made it past earlier scans. We have a company preference toward both open source and AWS native tooling due to the wide community knowledge base and support, as well as their products being budget friendly. Commercial products are great, but at a certain scale, they become cost prohibitive.</p><p>As you can see in the diagram below, we have incorporated various tooling and other processes into the SDLC process. Starting at the left hand side we will overview and describe the functionality and integration of each of these items.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lT8Ejkxax0Y0c9pq_5EWAQ.png" /></figure><p><strong>Education</strong></p><p>From my time and experience working with developers who use AWS, one common source of security misconfigurations comes from a lack of knowledge about what a setting or change would do. This is why education is especially important when working with AWS. At Life360 we ensure all developers who have access to the AWS cloud have the training resources required to perform their duties. We also have internal documentation about the preferred configuration states of AWS resources and when exceptions can be allowed.</p><p><strong>Preventative controls</strong></p><p>What is better than fixing something that has made it all the way to production? Making it impossible for that to ever happen! Life360 creates guardrails via technologies like <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps.html">AWS Service Control Policies</a> and global configuration items like “S3 account level block public access” to ensure undesired configurations are not allowed in the first place. We use SCPs for things like denying certain regions, preventing the disabling of security controls, and creating configurations that expose resources to the internet. Guardrails can be an impediment to progress, so it is important to only restrict where you are sure it will not block normal development.</p><p><strong>Design Reviews and Threat Modeling</strong></p><p>It is possible to identify security misconfiguration in the design and tech spec processes. This is why it is important that all designs and implementation plans are threat modeled and reviewed before engineering work commences. This way, security or other stakeholders can raise concerns earlier on in the design process, reducing the likelihood that a misconfiguration could happen. This is a multistage process that involves reviews at the high level design phase and the technical implementation phase. This is not including pull requests, which happens closer to the deployment phase.</p><p><strong>TFSec</strong></p><p><a href="https://aquasecurity.github.io/tfsec">TFSec</a> is an open source static analyzer for your terraform code. It can detect misconfigurations such as open security groups, S3 buckets as well as lack of encryption. We encourage all contributors of terraform at Life360 to run TFSec locally while they are developing infrastructure code. Additionally, TFSec is run on all pull requests as a Github action and within the terraform plan deployment step which uses Atlantis (a CI/CD tool for terraform deployments). If high criticality TFSec findings are introduced, TFSec automatically blocks the PR, preventing developers from applying terraform code at all and therefore introducing a security misconfiguration.</p><p><strong>Security Hub</strong></p><p>Security Hub is provided by AWS. It scans AWS resources and looks for configuration vulnerabilities. When new issues occur, it can trigger different workflows on how that alert should be handled. Those workflows can include automated remediation scripts, Slack notifications, or integration into a SOAR product for more complex analysis and remediations. Security Hub is a great cost effective solution, but lacks some of the reporting and automation capabilities that commercial products offer such as Prisma Cloud. We utilize Security Hub for real time notification of high criticality alerts, and to prioritize and plan future security remediation work and controls such as making Cloud Custodian remediation rules.</p><p><strong>Cloud Custodian</strong></p><p>Cloud Custodian is a great open source solution to write complex detection and remediation capabilities with little effort. With native Security Hub, we would often have to create custom complex lambdas to perform the remediations. With Cloud Custodian, it is often as simple as writing a few lines of code. We primarily reserve Cloud Custodian for alerts that are too noisy (just fix it for us please!) and where we think the risk of remediation efforts impacting production is minimal/acceptable. For example, we certainly would not enable a rule that would terminate an EC2 instance within production, but we might enable a rule like that within development. Our Cloud Custodian runs within a centralized security AWS account, and uses cross account IAM roles to query and remediate issues.</p><p><strong>Attack Surface Management</strong></p><p>Attack surface is one of the most underlooked items within AWS security. Attack surface in this context is EC2, or other AWS IP based resources that are reachable from the internet. Existing tooling provided by AWS, mainly the AWS Network Inspector, provides some level of scanning for attack surface but also relies on having a relatively cruft free environment and really good security group hygiene. If anyone has worked in a non greenfield environment, they know that security groups often grow into a mess that is difficult to untangle. At Life360, we opted for a custom solution that uses NMap, as well as an internal database to periodically list all EIPs across all AWS accounts, and port scan them to check to see if they are actually open and will accept a connection request, not simply if they have a security group that would allow it, which is how AWS Network Inspector works. This system alerts when an EIP and port is reachable from the internet in near real time, so that the security engineer can lock down that exposure. This system is not yet open sourced but we are considering publishing it in the future. Commercial tooling was also an option for this, like Censys, but with Life360’s scale it was cost prohibitive.</p><p><strong>CloudTrail Alerts</strong></p><p>We utilize organizational level Cloudtrail configuration to send all events to a log management cluster. From there, we create alerts for actions we would like notifications on and send it to security for review and next steps. One of these items could be creating an IAM user, since we have a preference for using IAM roles where possible.</p><p><strong>AWS Macie</strong></p><p>This is a relatively new tool for Life360. We use this to look for sensitive information only on public buckets, as we estimated if we scanned against all our buckets it would cost somewhere in the hundreds of thousands to millions per year. We have Macie configured to look for all the normal PII, PCI information but also utilize custom identifiers to look for Life360 specific sensitive information like location data, user and circle IDs.</p><p><strong>Lambda and Boto3 Script</strong></p><p>The last tools within our AWS security arsenal are lambdas and boto3 scripts. Where automation, security hub or cloud custodian might not fit well, we will often write custom python boto3 scripts and run them periodically across all our AWS accounts on a cron based schedule. This solution is not very elegant, but when time and engineering resources are constrained, it can be a very cost effective solution to just get things done.</p><p><strong>Conclusion</strong></p><p>When it comes to AWS security, we believe it’s important to shift left and right and not just focus on one or the other. Shifting left is great for preventing security misconfigurations and failing faster, but will not always catch everything. As you start, or continue your AWS security journey, here’s what’s worked for us in building a layered approach to security that supports rapid DevOps style releases while maintaining security.</p><p><strong>Detection</strong> is key to starting any successful AWS cloud security journey but the volume quickly becomes unmanageable with the amount of findings that need to be triaged. At a minimum, you should <strong>enable AWS Security Hub</strong> and review the findings starting with the most critical ones first. Once you complete the first review, keep an eye on new findings that occur as AWS is always adding new rules to their Security Hub product. <strong>Automation and preventative controls</strong> are the key to scaling your AWS security program and to allow for your development team to continue to be agile, but also secure!</p><p>We hope you enjoyed this article. If you have any questions, feel free to reach out to me. Also be on the lookout for our next security blog about container security at Life360!</p><h3>Come join us</h3><p>Life360 is the first-ever family safety membership, offering protection on the go, on the road, and online. We are on a mission to redefine how safety is delivered to families worldwide — and there is so much more to do! We’re looking for talented people to join the team: check out our <a href="http://www.life360.com/jobs">jobs page</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8487f999c07" width="1" height="1" alt=""><hr><p><a href="https://medium.com/life360-engineering/dont-just-shift-left-with-aws-cloud-security-you-might-miss-something-8487f999c07">Don’t just shift left with AWS cloud security, you might miss something!</a> was originally published in <a href="https://medium.com/life360-engineering">Life360 Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Setup — Customizing Android Studio with the IntelliJ Plugin SDK (Part 2)]]></title>
            <link>https://medium.com/life360-engineering/the-setup-customizing-android-studio-with-the-intellij-plugin-sdk-part-2-7d1ea0599113?source=rss----7d698da22bc9---4</link>
            <guid isPermaLink="false">https://medium.com/p/7d1ea0599113</guid>
            <category><![CDATA[intellij-plugin]]></category>
            <category><![CDATA[android-studio-plugins]]></category>
            <category><![CDATA[android-studio]]></category>
            <category><![CDATA[plugin-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Patches Klinefelter]]></dc:creator>
            <pubDate>Wed, 26 Jan 2022 01:01:45 GMT</pubDate>
            <atom:updated>2022-01-26T01:01:45.750Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Setup — Customizing Android Studio with the IntelliJ Plugin SDK (Part 2)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m777gOVrl_qtW5_azGj-jw.jpeg" /></figure><p>In <a href="https://medium.com/life360-engineering/customizing-android-studio-with-the-intellij-plugin-sdk-part-1-8827e3ddd217">part 1</a> of this blog series, we started diving into how Android Studio plugins were used to solve real problems faced by our engineering team. Now we can start discussing the prerequisites and setup required as well as how they evolved into something the Android team could feasibly use.</p><h3>Creating a New Project</h3><p>Both Plugins I’ve written so far have taught me valuable lessons about how to work with the IntelliJ Platform and its expectations. I first started by following the <a href="https://plugins.jetbrains.com/docs/intellij/gradle-prerequisites.html">Gradle guide</a> to create a new project with Kotlin and Groovy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qDfOyp1RHZIC82F1_S8ZWA.png" /><figcaption>New Project Creation</figcaption></figure><p>This was before the plugin projects had migrated to Kotlin DSL. You can leverage Java 11 as well, but at the time of writing Java 8 was selected since it was before Android Studio brought in better Java 11 support.</p><p>At this point, you will also want to setup your IDE to run the plugin if it’s not already done by default. Under Run -&gt; Edit Configurations you should see or create a task that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DW2xWks_QqdIc1ysV2FiMw.png" /><figcaption>runIde task</figcaption></figure><h3>A Plugin’s Structure</h3><p>A plugin’s project structure is very similar to most pure Java/Kotlin projects where there is a src/main/kotlin or src/main/java directory where the Kotlin or Java plugin code will be written as well as additional source directories like test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*EzSvvosgRaHPl6PgMMuq5w.png" /><figcaption>Project Structure</figcaption></figure><p>Within the structure, there are two main files that are vital and work together to define a plugin. These are:</p><ol><li>The resources/META-INF/plugin.xml file and</li><li>The build.gradle or build.gradle.kts</li></ol><p>These files contain crucial information such as what IDEs your plugin supports, the version for the plugin, changelog notes, and what additional SDK features are necessary for the plugin to function. We’ll dive into parts of these one at a time.</p><h3>The build.gradle</h3><p>Within the build.gradle is where additional plugins are enabled such as the IntelliJ plugin verifier (covered later), KTLint (<a href="https://github.com/pinterest/ktlint">https://github.com/pinterest/ktlint</a>), and basic Java/Kotlin support. This is not much different from a typical Gradle plugin setup where ids and versions are defined.</p><pre>plugins <strong>{<br>    </strong>id(&quot;java&quot;)<br>    // Kotlin support<br>    id(&quot;org.jetbrains.kotlin.jvm&quot;) <em>version </em>&quot;1.4.32&quot;<br>    // <a href="https://github.com/JetBrains/gradle-intellij-plugin">https://github.com/JetBrains/gradle-intellij-plugin</a><br>    id(&quot;org.jetbrains.intellij&quot;) <em>version </em>&quot;1.1.2&quot;<br>    // Kotlin linter - <a href="https://github.com/JLLeitschuh/ktlint-gradle">https://github.com/JLLeitschuh/ktlint-gradle</a><br>    id(&quot;org.jlleitschuh.gradle.ktlint&quot;) <em>version </em>&quot;9.4.1&quot;<br><strong>}</strong></pre><p>Similarly, dependencies, repositories, and publication details are also defined in this file. Below is an example that defines a version and group for publishing, sets up some basic Kotlin stblib imports, and also imports JUnit as well for unit tests.</p><pre><em>group </em>= &quot;com.life360.android&quot;<br><em>version </em>= pluginVersion</pre><pre><em>repositories </em><strong>{<br>    </strong>mavenCentral()<br>    gradlePluginPortal()<br><strong>}</strong></pre><pre><em>dependencies </em><strong>{<br>    </strong><em>compileOnly</em>(files(&quot;lib/wizard-template.jar&quot;))<br>    <em>implementation</em>(&quot;org.jetbrains.kotlin:kotlin-stdlib:1.4.32&quot;)<br>    <em>implementation</em>(&quot;org.jetbrains.kotlin:kotlin-reflect:1.4.32&quot;)</pre><pre>    <em>testImplementation</em>(&quot;junit:junit:4.13.1&quot;)<br><strong>}</strong></pre><p>The most unique portion of a Gradle file for a plugin project is the intellij closure. This is where the version, name, additional Intellij SDK plugin features, and IDEs supported are defined. There’s also a field to set the compile-time version of the IntelliJ Platform SDK similar to how you define the compile SDK version for Android.</p><pre>// See <a href="https://github.com/JetBrains/gradle-intellij-plugin/">https://github.com/JetBrains/gradle-intellij-plugin/</a><br><em>intellij </em><strong>{<br>    </strong>type.set(&quot;IC&quot;)<br>    version.set(compileIdeVersion)<br>    pluginName.set(&quot;Life360 Templating Plugin&quot;)<br>    plugins.set(<em>listOf</em>(&quot;android&quot;))</pre><pre><em>    /**<br>     * Download IntelliJ sources while configuring Gradle project.<br>     */</em><br>    downloadSources.set(true)</pre><pre><em>    /**<br>     * Patch plugin.xml with since and until build <br>     * values inferred from IDE version.<br>     */<br></em>    updateSinceUntilBuild.set(false)<br><strong>}</strong></pre><p>Another key feature is being able to test your plugin in a Sandboxed environment with the option to specify an alternate IDE. runIde handles creating a Sandboxed instance already, so there’s no additional work required there. It’s important to note that without defining an alternate IDE, the plugin will default to opening in IntelliJ Community Edition. In the example below, the location provided to the ideDir is for Android Studio. This means when runIde (sometimes called runPlugin) is executed, the plugin can be utilized and seen in a Sandboxed version of Android Studio for testing.</p><pre>import org.apache.tools.ant.taskdefs.condition.Os</pre><pre>val androidStudioPath = if (Os.isFamily(Os.<em>FAMILY_WINDOWS</em>)) {<br>    &quot;C:\\Program Files\\Android\\Android Studio&quot;<br>} else {<br>    &quot;/Applications/Android Studio.app/Contents&quot;<br>}</pre><pre><em>runIde </em><strong>{<br>    </strong>ideDir.set(File(androidStudioPath))<br><strong>}</strong></pre><h3>Plugin Verifier</h3><p>Along with manual verification, IntelliJ offers a tool (<a href="https://github.com/JetBrains/intellij-plugin-verifier">https://github.com/JetBrains/intellij-plugin-verifier</a>) that will run compatibility checks against a list of specified versions. This is extremely useful so that it is not necessary to track down and manually test each version of the IDE you want to support. By simply running ./gradlew runPluginVerifier the tool will run a set of checks against the specified list and output potential issues to look into. It’s also possible to specify the version of plugin verifier to use.</p><pre><em>runPluginVerifier </em><strong>{<br>    </strong>verifierVersion.set(&quot;1.256&quot;)<br>    ideVersions.set(<em>listOf</em>(&quot;IU-201.8743.12&quot;))<br><strong>}</strong></pre><p>The patchPluginXML closure is another place where information about the plugin is defined. It is important to know this piece of information from the docs (<a href="https://plugins.jetbrains.com/docs/intellij/gradle-guide.html#patching-the-plugin-configuration-file">https://plugins.jetbrains.com/docs/intellij/gradle-guide.html#patching-the-plugin-configuration-file</a>):</p><blockquote>If a patchPluginXml attribute value is explicitly defined, the attribute value will be substituted in <strong>plugin.xml</strong>.</blockquote><p>This means that regardless of values in the plugin.xml , the ones from the Gradle file will take priority. The minimum IDE version supported is defined by sinceBuild and the maximum is defined by untilBuild. You can also see in the example below that change notes can be specified.</p><pre><em>patchPluginXml </em><strong>{<br>    </strong>version.set(pluginVersion)<br>    sinceBuild.set(minIdeVersion)<br>    untilBuild.set(maxIdeVersion)<br>    changeNotes.set(<br>        &quot;Removes documentation directories before regenerating docs, updates Kotlin, &quot; +<br>            &quot;stabilizes plugin verifier version used, and updates org.jetbrains.intellij plugin&quot;<br>    )<br><strong>}</strong></pre><p>The plugin.xml feels much like and AndroidManifest.xml . The name, id, vendor, and description are defined. It is also possible to specify the minimum and maximum supported IDE versions, but if defined in the Gradle file, they will be override</p><h3>The Plugin.xml</h3><p>It does seem somewhat redundant to define the name and plugins in both the intellij closure of the Gradle file and the plugin.xml but as far as I can tell, the intellij closure does not patch the plugin.xml like patchPluginXml does.</p><pre>&lt;idea-plugin&gt;<br>    &lt;id&gt;com.life360.android.templating.plugin&lt;/id&gt;<br>    &lt;name&gt;Life360 Templating&lt;/name&gt;<br>    &lt;vendor&gt;Life360&lt;/vendor&gt;</pre><pre>    &lt;description&gt;<br>        A plugin that will add Life360 specific templates to the project creation screen of Android Studio<br>    &lt;/description&gt;</pre><pre>    &lt;idea-version since-build=&quot;201.8743.12&quot; until-build=&quot;203.*&quot; /&gt;</pre><pre>    &lt;!-- Product and plugin compatibility requirements --&gt;<br>    &lt;!-- <a href="https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html">https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html</a> --&gt;<br>    &lt;depends&gt;org.jetbrains.android&lt;/depends&gt;</pre><pre>    &lt;extensions defaultExtensionNs=&quot;com.android.tools.idea.wizard.template&quot;&gt;<br>        &lt;wizardTemplateProvider implementation=&quot;com.life360.android.templating.plugin.KitAndEngineTemplateProvider&quot; /&gt;<br>    &lt;/extensions&gt;</pre><pre>&lt;/idea-plugin&gt;</pre><p>With this setup, you should be able to see your plugin live in an IDE and begin to bring additional features to your</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k4fWJKMMDUy0y1YPXPAlTQ.png" /><figcaption>Plugin in the settings list</figcaption></figure><p>In the next entry of this series, I will cover some basics about plugins such as extension points, GUI work, and other key classes that can be used to actually start implementing your own neat features.</p><h3>Additional Resources</h3><ul><li><a href="https://plugins.jetbrains.com/docs/intellij/welcome.html">https://plugins.jetbrains.com/docs/intellij/welcome.html</a></li><li><a href="https://plugins.jetbrains.com/docs/intellij/gradle-prerequisites.html">https://plugins.jetbrains.com/docs/intellij/gradle-prerequisites.html</a></li><li><a href="https://plugins.jetbrains.com/docs/intellij/dev-alternate-products.html#configuring-pluginxml">https://plugins.jetbrains.com/docs/intellij/dev-alternate-products.html#configuring-pluginxml</a></li><li><a href="https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html">https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html</a></li><li><a href="https://github.com/pinterest/ktlint">https://github.com/pinterest/ktlint</a></li><li><a href="https://github.com/JetBrains/intellij-plugin-verifier">https://github.com/JetBrains/intellij-plugin-verifier</a></li><li><a href="https://github.com/JetBrains/gradle-intellij-plugin#setup-dsl">https://github.com/JetBrains/gradle-intellij-plugin#setup-dsl</a></li></ul><h3>Come join us</h3><p>Life360 is the first-ever family safety membership, offering protection on the go, on the road, and online. We are on a mission to redefine how safety is delivered to families worldwide — and there is so much more to do! We’re looking for talented people to join the team: check out our <a href="http://www.life360.com/jobs">jobs page</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d1ea0599113" width="1" height="1" alt=""><hr><p><a href="https://medium.com/life360-engineering/the-setup-customizing-android-studio-with-the-intellij-plugin-sdk-part-2-7d1ea0599113">The Setup — Customizing Android Studio with the IntelliJ Plugin SDK (Part 2)</a> was originally published in <a href="https://medium.com/life360-engineering">Life360 Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jenkins Mysteries: Phantom AWS Roles]]></title>
            <link>https://medium.com/life360-engineering/jenkins-mysteries-phantom-aws-roles-2d3afcb78d9?source=rss----7d698da22bc9---4</link>
            <guid isPermaLink="false">https://medium.com/p/2d3afcb78d9</guid>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[build]]></category>
            <dc:creator><![CDATA[Benjamin Galperin]]></dc:creator>
            <pubDate>Fri, 24 Dec 2021 21:30:46 GMT</pubDate>
            <atom:updated>2021-12-24T21:30:46.442Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YpJEJXKOqvU907FyFXe6Iw.png" /><figcaption>The Mysterious Case Of The Phantom AWS Roles</figcaption></figure><p>Hello and welcome to my little corner of Life360, please step into my office and make yourselves comfortable as I regale you with a tale of mystery, frustration, and automation: The case of the phantom AWS roles.</p><p>It was a damp and foggy night, not much different from any other night in San Francisco. There I sat, a dimly lit room with nothing but the glow of my laptop’s screen illuminating my face and the nearby trays that held small piles of paper. Sitting in the tray labeled “In Progress” sat a particularly troublesome ticket, one that had the audacity to travel back from the “In Testing” tray to its current resting spot. The ticket’s task was supposed to be simple: Configure the mobile pipeline to retrieve its secrets from AWS Secrets Manager using a bespoke AWS IAM Role, but it was proving to be anything but; When assuming this tailored AWS IAM Role we would sometimes come across a specter of itself, that in fact we had somehow already assumed the role, that some ghost in the machine was providing credentials where there should be none. But before diving deeper into this programming poltergeist, I should give a little background on our systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*lG7uPnYzqRhs4YigTW-c1w.gif" /></figure><p>A thorough overview of our mobile pipelines would need its own dedicated post, so in the immortal words of Inigo Montoya, “Let me explain. No, there is too much. Let me sum up.”</p><p>This particular pipeline is run on Jenkins, in which we use multi branch pipelines and split everything into distinct Build, Test and Deploy stages. The paradigm can be summed up along these lines: Determine what needs to be built first, go ahead and build it, then stash it somewhere so it can be passed along to the parts of the Test or Deploy stage that need it. We accomplish this using Jenkins Shared Libraries that take in parameters from a project’s Jenkinsfile, then use that information to determine what needs to be built, which tests to run, and whether or not something needs to be deployed once tests pass. Each of these stages can be split up to run various tasks on their own nodes in parallel with one another. Combine this with a steady use of caching dependencies and propagating artifacts to downstream tasks, we are able to cut down on end to end pipeline execution times. Lots of details are left out of this overview, but as Mr. Montoya mentioned, there is too much for now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*opOTuz09ahkP2rB5ncdebA.png" /><figcaption>Secrets management is important</figcaption></figure><p>However, one detail worth mentioning is how we handle our secrets. Typically keys, tokens, secrets, etc don’t belong in your source code, so you need to store them somewhere secure while also having the ability to safely retrieve them. We use AWS Secrets Manager and set up dedicated AWS IAM roles that have access to a small scope of secrets. For example, our android mobile pipelines only have access to android related secrets, while our iOS mobile pipelines only have access to iOS related secrets; Roles should only have access to what they need.</p><p>With that information out of the way, we can get back to the aforementioned task which lay on my desk. We had recently consolidated our mobile pipeline secrets into one AWS account and we needed to update the Jenkins pipeline to use the new AWS roles that were dedicated in the fashion previously mentioned. I swapped in the new AWS roles into our existing secrets fetching methods, all the tests passed, the changes were merged into our Jenkins shared library repository and all was well. Until it wasn’t. Builds started sporadically failing, different stages failing at different times in different locations, passing here, failing there, nothing made sense, it was the chaos of an intermittent issue.</p><p>After a hasty revert it was time to comb through the logs and see if we could determine the pipeline’s cause of death. The autopsy report beckoned:</p><blockquote>Office of Build &amp; Release Engineering<br>Autopsy Report<br>Case No: 42–069<br>Deceased: Pipeline, Android<br>Type of Death: Pipeline Error Signal</blockquote><blockquote>Autopsy: Jenkins pipeline containing Build, Test and Deploy stages, with each stage running various stages on their own nodes in parallel. Nodes appear to be running in Linux VMs with various resource sizes, scaling up and down via AWS EKS. No anomalies found in the Build stage. Sporadic failures across all testing stages that require fetching secrets. UI tests, unit tests, and analyzers all experiencing intermittent failures upon attempting to assume a role to fetch AWS SM secrets. Deploy stage never reached due to Test stage failures.</blockquote><blockquote>Cause of Death: Pipeline error signal upon receiving the following message</blockquote><blockquote><em>An error occurred (AccessDenied) when calling the AssumeRole operation: User: arn:aws:sts::&lt;ACCOUNT-REDACTED&gt;:assumed-role/&lt;ROLE-REDACTED&gt; is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::&lt;ACCOUNT-REDACTED&gt;:role/&lt;ROLE-REDACTED&gt;</em></blockquote><blockquote>Notes:<br>It is in my professional opinion that the cause of death is a terminal existential crisis in which the pipeline attempted to assume the role of itself.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3lXwmSTh2A-hdRWX3-MnHw.png" /><figcaption>The crime scene</figcaption></figure><p>After reading the autopsy report I began to troubleshoot the issue. The first thing I did was just a simple sanity check to ensure the AWS roles and resources had the required permissions. Everything looked fine: The base role our Jenkins pipeline used had the permissions to assume the new android mobile pipeline role, and that mobile role allowed itself to be assumed by the base Jenkins role. Similarly, the android mobile role had the correct read permissions to access the AWS SM entries we wanted to retrieve. With that out of the way I moved on to see how we were setting out AWS role credentials.</p><p>The report had pointed me in the right direction, so I created my own Jenkins shared library repository branch to start testing. While the failing stages were intermittent, the type of error was always the same: An AccessDenied error when attempting to assume the required role because it had already assumed it. Navigating to the common method we used for fetching secrets it was clear that it had logic in it to stash any existing AWS credentials, assume the requested role and retrieve the required secret entry, then revert back to the stashed credentials. What followed was an extreme saturation of debug print statements such that I could see what AWS credentials were in use at any given time by running the “aws sts get-caller-identity” command everywhere in which secrets were retrieved in this particular pipeline. The results would be equal parts surprising and confusing.</p><p>Two Jenkins “sh” steps running one immediately after the other would sometimes return different values for the “aws sts get-caller-identity” command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*I3aaNBZ32PzvDaH453fOhQ.png" /><figcaption>What?</figcaption></figure><p>I thought to myself, how is such a thing possible? Those two “sh” steps were running on the same node, and I could see nothing in those steps that would change the AWS credentials. I decided to explicitly clear any AWS credentials prior to assuming a requested role by following AWS documentation and using the “unset” command within those debug “sh” steps. The result was frustratingly the same, the “aws sts get-caller-identity” command would still intermittently return a different value than the step immediately before it.</p><p>In hindsight, these clues should have been enough to point me in the culprit’s direction, but I didn’t come to realize this until I took a step back and looked at the pipeline results as a whole. The Build stage never seemed to have this problem, so what was it doing differently than the Test stage? In this case, my testing branch Build stage was running one stage in one node, while the Test stage was running a number of stages in parallel, each on their own node. If the way we are setting AWS credentials is writing to a single location, this would lead to the precise asynchronous issue that killed this pipeline.</p><p>We were close, the culprit nearly in our grasp. Following this new set of clues brought us to the methods we used to set, get, and stash AWS credentials. One look at this code and it was clear what had happened: We were setting our AWS credentials to environment variables, but we were doing it by writing to the “env” map, the same map that’s accessible by all of the nodes that were running in parallel in our pipeline! Any time the nodes started a new “sh” step to begin the assume-role process they would default to the credentials stored in this global env map leading to the precise issue we were facing: Attempting to assume a new role while using an unexpected role’s credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*VAts4LLq8TgQ_QZOIWI1JQ.png" /></figure><p>The first fix that came to mind was to clear out any AWS credentials before assuming a new role, however that was not an option as there were other pipelines in the company that depended on nested role assumptions. Given the nature of Jenkins shared libraries it’s always beneficial to check how other pipelines may be using the methods you intend on changing in your shared library. I quickly ditched that proposal and moved on to the next, quite simpler one.</p><p>The simple fix for our pipeline would take advantage of our mobile secrets already being compartmentalized, and dedicated roles for each mobile pipeline. As mentioned earlier, our android mobile pipeline has a specific AWS role that caters to just the android mobile pipeline. There’s simply no need to constantly assume roles when we instead can assume the role once at the beginning of the pipeline and keep that role the entire way through. This assured us that multiple nodes were not writing to the global environment variable map and overriding the AWS credentials stored there.</p><p>A longer term fix would be to change the way we store AWS credentials to allow for parallel nodes to assume whatever roles they want in parallel with each other, but that’s a larger refactor, and a topic for another time.</p><p>And that’s where this detective story comes to an end. We analyzed the cause of failure, followed the clues and implemented a fix to keep the developer’s pipeline moving. Sometimes there’s no killer, it’s just an accident. No smoking gun, no bloody knife, nothing complicated, elaborate or malicious, just a simple case of asynchronous writing to a global object. Held in my hand was a circular rubber stamp that read “DONE” in large bold letters surrounded by the phrase “semper vigilantes, semper fluit”. The once elusive ticket now lay silent in the “In Testing” tray, awaiting the rubber stamp. I was eager to punch this ticket, but it would have to wait until more of my clients had triggered the pipeline and all looked well.</p><p>It’s late, and the night is still damp and foggy, but as I ponder the words on the stamp I take solace in successfully ensuring that the mobile pipeline must flow, and some days that’s just good enough.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W5bwL5GmvjNk-xJYq3o3LQ.jpeg" /><figcaption>Semper vigilantes, semper fluit</figcaption></figure><h3>Come join us</h3><p>Life360 is the first-ever family safety membership, offering protection on the go, on the road, and online. We are on a mission to redefine how safety is delivered to families worldwide — and there is so much more to do! We’re looking for talented people to join the team: check out our <a href="http://www.life360.com/jobs">jobs page</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d3afcb78d9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/life360-engineering/jenkins-mysteries-phantom-aws-roles-2d3afcb78d9">Jenkins Mysteries: Phantom AWS Roles</a> was originally published in <a href="https://medium.com/life360-engineering">Life360 Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How we reduced our iOS AppStore binary size]]></title>
            <link>https://medium.com/life360-engineering/how-we-reduced-our-ios-appstore-binary-size-54a870b7a4ed?source=rss----7d698da22bc9---4</link>
            <guid isPermaLink="false">https://medium.com/p/54a870b7a4ed</guid>
            <category><![CDATA[dsym]]></category>
            <category><![CDATA[life360]]></category>
            <category><![CDATA[bitcode]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[size]]></category>
            <dc:creator><![CDATA[Victor Sigler]]></dc:creator>
            <pubDate>Tue, 09 Nov 2021 19:50:29 GMT</pubDate>
            <atom:updated>2021-11-09T19:50:29.272Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*09sa5xp5n2G0xlJ6Zd37aQ.png" /></figure><p>A few months ago, our Forensics team was inspecting the crashes in the iOS app in Firebase Crashlytics. A beautiful red banner that I’m sure you have seen before was there alerting us that we were missing <strong>dSYMs </strong>and some crashes were not being shown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uBy_ilP1T6n8fqAXoRy6LA.jpeg" /></figure><p>We decided to start an investigation 🧐 right away to identify the causes of the missing <strong>dSYMs </strong>in Firebase Crashlytics. By now, you might be wondering what has <strong>dSYMs</strong> have to do with reducing app size? Read on 😉.</p><h3>Problem</h3><p>What are these <strong>dSYMs </strong>🤔 files that Crashlytics is complaining about? According to <a href="https://developer.apple.com/documentation/xcode/building-your-app-to-include-debugging-information">Apple</a>:</p><blockquote>When Xcode compiles your source code into machine code, it generates a list of symbols in your app — class names, global variables, and method and function names. These symbols correspond to the file and line numbers where they’re defined; this association creates a debug symbol, so you can use the debugger in Xcode, or refer to line numbers reported by a crash report. Debug builds of an app place the debug symbols inside the compiled binary file by default, while release builds of an app place the debug symbols in a companion Debug Symbol file (dSYM) to reduce the size of the distributed app.</blockquote><p>We have several environments in our app (QA, Alpha, Beta, Production), and for each environment, we upload the generated <strong>dSYMs </strong>to Crashlytics using <strong>fastlane</strong> and the <a href="https://docs.fastlane.tools/actions/upload_symbols_to_crashlytics/">upload_symbols_to_crashlytics</a><strong> </strong>action. We started checking if our build settings in the app were generating the necessary <strong>dSYM</strong> files for our production builds, and everything was good ✔️.</p><p>We didn’t have Bitcode enabled in our iOS app. We were aware of the <a href="https://developer.apple.com/documentation/xcode/doing-basic-optimization-to-reduce-your-app-s-size">benefits of Bitcode</a> and the optimization it allows to reduce the app’s size, but for unknown reasons, we had issues enabling it in the past, and we decided to turn it off. We noticed that some of our third-party and internal libraries have Bitcode enabled by default in their build settings, which could create issues in our binary as we didn’t have it enabled.</p><h3>Solution</h3><p><strong>We decided to enable Bitcode for our app! </strong>Enabling Bitcode for our entire app and all the project’s in the workspace was not a difficult task but a little tricky as we would need to be sure that Bitcode was enabled for all the projects and libraries consumed in the iOS app and we had to modify our lanes in our <strong>Fastfile </strong>to start adding the symbols when the app is archived.</p><p>Once we had everything compiling and running successfully in a private branch we decide to open a draft PR to test the CI and be able to get insights in how much our IPA size was growing now with Bitcode and the symbols included. We created a <a href="https://danger.systems/ruby/">Danger</a> plugin to control in each pull request how much our IPA is changing compared with the latest successful pull requests merged and we generate a report for developers to keep track of it. The change of our IPA binary size in the pull request was very interesting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bu9SYPzhrrO9IdpvvZFVug.jpeg" /></figure><p>Our IPA size grew by <strong>124.34MB</strong> ⬆️! We want to ensure that our problem with the <strong>dSYMs </strong>was solved and check the App Store estimated sizes for the generated IPA as the IPA size is not a reflection of the real size in the App Store.</p><p>We have the tooling to upload apps to Testflight from a private branch to test critical cases in Production mode and distribute to the stakeholders before it’s released. Once we uploaded the IPA to TestFlight, these were the results compared with our latest released version, 20.5.0:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*yNe2j76YrxmbN6tkt6vB_w.png" /></figure><p>The compressed file size was reduced by <strong>4.7 MB</strong>, but let’s see how the comparison between those two builds in App Store File Sizes was for each device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XoqamDD1I6jZaBYvR3EsDg.jpeg" /></figure><p><strong>Install Size</strong> is the amount of disk space the app will take up on the customer’s device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7ENh5ANS6fOo3FAOatKP9Q.jpeg" /></figure><p><strong>Download Size</strong> is the compressed size of the app downloaded over the air.</p><p>We reduced our download size by <strong>~5%, </strong>and our most significant improvement was in the install size reducing it by <strong>~22%</strong>⬇️.</p><h3>Sub-problems</h3><p>Enabling Bitcode for our app means that Apple recompiles our app to reduce its size. The recompilation happens when we upload the app to App Store Connect, so at this point, we had to introduce a job in our CI to download the <strong>dSYMs </strong>from Apple servers and upload it to Crashlytics<strong> </strong>every day. The other option was to wait until a build submitted to Testflight finished the processing, but this could take a long time, making our CI hang out unnecessarily.</p><p>Another problem we had to face enabling Bitcode in our app was that every vendor of a third-party library that distribute binaries needs to distribute the <strong>dSYMs </strong>and the <em>bitcode symbol map</em> (<strong>bcsymbolmap</strong>) included with the framework. Crash report tools like Crashlytics need the <em>bitcode symbol map</em> to symbolicate the crashes correctly. Otherwise, you will start seeing the <em>hidden#109</em> lines in Crashlytics. Xcode replaces the symbols in your app’s dSYM files with obfuscated symbols, and the <em>bitcode symbol map </em>is necessary to deobfuscate it correctly.</p><p><em>We couldn’t be happier with the results of enabling Bitcode in our app, and the numbers speak for themselves!</em></p><h3>Come join us</h3><p>Life360 is the first-ever family safety membership, offering protection on the go, on the road, and online. We are on a mission to redefine how safety is delivered to families worldwide — and there is so much more to do! We’re looking for talented people to join the team: check out our <a href="http://www.life360.com/jobs">jobs page</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54a870b7a4ed" width="1" height="1" alt=""><hr><p><a href="https://medium.com/life360-engineering/how-we-reduced-our-ios-appstore-binary-size-54a870b7a4ed">How we reduced our iOS AppStore binary size</a> was originally published in <a href="https://medium.com/life360-engineering">Life360 Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Customizing Android Studio with the IntelliJ Plugin SDK (Part 1)]]></title>
            <link>https://medium.com/life360-engineering/customizing-android-studio-with-the-intellij-plugin-sdk-part-1-8827e3ddd217?source=rss----7d698da22bc9---4</link>
            <guid isPermaLink="false">https://medium.com/p/8827e3ddd217</guid>
            <category><![CDATA[intellij-plugin]]></category>
            <category><![CDATA[android-studio-plugins]]></category>
            <category><![CDATA[plugin-development]]></category>
            <category><![CDATA[android-studio]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Patches Klinefelter]]></dc:creator>
            <pubDate>Fri, 01 Oct 2021 21:57:28 GMT</pubDate>
            <atom:updated>2021-10-01T21:57:28.344Z</atom:updated>
            <content:encoded><![CDATA[<h4>There’s a Plugin For That</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XwEpgAyjpF0rGhEdUvm_mQ.jpeg" /></figure><p>IDEs are a very powerful tool in today&#39;s world of software engineering. They help catch syntax errors, display static code analysis warnings, help refactor and migrate code, and even serve as code generators.</p><p>Some common uses for plugins are:</p><ul><li>Code generation (also known as templating)</li><li>Adding additional IDE support for customized architectures</li><li>Adding automation for repetitive tasks to make them less time consuming</li><li>Creating a brand new language or Intellij IDE</li></ul><p>Over the course of my tenure at Life360, I have written and supported two plugins for Android Studio. Both of them solved two very distinct problems but contributed to the ease of use and velocity for the Android team.</p><p>The first plugin came about due to our very customized design system. The system uses a JSON format and some syntactic sugar so that colors could in the future be pulled remotely from the backend. Native IDE support was hindered by diverging from the typical colors.xml approach, making it cumbersome to know if the purple or gray you were using was the purple or gray you really wanted. Setting out to bring back more native-like support for colors, this plugin helped engineers have a visual representation of a named color in the gutter by parsing the JSON and hex codes. The end result was this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*heKrCSHH2iA78b0BJo0-1w.png" /><figcaption>Color palette at time of writing plugin</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NOixsZvYSfVaj59tDCYDXg.png" /><figcaption>Usage by Engineer</figcaption></figure><p>The second plugin was more in-depth. Overall, the team moved the architecture for the app towards micro-services and well-defined, smaller pieces. We made the decision to have multiple repositories, but there was a need to solve the amount of engineering time it took to bring these new pieces online.</p><p>CI configuration, static analysis, test setup, documentation, publication, and sample apps were all major pieces that went into the majority of these repositories. That’s when I set out to incorporate our desired architecture into the new project wizard of Android Studio. At first, I investigated Free Maker (<a href="https://freemarker.apache.org/">https://freemarker.apache.org/</a>) and local files but eventually landed on the Intellij supported plugin way to add to the existing wizard. This methodology does not require local files to be in sync, only that the plugin is up-to-date. The end result was a quicker startup time and a more enjoyable engineering experience creating new pieces of our system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*cnVIWZrYJixiO71JEWdjcg.png" /><figcaption>Two additional options were added to the new project wizard</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*IeYSv7ExaMYbiWnpgjs1JQ.png" /><figcaption>Page 1 of the new kit wizard</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*G4Hvf3g_2vFkJk0linR8mQ.png" /><figcaption>Page 2 of the new kit wizard</figcaption></figure><p>Although the wizard looks pretty, it is not the most important piece. The files generated are what really makes this a true time-saver. The files included are:</p><ul><li>A sample app complete with the navigation component and dagger setup</li><li>Jenkinsfile for CI config</li><li>KLint, Lint, CPD, and static analysis tools pre-configured</li><li>GitHooks to keep non-passing commits from taking time and resources on CI</li><li>A template for a CHANGELOG.md</li><li>A README.md</li><li>Config for Dokka to generate markdown documentation from KDocs</li><li>Fastlane for easy-to-use commands and publication</li><li>Jacoco and code coverage setup as well as example instrumentation and unit tests</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*onu5Xw9k4IjRGwROllgNXg.png" /></figure><p>The sample app, if burrowed down into, has a default single activity, multiple fragment setup with a top-level application that handles dagger injection. Proguard rules and a set of modules depending on the project type are also included and it strives to be a good living/working example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*RJSCKY6_xAXwwX42NoFNXA.png" /></figure><p>Overall, the templating plugin took what normally would take an engineer about a month or two (2–3 sprints) of effort for configuration and initial setup and cut it down to ~5–10 minutes. This means more coding sooner!</p><p>The process took a lot of trial and error and I am hoping that through this series I can relay some lessons learned the hard way, show you some tricks, and dive more into how I used these technologies to solve problems for the larger team.</p><p>Below are some documentation primers, and in part 2, I’ll dive more into how plugins like these are implemented.</p><ul><li>Kotlin (<a href="https://kotlinlang.org/">https://kotlinlang.org/</a>)</li><li>Intellij SDK (<a href="https://plugins.jetbrains.com/docs/intellij/welcome.html">https://plugins.jetbrains.com/docs/intellij/welcome.html</a>)</li><li>Kotlin DSL (<a href="https://docs.gradle.org/current/userguide/kotlin_dsl.html">https://docs.gradle.org/current/userguide/kotlin_dsl.html</a>)</li><li>Plugin verifier (<a href="https://github.com/JetBrains/intellij-plugin-verifier">https://github.com/JetBrains/intellij-plugin-verifier</a>)</li></ul><h3>Come join us</h3><p>Life360 is the first-ever family safety membership, offering protection on the go, on the road, and online. We are on a mission to redefine how safety is delivered to families worldwide — and there is so much more to do! We’re looking for talented people to join the team: check out our <a href="http://www.life360.com/jobs">jobs page</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8827e3ddd217" width="1" height="1" alt=""><hr><p><a href="https://medium.com/life360-engineering/customizing-android-studio-with-the-intellij-plugin-sdk-part-1-8827e3ddd217">Customizing Android Studio with the IntelliJ Plugin SDK (Part 1)</a> was originally published in <a href="https://medium.com/life360-engineering">Life360 Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How We Leveraged MetricKit to Gauge Our New Releases]]></title>
            <link>https://medium.com/life360-engineering/how-we-leveraged-metrickit-to-gauge-our-new-releases-3675376410b6?source=rss----7d698da22bc9---4</link>
            <guid isPermaLink="false">https://medium.com/p/3675376410b6</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[metrics]]></category>
            <category><![CDATA[release-management]]></category>
            <category><![CDATA[metrickit]]></category>
            <dc:creator><![CDATA[Michael Garza]]></dc:creator>
            <pubDate>Thu, 12 Aug 2021 00:52:38 GMT</pubDate>
            <atom:updated>2021-08-12T00:52:37.881Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1MuYvGUr3wt8gGL5bBNzhw.jpeg" /></figure><p>Delivering the best possible app experience to users has always been of the utmost importance at Life360. Ironically, it can be rather difficult to truly gauge how an app is performing when finally released in the wild. Our codebases are living documents that are constantly changing, yet we expect the reliability of the finished app to be consistent.</p><p>We all try our hardest to fill every check box to ensure a stable release: automatic testing, manual testing, alpha builds, beta testers, etc., however, sometimes issues make it past all of our checkpoints. What really concerns us the most is there are issues our users are experiencing that we don’t know exist yet. This is where the introduction of <a href="https://developer.apple.com/documentation/metrickit/">MetricKit</a> with iOS 13 came in to help fill in the gaps.</p><p>Integrating MetricKit is a very straightforward task. Simply import MetricKit, add a MXMetricManagerSubscriber, and wait for callbacks with func didReceive(_ payloads: [MXMetricPayload]). Once Apple sends a payload to the device, the data will need to be uploaded somewhere to be aggregated. There were some hiccups along the way during our integration though. As we experienced issues, it was nearly impossible to find any information on the internet, even in Apple’s Developer forums. Below are some oddities I discovered that will hopefully save you frustration in the future when it becomes time for implementation.</p><h3><strong>Implementation Pitfalls</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-t7UjZ27DFpE1AFGx7_BsQ.jpeg" /></figure><h4>Junk Data</h4><p>Apple will send junk data in MXMetricPayloads. We started noticing some weird values in our data such as negative numbers and MXAverages with an average, but a count of 0. I dug into my implementation on the iOS side and could not find any errors. Only after finally deciding to log the raw payloads during alpha testing did I discover that this data was sent to us malformed. MXMetricPayload’s jsonRepresentation() function isn’t always perfect either, as sometimes we would see values encoded this way 69,940 ms and also 69 440 ms . For the best results, clean up any junk on your end before sending the data along.</p><h4>Duplicate Payloads or no Payloads at All</h4><p>MXMetricPayloads are finicky and can also be sent twice. Testing the receiving of payloads requires an actual iOS device and Xcode. I found that I would not receive live payloads on my device after I have been testing debug payloads (test payloads sent through Xcode) for some time. Eventually after a few days to a week, live payloads would start being sent to my device again. I couldn’t figure out any rhyme or reason, just something I had to work around. If you have a designated debug device, I would highly recommend using that for your MetricKit testing. I’ve also seen payloads get sent twice, sometimes within the same delegate callback. Apple says we only ever get one report per 24 hours, but there is a bug out there where you will receive duplicates. Luckily, duplicate payloads will have the same start and end timestamps. A simple workaround is to keep a light cache of these timestamps for already processed payloads.</p><h4>Missing Certain Properties Within a Payload</h4><p>Are you missing some of your histograms at times and scratching your head as to why? Histograms are only sent when they have data for that 24 hour period. While the key/value pairs will return 0 for values with no data during a period, histograms are omitted entirely. It took a little bit of digging into payloads and the event stream of users to figure this out. If there are no metrics for histogrammedApplicationResumeTime for example, it is because the user did not resume the app during that period.</p><h4>Unit Tests Failing Due to iOS Version</h4><p>Unit tests will fail with a cryptic error message if not on iOS 13+. This one will drive other developers insane as they try to figure out how they broke the MetricKit tests. Turns out they just ran the tests on iOS 12 or lower. Even though the tests around MetricKit are wrapped in iOS 13 checks, running all unit tests locally with CMD + U will run everything, even if the conditions are wrong.</p><h3><strong>Let’s talk about the good</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BUEoBRP9LlUSNJ5wGCsOhQ.jpeg" /></figure><p>After we process and normalize the payloads on the device, we send the data as an analytics event to our provider. From there, we can create graphs of MetricKit data that we use to monitor our releases as they ramp up to 100% as well as some of our other use cases. Below are a few examples of these graphs.</p><p>The real strength comes during our new app version’s release. If any of our battery or performance graphs are off unexpectedly, we can pull back a potentially harmful release before the majority of our userbase is even aware of it. The graphs show that our 21.1 release went smoothly with basically zero change in our Peak Memory Usage and Cumulative Logical Writes.</p><p>Peak Memory Usage</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*brfrPCtndOootQQK" /></figure><p>Cumulative Logical Writes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sawuTB-B4_cLTh3p" /></figure><p>MetricKit also enabled us to finally answer questions with more certainty for our users and testers. If a tester noticed irregular battery drain on a certain day over others, we could see that their brightness was set to 100% that day instead of their usual 30%. If a user is worried about our app sending data over cellular and not wifi, we can prove not only how much we sent during that period, but over which type of connection.</p><p>While we do look at MetricKit data during our Beta testing, the small sample sizes can create some false positives in the data. A few in-house testers doing days of regression tests can easily skew numbers in such a small sample size. I’d recommend not taking any oddities at full face value when using a small sample size.</p><p>We still have more we can do with MetricKit in our future. iOS 14 introduced MXDiagnostics which look promising. We also want to roll out MetricKit to more, if not all of our users. While the team I’m a part of is in charge of monitoring the app and MetricKit, I would like to create a mechanism for other developers to utilize MXSignPosts. Creating an elegant way to consume histograms while not prematurely normalizing the data is also on my radar.</p><p>All in all, implementing MetricKit has proven to be a positive endeavor and I’d highly recommend adopting it to any iOS developer.</p><h3>Come join us</h3><p>Life360 is the first-ever family safety membership, offering protection on the go, on the road, and online. We are on a mission to redefine how safety is delivered to families worldwide — and there is so much more to do! We’re looking for talented people to join the team: check out our <a href="http://www.life360.com/jobs">jobs page</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3675376410b6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/life360-engineering/how-we-leveraged-metrickit-to-gauge-our-new-releases-3675376410b6">How We Leveraged MetricKit to Gauge Our New Releases</a> was originally published in <a href="https://medium.com/life360-engineering">Life360 Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[View Binding@Life360]]></title>
            <link>https://medium.com/life360-engineering/view-binding-life360-b8af648f3f3a?source=rss----7d698da22bc9---4</link>
            <guid isPermaLink="false">https://medium.com/p/b8af648f3f3a</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[view-binding]]></category>
            <category><![CDATA[android-view-binding]]></category>
            <category><![CDATA[androiddev]]></category>
            <dc:creator><![CDATA[Nisha Karamchandani]]></dc:creator>
            <pubDate>Fri, 02 Jul 2021 01:02:02 GMT</pubDate>
            <atom:updated>2021-07-02T15:50:00.118Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6CCBcedQ7DG2idEB1NmJvQ.png" /></figure><blockquote><strong>Section 1: Why view binding and how did we do it?</strong></blockquote><h3>Why did we want to move to view binding?</h3><p>ButterKnife is deprecated and is replaced by View Binding(VB). View Binding generates a binding class that contains direct references to all the views in the layout. This enables developers to write null safe, type safe and easy to maintain code for referencing UI. View Binding compiles faster because it does not require annotation processing. It also enables developers to implement features with less code. <a href="https://developer.android.com/topic/libraries/view-binding">https://developer.android.com/topic/libraries/view-binding</a></p><h3><strong>Benefits of View Binding over ButterKnife, Kotlin Synthetics and findViewById:</strong></h3><ol><li><strong>Reference Variables:</strong> View Binding generates a binding class which has reference to all layout components. We would not need variables like TextView, EditText in class files to access the XML components. Thus removing the need to add @BindView or equivalent to each component and reducing significant lines of code from all the View classes.</li><li><strong>Null safety:</strong> Since view binding creates direct references to views, there’s no risk of a null pointer exception due to an invalid view ID. Additionally, when a view is only present in some configurations of a layout, the field containing its reference in the binding class is marked with @Nullable.</li><li><strong>Type safety:</strong> The fields in each binding class have types matching the views they reference in the XML file. This means that there’s no risk of a class cast exception.</li></ol><h3>Phases of Implementation:</h3><p>The Life360 android codebase contains about ~25 modules, 15 of which have some layout views that needed to be modified. I created a spreadsheet which served as a blueprint of this implementation plan, with modules broken down into sub modules further broken into individual tasks (about 12 files in each task). Breaking the tasks in this pattern made sure that the changes were contained to one app feature at the most which makes testing a lot easier. At Life360 we have component ownership which kinda translates to modules in the code base, so my strategy for task break down also ensured that a PR would not require multiple component owners to sign off, avoiding delays in the process.</p><p>In one of our android tech sync’s which is a Triweekly meeting at Life360, I presented the view binding project with task breakdown to kick things off. I had my first PR for VB changes ready before this meeting to give a walk through of code changes and to serve as an example PR when developers picked up these tasks to work on.</p><p>I also used the spreadsheet to track progress outside JIRA in one place as all android developers from multiple teams were involved. I would color code every task to keep track of the status, follow up with developers and eventually every task would be green to indicate completion</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y6N7j1EDMkIVwcwNJJCOWQ.png" /></figure><p><em>Phase 1:</em> Consolidate to a list of modules that need to be upgraded/modified and create JIRA tickets for reviewable and easier to test PR’s</p><ol><li>Evaluate and create a list of modules where @BindView is being used</li><li>Evaluate and create a list of modules where usage of ButterKnife @OnClick needs to be replaced with setOnClickListener()</li><li>Evaluate and create a list of modules where usage of findViewById needs to be replaced with View Binding</li><li>Evaluate and create a list of modules where usage of Kotlin Synthetics needs to be replaced with View Binding</li></ol><p><em>Phase 2:</em> Introduce View Binding to our code base: Make sure everyone (25 developers) on the android team upgrades to the required Android Studio — 3.6, Android Gradle Plugin Version 3.6.0 and Gradle version 5.6.4.</p><p><em>Phase 3:</em> For each module:</p><p>Task 1: Module level. Modify build.gradle for every module to enable View Binding in the codebase</p><p>Task 2: Depending on the packages</p><ol><li>Replace usages of ButterKnife @BindView with View Binding</li><li>Replace usage of ButterKnife @OnClick with setOnClickListener(). @OnClick is the only functionality of ButterKnife that we use in our code which does not have an equivalent alternative in View Binding. We would need to change all the @OnClick implementation to .setOnClickListener() to ensure the click functionality doesn’t break.</li><li>Replace Kotlin Synthetics with View Binding</li><li>After all the code changes, run unit tests and perform manual testing on the affected module to ensure all the functionality is intact.</li></ol><p><em>Phase 4:</em> Clean Up Tasks:</p><ol><li>Make sure ButterKnife is removed from the codebase completely.</li><li>Remove Proguard rules for ButterKnife.</li><li>Remove ButterKnife code from gradle.properties</li></ol><h3>Here’s the code you need for the binding:</h3><p>View Binding is enabled on a module by module basis. To enable view binding in a module, add the viewBinding element to its build.gradle file</p><pre>android {<br>    ...<br>    buildFeatures {<br>        viewBinding = true<br>    }<br>}</pre><p>If view binding is enabled for a module, a binding class is generated for each XML layout file that the module contains. Each binding class contains references to the root view and all views that have an ID. The name of the binding class is generated by converting the name of the XML file to camel case and adding the word “Binding” to the end.</p><p>To set up an instance of the binding class for use with an activity, perform the following steps in the activity’s onCreate() method, call the static inflate() method included in the generated binding class. This creates an instance of the binding class for the activity to use. Get a reference to the root view by either calling the getRoot() method or using Kotlin property syntax. Pass the root view to setContentView() to make it the active view on the screen. You can then use the instance of the binding class to reference any of the views.</p><pre>private lateinit var binding: ResultProfileBinding<br><br>override fun onCreate(savedInstanceState: Bundle?) {<br>    super.onCreate(savedInstanceState)<br>    binding = ResultProfileBinding.inflate(layoutInflater)<br>    val view = binding.root<br>    setContentView(view)<br>}</pre><p>If case of a layout where you do not need to refer its UI components in the class file, you do not need view binding class generated. You can simply cause a layout file to be ignored while generating binding classes by adding the tools:viewBindingIgnore=”true” attribute to the root view of that layout file. This will help reduce the overall APK size.</p><pre>&lt;LinearLayout<br>        ...<br>        tools:viewBindingIgnore=&quot;true&quot; &gt;<br>    ...<br>&lt;/LinearLayout&gt;</pre><blockquote>Section II: Best Practices</blockquote><h3>Inflating Layouts</h3><p>The inflate method for view binding takes three arguments — Inflater, Parent and AttachToRoot. The inflater is passed using LayoutInflater.from(context) and the attachToRoot needs to be true in most cases. If your layout does not show up on the device check if attachToRoot is set to false.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*cC3dpI5wPYoLhyfP7__jyw.png" /></figure><h3>Using binding variables without inflating layouts</h3><p>For view classes where the layout does not need to be inflated but we need the binding variable to reference to UI components use .bind(View) of the binding class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*joFNgONHpBXBrZWoj9b1uQ.png" /></figure><h3>Binding variables and referencing UI components</h3><p>Accessing views should be done through the generated binding object. The binding object should be stored as a class-level variable for the view or passed into the view holder. This will mean that the view types will be automatically updated when the XML is altered and the full benefits of view binding can be taken advantage of.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*_JAhUEWEhHaYoaBS7VIRkg.png" /></figure><h3>Binding for included layouts</h3><p>&lt;include&gt;ed layouts in XML will generate their own binding class which needs to be referenced through parent XML layout’s binding class. For the included layout binding to be generated correctly, the id in the &lt;include&gt; tag needs to match the container layout’s id of the child layout.</p><p>Note: If the id does not match, the child binding variable within the parent layout’s binding is not generated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*1FYQrNWgkewKWA_RDTMLLA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*B_7m9DcRFGQD9fwcHewzPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*ss7M_iBYbXcvX4DUYLdc2Q.png" /></figure><p>subLayout in the third code snippet is the binding variable for the included layout that is auto generated by the SubLayoutBinding.class</p><p><strong>Link to Github Sample project</strong>:</p><p><a href="https://github.com/life360/android-viewbinding-sample">https://github.com/life360/android-viewbinding-sample</a></p><h3>Come join us</h3><p>Life360 is the first-ever family safety membership, offering protection on the go, on the road, and online. We are on a mission to redefine how safety is delivered to families worldwide — and there is so much more to do! We’re looking for talented people to join the team: check out our <a href="http://www.life360.com/jobs">jobs page</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8af648f3f3a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/life360-engineering/view-binding-life360-b8af648f3f3a">View Binding@Life360</a> was originally published in <a href="https://medium.com/life360-engineering">Life360 Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lint and why We Remove It]]></title>
            <link>https://medium.com/life360-engineering/lint-and-why-we-remove-it-600a521f1ecd?source=rss----7d698da22bc9---4</link>
            <guid isPermaLink="false">https://medium.com/p/600a521f1ecd</guid>
            <category><![CDATA[linter]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[warning]]></category>
            <dc:creator><![CDATA[Meghneel Gore]]></dc:creator>
            <pubDate>Fri, 28 May 2021 22:18:38 GMT</pubDate>
            <atom:updated>2021-05-28T22:18:38.204Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XnCgYLeFkozpByv9foSS4g.jpeg" /><figcaption>Lint Warnings: No one likes them, no one likes to see them, no one wants to clean them up. They don’t cause your release to stop. They’re like Error-lite!</figcaption></figure><p>Lint warnings have a tendency to accumulate. Sometimes, their sheer number makes one balk at fixing them. Most warnings, however, are important flags that signal the health of your codebase.</p><p>January 2020, unbeknownst to us, we had about 5,000 warnings in the Android codebase. Fixing these warnings would give us great returns. It is an established fact that fewer warnings means fewer potential future or current bugs and a cleaner codebase. That’s why we came up with Project Zero. We did it in 3 phases.</p><h3>Tabulation, Categorization, and Baselining Phase</h3><p>In the beginning, we had no idea about the number of warnings we had in the codebase. Phase 1 consisted of <strong>tabulation, categorization , and baselining </strong>of warnings.</p><h4>Tabulation &amp; Categorization</h4><p>Since 5,000 warnings is a lot to try to resolve in one go, we started with tabulating and categorizing them. Below, you can see an excerpt of this tabulation. While tabulating, we were also able to categorize the warnings. This proved quite useful in the subsequent phases because we were easily able to find warnings that were Engineering-bound* — like UnusedResources versus ones that were Product-bound* — like ContentDescription.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*50lAeMNqIOcmOjwWB1PGjw.png" /><figcaption>Top 10 warning types in our codebase</figcaption></figure><h4>Baselining</h4><p>Lint allows us to stop the warnings list from growing even before reducing the list of warnings by setting the baseline warnings state. Baselining proved to be a very big stepping stone towards getting rid of warnings. It provided a way to disregard existing warnings. Combined with some other lint flags, we were able to make sure that we could keep paring down the issues while not allowing new issues to be merged into the codebase.</p><p>The way to do lint baselining is to add</p><pre>android {<br>  ...<br>  lintOptions {<br>    baseline file(&quot;lint-baseline.xml&quot;)<br>  }<br>}</pre><p>In your build.gradle file’s lintOptions</p><p>Now, the next time lint is run, a lint-baseline.xml file is created with all the current lint issues listed out. These issues do <em>not</em> get flagged as warnings.</p><p>Once the baseline file is created, the following two lines can also be added to lintOptions</p><pre>android {<br>  ...<br>  lintOptions {<br>    baseline file(&quot;lint-baseline.xml&quot;)<br>    <strong>warningsAsErrors true<br>    abortOnError true  </strong><br>  }<br>}</pre><p>These make sure that any <em>new </em>warnings that come up in a PR will be flagged as errors and if the build process is properly configured, the code change can’t be merged unless the warnings are fixed.</p><p>As and when old warnings are fixed, we delete the lint-baseline.xml file and re-run lint. This creates a new lint-baseline.xml file with only the remainder of the warnings.</p><p>One thing to remember here is that baselining is very literal with line numbers in the code. If a previously baselined warning gets offset due to code changes, it will start showing up as a warning (or error, depending on your config) again.</p><p>Since all newly introduced warnings were build errors, we sat back assured that no <em>new</em> warnings would be inadvertently added to the codebase. Now we started to pare down existing warnings!</p><h3>Organization &amp; Execution Phase</h3><p>This phase consisted of swarming on the warnings that didn’t require coordination between organizations to resolve. As mentioned above, we were able to determine that some of the warnings — like UnusedResources can be easily fixed whereas others — like ExtraTranslation would have a less obvious of a fix. To mitigate this dichotomy and to make sure that we could distribute the task of fixing all warnings to the entire Android team, we created “Example PRs” which fixed one instance of a warning.</p><h4>Organization &amp; Execution</h4><p>Next, we ticketed the different warnings and engineers volunteered to fix them. We took every opportunity to pare down warnings. We had a “Quality Week” in which we got rid of many warnings. We have an Android Slack channel in which certain amounts of prodding and *cough-cough* pestering were done. We have a regular Android tech sync meeting during which, multiple “opportunities” were taken to remind everyone to fix the warnings. We even employed it as a ramp-up tool. Two of our engineers from Ukraine got a taste of the codebase by actually fixing some of the warnings!</p><p>Over the course of 5 months, while continuing to work on feature projects and bugs, our Android team closed off ~4,500 warnings.</p><p>As mentioned above, we found out that some warnings would need Product or Design involvement. Moreover, there were some that just didn’t need fixing. We decided to ignore such warnings en-masse by adding the disable option in lintOptions like so:</p><pre>android {<br>  ...<br>  lintOptions {<br>    baseline file(&quot;lint-baseline.xml&quot;)</pre><pre><strong>    disable &#39;NewerVersionAvailable&#39;, &#39;TypographyFractions&#39;,    &#39;TypographyQuotes&#39;, &#39;TypographyDashes&#39;</strong><strong> </strong>   <br>    warningsAsErrors true<br>    abortOnError true  <br>  }<br>}</pre><p>We created separate tickets for these warnings and these little gems we we saved for the next phase!</p><h3>End Boss Phase</h3><p>This phase is currently an ongoing effort consisting of multiple departments working together.</p><h4>Baselining Compilation Warnings</h4><p>Java and Kotlin compilation warnings are also being targeted in this phase. Unfortunately, there’s no easy way to baseline compilation warnings like lint warnings. However, there <em>is </em>a hard way.</p><p>In order for gradle to spit out warning numbers, we added</p><pre>gradle.projectsEvaluated <strong>{<br>    </strong>tasks.withType(JavaCompile) <strong>{<br>        </strong>options.compilerArgs &lt;&lt; &quot;-Xlint:all&quot;<br>    <strong>}<br>}</strong></pre><p>In the allProjects section of the app-level build.gradle</p><p>This makes the compiler spit out warnings with a “w:” prefix for Kotlin like so</p><pre>w: Type mismatch: inferred type is String? but String was expected</pre><p>and a “warning:” prefix for Java warnings like so</p><pre>warning: [deprecation] getDefaultDisplay() in WindowManager has been deprecated</pre><p>Using bash programming, we added a function in our CI that counts the current number of warning: and w: instances and compares the number to a constant. If the number of current warnings is lower than the constant, the build passes, if not, it fails. In this way we have a pseudo-baseline to get a quick heuristic for new warnings.</p><pre>numWarns=$(./gradlew assemble --no-daemon 2&gt;&amp;1 | grep -c &#39;w: /\|warning: &#39;)<br>echo &quot;Current number of warnings: $numWarns&quot;<br>maxCappedWarnings=&lt;some constant&gt;<br>if (($numWarns &gt; $maxCappedWarnings)); then<br>  echo &quot;You went over the magic number. Please fix a few warnings!&quot;<br>  exit 1<br>else<br>  echo &quot;You may have reduced the number of warnings! If so, thank you! Please consider opening a separate PR to reduce maxCappedWarnings&quot;<br>fi</pre><h4>Conclusion</h4><p>We’re continuing to reduce the number of warnings. We’re committed to Project Zero and to have zero warnings in our codebase soon!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=600a521f1ecd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/life360-engineering/lint-and-why-we-remove-it-600a521f1ecd">Lint and why We Remove It</a> was originally published in <a href="https://medium.com/life360-engineering">Life360 Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>