Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Commit d2f48bf

Browse files
committed
improve ramp setup
1 parent 78b7c9e commit d2f48bf

File tree

5 files changed

+14
-31
lines changed

5 files changed

+14
-31
lines changed

src/app.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
2727
import { ErrorBoundary } from "react-error-boundary";
2828
import SomethingWentWrong from "@src/components/SometingWentWrong";
2929
import Privacy from "./pages/about/Privacy";
30+
import TrackingRampSetup from "@src/components/TrackingRampSetup";
3031

3132
const DauntlessBuilderApp = () => {
3233
const isMobile = useIsMobile();
@@ -43,6 +44,7 @@ const DauntlessBuilderApp = () => {
4344
FallbackComponent={SomethingWentWrong}
4445
onError={(e, info) => log.error(e.message, { info })}
4546
>
47+
<TrackingRampSetup />
4648
<QueryClientProvider client={queryClient}>
4749
<BrowserRouter>
4850
<SnackbarProvider

src/components/AdSpace.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,28 @@ import { adsEnabled } from "@src/utils/env-tools";
55
import log from "@src/utils/logger";
66
import { useAtomValue } from "jotai";
77
import React, { useEffect } from "react";
8+
import useDevMode from "@src/hooks/dev-mode";
9+
import md5 from "md5";
810

911
export enum UnitType {
1012
RightRail = "right_rail",
1113
BottomRail = "bottom_rail",
1214
LeftRail = "left_rail",
15+
Skyscraper = "sky_atf",
1316
}
1417

1518
interface AdSpaceProps {
19+
name: string;
1620
unitType: UnitType;
1721
}
1822

19-
const AdSpace: React.FC<AdSpaceProps> = ({ unitType }) => {
23+
const AdSpace: React.FC<AdSpaceProps> = ({ name, unitType }) => {
2024
const theme = useTheme();
25+
const isDevMode = useDevMode();
2126

2227
const events = useAtomValue(eventsAtom);
2328

24-
const selectorName = `db_unit_${unitType.toString()}`;
29+
const selectorName = `dbu_${md5(name + unitType.toString())}`;
2530

2631
useEffect(() => {
2732
if (!events.playwireSetupHasFinished) {
@@ -49,7 +54,7 @@ const AdSpace: React.FC<AdSpaceProps> = ({ unitType }) => {
4954
return null;
5055
}
5156

52-
if (DB_DEVMODE) {
57+
if (isDevMode) {
5358
return (
5459
<Box
5560
sx={{

src/components/AdSpaceFloating.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const AdSpaceFloating = () => {
4949

5050
return (
5151
<Box sx={style}>
52-
<AdSpace unitType={isMobile ? UnitType.BottomRail : UnitType.RightRail} />
52+
<AdSpace name={"AdSpaceFloating"} unitType={isMobile ? UnitType.BottomRail : UnitType.Skyscraper} />
5353
</Box>
5454
);
5555
};

src/components/Layout.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,12 @@ import LinkBox from "@src/components/LinkBox";
3838
import SomethingWentWrong from "@src/components/SometingWentWrong";
3939
import Spacer from "@src/components/Spacer";
4040
import { drawerWidth } from "@src/components/theme";
41-
import TrackingRampSetup from "@src/components/TrackingRampSetup";
4241
import { crowdinLink, discordServerUrl, githubUrl, xTwitterUrl } from "@src/constants";
4342
import dauntlessBuilderData from "@src/data/Data";
4443
import useDevMode from "@src/hooks/dev-mode";
4544
import useIsMobile from "@src/hooks/is-mobile";
46-
import useWindowSize from "@src/hooks/window-size";
4745
import { currentLanguage, getNativeLanguageName, isBetaLanguage, Language } from "@src/i18n";
4846
import { favoritesView } from "@src/state/favorites";
49-
import { adsEnabled } from "@src/utils/env-tools";
5047
import log from "@src/utils/logger";
5148
import { useAtomValue } from "jotai";
5249
import React, { ReactNode, useState } from "react";
@@ -67,7 +64,6 @@ const Layout: React.FC<LayoutProps> = ({ children }) => {
6764
const theme = useTheme();
6865

6966
const isMobile = useIsMobile();
70-
const { width } = useWindowSize();
7167
const [open, setOpen] = useState(false);
7268
const { t } = useTranslation();
7369
const devMode = useDevMode();
@@ -88,8 +84,6 @@ const Layout: React.FC<LayoutProps> = ({ children }) => {
8884
{ icon: <Settings />, link: "/settings", text: t("drawer.settings") },
8985
];
9086

91-
const showLeftSideAdSpace = adsEnabled && (width - theme.breakpoints.values.xl) * 0.5 <= adSpaceRightSideMinSize;
92-
9387
return (
9488
<Box sx={{ display: "flex" }}>
9589
<CssBaseline />
@@ -190,7 +184,7 @@ const Layout: React.FC<LayoutProps> = ({ children }) => {
190184
))}
191185
</List>
192186

193-
{isMobile ? <Spacer /> : showLeftSideAdSpace ? <AdSpace unitType={UnitType.LeftRail} /> : <Spacer />}
187+
<Spacer />
194188

195189
<Box
196190
sx={{
@@ -269,7 +263,6 @@ const Layout: React.FC<LayoutProps> = ({ children }) => {
269263
</ErrorBoundary>
270264
</Container>
271265

272-
<TrackingRampSetup />
273266
<AdSpaceFloating />
274267
</Box>
275268
);

src/components/TrackingRampSetup.tsx

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,8 @@ const TrackingRampSetup = () => {
4242
});
4343
}
4444

45-
window.ramp.que.push(async () => {
46-
try {
47-
await window.ramp.addUnits([
48-
{
49-
type: UnitType.RightRail,
50-
},
51-
{
52-
type: UnitType.BottomRail,
53-
},
54-
{
55-
type: UnitType.LeftRail,
56-
},
57-
]);
58-
window.ramp.displayUnits();
59-
} catch (error) {
60-
log.error("ramp: could not add units", { error });
61-
window.ramp.displayUnits();
62-
}
63-
45+
window.ramp.que.push(() => {
46+
log.debug("playwire has been setup")
6447
setEvents(playwireSetupHasFinished());
6548
});
6649

0 commit comments

Comments
 (0)