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

TW-1252: Cashback services domains tracking #1048

Merged
merged 7 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
domains track
  • Loading branch information
lendihop committed Jan 10, 2024
commit bba3ff94aa2311c1d96b9facdff0bfe96f027a59
14 changes: 10 additions & 4 deletions src/lib/temple/back/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { BACKGROUND_IS_WORKER } from 'lib/env';
import { encodeMessage, encryptMessage, getSenderId, MessageType, Response } from 'lib/temple/beacon';
import { clearAsyncStorages } from 'lib/temple/reset';
import { TempleMessageType, TempleRequest, TempleResponse } from 'lib/temple/types';
import { getTrackedUrl } from 'lib/utils/url-track/get-tracked-url';
import { getTrackedCashbackServiceDomain, getTrackedUrl } from 'lib/utils/url-track/url-track.utils';

import * as Actions from './actions';
import * as Analytics from './analytics';
Expand Down Expand Up @@ -247,13 +247,19 @@ const processRequest = async (req: TempleRequest, port: Runtime.Port): Promise<T
browser.runtime.onMessage.addListener(msg => {
switch (msg?.type) {
case ContentScriptType.ExternalLinksActivity:
const url = getTrackedUrl(msg.url);
const trackedCashbackServiceDomain = getTrackedCashbackServiceDomain(new URL(msg.url).hostname);

if (url) {
if (trackedCashbackServiceDomain) {
Analytics.client.track('External Cashback Links Activity', { domain: trackedCashbackServiceDomain });
}

const trackedUrl = getTrackedUrl(msg.url);

if (trackedUrl) {
browser.storage.local
.get(ACCOUNT_PKH_STORAGE_KEY)
.then(({ [ACCOUNT_PKH_STORAGE_KEY]: accountPkh }) =>
Analytics.client.track('External links activity', { url, accountPkh })
Analytics.client.track('External links activity', { url: trackedUrl, accountPkh })
)
.catch(console.error);
}
Expand Down
Loading
Loading