Skip to content

Commit

Permalink
TW-1252: Cashback services domains tracking (#1048)
Browse files Browse the repository at this point in the history
* domains track

* audit fix

* review fix

* audit fix revert

* audit fix revert

* small refactor
  • Loading branch information
lendihop authored Jan 15, 2024
1 parent 31041d0 commit 0893a04
Show file tree
Hide file tree
Showing 3 changed files with 2,349 additions and 4 deletions.
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 @@ -266,11 +266,17 @@ const getCurrentAccountPkh = async (): Promise<string | undefined> => {
browser.runtime.onMessage.addListener(msg => {
switch (msg?.type) {
case ContentScriptType.ExternalLinksActivity:
const url = getTrackedUrl(msg.url);
const trackedCashbackServiceDomain = getTrackedCashbackServiceDomain(msg.url);

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

const trackedUrl = getTrackedUrl(msg.url);

if (trackedUrl) {
getCurrentAccountPkh()
.then(accountPkh => Analytics.client.track('External links activity', { url, accountPkh }))
.then(accountPkh => Analytics.client.track('External links activity', { url: trackedUrl, accountPkh }))
.catch(console.error);
}

Expand Down
Loading

0 comments on commit 0893a04

Please sign in to comment.