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

86 analytics #196

Merged
merged 7 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
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
17 changes: 15 additions & 2 deletions scripts/delayed.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
// eslint-disable-next-line import/no-cycle
import { sampleRUM } from './aem.js';
import { sampleRUM, loadScript } from './aem.js';
import { getEnvType } from './util.js';

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

// add more delayed functionality here
async function loadAdobeLaunch() {
const adobedtmSrc = {
dev: 'https://assets.adobedtm.com/2079c5a4620d/addee6043c9b/launch-EN41458ac9f88145ac942b876e3362c32f-development.min.js',
preview: 'https://assets.adobedtm.com/2079c5a4620d/addee6043c9b/launch-EN367ab3c0970e43a0afba6d1110494ef4-staging.min.js',
live: 'https://assets.adobedtm.com/2079c5a4620d/addee6043c9b/launch-EN8919423a46da4e859aad8cef6f514471.min.js',
};
await loadScript(adobedtmSrc[getEnvType()], {
type: 'text/javascript',
async: true,
});
}

if (!window.location.host.includes('localhost')) await loadAdobeLaunch();
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;
Loading