inbrain-surveys
Version:
In-App monetization via surveys, powered by inBrain.ai.
142 lines • 4.2 kB
JavaScript
// Map Native Surveys //
export var mapSurveys = function (nativeSurveys) {
return nativeSurveys.map(function (survey) {
if (survey.categories) {
survey.namedCategories = mapCategories(survey.categories);
}
else {
// Avoid crashes, as the property stated as mandatory
survey.categories = [];
}
var conversionId = survey.conversionLevel;
survey.conversionLevel = {
id: conversionId,
name: getConversionName(conversionId),
};
return survey;
});
};
// Map rewards from the onClose callback
export var mapRewards = function (nativeRewards) {
return nativeRewards.map(function (reward) {
if (reward.categories) {
reward.categories = mapCategories(reward.categories);
}
var outcomeTypeId = reward.outcomeType;
reward.outcomeType = {
id: outcomeTypeId,
name: getOutcomeTypeName(outcomeTypeId),
};
return reward;
});
};
// Map categories for Native Surveys and for the rewards from onClose callback
export var mapCategories = function (categories) {
return categories.map(function (categoryId) {
return { id: categoryId, name: getCategoryName(categoryId) };
});
};
// Get survey's conversion name by it's id.
var getConversionName = function (conversionId) {
switch (conversionId) {
case 0:
return "New Survey";
case 1:
return "Very Poor Conversion";
case 2:
return "Poor Conversion";
case 3:
return "Fair Conversion";
case 4:
return "Good Conversion";
case 5:
return "Very Good Conversion";
case 6:
return "Excellent Conversion";
default:
return "Unknown";
}
};
// Get outcome type name by it's id
var getOutcomeTypeName = function (outcomeTypeId) {
switch (outcomeTypeId) {
case 0:
return "Completed";
case 1:
return "Terminated";
default:
return "Unknown";
}
};
// Get category name by it's id.
var getCategoryName = function (categoryId) {
switch (categoryId) {
case 1:
return "Automotive";
case 2:
return "Beverages Alcoholic";
case 3:
return "Beverages Non Alcoholic";
case 4:
return "Business";
case 5:
return "Children & Parenting";
case 6:
return "Coalition Loyalty Programs";
case 7:
return "Destinations & Tourism";
case 8:
return "Education";
case 9:
return "Electronics, Computer Software";
case 10:
return "Entertainment And Leisure";
case 11:
return "Finance, Banking, Investing & Insurance";
case 12:
return "Food";
case 13:
return "Gambling, Lottery";
case 14:
return "Government & Politics";
case 15:
return "HealthCare";
case 16:
return "Home";
case 17:
return "Media & Publishing";
case 18:
return "Personal Care";
case 19:
return "Restaurants";
case 20:
return "Sensitive & Explicit Content";
case 21:
return "Smoking & Tobacco";
case 22:
return "Social Research";
case 23:
return "Sports Recreation Fitness";
case 24:
return "Telecommunications";
case 25:
return "Transportation";
case 26:
return "Travel - Airlines";
case 27:
return "Travel - Hotels";
case 28:
return "Travel - Services, Agency, Booking";
case 29:
return "Credit Cards";
case 30:
return "Video Games";
case 31:
return "Fashion & Clothing - Other";
case 32:
return "Fashion & Clothing - Department Store";
default:
return "Unknown";
}
};
//# sourceMappingURL=MappingUtils.js.map