## Description - Remove page visibility change listener in Page load instrumentation. The page visibility data is not working as expected. - Add `otlpSessionId` and `appMode` attributes to all PageView and PageViewTimings data pushed by the new relic browser agent. This will help us infer session based information and join reports with Page load Spans - Add network and device specific attributes to the `PAGE_LOAD` span Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## 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/10934682384> > Commit: de172593ce8d7782fb526d3294e8a63155e3c849 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=10934682384&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity` > Spec: > <hr>Thu, 19 Sep 2024 05:22:19 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced telemetry data collection during page load events, capturing device memory and network attributes. - Introduced functionality to gather operating system details (name and version) for improved telemetry insights. - Improved integration with New Relic for detailed monitoring through custom attributes. - **Bug Fixes** - Removed outdated logic for tracking page visibility, focusing on more relevant metrics. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
139 lines
4.3 KiB
TypeScript
Executable File
139 lines
4.3 KiB
TypeScript
Executable File
// This file must be executed as early as possible to ensure the preloads are triggered ASAP
|
|
import "./preload-route-chunks";
|
|
|
|
import React from "react";
|
|
import "./wdyr";
|
|
import ReactDOM from "react-dom";
|
|
import { Provider } from "react-redux";
|
|
import "./index.css";
|
|
import "@appsmith/ads-old/src/themes/default/index.css";
|
|
import "@appsmith/ads/src/__theme__/default/index.css";
|
|
import { ThemeProvider } from "styled-components";
|
|
import { appInitializer } from "utils/AppUtils";
|
|
import store, { runSagaMiddleware } from "./store";
|
|
import { LayersContext, Layers } from "constants/Layers";
|
|
import AppRouter from "ee/AppRouter";
|
|
import * as Sentry from "@sentry/react";
|
|
import { getCurrentThemeDetails } from "selectors/themeSelectors";
|
|
import { connect } from "react-redux";
|
|
import type { AppState } from "ee/reducers";
|
|
import { Toast } from "@appsmith/ads";
|
|
import "./assets/styles/index.css";
|
|
import "./polyfills";
|
|
import GlobalStyles from "globalStyles";
|
|
// enable autofreeze only in development
|
|
import { setAutoFreeze } from "immer";
|
|
import AppErrorBoundary from "./AppErrorBoundry";
|
|
import log from "loglevel";
|
|
import { getAppsmithConfigs } from "ee/configs";
|
|
import { PageViewTiming } from "@newrelic/browser-agent/features/page_view_timing";
|
|
import { PageViewEvent } from "@newrelic/browser-agent/features/page_view_event";
|
|
import { Agent } from "@newrelic/browser-agent/loaders/agent";
|
|
import { getCommonTelemetryAttributes } from "UITelemetry/generateTraces";
|
|
|
|
const { newRelic } = getAppsmithConfigs();
|
|
const { enableNewRelic } = newRelic;
|
|
|
|
const newRelicBrowserAgentConfig = {
|
|
init: {
|
|
distributed_tracing: { enabled: true },
|
|
privacy: { cookies_enabled: true },
|
|
},
|
|
info: {
|
|
beacon: newRelic.browserAgentEndpoint,
|
|
errorBeacon: newRelic.browserAgentEndpoint,
|
|
licenseKey: newRelic.browserAgentlicenseKey,
|
|
applicationID: newRelic.applicationId,
|
|
sa: 1,
|
|
},
|
|
loader_config: {
|
|
accountID: newRelic.accountId,
|
|
trustKey: newRelic.accountId,
|
|
agentID: newRelic.applicationId,
|
|
licenseKey: newRelic.browserAgentlicenseKey,
|
|
applicationID: newRelic.applicationId,
|
|
},
|
|
};
|
|
|
|
// The agent loader code executes immediately on instantiation.
|
|
if (enableNewRelic) {
|
|
const newRelicBrowserAgent = new Agent(
|
|
{
|
|
...newRelicBrowserAgentConfig,
|
|
features: [PageViewTiming, PageViewEvent],
|
|
},
|
|
// The second argument agentIdentifier is not marked as optional in its type definition.
|
|
// Passing a null value throws an error as well. So we pass undefined.
|
|
undefined,
|
|
);
|
|
|
|
const { appMode, otlpSessionId } = getCommonTelemetryAttributes();
|
|
|
|
newRelicBrowserAgent.setCustomAttribute("otlpSessionId", otlpSessionId);
|
|
newRelicBrowserAgent.setCustomAttribute("appMode", appMode);
|
|
}
|
|
|
|
const shouldAutoFreeze = process.env.NODE_ENV === "development";
|
|
|
|
setAutoFreeze(shouldAutoFreeze);
|
|
runSagaMiddleware();
|
|
|
|
appInitializer();
|
|
|
|
enableNewRelic &&
|
|
(async () => {
|
|
try {
|
|
await import(
|
|
/* webpackChunkName: "otlpTelemetry" */ "./UITelemetry/auto-otel-web"
|
|
);
|
|
} catch (e) {
|
|
log.error("Error loading telemetry script", e);
|
|
}
|
|
})();
|
|
|
|
function App() {
|
|
return (
|
|
<Sentry.ErrorBoundary fallback={"An error has occured"}>
|
|
<Provider store={store}>
|
|
<LayersContext.Provider value={Layers}>
|
|
<ThemedAppWithProps />
|
|
</LayersContext.Provider>
|
|
</Provider>
|
|
</Sentry.ErrorBoundary>
|
|
);
|
|
}
|
|
|
|
class ThemedApp extends React.Component<{
|
|
// TODO: Fix this the next time the file is edited
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
currentTheme: any;
|
|
}> {
|
|
render() {
|
|
return (
|
|
<ThemeProvider theme={this.props.currentTheme}>
|
|
<Toast />
|
|
<GlobalStyles />
|
|
<AppErrorBoundary>
|
|
<AppRouter />
|
|
</AppErrorBoundary>
|
|
</ThemeProvider>
|
|
);
|
|
}
|
|
}
|
|
const mapStateToProps = (state: AppState) => ({
|
|
currentTheme: getCurrentThemeDetails(state),
|
|
});
|
|
|
|
const ThemedAppWithProps = connect(mapStateToProps)(ThemedApp);
|
|
|
|
ReactDOM.render(<App />, document.getElementById("root"));
|
|
|
|
// expose store when run in Cypress
|
|
// TODO: Fix this the next time the file is edited
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
if ((window as any).Cypress) {
|
|
// TODO: Fix this the next time the file is edited
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
(window as any).store = store;
|
|
}
|