Skip to content

Commit

Permalink
move getEnvType to util.js
Browse files Browse the repository at this point in the history
  • Loading branch information
rrusher committed Feb 6, 2024
1 parent 75d5273 commit 56140b7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
14 changes: 1 addition & 13 deletions scripts/delayed.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
// eslint-disable-next-line import/no-cycle
import { sampleRUM, loadScript } from './aem.js';
import { getEnvType } from './util.js';

// Core Web Vitals RUM collection
sampleRUM('cwv');

/*
* Returns the environment type based on the hostname.
*/
function getEnvType(hostname = window.location.hostname) {
const fqdnToEnvType = {
'commonmoves.com': 'preview',
'www.commonmoves.com': 'preview',
'main--hsf-commonmoves--hlxsites.hlx.page': 'dev',
'main--hsf-commonmoves--hlxsites.hlx.live': 'dev',
};
return fqdnToEnvType[hostname] || 'dev';
}

async function loadAdobeLaunch() {
const adobedtmSrc = {
dev: 'https://assets.adobedtm.com/2079c5a4620d/addee6043c9b/launch-EN41458ac9f88145ac942b876e3362c32f-development.min.js',
Expand Down
16 changes: 16 additions & 0 deletions scripts/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,26 @@ export async function i18nLookup(prefix) {
};
}

/*
* Returns the environment type based on the hostname.
*/
export function getEnvType(hostname = window.location.hostname) {
const fqdnToEnvType = {
'commonmoves.com': 'live',
'www.commonmoves.com': 'live',
'stage.commonmoves.com': 'preview',
'preview.commonmoves.com': 'preview',
'main--hsf-commonmoves--hlxsites.hlx.page': 'dev',
'main--hsf-commonmoves--hlxsites.hlx.live': 'dev',
};
return fqdnToEnvType[hostname] || 'dev';
}

const Util = {
getSpinner,
showModal,
i18nLookup,
getEnvType,
};

export default Util;

0 comments on commit 56140b7

Please sign in to comment.