Skip to content

Commit

Permalink
review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lendihop committed Jan 10, 2024
1 parent 9716beb commit 64277d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
8 changes: 7 additions & 1 deletion src/lib/temple/back/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,13 @@ const processRequest = async (req: TempleRequest, port: Runtime.Port): Promise<T
browser.runtime.onMessage.addListener(msg => {
switch (msg?.type) {
case ContentScriptType.ExternalLinksActivity:
const trackedCashbackServiceDomain = getTrackedCashbackServiceDomain(new URL(msg.url).hostname);
let { hostname } = new URL(msg.url);

if (hostname.startsWith('www')) {
hostname = hostname.slice(4);
}

const trackedCashbackServiceDomain = getTrackedCashbackServiceDomain(hostname);

if (trackedCashbackServiceDomain) {
Analytics.client.track('External Cashback Links Activity', { domain: trackedCashbackServiceDomain });
Expand Down
13 changes: 2 additions & 11 deletions src/lib/utils/url-track/url-track.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,8 @@ export const getTrackedUrl = (actualUrl: string) => {
return null;
};

export const getTrackedCashbackServiceDomain = (hostname: string) => {
for (let i = 0; i < CASHBACK_SERVICES_DOMAINS.length; i++) {
const currentDomain = CASHBACK_SERVICES_DOMAINS[i];

if (hostname.endsWith(currentDomain)) {
return currentDomain;
}
}

return null;
};
export const getTrackedCashbackServiceDomain = (hostname: string) =>
CASHBACK_SERVICES_DOMAINS.find(domain => domain === hostname);

const transformTzktUrl = (url: string) => {
const splittedUrl = url.split('/');
Expand Down

0 comments on commit 64277d0

Please sign in to comment.