Skip to content

Add username to splunk event information#2337

Closed
dividedmind wants to merge 2 commits into
mainfrom
feat/splunk-user-name
Closed

Add username to splunk event information#2337
dividedmind wants to merge 2 commits into
mainfrom
feat/splunk-user-name

Conversation

@dividedmind

Copy link
Copy Markdown
Collaborator

Splunk telemetry is typically used in corporate environments where username is useful for tracking usage.

@dividedmind dividedmind self-assigned this Oct 21, 2025
@dividedmind dividedmind added the build native Build and save native packages in the GitHub workflow label Oct 21, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds username tracking to Splunk telemetry events for better usage monitoring in corporate environments. The username is captured from the system's user information and automatically included in all telemetry events sent to Splunk.

Key changes:

  • Username is now captured and added to every Splunk event payload
  • Removed automatic flush after each event send operation
  • Updated tests to verify username inclusion in event data

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/telemetry/src/backends/splunk.ts Adds username capture via os.userInfo() and includes it in event payloads
packages/telemetry/src/client.ts Removes automatic flush call after sending events
packages/telemetry/tests/backends/splunk.spec.ts Adds os module mocking and updates test assertions to verify username in events

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +21 to 22
private username = os.userInfo().username;

Copilot AI Oct 21, 2025

Copy link

Choose a reason for hiding this comment

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

The username is captured once during class initialization. If the process runs under different user contexts or if os.userInfo() throws an exception (e.g., in certain containerized environments), this could cause runtime errors or capture incorrect data. Consider wrapping this in a try-catch block or making it a method that can handle errors gracefully.

Suggested change
private username = os.userInfo().username;
/**
* Safely retrieves the current username.
* Returns 'unknown' if os.userInfo() throws or username is unavailable.
*/
private getUsername(): string {
try {
return os.userInfo().username || 'unknown';
} catch (e) {
return 'unknown';
}
}

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@dividedmind I think suggestion is minor but worthful change, just in case. At least unless use cases totally rule it out (but I'd still add failsafe variant anyway)

Comment thread packages/telemetry/src/client.ts
@dividedmind

Copy link
Copy Markdown
Collaborator Author

Deprecated by #2339

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build native Build and save native packages in the GitHub workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants