PromucFlow_constructor/app/client/src/instrumentation/utils.ts
Diljit 6505dae680
chore: add grafana faro sdk (CE) (#38301)
## Description
- Remove new relic browser agent
- Add faro sdk to capture frontend perf metrics and traces.

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.All"

### 🔍 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/12490844984>
> Commit: c9d4264027467bf33e1de519eb69c7762b6e7f75
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12490844984&attempt=2"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Wed, 25 Dec 2024 09:33:26 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [x] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Summary by CodeRabbit

- **New Features**
- Introduced new environment variable `APPSMITH_HOSTNAME` for dynamic
hostname configuration in HTML files.
- Enhanced telemetry capabilities with new imports and updated types for
better observability.
- Added `tracingUrl` under the observability section in configuration
files for improved telemetry tracking.

- **Bug Fixes**
- Adjusted telemetry data handling to utilize new `Attributes` type for
improved consistency.

- **Documentation**
- Updated import paths for various telemetry-related components to
reflect new module organization.

- **Chores**
- Removed deprecated telemetry configurations and streamlined build
processes.
	- Updated Nginx configuration to reflect new telemetry parameters.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-12-26 10:37:41 +05:30

64 lines
1.3 KiB
TypeScript

import {
deviceType,
browserName,
browserVersion,
osName,
osVersion,
} from "react-device-detect";
import nanoid from "nanoid";
import memoizeOne from "memoize-one";
import { getApplicationParamsFromUrl } from "ee/utils/serviceWorkerUtils";
import { getAppsmithConfigs } from "ee/configs";
const OTLP_SESSION_ID = nanoid();
const getAppParams = memoizeOne(
(origin: string, pathname: string, search: string) => {
const applicationParams = getApplicationParamsFromUrl({
origin,
pathname,
search,
});
const {
applicationSlug,
appMode = "",
basePageId: pageId,
branchName,
} = applicationParams || {};
return {
appMode,
pageId,
branchName,
applicationSlug,
};
},
);
export const getCommonTelemetryAttributes = () => {
const { origin, pathname, search } = window.location;
const appParams = getAppParams(origin, pathname, search);
return {
...appParams,
deviceType,
browserName,
browserVersion,
otlpSessionId: OTLP_SESSION_ID,
hostname: window.location.hostname,
osName,
osVersion,
};
};
export const isTracingEnabled = () => {
const { observability } = getAppsmithConfigs();
if (observability.tracingUrl) {
return true;
}
return false;
};