Skip to content

Commit

Permalink
Release 1.19.11 (#1102)
Browse files Browse the repository at this point in the history
Merge pull request #1102 from madfish-solutions/development
  • Loading branch information
alex-tsx authored Mar 5, 2024
2 parents e5a1fef + 6f8f239 commit 5e05cb7
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "temple-wallet",
"version": "1.19.10",
"version": "1.19.11",
"private": true,
"scripts": {
"start-run": "cross-env TS_NODE_PROJECT=\"webpack/tsconfig.json\" webpack --watch --stats errors-warnings",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const bannerIsDisplayed = (element: BannerElement) => {
const adAttributesObserverOptions = { attributes: true };

export const HypelabImagePromotion: FC<Omit<SingleProviderPromotionProps, 'variant'>> = ({
providerTitle,
pageName,
isVisible,
onAdRectSeen,
onClose,
Expand Down Expand Up @@ -79,6 +81,8 @@ export const HypelabImagePromotion: FC<Omit<SingleProviderPromotionProps, 'varia

return (
<ImagePromotionView
pageName={pageName}
providerTitle={providerTitle}
onClose={onClose}
href={currentAd?.cta_url ?? '#'}
isVisible={isVisible}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const dummyImageSrc =
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==';

export const HypelabTextPromotion: FC<Omit<SingleProviderPromotionProps, 'variant'>> = ({
providerTitle,
pageName,
isVisible,
onAdRectSeen,
onClose,
Expand All @@ -45,6 +47,8 @@ export const HypelabTextPromotion: FC<Omit<SingleProviderPromotionProps, 'varian
<Native placement={EnvVars.HYPELAB_NATIVE_PLACEMENT_SLUG} ref={hypelabNativeElementRef}>
<span className="hidden" ref={hypelabHeadlineRef} data-ref="headline" />
<TextPromotionView
pageName={pageName}
providerTitle={providerTitle}
href={currentAd?.cta_url ?? '/'}
imageSrc={currentAd?.creative_set.icon.url ?? dummyImageSrc}
isVisible={isVisible}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,44 @@
import React, { FC, MouseEventHandler, PropsWithChildren, useRef } from 'react';
import React, { FC, MouseEventHandler, PropsWithChildren, useMemo, useRef } from 'react';

import clsx from 'clsx';

import { Anchor } from 'app/atoms/Anchor';
import { useAdRectObservation } from 'app/hooks/ads/use-ad-rect-observation';
import { useAccount } from 'lib/temple/front';

import { PartnersPromotionSelectors } from '../index.selectors';
import { PartnersPromotionVariant } from '../types';

import { CloseButton } from './close-button';

interface TextPromotionViewProps extends PropsWithChildren {
pageName: string;
providerTitle: string;
href: string;
isVisible: boolean;
onAdRectSeen: EmptyFn;
onClose: MouseEventHandler<HTMLButtonElement>;
}

export const ImagePromotionView: FC<TextPromotionViewProps> = ({
pageName,
providerTitle,
children,
href,
isVisible,
onAdRectSeen,
onClose
}) => {
const { publicKeyHash: accountPkh } = useAccount();

const ref = useRef<HTMLAnchorElement>(null);
useAdRectObservation(ref, onAdRectSeen, isVisible);

const testIDProperties = useMemo(
() => ({ variant: PartnersPromotionVariant.Image, page: pageName, provider: providerTitle, href, accountPkh }),
[href, accountPkh, providerTitle, pageName]
);

return (
<Anchor
className={clsx(
Expand All @@ -39,7 +51,7 @@ export const ImagePromotionView: FC<TextPromotionViewProps> = ({
rel="noreferrer"
ref={ref}
testID={PartnersPromotionSelectors.promoLink}
testIDProperties={{ variant: PartnersPromotionVariant.Image, href }}
testIDProperties={testIDProperties}
>
{children}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import { ImagePromotionView } from './image-promotion-view';
import { TextPromotionView } from './text-promotion-view';

export const OptimalPromotion: FC<SingleProviderPromotionProps> = ({
isVisible,
variant,
providerTitle,
pageName,
isVisible,
onAdRectSeen,
onClose,
onReady,
Expand Down Expand Up @@ -64,14 +66,23 @@ export const OptimalPromotion: FC<SingleProviderPromotionProps> = ({

if (variant === PartnersPromotionVariant.Image) {
return (
<ImagePromotionView onClose={onClose} onAdRectSeen={onAdRectSeen} href={href} isVisible={isVisible}>
<ImagePromotionView
pageName={pageName}
providerTitle={providerTitle}
onClose={onClose}
onAdRectSeen={onAdRectSeen}
href={href}
isVisible={isVisible}
>
<img src={imageSrc} alt="Partners promotion" className="shadow-lg rounded-lg" onError={onImageError} />
</ImagePromotionView>
);
}

return (
<TextPromotionView
pageName={pageName}
providerTitle={providerTitle}
href={href}
imageSrc={imageSrc}
isVisible={isVisible}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import clsx from 'clsx';
import { Anchor } from 'app/atoms/Anchor';
import { useAppEnv } from 'app/env';
import { useAdRectObservation } from 'app/hooks/ads/use-ad-rect-observation';
import { useAccount } from 'lib/temple/front';

import { PartnersPromotionSelectors } from '../index.selectors';
import { PartnersPromotionVariant } from '../types';

import { CloseButton } from './close-button';

interface TextPromotionViewProps {
pageName: string;
providerTitle: string;
href: string;
isVisible: boolean;
imageSrc: string;
Expand All @@ -23,8 +26,21 @@ interface TextPromotionViewProps {
}

export const TextPromotionView = memo<TextPromotionViewProps>(
({ imageSrc, href, headline, isVisible, contentText = '', onAdRectSeen, onImageError, onClose }) => {
({
pageName,
providerTitle,
imageSrc,
href,
headline,
isVisible,
contentText = '',
onAdRectSeen,
onImageError,
onClose
}) => {
const { popup } = useAppEnv();
const { publicKeyHash: accountPkh } = useAccount();

const truncatedContentText = useMemo(
() => (contentText.length > 80 ? `${contentText.slice(0, 80)}...` : contentText),
[contentText]
Expand All @@ -33,6 +49,11 @@ export const TextPromotionView = memo<TextPromotionViewProps>(
const ref = useRef<HTMLAnchorElement>(null);
useAdRectObservation(ref, onAdRectSeen, isVisible);

const testIDProperties = useMemo(
() => ({ variant: PartnersPromotionVariant.Text, page: pageName, provider: providerTitle, href, accountPkh }),
[href, accountPkh, providerTitle, pageName]
);

return (
<Anchor
className={clsx(
Expand All @@ -45,7 +66,7 @@ export const TextPromotionView = memo<TextPromotionViewProps>(
rel="noreferrer"
ref={ref}
testID={PartnersPromotionSelectors.promoLink}
testIDProperties={{ variant: PartnersPromotionVariant.Text, href }}
testIDProperties={testIDProperties}
>
<div className="flex items-center justify-start gap-2.5 p-4 max-w-sm w-full">
<div className="self-stretch">
Expand Down
17 changes: 15 additions & 2 deletions src/app/templates/partners-promotion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from 'app/store/partners-promotion/selectors';
import { AnalyticsEventCategory, useAnalytics } from 'lib/analytics';
import { AD_HIDING_TIMEOUT } from 'lib/constants';
import { useAccount } from 'lib/temple/front';

import { HypelabPromotion } from './components/hypelab-promotion';
import { OptimalPromotion } from './components/optimal-promotion';
Expand All @@ -34,6 +35,7 @@ const shouldBeHiddenTemporarily = (hiddenAt: number) => {

export const PartnersPromotion = memo<PartnersPromotionProps>(({ variant, id, pageName }) => {
const isImageAd = variant === PartnersPromotionVariant.Image;
const { publicKeyHash: accountPkh } = useAccount();
const { trackEvent } = useAnalytics();
const { popup } = useAppEnv();
const dispatch = useDispatch();
Expand All @@ -46,6 +48,8 @@ export const PartnersPromotion = memo<PartnersPromotionProps>(({ variant, id, pa
const [adError, setAdError] = useState(false);
const [adIsReady, setAdIsReady] = useState(false);

const providerTitle = shouldUseOptimalAd ? 'Optimal' : 'HypeLab';

useEffect(() => {
const newIsHiddenTemporarily = shouldBeHiddenTemporarily(hiddenAt);
setIsHiddenTemporarily(newIsHiddenTemporarily);
Expand All @@ -65,9 +69,14 @@ export const PartnersPromotion = memo<PartnersPromotionProps>(({ variant, id, pa
const handleAdRectSeen = useCallback(() => {
if (lastReportedPageName !== pageName) {
dispatch(setLastReportedPageNameAction(pageName));
trackEvent('Internal Ads Activity', AnalyticsEventCategory.General, { page: pageName });
trackEvent('Internal Ads Activity', AnalyticsEventCategory.General, {
variant,
page: pageName,
provider: providerTitle,
accountPkh
});
}
}, [dispatch, lastReportedPageName, pageName, trackEvent]);
}, [providerTitle, lastReportedPageName, variant, pageName, accountPkh, trackEvent, dispatch]);

const handleClosePartnersPromoClick = useCallback<MouseEventHandler<HTMLButtonElement>>(
e => {
Expand All @@ -92,6 +101,8 @@ export const PartnersPromotion = memo<PartnersPromotionProps>(({ variant, id, pa
{shouldUseOptimalAd ? (
<OptimalPromotion
variant={variant}
providerTitle={providerTitle}
pageName={pageName}
isVisible={adIsReady}
onAdRectSeen={handleAdRectSeen}
onClose={handleClosePartnersPromoClick}
Expand All @@ -101,6 +112,8 @@ export const PartnersPromotion = memo<PartnersPromotionProps>(({ variant, id, pa
) : (
<HypelabPromotion
variant={variant}
providerTitle={providerTitle}
pageName={pageName}
isVisible={adIsReady}
onAdRectSeen={handleAdRectSeen}
onClose={handleClosePartnersPromoClick}
Expand Down
2 changes: 2 additions & 0 deletions src/app/templates/partners-promotion/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export enum PartnersPromotionVariant {

export interface SingleProviderPromotionProps {
variant: PartnersPromotionVariant;
pageName: string;
providerTitle: string;
isVisible: boolean;
onClose: MouseEventHandler<HTMLButtonElement>;
onReady: EmptyFn;
Expand Down

0 comments on commit 5e05cb7

Please sign in to comment.