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

[editor][client] Enable Telemetry based on User Config settings #899

Merged
merged 2 commits into from
Jan 14, 2024

Conversation

Ankush-lastmile
Copy link
Member

@Ankush-lastmile Ankush-lastmile commented Jan 11, 2024

[editor][client] Enable Telemetry based on User Config settings

This diff builds on top of @rholinshead's starting point for telemetry diff. Most of that looked good to me so I didn't touch it beside @rossdanlm 's .

Testplan:

  1. yarn build
  2. run in "prod" mode
  3. Edit AIconfig
  4. Hit Save button -> validate datadog log sent

repeat with aiconfig.rc set with false logging

Screenshot 2024-01-12 at 7 24 33 PM Screenshot 2024-01-12 at 7 23 51 PM

|
Screenshot 2024-01-12 at 7 26 35 PM | -> No logs |

I tried taking a video but datadog doesn't immediately update with logs which made the video too long to upload


Stack created with Sapling. Best reviewed with ReviewStack.

@rossdanlm
Copy link
Contributor

This diff builds on top of @rholinshead's starting point for telemetry diff.

Can you link diff?

Copy link
Contributor

@rossdanlm rossdanlm left a comment

Choose a reason for hiding this comment

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

Generally lgtm, just some comments and nits

Comment on lines +38 to +47
service: "aiconfig-editor",
site: "us5.datadoghq.com",
forwardErrorsToLogs: true,
sessionSampleRate: 100,
Copy link
Contributor

Choose a reason for hiding this comment

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

In diff summary, can you link to website for API docs so we can read more on what these mean?

Copy link
Member Author

@Ankush-lastmile Ankush-lastmile Jan 13, 2024

Choose a reason for hiding this comment

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

whoops forgot to link docs. Generally, datadog docs are easily googleable and easily navigate able. Can just google "datadog <search term>"

"datadog browser logging" -> https://docs.datadoghq.com/logs/log_collection/javascript/

python/src/aiconfig/editor/client/src/utils/logging.ts Outdated Show resolved Hide resolved
python/src/aiconfig/editor/client/src/utils/logging.ts Outdated Show resolved Hide resolved
python/src/aiconfig/editor/client/src/utils/logging.ts Outdated Show resolved Hide resolved
@Ankush-lastmile
Copy link
Member Author

Ankush-lastmile commented Jan 13, 2024

  • removed custom sessionID because @rholinshead pointed out that datadog already creates one by default.
  • only log in "prod" mode, as @rholinshead pointed out, in dev mode we would be spamming the logs when hot reloads occur
  • added in check for aiconfigrc
  • addressed some nits

@Ankush-lastmile Ankush-lastmile marked this pull request as ready for review January 13, 2024 00:34
@Ankush-lastmile
Copy link
Member Author

Can you link diff?

Its the diff below this one, sapling created a new pr

Copy link
Contributor

@rholinshead rholinshead left a comment

Choose a reason for hiding this comment

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

LGTM, but let's do the dev check & return before sending the request unnecessarily

python/src/aiconfig/editor/client/src/LocalEditor.tsx Outdated Show resolved Hide resolved
const res = await ufetch.get(ROUTE_TABLE.GET_AICONFIGRC, {}); // change this to the endpoint used to get the config

const enableTelemetry = res.allow_usage_data_sharing;
const isDev = (process.env.NODE_ENV ?? "development") === "development";
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's do the dev check at the top so we don't need to make a request unnecessarily

Copy link
Member Author

Choose a reason for hiding this comment

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

Checked for isDev before making the request, and if so return early.

Manually tested the flows and verified telemetry is only sent in prod and not dev

@@ -61,3 +61,6 @@ export function aiConfigToClientConfig(aiconfig: AIConfig): ClientAIConfig {
},
};
}

export type LogEvent = "ADD_PROMPT" | "SAVE_BUTTON_CLICKED";
export type LogEventData = JSONObject;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should, TODOs were mainly from when it was pre-release

@@ -14,6 +14,7 @@ export const ROUTE_TABLE = {
CANCEL: urlJoin(API_ENDPOINT, "/cancel"),
CLEAR_OUTPUTS: urlJoin(API_ENDPOINT, "/clear_outputs"),
DELETE_PROMPT: urlJoin(API_ENDPOINT, "/delete_prompt"),
GET_AICONFIGRC: urlJoin(API_ENDPOINT, "/get_aiconfigrc"),
Copy link
Contributor

Choose a reason for hiding this comment

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

What does rc mean?

Copy link
Member Author

Choose a reason for hiding this comment

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

fairly certain that rc stands for run commands. Most people will have multiple of these on their system already, you can see which rc files you have on your own computer by running this in terminal ls -a $HOME | grep rc.

To define if telemetry is to be disabled, user will need to define their own .aiconfigrc. Will need to add this to docs as well

Ryan Holinshead added 2 commits January 13, 2024 21:04
rebased version of #804 onto main
This diff builds on top of @rholinshead's starting point for telemetry diff. Most of that looked good to me so I didn't touch it beside @rossdanlm 's .


- Building off of #869, if `allow_usage_data_sharing` is set to True, initialize Datadog Browser logging with a session ID.
- Disabled telemetry in dev mode as per @rholinshead 's comment that the hot reload spams the logs with something like "datadog logging already initialized"
- Moved the initialization logic away from`index.tsx` into `editor.tsx` so that it can be configurable.


## Testplan:

1. yarn build
2. run in "prod" mode
3. Edit AIconfig
4. Hit Save button -> validate datadog log sent

repeat with aiconfig.rc set with false logging

|<img width="963" alt="Screenshot 2024-01-12 at 7 24 33 PM" src="https://github.com/lastmile-ai/aiconfig/assets/141073967/c2f979df-327e-40c4-9f06-034531437a65">  | <img width="1455" alt="Screenshot 2024-01-12 at 7 23 51 PM" src="https://github.com/lastmile-ai/aiconfig/assets/141073967/edb022b5-4abd-4ddc-b9bb-97713d32e5dc"> |
| ------------- | ------------- |
|
<img width="604" alt="Screenshot 2024-01-12 at 7 26 35 PM" src="https://github.com/lastmile-ai/aiconfig/assets/141073967/4a2e49a3-061e-404c-9681-13a15aca8e9c">  |  -> No logs |




I tried taking a video but datadog doesn't immediately update with logs which made the video too long to upload
@Ankush-lastmile
Copy link
Member Author

  • moved isDev check to occur before making the request to get the aiconfigrc data. This way the request is only made if needed
    • Manually tested the flows and verified telemetry is only sent in prod and not dev

@Ankush-lastmile Ankush-lastmile merged commit f110958 into main Jan 14, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants