RudderStack's Device Mode Transformations feature enables you to use the powerful user transformations with the device mode-only destinations, for example, Firebase, Hotjar, etc.

Using this feature, you can enrich the event data using your custom logic. Moreover, it provides an easier way to filter out the events to get rid of the bad data, sample events to reduce costs to some destinations, and many more interesting use cases. To learn more about the use cases, refer to the Use case section.

Only the Android, iOS, and JavaScript SDKs support the Transformations feature to send events to the device mode destinations.
Github BadgeGithub Badge

Client Transformation service architecture

RudderStack provides the Client Transformation service to facilitate the Transformations feature for device mode destinations. It ensures that the event ingestion to RudderStack backend isn't affected, assuring minimum response time from the RudderStack backend.

Transformations workflow

When you add a transformation and connect it to a destination supporting the device mode, the following steps are performed:

  1. RudderStack SDK sends the event to the Client Transformation service. It multiplexes the event for different destinations and connects with the transformations attached to these device mode destinations.
  2. Client Transformation service sends the event to the RudderStack Transformation service to transform the event according to the functions defined in the attached transformations.
  3. After the transformation is applied, the transformed event is returned to the Client Transformation service.
  4. Client Transformation service responds to the SDK with the transformed events for all the destinations.
  5. Finally, the SDK parses the transformed events and forwards them to the specified device-mode destinations.

SDK setup

After adding a transformation and connecting it to a destination supporting the device mode, you can connect your SDK source to it.

Further, follow the below steps for setting up the required SDK:

The detailed steps to setup the JavaScript SDK are mentioned in the Quickstart guide. You need to change the CDN URL in the SDK installation snippet to: https://cdn.rudderlabs.com/v1.1/beta/dmt/v1/rudder-analytics.min.js

Alternatively, you can use the following snippet with the updated URL:

<script type="text/javascript">
!function(){var e=window.rudderanalytics=window.rudderanalytics||[];e.methods=["load","page","track","identify","alias","group","ready","reset","getAnonymousId","setAnonymousId","getUserId","getUserTraits","getGroupId","getGroupTraits","startSession","endSession"],e.factory=function(t){return function(){var r=Array.prototype.slice.call(arguments);return r.unshift(t),e.push(r),e}};for(var t=0;t<e.methods.length;t++){var r=e.methods[t];e[r]=e.factory(r)}e.loadJS=function(e,t){var r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src="https://cdn.rudderlabs.com/v1.1/beta/dmt/v1/rudder-analytics.min.js";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(r,a)},e.loadJS(),
e.load(<WRITE_KEY>,<DATA_PLANE_URL>),
e.page()}();
</script>
Device mode transformations are supported in Android SDK v1.8.0 and above.

Install the Android SDK following the detailed steps mentioned in Installing the Android SDK section. Additionally, use the following dependency in the Android app level build.gradle:

implementation 'com.rudderstack.android.sdk:core:1.8.0-beta.1'
Device mode transformations are supported in iOS SDK v1.8.0 and above.

Install the iOS SDK following the detailed steps mentioned in Installing the iOS SDK section. Additionally, use the following dependency in Podfile:

pod 'Rudder', '1.8.0.beta.1'

Limitations

The following limitations are applicable when invoking a transformation in the device mode:

  • The network unavailability can lead to higher latency than expected while sending the events to the destinations. RudderStack doesn't lose data due to the network loss and stores the events in the client device until those are successfully delivered to the destination.

  • The iOS SDK does not support the background processing of an event when the app is closed. However, the pending events are sent the next time the app is opened.

  • The following memory and time limits must be followed:

    ParameterLimit
    Memory limit128 MB
    Execution time limit4 seconds

Contact us

For more information on the topics covered on this page, email us or start a conversation in our Slack community.

On this page