Introducing RudderStack Transformations
Tags: opensource, android, ios, rudderstack
Published: 2020-04-27 19:57:26

<!-- wp:paragraph -->
<p><a href="http://rudderstack.com">RudderStack</a> is an open-source platform for collecting and routing your customer event data (commonly known as customer data infrastructure or CDI platform). RudderStack is enterprise-ready, with a special focus on data privacy and security.  This blog talks more about RudderStack and RudderStack Transformations that allow you to customize your customer data platforms.<br></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>We started building RudderStack because, as data engineers ourselves, we found that existing CDI solutions lack crucial attributes that today's data-driven enterprises need. Most solutions have a trade-off between flexibility and complexity. On the complete opposite side of the spectrum, extensibility and functionality are sacrificed on the altar of usability for cloud SaaS products.<br></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>At RudderStack, we are building a data platform that can offer the environment a data engineer needs. We aim to provide a platform that addresses the unique challenges of everyday business, together with operational peace of mind. We want RudderStack to:<br></p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>Be <strong>extensible </strong>and <strong>customizable</strong>. A data engineer should be able to deal with various issues and requirements</li><li>Be easy to <strong>deploy</strong>, <strong>manage</strong>, and <strong>monitor</strong></li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>Towards the above goals, we have implemented and delivered as part of the core platform, <em>RudderStack Transformations</em>. It is a mechanism where a data engineer can define and deploy custom logic which gets executed on the stream of events that flow inside RudderStack.<br></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>The Architecture</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>At RudderStack, we believe that being able to manipulate the event data is an integral part of any data platform, and we wanted to treat this functionality as a first-class citizen of our product. We have architectured this platform to reflect this very belief.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":26820,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://rudderstack.com/wp-content/uploads/2020/04/Rudder-Core-Architecture-1024x703.png" alt="" class="wp-image-26820"/><figcaption> RudderStack Architecture  </figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p> </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The above diagram shows a high-level architecture of RudderStack. The underlying mechanism on the BackEnd or Data Plane is responsible for implementing the integrations with the destinations. Also, this same mechanism is responsible for user transformations.&nbsp;<br></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>By implementing a single mechanism responsible for both executing user transformations and integrations with destinations, we manage to:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>Simplify the architecture</li><li>Simplify implementing and debugging custom logic</li><li>Make it easier to reason around performance as there aren't many moving parts that can add overhead</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>If you wish to learn more about the implementation details, please visit our <a href="https://github.com/rudderlabs/rudder-server">Github repository</a> or join our <a href="https://discordapp.com/invite/xNEdEGw">Discord channel</a>, where our engineering team is available.<br></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Deploying RudderStack Transformations</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Deploying <em>RudderStack Transformations</em> is an easy process, and it happens from within the RudderStack Control Plane or UI. You can write transformations in JavaScript. The environment allows you to test and debug these transformations by executing the transformation on sample events. You can see the whole process in the following visual example.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":26818,"sizeSlug":"large"} -->
<figure class="wp-block-image size-large"><img src="https://rudderstack.com/wp-content/uploads/2020/04/UDF.gif" alt="RudderStack Transformations" class="wp-image-26818"/><figcaption>RudderStack Transformations</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>What you can do with RudderStack Transformations</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><em>RudderStack Transformations</em> is the way to add custom logic to your Customer Data Platform. To this end, we added support for a rich language like Javascript. This means that you can implement complex scripts that can be applied to an individual event or on batches. The following sections discuss some of the use cases RudderStack users have implemented so far.<br></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>Working with PII Data</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Developers often embed PII data in events either accidentally (e.g., developer error) or on purpose. However, there are often strong reasons to avoid sending PII to the downstream cloud or on-prem destinations. Even for internal destinations like data-warehouse, storing PII can lead to security challenges.&nbsp; At the same time, it is crucial to be able to address any possible edge case in terms of how the data appears and how it is stored. With <em>RudderStack Transformations,</em> it is possible to implement complex PII scanners and masks. You can also create a notification system that can act on the event level and notify you when it detects something.<br></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>Event Sampling and Aggregation</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Having access to all your events is useful, but not all applications need to have access to this level of data granularity. However, you can sample your data when delivering to certain applications such as analytics tools. This functionality is even more useful when these data receiving services charge you based on volume. Similarly, you might prefer to pre-aggregate your data before you deliver them into a visualization tool and simplify their interaction with the data.<br></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>Hunting Down the <em>Nulls</em></h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Errors in your data are inevitable- event schemas might change, developers introduce errors, or sometimes fields need decommissioning. Being able to detect data anomalies and react on them closely from the backend can save a lot of the time of a data engineer who's trying to debug a broken data pipeline. With <em>RudderStack Transformations, you can detect common </em>errors such as <em>null</em> values and correct early on the data pipeline.&nbsp;<br></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3>Schema Transformations</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Many times, you want to transform data into different representations. In one system, you might have only one field for the name and the surname. In another, you would like to have two separate fields. You may also want to extract and break down UTM parameters from a URL. Being able to transform the schema of the events is very important in maintaining a realistic data infrastructure for any company, and <em>RudderStack Transformations</em> provide all the functionality needed to do that.<br></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The above are just some everyday use cases that we have encountered so far, and they demonstrate the versatility of <em>RudderStack Transformations</em>. You can find templates for these cases on our <a href="https://github.com/rudderlabs/sample-user-transformers">Github Repository for <em>RudderStack Transformations</em></a>.<br></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>We Want You to Contribute</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>As we said in the opening of this post, our goal at RudderStack is to build the next-generation data platform that can address all the challenges data engineers face today. Our core assumption is that, in such a complex and open problem, one can provide a robust solution only by having a strong community of people who shares the same problems and vision.<br></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Hence, instead of delivering every possible function as a new feature, we provide the infrastructure that you can deploy and run functions to transform your data.&nbsp;<br></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>On this <a href="https://github.com/rudderlabs/sample-user-transformers">Github Repository for <em>RudderStack </em>transformations</a>, you can find various templates. These are community provided templates for common use cases like the ones we mentioned earlier in this post. We encourage you to participate, create issues, make pull requests, and share the knowledge.<br></p>
<!-- /wp:paragraph -->