Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add grafana faro sdk (CE) #38301

Merged
merged 29 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ee46926
chore: add grafana faro sdk
dvj1988 Dec 23, 2024
c4ca320
Merge remote-tracking branch 'origin' into chore/add-faro-integration
dvj1988 Dec 23, 2024
02a8e73
fix type issues
dvj1988 Dec 23, 2024
c8c07e5
remove new relic envs and revert caddy changes
dvj1988 Dec 23, 2024
a5b2046
remove unused new relic variables
dvj1988 Dec 23, 2024
f6d216e
type error fixes
dvj1988 Dec 23, 2024
d466781
add a new line
dvj1988 Dec 23, 2024
789ca05
remove tracing instrumentation
dvj1988 Dec 23, 2024
e9270ed
fix jest test cases
dvj1988 Dec 23, 2024
7a79f71
fix path change for generateTraces
dvj1988 Dec 23, 2024
78f2ead
Merge remote-tracking branch 'origin' into chore/add-faro-integration
dvj1988 Dec 23, 2024
ab35c43
revert envvariables.java
dvj1988 Dec 23, 2024
63d4868
move convertWebworkerSpansToRegularSpans from generateWebWorkerTraces…
dvj1988 Dec 24, 2024
7095223
disable faro errors in console
dvj1988 Dec 24, 2024
de9249e
configure log levels for faro sdk
dvj1988 Dec 24, 2024
c845ab4
Merge remote-tracking branch 'origin' into chore/add-faro-integration
dvj1988 Dec 24, 2024
149ab89
move span and attributes type to instrumentation/types
dvj1988 Dec 24, 2024
4a40d66
move span and attributes type to instrumentation/types
dvj1988 Dec 24, 2024
265ac2e
rever unintended changes
dvj1988 Dec 24, 2024
33ca23b
Merge remote-tracking branch 'origin' into chore/add-faro-integration
dvj1988 Dec 25, 2024
5d2881c
revert yarn.lock
dvj1988 Dec 25, 2024
3160036
remove @sentry/webpack-plugin
dvj1988 Dec 25, 2024
3842f6c
add faro packages
dvj1988 Dec 25, 2024
459a9c0
prune dependencies
dvj1988 Dec 25, 2024
91fe8aa
remove default values of observability variables from index.html
dvj1988 Dec 25, 2024
382098a
resolve pr comments
dvj1988 Dec 25, 2024
6db7362
remove widget profiler
dvj1988 Dec 25, 2024
46a6c29
update opentelemetry packages
dvj1988 Dec 25, 2024
c9d4264
Merge remote-tracking branch 'origin' into chore/add-faro-integration
dvj1988 Dec 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/client-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ jobs:
env:
ALL_CHANGED_FILES: ${{ steps.changed-files-specific.outputs.all_changed_files }}
run: |
echo "One or more files in the server folder has changed."
echo "List all the files that have changed: $ALL_CHANGED_FILES"
echo "One or more files in the server folder has changed."
echo "List all the files that have changed: $ALL_CHANGED_FILES"

- name: Check compliance
if: inputs.pr != 0 && steps.changed-files-specific.outputs.any_changed == 'true'
Expand Down Expand Up @@ -166,6 +166,11 @@ jobs:
export REACT_APP_SEGMENT_CE_KEY="${{ secrets.APPSMITH_SEGMENT_CE_KEY_RELEASE }}"
fi
REACT_APP_ENVIRONMENT=${{steps.vars.outputs.REACT_APP_ENVIRONMENT}} \
REACT_APP_FARO_APP_ID=${{ secrets.REACT_APP_FARO_APP_ID }} \
REACT_APP_FARO_APP_NAME=${{ secrets.REACT_APP_FARO_APP_NAME }} \
REACT_APP_FARO_SOURCEMAP_UPLOAD_API_KEY=${{ secrets.REACT_APP_FARO_SOURCEMAP_UPLOAD_API_KEY }} \
REACT_APP_FARO_SOURCEMAP_UPLOAD_ENDPOINT=${{ secrets.REACT_APP_FARO_SOURCEMAP_UPLOAD_ENDPOINT }} \
REACT_APP_FARO_STACK_ID=${{ secrets.REACT_APP_FARO_STACK_ID }} \
REACT_APP_FUSIONCHARTS_LICENSE_KEY=${{ secrets.APPSMITH_FUSIONCHARTS_LICENSE_KEY }} \
SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} \
REACT_APP_VERSION_EDITION="Community" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Clean up Sentry configuration and implementation

Both Sentry and Grafana Faro instrumentation code are present in the codebase. While Grafana Faro is being implemented (instrumentation/index.ts), Sentry is still actively used with a full implementation in sentry.ts and the SENTRY_AUTH_TOKEN is used in the build workflow. To maintain a clean codebase:

  • Remove SENTRY_AUTH_TOKEN from the build workflow
  • Clean up app/client/src/utils/Analytics/sentry.ts and related imports
  • Update any remaining Sentry configurations in the app configs
🔗 Analysis chain

Consider cleaning up Sentry configuration

The SENTRY_AUTH_TOKEN environment variable is still present while migrating to Grafana Faro.


The previous search was limited to YAML files, but Sentry configurations could be present in other file types. Let's broaden our search to verify if there are any remaining Sentry-related configurations or code before making a conclusion.


Let's verify if there are any remaining Sentry configurations and check for the Grafana Faro migration to make a more informed decision.


Let's examine the actual implementation files to understand if Sentry is still actively used or if it's been fully migrated to Grafana Faro.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for remaining Sentry configurations
rg -l 'SENTRY|sentry' --type yaml

Length of output: 35


Script:

#!/bin/bash
# Let's check for Sentry-related configurations in all files
rg -l 'SENTRY|sentry'

# Also check for any Sentry imports or usage in JavaScript/TypeScript files
ast-grep --pattern 'import $_ from "@sentry/$_"'

Length of output: 71494


Script:

#!/bin/bash
# Let's check for Sentry-related code and configurations in the client codebase
rg -l 'SENTRY|sentry' app/client/src/utils/Analytics/sentry.ts
rg -l 'SENTRY|sentry' app/client/src/configs/
rg -l 'SENTRY|sentry' app/client/.env*

# Check for Grafana Faro related code
rg -l 'GRAFANA_FARO|grafana.faro|@grafana/faro' app/client/

Length of output: 518


Script:

#!/bin/bash
# Let's check the content of sentry.ts and instrumentation files
rg -A 5 'SENTRY|sentry' app/client/src/utils/Analytics/sentry.ts
rg -A 5 '@grafana/faro' app/client/src/instrumentation/index.ts

# Check if SENTRY_AUTH_TOKEN is used in any workflow files
rg -A 5 'SENTRY_AUTH_TOKEN' .github/workflows/

Length of output: 2062

Expand Down
34 changes: 14 additions & 20 deletions app/client/craco.build.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const SentryWebpackPlugin = require("@sentry/webpack-plugin");
const { merge } = require("webpack-merge");
const common = require("./craco.common.config.js");
const WorkboxPlugin = require("workbox-webpack-plugin");
const CompressionPlugin = require("compression-webpack-plugin");
const { RetryChunkLoadPlugin } = require("webpack-retry-chunk-load-plugin");
const FaroSourceMapUploaderPlugin = require("@grafana/faro-webpack-plugin");
const path = require("path");

const env = process.env.REACT_APP_ENVIRONMENT;
Expand Down Expand Up @@ -39,26 +39,20 @@ plugins.push(
);

if (env === "PRODUCTION" || env === "STAGING") {
if (
process.env.SENTRY_AUTH_TOKEN != null &&
process.env.SENTRY_AUTH_TOKEN !== ""
) {
plugins.push(
new SentryWebpackPlugin({
include: "build",
ignore: ["node_modules", "webpack.config.js"],
release: process.env.REACT_APP_SENTRY_RELEASE,
deploy: {
env: process.env.REACT_APP_SENTRY_ENVIRONMENT,
},
}),
);
} else {
console.log(
"Sentry configuration missing in process environment. Sentry will be disabled.",
);
}
plugins.push(
new FaroSourceMapUploaderPlugin({
appId: process.env.REACT_APP_FARO_APP_ID,
appName: process.env.REACT_APP_FARO_APP_NAME,
endpoint: process.env.REACT_APP_FARO_SOURCEMAP_UPLOAD_ENDPOINT,
stackId: process.env.REACT_APP_FARO_STACK_ID,
// instructions on how to obtain your API key are in the documentation
// https://grafana.com/docs/grafana-cloud/monitor-applications/frontend-observability/sourcemap-upload-plugins/#obtain-an-api-key
apiKey: process.env.REACT_APP_FARO_SOURCEMAP_UPLOAD_API_KEY,
gzipContents: true,
}),
);
}

plugins.push(new CompressionPlugin());

plugins.push(
Expand Down
9 changes: 2 additions & 7 deletions app/client/docker/templates/nginx-app.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,10 @@ server {
sub_filter __APPSMITH_ZIPY_SDK_KEY__ '${APPSMITH_ZIPY_SDK_KEY}';
sub_filter __APPSMITH_HIDE_WATERMARK__ '${APPSMITH_HIDE_WATERMARK}';
sub_filter __APPSMITH_DISABLE_IFRAME_WIDGET_SANDBOX__ '${APPSMITH_DISABLE_IFRAME_WIDGET_SANDBOX}';
sub_filter __APPSMITH_NEW_RELIC_ACCOUNT_ID__ '${APPSMITH_NEW_RELIC_ACCOUNT_ID}';
sub_filter __APPSMITH_NEW_RELIC_APPLICATION_ID__ '${APPSMITH_NEW_RELIC_APPLICATION_ID}';
sub_filter __APPSMITH_NEW_RELIC_BROWSER_AGENT_LICENSE_KEY__ '${APPSMITH_NEW_RELIC_BROWSER_AGENT_LICENSE_KEY}';
sub_filter __APPSMITH_NEW_RELIC_BROWSER_AGENT_ENDPOINT__ '${APPSMITH_NEW_RELIC_BROWSER_AGENT_ENDPOINT}';
sub_filter __APPSMITH_NEW_RELIC_ACCOUNT_ENABLE__ '${APPSMITH_NEW_RELIC_ACCOUNT_ENABLE}';

sub_filter __APPSMITH_NEW_RELIC_OTLP_LICENSE_KEY__ '${APPSMITH_NEW_RELIC_OTLP_LICENSE_KEY}';
sub_filter __APPSMITH_NEW_RELIC_OTEL_SERVICE_NAME__ '${APPSMITH_NEW_RELIC_OTEL_SERVICE_NAME}';
sub_filter __APPSMITH_NEW_RELIC_OTEL_EXPORTER_OTLP_ENDPOINT__ '${APPSMITH_NEW_RELIC_OTEL_EXPORTER_OTLP_ENDPOINT}';

sub_filter __APPSMITH_FRONTEND_TRACING_URL__ '${APPSMITH_FRONTEND_TRACING_URL}';
}
KelvinOm marked this conversation as resolved.
Show resolved Hide resolved


Expand Down
19 changes: 1 addition & 18 deletions app/client/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,10 @@ module.exports = {
apiKey: parseConfig("__APPSMITH_SEGMENT_KEY__"),
ceKey: parseConfig("__APPSMITH_SEGMENT_CE_KEY__"),
},
newRelic: {
enableNewRelic: parseConfig("__APPSMITH_NEW_RELIC_ACCOUNT_ENABLE__"),
accountId: parseConfig("__APPSMITH_NEW_RELIC_ACCOUNT_ID__"),
applicationId: parseConfig("__APPSMITH_NEW_RELIC_APPLICATION_ID__"),
browserAgentlicenseKey: parseConfig(
"__APPSMITH_NEW_RELIC_BROWSER_AGENT_LICENSE_KEY__",
),
browserAgentEndpoint: parseConfig(
"__APPSMITH_NEW_RELIC_BROWSER_AGENT_ENDPOINT__",
),
otlpLicenseKey: parseConfig("__APPSMITH_NEW_RELIC_OTLP_LICENSE_KEY__"),
otlpServiceName: parseConfig(
"__APPSMITH_NEW_RELIC_OTEL_SERVICE_NAME__",
),
otlpEndpoint: parseConfig(
"__APPSMITH_NEW_RELIC_OTEL_EXPORTER_OTLP_ENDPOINT__",
),
},
observability: {
deploymentName: "jest-run",
serviceInstanceId: "appsmith-0",
tracingUrl: "",
},
fusioncharts: {
licenseKey: parseConfig("__APPSMITH_FUSIONCHARTS_LICENSE_KEY__"),
Expand Down
2 changes: 1 addition & 1 deletion app/client/knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"postcss-url",
"@types/dom-view-transitions",
"@types/jest",
"@sentry/webpack-plugin",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"@sentry/react": "^6.2.4" — should this package also be deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are planning to do this in the next pr.

"compression-webpack-plugin",
"webpack-retry-chunk-load-plugin",
"lint-staged",
Expand All @@ -47,6 +46,7 @@
"@aws-sdk/lib-storage",
"@octokit/rest",
"@faker-js/faker",
"@grafana/faro-webpack-plugin",
"pg",
"factory.ts"
]
Expand Down
4 changes: 3 additions & 1 deletion app/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
"@github/g-emoji-element": "^1.1.5",
"@googlemaps/markerclusterer": "^2.0.14",
"@googlemaps/react-wrapper": "^1.1.35",
"@grafana/faro-react": "^1.12.2",
"@grafana/faro-web-tracing": "^1.12.2",
"@manaflair/redux-batch": "^1.0.0",
"@mantine/hooks": "^5.10.1",
"@newrelic/browser-agent": "^1.255.0",
Expand Down Expand Up @@ -251,9 +253,9 @@
"@craco/craco": "^7.0.0",
"@cypress/grep": "^4.0.1",
"@faker-js/faker": "^7.4.0",
"@grafana/faro-webpack-plugin": "^0.1.1",
"@octokit/rest": "^20.0.1",
"@peculiar/webcrypto": "^1.4.3",
"@sentry/webpack-plugin": "^1.18.9",
"@simonsmith/cypress-image-snapshot": "^9.1.0",
"@testing-library/jest-dom": "5.16.1",
"@testing-library/react": "12.1.2",
Expand Down
93 changes: 51 additions & 42 deletions app/client/public/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand All @@ -17,31 +17,31 @@
transition: all ease-in 0.3s;
}
</style>
<script>
// '' (empty strings), 'false' are falsy
// could return either boolean or string based on value
const parseConfig = (config) => {
if (
(config.startsWith("{") && config.startsWith("}")) ||
config.indexOf("__") === 0 ||
config.indexOf("$") === 0 ||
config.indexOf("%") === 0
)
return "";
<script>
// '' (empty strings), 'false' are falsy
// could return either boolean or string based on value
const parseConfig = (config) => {
if (
(config.startsWith("{") && config.startsWith("}")) ||
config.indexOf("__") === 0 ||
config.indexOf("$") === 0 ||
config.indexOf("%") === 0
)
return "";

const result = config.trim();
if (result.toLowerCase() === "false" || result === "") {
return false;
} else if (result.toLowerCase() === "true") {
return true;
}
const result = config.trim();
if (result.toLowerCase() === "false" || result === "") {
return false;
} else if (result.toLowerCase() === "true") {
return true;
}

return result;
};
const CLOUD_HOSTING = parseConfig('{{env "APPSMITH_CLOUD_HOSTING"}}');
const AIRGAPPED = parseConfig('{{env "APPSMITH_AIRGAP_ENABLED"}}');
const REO_CLIENT_ID = parseConfig('{{env "APPSMITH_REO_CLIENT_ID"}}');
</script>
return result;
};
const CLOUD_HOSTING = parseConfig('{{env "APPSMITH_CLOUD_HOSTING"}}');
const AIRGAPPED = parseConfig('{{env "APPSMITH_AIRGAP_ENABLED"}}');
const REO_CLIENT_ID = parseConfig('{{env "APPSMITH_REO_CLIENT_ID"}}');
</script>
<script>
window.__APPSMITH_CHUNKS_TO_PRELOAD =
<%=
Expand All @@ -67,7 +67,18 @@
<!-- Start of Reo Javascript -->
<script type="text/javascript">
if (CLOUD_HOSTING && REO_CLIENT_ID) {
!function(){var e,t,n;e=REO_CLIENT_ID,t=function(){Reo.init({clientID:REO_CLIENT_ID})},(n=document.createElement("script")).src="https://static.reo.dev/"+e+"/reo.js",n.async=!0,n.onload=t,document.head.appendChild(n)}();
!(function () {
var e, t, n;
(e = REO_CLIENT_ID),
(t = function () {
Reo.init({ clientID: REO_CLIENT_ID });
}),
((n = document.createElement("script")).src =
"https://static.reo.dev/" + e + "/reo.js"),
(n.async = !0),
(n.onload = t),
document.head.appendChild(n);
})();
}
</script>
<!-- End of Reo Javascript -->
Expand Down Expand Up @@ -159,7 +170,9 @@
const INTERCOM_APP_ID =
parseConfig("%REACT_APP_INTERCOM_APP_ID%") ||
parseConfig('{{env "APPSMITH_INTERCOM_APP_ID"}}');
const DISABLE_INTERCOM = parseConfig('{{env "APPSMITH_DISABLE_INTERCOM"}}');
const DISABLE_INTERCOM = parseConfig(
'{{env "APPSMITH_DISABLE_INTERCOM"}}',
);

// Initialize the Intercom library
if (INTERCOM_APP_ID.length && !DISABLE_INTERCOM) {
Expand Down Expand Up @@ -213,23 +226,17 @@
ceKey: parseConfig('{{env "APPSMITH_SEGMENT_CE_KEY"}}'),
},
observability: {
deploymentName: parseConfig('{{env "APPSMITH_DEPLOYMENT_NAME"}}') || "self-hosted",
serviceInstanceId: parseConfig('{{env "HOSTNAME"}}') || "appsmith-0",
},
newRelic:{
enableNewRelic: parseConfig('{{env "APPSMITH_NEW_RELIC_ACCOUNT_ENABLE"}}'),
accountId: parseConfig('{{env "APPSMITH_NEW_RELIC_ACCOUNT_ID"}}'),
applicationId: parseConfig('{{env "APPSMITH_NEW_RELIC_APPLICATION_ID"}}'),
browserAgentlicenseKey: parseConfig('{{env "APPSMITH_NEW_RELIC_BROWSER_AGENT_LICENSE_KEY"}}'),
browserAgentEndpoint: parseConfig('{{env "APPSMITH_NEW_RELIC_BROWSER_AGENT_ENDPOINT"}}'),
otlpLicenseKey: parseConfig('{{env "APPSMITH_NEW_RELIC_OTLP_LICENSE_KEY"}}'),
//OTLP following the naming convention of Sdk initialisation
otlpServiceName: parseConfig('{{env "APPSMITH_NEW_RELIC_OTEL_SERVICE_NAME"}}'),
otlpEndpoint:parseConfig('{{env "APPSMITH_NEW_RELIC_OTEL_EXPORTER_OTLP_ENDPOINT"}}'),

deploymentName:
parseConfig('{{env "APPSMITH_DEPLOYMENT_NAME"}}') || "self-hosted",
serviceInstanceId:
parseConfig('{{env "APPSMITH_HOSTNAME"}}') || "appsmith-0",
tracingUrl:
parseConfig('{{env "APPSMITH_FRONTEND_TRACING_URL"}}') || "",
},
fusioncharts: {
licenseKey: parseConfig('{{env "APPSMITH_FUSIONCHARTS_LICENSE_KEY"}}'),
licenseKey: parseConfig(
'{{env "APPSMITH_FUSIONCHARTS_LICENSE_KEY"}}',
),
},
mixpanel: {
enabled: parseConfig('{{env "APPSMITH_SEGMENT_KEY"}}'),
Expand All @@ -247,7 +254,9 @@
},
intercomAppID: INTERCOM_APP_ID,
mailEnabled: parseConfig('{{env "APPSMITH_MAIL_ENABLED"}}'),
googleRecaptchaSiteKey: parseConfig('{{env "APPSMITH_RECAPTCHA_SITE_KEY"}}'),
googleRecaptchaSiteKey: parseConfig(
'{{env "APPSMITH_RECAPTCHA_SITE_KEY"}}',
),
hideWatermark: parseConfig('{{env "APPSMITH_HIDE_WATERMARK"}}'),
disableIframeWidgetSandbox: parseConfig(
'{{env "APPSMITH_DISABLE_IFRAME_WIDGET_SANDBOX"}}',
Expand Down
90 changes: 0 additions & 90 deletions app/client/src/UITelemetry/auto-otel-web.ts

This file was deleted.

Loading
Loading