-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4717 from coopcycle/frontend-monitoring
Frontend monitoring
- Loading branch information
Showing
13 changed files
with
217 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { datadogLogs } from '@datadog/browser-logs' | ||
import { datadogRum } from '@datadog/browser-rum' | ||
|
||
const el = document.getElementById('datadog') | ||
const datadogEnabled = Boolean(el) | ||
|
||
if (datadogEnabled) { | ||
datadogLogs.init({ | ||
clientToken: el.dataset.clientToken, | ||
site: 'datadoghq.com', | ||
service: el.dataset.service, | ||
forwardErrorsToLogs: true, | ||
// Only tracked sessions send logs; from 0 to 100 | ||
sessionSampleRate: 100, | ||
telemetrySampleRate: 0, | ||
}) | ||
|
||
datadogRum.init({ | ||
applicationId: el.dataset.applicationId, | ||
clientToken: el.dataset.clientToken, | ||
site: 'datadoghq.com', | ||
service: el.dataset.service, | ||
// Specify a version number to identify the deployed version of your application in Datadog | ||
// version: '1.0.0', | ||
// 'Browser RUM' session sample rate; from 0 to 100 | ||
sessionSampleRate: 1, | ||
// 'Browser RUM & Session Replay' sample rate (% from sessions tracked by RUM/sessionSampleRate); from 0 to 100 | ||
sessionReplaySampleRate: 10, | ||
telemetrySampleRate: 0, | ||
trackUserInteractions: true, | ||
trackResources: true, | ||
trackLongTasks: true, | ||
defaultPrivacyLevel: 'mask-user-input', | ||
}) | ||
} | ||
|
||
const DatadogLogger = { | ||
/** | ||
* Send a log with debug level. | ||
* @param message: The message to send. | ||
* @param context: The additional context to send. | ||
*/ | ||
debug(message, context) { | ||
if (!datadogEnabled) { | ||
console.debug(message, context) | ||
return | ||
} | ||
|
||
datadogLogs.logger.debug(message, context) | ||
}, | ||
|
||
/** | ||
* Send a log with info level. | ||
* @param message: The message to send. | ||
* @param context: The additional context to send. | ||
*/ | ||
info(message, context) { | ||
if (!datadogEnabled) { | ||
console.info(message, context) | ||
return | ||
} | ||
|
||
datadogLogs.logger.info(message, context) | ||
}, | ||
|
||
/** | ||
* Send a log with warn level. | ||
* @param message: The message to send. | ||
* @param context: The additional context to send. | ||
*/ | ||
warn(message, context) { | ||
if (!datadogEnabled) { | ||
console.warn(message, context) | ||
return | ||
} | ||
|
||
datadogLogs.logger.warn(message, context) | ||
}, | ||
|
||
/** | ||
* Send a log with error level. | ||
* @param message: The message to send. | ||
* @param context: The additional context to send. | ||
*/ | ||
error(message, context) { | ||
if (!datadogEnabled) { | ||
console.error(message, context) | ||
return | ||
} | ||
|
||
datadogLogs.logger.error(message, context) | ||
}, | ||
} | ||
|
||
window.DatadogLogger = DatadogLogger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const useDatadog = () => { | ||
return { | ||
logger: window.DatadogLogger, | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{% if app.environment == "prod" %} | ||
<div id="sentry" data-dsn="{{ sentry_public_dsn }}"></div> | ||
{{ encore_entry_script_tags('sentry') }} | ||
{% endif %} | ||
|
||
{% if app.environment == "prod" %} | ||
<div id="datadog" | ||
data-client-token="{{ datadog_client_token }}" | ||
data-application-id="{{ datadog_application_id }}" | ||
data-service="{{ instance_name }}" | ||
></div> | ||
{% endif %} | ||
|
||
{# inject on all environments (on dev: logs to console) #} | ||
{{ encore_entry_script_tags('datadog') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters