Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@redhat-developer/vscode-redhat-telemetry",
"version": "0.10.1",
"version": "0.10.2",
"description": "Provides Telemetry APIs for Red Hat applications",
"main": "lib/index.js",
"types": "lib",
Expand Down
3 changes: 2 additions & 1 deletion src/common/utils/telemetryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

// Regex patterns for path sanitization
const NODE_MODULES_REGEX = /[\\\/]?(node_modules|node_modules\.asar)[\\\/]/;
const FILE_REGEX_PATTERN = /(file:\/\/)?([a-zA-Z]:(\\\\|\\|\/)|(\\\\|\\|\/))?([\w-\._]+(\\\\|\\|\/))+[\w-\._]+/g;
const FILE_REGEX_PATTERN = /(file:\/\/?)?([a-zA-Z]:(\\\\|\\|\/)|(\\\\|\\|\/))?([\w-\._%]+(\\\\|\\|\/))+[\w-\._%]+/g;

// Default cleanup patterns to preserve common system/library paths
const DEFAULT_CLEANUP_PATTERNS: RegExp[] = [
/java\.\S*/, // Java standard library and related packages (any non-whitespace chars)
/\/jdt\.ls-java-project\S*/, // Eclipse JDT Language Server Java project paths
];

/**
Expand Down
12 changes: 12 additions & 0 deletions src/tests/utils/telemetryUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,18 @@ suite('Test anonymizeFilePaths', () => {
assert.strictEqual(result, input);
});

test('should preserve JDT Language Server Java project paths with default patterns', () => {
const input = 'Error at /jdt.ls-java-project/src/main/java/com/example/MyClass.java:45';
const result = anonymizeFilePaths(input);
assert.strictEqual(result, input);
});

test('should anonymize file:/ URLs even with JDT workspace paths', () => {
const input = 'Failed to read package name from file:/Users/someguy/Library/Application%20Support/Code/User/workspaceStorage/4f4553a7f3f79b5e8qa7c889b39fe96b/redhat.java/jdt_ws/Hello.java/';
const result = anonymizeFilePaths(input);
assert.strictEqual(result, 'Failed to read package name from <REDACTED: user-file-path>/');
});

test('should anonymize user paths but preserve Java paths with default patterns', () => {
const input = 'Error at /Users/john/project/src/main.ts:45 and java.base/java.lang.String.<init>(String.java:123)';
const result = anonymizeFilePaths(input);
Expand Down