Skip to content

Instantly share code, notes, and snippets.

@koladilip
Created August 13, 2024 12:22
Show Gist options
  • Save koladilip/c996a0628a1ae38a6d77ac0a38166855 to your computer and use it in GitHub Desktop.
Save koladilip/c996a0628a1ae38a6d77ac0a38166855 to your computer and use it in GitHub Desktop.
sample mappings
{"code":"[\n {\n \"to\": \"$.events[0].params.item_list_id\",\n \"from\": \"$.properties.list_id\"\n },\n {\n \"to\": \"$.events[0].params.item_list_name\",\n \"from\": \"$.properties.category\"\n },\n\n {\n \"to\": \"$.events[0].params.items[*].item_name_2\",\n \"from\": \"$.properties.products[*].name\"\n },\n {\n \"to\": \"$.events[0].params.items[*].coupon\",\n \"from\": \"$.properties.products[*].coupon\"\n },\n {\n \"to\": \"$.events[0].params.items[*].price\",\n \"from\": \"$.properties.products[*].price\"\n },\n {\n \"to\": \"$.events[0].params.items[*].position\",\n \"from\": \"$.properties.products[*].position\"\n },\n {\n \"to\": \"$.events[0].params.items[*].quantity\",\n \"from\": \"$.properties.products[*].quantity\"\n },\n {\n \"to\": \"$.events[0].params.items[*].affiliation\",\n \"from\": \"$.properties.products[*].affiliation\"\n },\n {\n \"to\": \"$.events[0].params.items[*].currency\",\n \"from\": \"$.properties.products[*].currency\"\n },\n {\n \"to\": \"$.events[0].params.items[*].discount\",\n \"from\": \"$.properties.products[*].discount\"\n },\n {\n \"to\": \"$.events[0].params.items[*].item_category2\",\n \"from\": \"$.properties.products[*].item_category2\"\n },\n {\n \"to\": \"$.events[0].params.items[*].item_category3\",\n \"from\": \"$.properties.products[*].item_category3\"\n },\n {\n \"to\": \"$.events[0].params.items[*].item_category4\",\n \"from\": \"$.properties.products[*].item_category4\"\n },\n {\n \"to\": \"$.events[0].params.items[*].item_category5\",\n \"from\": \"$.properties.products[*].item_category5\"\n },\n {\n \"to\": \"$.events[0].params.items[*].item_list_id\",\n \"from\": \"$.properties.products[*].item_list_id\"\n },\n {\n \"to\": \"$.events[0].params.items[*].item_list_name\",\n \"from\": \"$.properties.products[*].item_list_name\"\n },\n {\n \"to\": \"$.events[0].params.items[*].location_id\",\n \"from\": \"$.properties.products[*].location_id\"\n },\n {\n \"to\": \"$.user_properties.*.value\",\n \"from\": \"$.context.traits.* \"\n }\n]","data":"{\n \"type\": \"track\",\n \"event\": \"Checkout Step Completed\",\n \"userId\": \"joh@doe\",\n \"anonymousId\": \"anonymous@john@doe\",\n \"context\": {\n \"traits\": {\n \"firstName\": \"John\",\n \"lastName\": \"Doe\",\n \"name\": \"John Doe\",\n \"age\": 30,\n \"email\": \"[email protected]\",\n \"phone\": 7832377652,\n \"address\": {\n \"city\": \"Brooklyn\",\n \"country\": \"US\",\n \"postalCode\": \"10001\",\n \"state\": \"NY\",\n \"street\": \"51st Avenue\"\n },\n \"company\": {\n \"name\": \"RudderStack\",\n \"id\": 18,\n \"industry\": \"SaaS\",\n \"employee_count\": 130,\n \"plan\": \"Enterprise\"\n },\n \"createdAt\": \"2024-06-10T00:12:09.544Z\"\n }\n },\n \"properties\": {\n \"currency\": \"USD\",\n \"coupon\": \"DISCOUNT 25\",\n \"shipping_method\": \"Transit\",\n \"revenue\": 299,\n \"products\": [\n {\n \"product_id\": \"507f1f77bcf86cd799439099\",\n \"name\": \"Risk: World Domination\",\n \"coupon\": \"STRATEGY_GAMES\",\n \"category\": \"Games\",\n \"brand\": \"Hasbro\",\n \"variant\": \"Standard Edition\",\n \"price\": 34.50,\n \"quantity\": 1,\n \"position\": 2,\n \"affiliation\": \"Local Game Store\",\n \"currency\": \"USD\",\n \"discount\": 2.5,\n \"item_category2\": \"Family\",\n \"item_category3\": \"Board Games\",\n \"item_category4\": \"Strategy\",\n \"item_category5\": \"Offer\",\n \"item_list_id\": \"related_products\",\n \"item_list_name\": \"Related Products\",\n \"location_id\": \"L_98765\",\n \"klax\": \"Klax1\"\n },\n {\n \"product_id\": \"789012345678901234567890\",\n \"name\": \"Comfy Cozy Crew Socks (3-pack)\",\n \"coupon\": \"SUMMER_FUN\",\n \"category\": \"Apparel\",\n \"brand\": \"Google\",\n \"variant\": \"Multicolor\",\n \"price\": 12.99,\n \"quantity\": 15,\n \"currency\": \"USD\",\n \"discount\": 1.50,\n \"item_category2\": \"Adult\",\n \"item_category3\": \"Accessories\",\n \"item_category4\": \"\",\n \"item_category5\": \"\",\n \"item_list_id\": \"related_products\",\n \"item_list_name\": \"Related Products\",\n \"location_id\": \"L_12345\",\n \"klax\": \"Klax2\"\n }\n ]\n },\n \"originalTimestamp\": \"2024-07-10T00:12:09.544Z\"\n}","bindings":"const bindings = {\n \"description\": \"Enter your bindings here\"\n };","result":{"output":"{\n \"events\": [{\n \"params\": {\n \"item_list_id\": $.properties.list_id,\n \"item_list_name\": $.properties.category,\n \"items\": $.properties.products[*].({\n \"item_name_2\": @.name,\n \"coupon\": @.coupon,\n \"price\": @.price,\n \"position\": @.position,\n \"quantity\": @.quantity,\n \"affiliation\": @.affiliation,\n \"currency\": @.currency,\n \"discount\": @.discount,\n \"item_category2\": @.item_category2,\n \"item_category3\": @.item_category3,\n \"item_category4\": @.item_category4,\n \"item_category5\": @.item_category5,\n \"item_list_id\": @.item_list_id,\n \"item_list_name\": @.item_list_name,\n \"location_id\": @.location_id\n })[]\n }\n }],\n \"user_properties\": $.context.traits.({\n @e [e.key]: {\n \"value\": e.value\n }\n })\n}","langugage":"javascript"},"type":"Mappings","name":""}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment