improved

Unlimited features on a single activity

You can now add as many features as you want on a single activity!

Previously, users could only add three features on each activity and then they'd have to add additional features using an activity enrichment table. Now, users are able to add as many features as they'd like on a single activity by adopting a new feature naming convention.






How to add features to activities

  • For each feature you'd like to use, append feature_ in front of the column name
    EXAMPLE ACTIVITY TRANSFORMATION SQL

    SELECT
        id AS activity_id,
        returned_at AS ts,
    
    
        NULL AS anonymous_customer_id, 
        email AS customer,
    
       'returned_shoe' AS activity, 
    
        -- Add as many feature columns by naming it `feature_COLUMN_NAME`
        -- ex. p.id as feature_product_id
    
        r.sku as feature_sku,
        r.reason as feature_reason,
        r.is_exchange as feature_is_exchange,
    
        NULL AS revenue_impact,
        NULL AS link
    FROM orders.returns r 
    
  • Push to production and Narrator will automatically recognize the features you've added

  • Just like before, you can update the feature labels in the activity details page



How it works (the technical details)

  • All features are combined into a single JSON column in your activity stream
    Once the activity is pushed to production, Narrator combines all the feature_ columns into a single JSON column called feature_json

  • Features are extracted from JSON when used in a dataset
    When the activity is used in a dataset, the feature will be extracted from the JSON for use. Ex. JSON_VALUE(s.feature_json['a1']) AS sku
    The end-user will have the same experience in the dataset UI, but the SQL will be modified under the hood.

    EXAMPLE DATASET QUERY USING FEATURE JSON

    WITH
    cohort_stream AS (
    	SELECT
    		*
    	FROM narrator.activity_stream_returned_shoe AS s 
    	WHERE s.activity_occurrence is not NULL
    ),
    cohort AS (
    	SELECT
    		s.activity_id AS activity_id
    		, TIMESTAMP(DATETIME(s.ts,"America/New_York")) AS timestamp
    		, s.customer AS customer
    		, JSON_VALUE(s.feature_json['a1']) AS sku
    		, JSON_VALUE(s.feature_json['a2']) AS return_reason
    		, JSON_VALUE(s.feature_json['a3']) AS is_exchange
    		, s.customer AS join_customer
    		, s.ts AS join_ts
    	FROM cohort_stream AS s 
    	ORDER BY timestamp DESC
    )
    SELECT
    	c.activity_id
    	, c.timestamp
    	, c.customer
    	, c.sku
    	, c.return_reason
    	, c.is_exchange
    FROM cohort AS c 
    ORDER BY timestamp DESC
    




FAQ

General FAQs:

  • How does this affect performance of my dataset queries?
    With modern data warehouse improvements, JSON column extraction is increasingly faster. This is what encouraged us to move to this new structure since the performance impact would be minimal, if not better.

Migration FAQs:

  • Do I need to migrate my existing feature_1, feature_2, feature_3 columns to this new format?
    No, they will be automatically moved into the new JSON structure.

  • What should I do if I want to add a 4th column to my existing activity with feature_1, feature_2, feature_3 values?
    Simply add another column to your query using the new feature_ convention.




User feedback helps Narrator improve. ❤️
We'd love to hear what you think. Email us @ [email protected]