-
Notifications
You must be signed in to change notification settings - Fork 1
fix: analytics #35
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
fix: analytics #35
Changes from all commits
8bddb7c
422961c
a9bf4ce
1e6100d
b667f49
6da9876
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ const SERVICE_NAME = 'v4-web'; | |
| const LOGGER_NAME = 'v4-web'; | ||
| const SITE_NAME = 'datadoghq.com'; | ||
| const instanceId = crypto.randomUUID(); | ||
| const FRONTEND = 'bonk'; | ||
|
|
||
| const LOG_ENDPOINT_PATH = (PROXY_URL ?? '').endsWith('/') ? 'api/v2/logs' : '/api/v2/logs'; | ||
|
|
||
|
|
@@ -22,14 +23,18 @@ if (CLIENT_TOKEN) { | |
| proxy: PROXY_URL ? `${PROXY_URL}${LOG_ENDPOINT_PATH}` : undefined, | ||
| sendLogsAfterSessionExpiration: true, | ||
| }); | ||
|
|
||
| datadogLogs.setGlobalContextProperty('frontend', FRONTEND); | ||
| datadogLogs.setGlobalContextProperty('dd-client-token', CLIENT_TOKEN); | ||
| datadogLogs.setGlobalContextProperty('instance-id', instanceId); | ||
|
Comment on lines
+27
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the difference between the Global and non-Global context property?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The difference is when they are executed, global sets the context pre-init and regular is called synchronously after init. This is really just a belt and suspenders incase we were setting the context async before the SDK was fully initialized |
||
| } | ||
|
|
||
| datadogLogs.createLogger(LOGGER_NAME); | ||
|
|
||
| const datadogLogger = datadogLogs.getLogger(LOGGER_NAME)!; | ||
| datadogLogger.setContextProperty('dd-client-token', CLIENT_TOKEN); | ||
| datadogLogger.setContextProperty('instance-id', instanceId); | ||
| datadogLogger.setContextProperty('frontend', 'bonk'); | ||
| datadogLogger.setContextProperty('frontend', FRONTEND); | ||
|
|
||
| /** | ||
| * TODO: make a logger wrapper that enables us also log to the console | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't you also need setup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the docs they say its optional and the setup that was there didnt do anything so i dont think we need it.
for reference see Amplitude browser sdk plugins and scroll down to the table in the Create a custom plugin section