Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PID in metadata #467

Merged
merged 3 commits into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions solutions/scripts/utils/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { getMetadata } from './aem.js';

Check failure on line 1 in solutions/scripts/utils/utils.js

View workflow job for this annotation

GitHub Actions / linting

Unable to resolve path to module './aem.js'

const cacheResponse = new Map();
const FETCH_URL = 'https://www.bitdefender.com.au/site/Store/ajax';

Expand Down Expand Up @@ -50,19 +52,24 @@
*/
export async function fetchProduct(code = 'av', variant = '1u-1y', pid = null) {
const data = new FormData();
let pidFromUrl;
let pidFromMetadata;
// extract pid from url
if (!pid) {
const url = new URL(window.location.href);
// eslint-disable-next-line no-param-reassign
pid = url.searchParams.get('pid');
pidFromUrl = url.searchParams.get('pid');
}

if (!pidFromUrl) {
pidFromMetadata = getMetadata('pid');
}

data.append('data', JSON.stringify({
ev: 1,
product_id: code,
config: {
extra_params: {
pid,
pid: pidFromUrl || pidFromMetadata,
},
},
}));
Expand Down
Loading