1.0.0 • Published 1 year ago

streaming-profile-transformations v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

streaming-profile-transformations

Features

getMainID (ID string)

This function will return an object containing (MAIN_ID, TYPE, VALID_AT) as a promise. Here "TYPE" is the id_type of "ID", for example, user_ID.

Example:

const mainIdObj = await getMainID(userID)

getFeature (ID string, optional: isMainID = false)

This function will return an object as a promise, which contains all the features of a user present in the Feature table.

If "ID" is MAIN_ID then this function will skip calling the getMainID function and will directly return features corresponding to that MAIN_ID.

Example:

const featuresObj = await getFeature(mainID, true)

const featuresObj = await getFeature(userID)

Steps to use this package in transformer

1. Set up a Redis

  1. Login to Redis lab.
  2. Create a New Database.

2. Set up a reverse ETL connection

You can check this tutorial to setup a rETL connection Video 1. Login to RudderStack. 2. Add the Snowflake ID Graph table as a new Source and set up Connection Settings.

*As the ID Graph table doesn't have any primary key we have to generate a dummy primary key*

use this model to generate a dummy primary key
````
select distinct(concat(ID1, ID1_TYPE, VALID_AT)) as key, ID1, ID1_TYPE, MAIN_ID, VALID_AT
from TABLE_NAME;
````
  1. Add Redis as a new Destination, use the Redis Cluster address

    (optional) Add this Transformation to Redis Destination

    export function transformEvent(event, metadata) {
        event.traits = {
            "TYPE": event.traits.ID1_TYPE,
            "MAIN_ID": event.traits.MAIN_ID,
            "VALID_AT": event.traits.VALID_AT,
        }
        return event
    }
  2. Create an rETL connection between the Snowflake ID Graph table and Redis.

  3. Add the Snowflake Feature table as a new Source and use MAIN_ID as the primary key.
  4. Create another rETL connection between the Snowflake Feature table and Redis.

3. Use getMainID() and getFeatures() in transformer.

1.0.0

1 year ago