You can use RudderStack's Transformations feature with the device mode-supported destinations like Firebase, Hotjar, etc.
To learn more about the use cases of device mode transformations, refer to the Use case section.
- Only the JavaScript, Android, and iOS SDKs support device mode transformations.
- Currently, RudderStack supports writing device mode transformations only in JavaScript. Python support will be added soon.
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.
When you add a transformation and connect it to a destination supporting the device mode, the following steps are performed:
- 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.
- Client Transformation service sends the event to the RudderStack Transformation service to transform the event according to the functions defined in the attached transformations.
- After the transformation is applied, the transformed event is returned to the Client Transformation service.
- Client Transformation service responds to the SDK with the transformed events for all the destinations.
- 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 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","getSessionId"],e.factory=function(t){return function(){e.push([t].concat(Array.prototype.slice.call(arguments)))}};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>
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'
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 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:
Parameter Limit Memory limit 128 MB Execution time limit 4 seconds
Contact us
For more information on the topics covered on this page, email us or start a conversation in our Slack community.