PromucFlow_constructor/app/client/src/pages/AppViewer/AppPage.tsx
Ankita Kinger 6244e28fed
chore: Update analytics to pass the correct source information in identify user call (#32591)
## Description

Updating analytics to pass the correct source information

Fixes [#32266](https://github.com/appsmithorg/appsmith/issues/32266)

## Automation

/ok-to-test tags="@tag.Sanity"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/8750877755>
> Commit: 6fedefebd3867aee79877b7ed105c90888005cfd
> Cypress dashboard url: <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=8750877755&attempt=1"
target="_blank">Click here!</a>

<!-- end of auto-generated comment: Cypress test results  -->
2024-04-19 15:06:50 +05:30

58 lines
1.9 KiB
TypeScript

import React, { useEffect, useMemo } from "react";
import AnalyticsUtil from "@appsmith/utils/AnalyticsUtil";
import { useDynamicAppLayout } from "utils/hooks/useDynamicAppLayout";
import type { CanvasWidgetStructure } from "WidgetProvider/constants";
import { useSelector } from "react-redux";
import { getAppMode } from "@appsmith/selectors/applicationSelectors";
import { PageView, PageViewWrapper } from "./AppPage.styled";
import { APP_MODE } from "entities/App";
import { renderAppsmithCanvas } from "layoutSystems/CanvasFactory";
import type { WidgetProps } from "widgets/BaseWidget";
import { useAppViewerSidebarProperties } from "utils/hooks/useAppViewerSidebarProperties";
import { getIsAnvilLayout } from "layoutSystems/anvil/integrations/selectors";
interface AppPageProps {
appName?: string;
canvasWidth: number;
pageId?: string;
pageName?: string;
widgetsStructure: CanvasWidgetStructure;
}
export function AppPage(props: AppPageProps) {
const appMode = useSelector(getAppMode);
const isPublished = appMode === APP_MODE.PUBLISHED;
const isAnvilLayout = useSelector(getIsAnvilLayout);
const { hasSidebarPinned, sidebarWidth } = useAppViewerSidebarProperties();
const width: string = useMemo(() => {
return isAnvilLayout ? "100%" : `${props.canvasWidth}px`;
}, [isAnvilLayout, props.canvasWidth]);
useDynamicAppLayout();
useEffect(() => {
AnalyticsUtil.logEvent("PAGE_LOAD", {
pageName: props.pageName,
pageId: props.pageId,
appName: props.appName,
mode: "VIEW",
});
}, [props.pageId, props.pageName]);
return (
<PageViewWrapper
hasPinnedSidebar={hasSidebarPinned}
isPublished={isPublished}
sidebarWidth={sidebarWidth}
>
<PageView className="t--app-viewer-page" width={width}>
{props.widgetsStructure.widgetId &&
renderAppsmithCanvas(props.widgetsStructure as WidgetProps)}
</PageView>
</PageViewWrapper>
);
}
export default AppPage;