Last active
June 19, 2024 05:52
-
-
Save Brontojoris/735e6f5a99b4e9c2686017abfa433ebb to your computer and use it in GitHub Desktop.
Pretty print Adobe Analytics Mobile SDK beacons in the Proxyman Form tab.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This ProxyMan script tidies up the display of | |
Adobe Analyics beacons in the Form preview tab. | |
Its very possible these hits will not be valid | |
and not be processed correctly by the data collection server. | |
*/ | |
function onRequest(context, url, request) { | |
var shortenProductStrings = false, | |
deleteNoise = true, | |
visualSeperators = false, | |
visualSeperators2 = true, | |
visualDepth = 0, | |
hideProductListItems = true, | |
debugProductListItems = false, | |
debugProductString = true; | |
var products = request.body["products"] || "", | |
productListItems = request.body["productListItems"] || ""; | |
if(deleteNoise){ | |
delete request.body[".a"] | |
delete request.body[".c"] | |
delete request.body[".ccpid"] | |
delete request.body[".cid"] | |
delete request.body["a."] | |
delete request.body["aamb"] | |
delete request.body["aamlh"] | |
delete request.body["as"] | |
delete request.body["c."] | |
delete request.body["ccpid."] | |
delete request.body["ce"] | |
delete request.body["cid."] | |
delete request.body["cp"] | |
delete request.body["ndh"] | |
delete request.body["Resolution"] | |
delete request.body["RunMode"] | |
delete request.body["t"] | |
delete request.body["testlog"] | |
delete request.body[".profile"] | |
delete request.body["profile."] | |
} | |
if(visualSeperators2){ | |
for(key in request.body){ | |
// If the last character is a dot (.) then increase the depth | |
if(key.lastIndexOf(".") > 0){ | |
visualDepth = visualDepth + 1 | |
request.body[key] = Array(visualDepth).join(" ") + "{" | |
//console.log('Increase VisualDepth of', key, visualDepth); | |
// If the first character is a dot (.) then decrease the depth | |
}else if(key.indexOf(".")===0){ | |
request.body[key] = Array(visualDepth).join(" ") + "}," | |
visualDepth = visualDepth - 1; | |
//console.log('Decrease VisualDepth of', key, visualDepth); | |
}else{ | |
request.body[key] = Array(visualDepth).join(" ") + request.body[key] | |
} | |
} | |
} | |
if(shortenProductStrings){ | |
// Shorten productListItems | |
if (productListItems.length > 250) { | |
request.body["productListItems"] = "[MODDED] "+productListItems.substring(0,250) | |
} | |
// Shorten &&products | |
if (products.length > 250) { | |
request.body["products"] = "[MODDED] " + products.substring(0,250) | |
} | |
} | |
if(hideProductListItems && productListItems){ | |
delete request.body["productListItems"] | |
} | |
if(debugProductListItems && productListItems){ | |
request.body["productListItems"] = JSON.parse(decodeURIComponent(productListItems)) | |
} | |
if(debugProductString && products){ | |
request.body["products"] = decodeURIComponent(products).split(",").join(",\n") | |
} | |
if(visualSeperators){ | |
request.body["dim."] = "܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅" | |
request.body[".dim"] = "܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅܅" | |
request.body["event."] = "┈┈┈┈┈┈┈┈┈┈┈┈┈┈" | |
request.body[".event"] = "┈┈┈┈┈┈┈┈┈┈┈┈┈┈" | |
} | |
return request; | |
} | |
function onResponse(context, url, request, response) { | |
try { | |
if (request.headers["Icon"]) { | |
response.headers["Icon"] = request.headers["Icon"]; | |
} | |
}catch{ | |
// meh | |
} | |
return response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use the following configuration: