Skip to content

Commit

Permalink
feat(customParticipantButton): metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
hristoterezov committed Jan 8, 2025
1 parent 97146ed commit 787a0ed
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions react/features/analytics/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,30 @@ export async function createHandlers({ getState }: IStore) {
return handlers;
}

/**
* Checks whether a url is a data URL or not.
*
* @param {string} url - The URL to be checked.
* @returns {boolean}
*/
function isDataURL(url?: string): boolean {
if (typeof url !== 'string') { // The icon will be ignored
return false;
}

try {
const urlObject = new URL(url);

if (urlObject.protocol === 'data:') {
return false;
}
} catch {
return false;
}

return true;
}

/**
* Inits JitsiMeetJS.analytics by setting permanent properties and setting the handlers from the loaded scripts.
* NOTE: Has to be used after JitsiMeetJS.init. Otherwise analytics will be null.
Expand Down Expand Up @@ -186,6 +210,7 @@ export function initAnalytics(store: IStore, handlers: Array<Object>): boolean {
isPromotedFromVisitor?: boolean;
isVisitor?: boolean;
overwritesCustomButtonsWithURL?: boolean;
overwritesCustomParticipantButtonsWithURL?: boolean;
overwritesDefaultLogoUrl?: boolean;
overwritesDeploymentUrls?: boolean;
overwritesEtherpadBase?: boolean;
Expand Down Expand Up @@ -287,23 +312,12 @@ export function initAnalytics(store: IStore, handlers: Array<Object>): boolean {
const customToolbarButtons = params['config.customToolbarButtons'] ?? [];

permanentProperties.overwritesCustomButtonsWithURL = Boolean(
customToolbarButtons.find(({ icon }: { icon: string; }) => {
if (typeof icon !== 'string') { // The icon will be ignored
return false;
}

try {
const url = new URL(icon);
customToolbarButtons.find(({ icon }: { icon: string; }) => isDataURL(icon)));

if (url.protocol === 'data:') {
return false;
}
} catch {
return false;
}
const customParticipantMenuButtons = params['config.customParticipantMenuButtons'] ?? [];

return true;
}));
permanentProperties.overwritesCustomParticipantButtonsWithURL = Boolean(
customParticipantMenuButtons.find(({ icon }: { icon: string; }) => isDataURL(icon)));

// Optionally, include local deployment information based on the
// contents of window.config.deploymentInfo.
Expand Down

0 comments on commit 787a0ed

Please sign in to comment.