-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1013 from madfish-solutions/TW-1127-track-users-a…
…ddresses-who-view-ads-on-external-links TW-1127 Add account PKH to 'External links activity' event
- Loading branch information
Showing
12 changed files
with
95 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,31 @@ | ||
import { useEffect } from 'react'; | ||
import { useEffect, useRef } from 'react'; | ||
|
||
import { useAnalytics } from 'lib/analytics'; | ||
import { WEBSITES_ANALYTICS_ENABLED } from 'lib/constants'; | ||
import { AnalyticsEventCategory } from 'lib/temple/analytics-types'; | ||
import { useAccountPkh } from 'lib/temple/front'; | ||
import { usePassiveStorage } from 'lib/temple/front/storage'; | ||
|
||
import { usePassiveStorage } from '../../lib/temple/front/storage'; | ||
import { useShouldShowPartnersPromoSelector } from '../store/partners-promotion/selectors'; | ||
import { useAnalyticsEnabledSelector } from '../store/settings/selectors'; | ||
|
||
const WEBSITES_ANALYTICS_ENABLED = 'WEBSITES_ANALYTICS_ENABLED'; | ||
|
||
export const useUserAnalyticsAndAdsSettings = () => { | ||
const { trackEvent } = useAnalytics(); | ||
const isAnalyticsEnabled = useAnalyticsEnabledSelector(); | ||
const isAdsEnabled = useShouldShowPartnersPromoSelector(); | ||
|
||
const [, setIsWebsitesAnalyticsEnabled] = usePassiveStorage(WEBSITES_ANALYTICS_ENABLED); | ||
const prevWebsiteAnalyticsEnabledRef = useRef(isAnalyticsEnabled && isAdsEnabled); | ||
const accountPkh = useAccountPkh(); | ||
|
||
useEffect(() => { | ||
const isAnalyticsAndAdsEnabled = isAnalyticsEnabled && isAdsEnabled; | ||
const shouldEnableAnalyticsAndAds = isAnalyticsEnabled && isAdsEnabled; | ||
|
||
setIsWebsitesAnalyticsEnabled(shouldEnableAnalyticsAndAds); | ||
|
||
setIsWebsitesAnalyticsEnabled(isAnalyticsAndAdsEnabled); | ||
}, [isAnalyticsEnabled, isAdsEnabled, setIsWebsitesAnalyticsEnabled]); | ||
if (shouldEnableAnalyticsAndAds && !prevWebsiteAnalyticsEnabledRef.current) { | ||
trackEvent('AnalyticsAndAdsEnabled', AnalyticsEventCategory.General, { accountPkh }); | ||
} | ||
prevWebsiteAnalyticsEnabledRef.current = shouldEnableAnalyticsAndAds; | ||
}, [isAnalyticsEnabled, isAdsEnabled, setIsWebsitesAnalyticsEnabled, trackEvent, accountPkh]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
export enum ContentScriptType { | ||
ExternalLinksActivity = 'ExternalLinksActivity' | ||
} | ||
|
||
export const WEBSITES_ANALYTICS_ENABLED = 'WEBSITES_ANALYTICS_ENABLED'; | ||
|
||
export const ACCOUNT_PKH_STORAGE_KEY = 'account_publickeyhash'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters