Skip to content

Commit

Permalink
Merge pull request #466 from bitdefender/dex-20840-vlaicu-implementation
Browse files Browse the repository at this point in the history
added config in Franklin for product ids
  • Loading branch information
iconstantin-bd authored Dec 19, 2024
2 parents b051d09 + e0705b2 commit 89a1ea2
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 146 deletions.
2 changes: 1 addition & 1 deletion _src/blocks/products/products.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function renderPlanSelector(plans, defaultSelection) {
liStoreParameters['data-store-click-set-product'] = '';
liStoreParameters['data-store-product-id'] = productCode;
liStoreParameters['data-store-department'] = 'consumer';
liStoreParameters['data-product-type'] = Constants.MONTHLY_PRODUCTS.includes(productCode) ? 'monthly' : 'yearly';
liStoreParameters['data-product-type'] = Constants.PRODUCT_ID_MAPPINGS[productCode].isMonthlyProduct ? 'monthly' : 'yearly';
liStoreParameters['data-store-product-option'] = variation;
}

Expand Down
189 changes: 96 additions & 93 deletions _src/scripts/libs/constants.js
Original file line number Diff line number Diff line change
@@ -1,86 +1,48 @@
import Page from "./page.js"

export const Constants = {
DEV_BASE_URL: ['localhost', 'stage', '.hlx.'].some((domain) =>
window.location.hostname.includes(domain)) ? 'https://www.bitdefender.com' : '',

FINGERPRINT_LOCAL_STORAGE_NAME: 'rhvID',

NO_FINGERPRINT_COOKIE_NAME: 'fgpnoneBD',

LOGIN_LOGGED_USER_EXPIRY_COOKIE_NAME: 'bdcslue',

ZUROA_LOCALES: ['nl-nl', 'nl-be'],

DEV_DOMAINS: ['localhost', 'stage', '.hlx.'],

PRODUCT_ID_MAPPINGS: {
av: "com.bitdefender.cl.av",
is: "com.bitdefender.cl.is",
tsmd: "com.bitdefender.cl.tsmd",
fp: ['nl-nl', 'nl-be'].includes(Page.locale) ? "com.bitdefender.fp" : "com.bitdefender.cl.fp",
ps: "com.bitdefender.premiumsecurity",
psm: "com.bitdefender.premiumsecurity",
psp: "com.bitdefender.premiumsecurityplus",
pspm: "com.bitdefender.premiumsecurityplus",
soho: "com.bitdefender.soho",
mac: "com.bitdefender.avformac",
vpn: "com.bitdefender.vpn",
"vpn-monthly": "com.bitdefender.vpn",
pass: "com.bitdefender.passwordmanager",
passm: "com.bitdefender.passwordmanager",
pass_sp: "com.bitdefender.passwordmanager",
pass_spm: "com.bitdefender.passwordmanager",
bms: "com.bitdefender.bms",
mobile: "com.bitdefender.bms",
ios: "com.bitdefender.iosprotection",
mobileios: "com.bitdefender.iosprotection",
dip: "com.bitdefender.dataprivacy",
dipm: "com.bitdefender.dataprivacy",
avpm: 'com.bitdefender.cl.avplus.v2',
ultsec: "com.bitdefender.ultimatesecurityus",
ultsecplus: "com.bitdefender.ultimatesecurityplusus",
ultsecm: "com.bitdefender.ultimatesecurityus",
ultsecplusm: "com.bitdefender.ultimatesecurityplusus",
idthefts: "com.bitdefender.idtheftstandard",
idtheftp: "com.bitdefender.idtheftpremium",
idtheftsm: "com.bitdefender.idtheftstandard",
idtheftpm: "com.bitdefender.idtheftpremium",
// DLP
ts_i: 'com.bitdefender.tsmd.v2',
ts_f: 'com.bitdefender.tsmd.v2',
ps_i: 'com.bitdefender.premiumsecurity.v2',
ps_f: 'com.bitdefender.premiumsecurity.v2',
us_i: 'com.bitdefender.ultimatesecurityeu.v2',
us_i_m: 'com.bitdefender.ultimatesecurityeu.v2',
us_f: 'com.bitdefender.ultimatesecurityeu.v2',
us_f_m: 'com.bitdefender.ultimatesecurityeu.v2',
us_pf: 'com.bitdefender.ultimatesecurityus.v2',
us_pf_m: 'com.bitdefender.ultimatesecurityus.v2',
us_pi: 'com.bitdefender.ultimatesecurityus.v2',
us_pi_m: 'com.bitdefender.ultimatesecurityus.v2',
us_pie: 'com.bitdefender.ultimatesecurityplusus.v2',
us_pie_m: 'com.bitdefender.ultimatesecurityplusus.v2',
us_pfe: 'com.bitdefender.ultimatesecurityplusus.v2',
us_pfe_m: 'com.bitdefender.ultimatesecurityplusus.v2',
secpass: 'com.bitdefender.securepass',
secpassm: 'com.bitdefender.securepass',
vsb: 'com.bitdefender.vsb',
vsbm: 'com.bitdefender.vsb',
sc: 'com.bitdefender.ccp',
scm: 'com.bitdefender.ccp'
},

PRODUCT_ID_NAME_MAPPINGS: {
pass: "Bitdefender Password Manager",
pass_sp: "Bitdefender Password Manager Shared Plan",
passm: "Bitdefender Password Manager",
pass_spm: "Bitdefender Password Manager Shared Plan"
},

MONTHLY_PRODUCTS: ["psm", "pspm", "vpn-monthly", "passm", "pass_spm", "dipm", "us_i_m", "us_f_m", "us_pf_m", "us_pi_m", "us_pie_m", "us_pfe_m", "ultsecm", "ultsecplusm", "idtheftsm", "idtheftpm", "secpassm", "vsbm", "scm"],

WRONG_DEVICES_PRODUCT_IDS: {
export class Constants {
static DEV_BASE_URL = ['localhost', 'stage', '.hlx.'].some((domain) =>
window.location.hostname.includes(domain)) ? 'https://www.bitdefender.com' : '';

static FINGERPRINT_LOCAL_STORAGE_NAME = 'rhvID';

static NO_FINGERPRINT_COOKIE_NAME = 'fgpnoneBD';

static LOGIN_LOGGED_USER_EXPIRY_COOKIE_NAME = 'bdcslue';

static ZUROA_LOCALES = ['nl-nl', 'nl-be'];

static DEV_DOMAINS = ['localhost', 'stage', '.hlx.'];

static PRODUCT_ID_MAPPINGS_CALL = this.#getVlaicuProductIdsMapping();

/**
* @typedef {Object} VlaicuDataEntry
* @property {string} websiteId
* @property {string} storeBundleId
* @property {boolean} isMonthlyProduct
* @property {string} campaign
*/

/**
*
* @typedef {{
* [key: string]: VlaicuDataEntry
* }} VlaicuData
*/

/**
* @typedef {{
* campaign: string
* }} VlaicuDataCampaign
*/

/**
* @type {VlaicuData & VlaicuDataCampaign | null}
*/
static PRODUCT_ID_MAPPINGS = null;

static WRONG_DEVICES_PRODUCT_IDS = {
'pass_sp': {
contentDevices: 1,
providerDevices: 4,
Expand All @@ -97,27 +59,68 @@ export const Constants = {
contentDevices: 10,
providerDevices: 1,
}
},
};

DISABLE_TARGET_PARAMS: {
static DISABLE_TARGET_PARAMS = {
key: "dotest",
value: "1"
},
};

TARGET_EXPERIMENT_METADATA_KEY: "target-experiment-location",
static TARGET_EXPERIMENT_METADATA_KEY = "target-experiment-location";

ADOBE_TARGET_SESSION_ID_PARAM: "adobeTargetSessionId",
static ADOBE_TARGET_SESSION_ID_PARAM = "adobeTargetSessionId";

TARGET_TENANT: "bitdefender",
static TARGET_TENANT = "bitdefender";

PUBLIC_URL_ORIGIN: ['www.', 'stage.'].some(domain => window.location.hostname.includes(domain))
? '' : 'https://www.bitdefender.com',
static PUBLIC_URL_ORIGIN = ['www.', 'stage.'].some(domain => window.location.hostname.includes(domain))
? '' : 'https://www.bitdefender.com';

LOGIN_URL_ORIGIN: ['www.', 'stage.'].some(domain => window.location.hostname.includes(domain))
? window.location.origin : 'https://www.bitdefender.com',
static LOGIN_URL_ORIGIN = ['www.', 'stage.'].some(domain => window.location.hostname.includes(domain))
? window.location.origin : 'https://www.bitdefender.com';

NO_PROMOTION: "ignore",
static NO_PROMOTION = "ignore";

// TODO: please remove this once digital river starts working correctly
SOHO_CORNER_CASES_LOCALSE: ["de-de", "de-at", "de-ch"]
static SOHO_CORNER_CASES_LOCALSE = ["de-de", "de-at", "de-ch"];

/**
* fetch all the product id mappings for Vlaicu from websites
*/
static async #getVlaicuProductIdsMapping() {
try {
const localeForVlaicuConfig = this.ZUROA_LOCALES.includes(Page.locale) ? "nl-nl" : "en-us";
const response = await fetch(`/${localeForVlaicuConfig}/consumer/vlaicuconfig.json`);
if (!response.ok) {
console.error(`Failed to fetch data.`);
return;
}

/**
* @type {{
* websiteId: string,
* bundleId: string,
* isMonthlyProduct: boolean,
* campaign: string
* }[]}
*/
const data = (await response.json())?.data;
if (!data) {
return;
}

const vlaicuProductIdsMapping = data.reduce((accumulator, currentValue) => {
accumulator[currentValue.websiteId] = {
...currentValue,
isMonthlyProduct: currentValue.isMonthlyProduct === "false" ? false : true
};
return accumulator;
}, {});
vlaicuProductIdsMapping.campaign = data[0].campaign || this.NO_PROMOTION;

this.PRODUCT_ID_MAPPINGS = vlaicuProductIdsMapping;
} catch(e) {
console.error(`Failed to fetch data.`);
return;
}
};
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GlobalContext } from "../resolver.js";
import { monthlyProducts } from "../../store.js";
import { Constants } from "../../../constants.js";

/**
* @param {string} hideCondition
Expand Down Expand Up @@ -33,7 +33,7 @@ const getMinOrMax = (value, options, fn) => {

for (const option of options) {
let localValue = fn(option);
localValue = monthlyProducts[option.getId()] ? localValue * 12 : localValue;
localValue = Constants.PRODUCT_ID_MAPPINGS[option.getId()].isMonthlyProduct ? localValue * 12 : localValue;
if (localValue && (value === "min" && localValue < minOrMax) || (value === "max" && localValue > minOrMax)) {
minOrMax = localValue;
productValue = option;
Expand Down
Loading

0 comments on commit 89a1ea2

Please sign in to comment.