Skip to content

Commit

Permalink
New config hide_dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhamlett committed Jan 6, 2025
1 parent 02eefc9 commit f73a076
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 44 deletions.
64 changes: 33 additions & 31 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ api_url = https://api.wakatime.com/api/v1
hide_file_names = false
hide_project_names = false
hide_branch_names =
hide_dependencies =
hide_project_folder = false
exclude =
^COMMIT_EDITMSG$
Expand Down Expand Up @@ -85,34 +86,35 @@ some/submodule/name = new project name

### Settings Section

| option | description | type | default value |
| --- | --- | --- | --- |
| debug | Turns on debug messages in log file. | _bool_ | `false` |
| api_key | Your wakatime api key. | _string_ | |
| api_key_vault_cmd | A command to get your api key, perhaps from some sort of secure vault. Actually a space-separated list of an executable and its arguments. Executables in PATH can be referred to by their basenames. Shell syntax not supported. | _string_ | |
| api_url | The WakaTime API base url. | _string_ | <https://api.wakatime.com/api/v1> |
| heartbeat_rate_limit_seconds | Rate limit sending heartbeats to the API once per duration. Set to 0 to disable rate limiting. | _int_ | `120` |
| hide_file_names | Obfuscate filenames. Will not send file names to api. | _bool_;_list_ | `false` |
| hide_project_names | Obfuscate project names. When a project folder is detected instead of using the folder name as the project, a `.wakatime-project file` is created with a random project name. | _bool_;_list_ | `false` |
| hide_branch_names | Obfuscate branch names. Will not send revision control branch names to api. | _bool_;_list_ | `false` |
| hide_project_folder | When set, send the file's path relative to the project folder. For ex: `/User/me/projects/bar/src/file.ts` is sent as `src/file.ts` so the server never sees the full path. When the project folder cannot be detected, only the file name is sent. For ex: `file.ts`. | _bool_ | `false` |
| exclude | Filename patterns to exclude from logging. POSIX regex syntax. | _bool_;_list_ | |
| include | Filename patterns to log. When used in combination with `exclude`, files matching `include` will still be logged. POSIX regex syntax | _bool_;_list_ | |
| include_only_with_project_file | Disables tracking folders unless they contain a `.wakatime-project file`. | _bool_ | `false` |
| exclude_unknown_project | When set, any activity where the project cannot be detected will be ignored. | _bool_ | `false` |
| status_bar_enabled | Turns on wakatime status bar for certain editors. | _bool_ | `true` |
| status_bar_coding_activity | Enables displaying Today's code stats in the status bar of some editors. When false, only the WakaTime icon is displayed in the status bar. | _bool_ | `true` |
| status_bar_hide_categories | When `true`, --today only displays the total code stats, never displaying Categories in the output. | _bool_ | `false` |
| offline | Enables saving code stats locally to ~/.wakatime/offline_heartbeats.bdb when offline, and syncing to the dashboard later when back online. | _bool_ | `true` |
| proxy | Optional proxy configuration. Supports HTTPS, SOCKS and NTLM proxies. For ex: `https://user:pass@host:port`, `socks5://user:pass@host:port`, `domain\\user:pass` | _string_ | |
| no_ssl_verify | Disables SSL certificate verification for HTTPS requests. By default, SSL certificates are verified. | _bool_ | `false` |
| ssl_certs_file | Path to a CA certs file. By default, uses bundled Letsencrypt CA cert along with system ca certs. | _filepath_ | |
| timeout | Connection timeout in seconds when communicating with the api. | _int_ | `120` |
| hostname | Optional name of local machine. By default, auto-detects the local machine’s hostname. | _string_ | |
| log_file | Optional log file path. | _filepath_ | `~/.wakatime/wakatime.log` |
| import_cfg | Optional path to another wakatime.cfg file to import. If set it will overwrite values loaded from $WAKATIME_HOME/.wakatime.cfg file. | _filepath_ | |
| metrics | When set, collects metrics usage in `~/.wakatime/metrics` folder. For further reference visit <https://go.dev/blog/pprof>. | _bool_ | `false` |
| guess_language | When `true`, enables detecting programming language from file contents. | _bool_ | `false` |
| option | description | type | default value |
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | --------------------------------- |
| debug | Turns on debug messages in log file. | _bool_ | `false` |
| api_key | Your wakatime api key. | _string_ | |
| api_key_vault_cmd | A command to get your api key, perhaps from some sort of secure vault. Actually a space-separated list of an executable and its arguments. Executables in PATH can be referred to by their basenames. Shell syntax not supported. | _string_ | |
| api_url | The WakaTime API base url. | _string_ | <https://api.wakatime.com/api/v1> |
| heartbeat_rate_limit_seconds | Rate limit sending heartbeats to the API once per duration. Set to 0 to disable rate limiting. | _int_ | `120` |
| hide_file_names | Obfuscate filenames. Will not send file names to api. | _bool_;_list_ | `false` |
| hide_project_names | Obfuscate project names. When a project folder is detected instead of using the folder name as the project, a `.wakatime-project file` is created with a random project name. | _bool_;_list_ | `false` |
| hide_branch_names | Obfuscate branch names. Will not send revision control branch names to api. | _bool_;_list_ | `false` |
| hide_dependencies | Prevent sending imports/libraries/dependencies used in currently focused file to the api. | _bool_;_list_ | `false` |
| hide_project_folder | When set, send the file's path relative to the project folder. For ex: `/User/me/projects/bar/src/file.ts` is sent as `src/file.ts` so the server never sees the full path. When the project folder cannot be detected, only the file name is sent. For ex: `file.ts`. | _bool_ | `false` |
| exclude | Filename patterns to exclude from logging. POSIX regex syntax. | _bool_;_list_ | |
| include | Filename patterns to log. When used in combination with `exclude`, files matching `include` will still be logged. POSIX regex syntax | _bool_;_list_ | |
| include_only_with_project_file | Disables tracking folders unless they contain a `.wakatime-project file`. | _bool_ | `false` |
| exclude_unknown_project | When set, any activity where the project cannot be detected will be ignored. | _bool_ | `false` |
| status_bar_enabled | Turns on wakatime status bar for certain editors. | _bool_ | `true` |
| status_bar_coding_activity | Enables displaying Today's code stats in the status bar of some editors. When false, only the WakaTime icon is displayed in the status bar. | _bool_ | `true` |
| status_bar_hide_categories | When `true`, --today only displays the total code stats, never displaying Categories in the output. | _bool_ | `false` |
| offline | Enables saving code stats locally to ~/.wakatime/offline_heartbeats.bdb when offline, and syncing to the dashboard later when back online. | _bool_ | `true` |
| proxy | Optional proxy configuration. Supports HTTPS, SOCKS and NTLM proxies. For ex: `https://user:pass@host:port`, `socks5://user:pass@host:port`, `domain\\user:pass` | _string_ | |
| no_ssl_verify | Disables SSL certificate verification for HTTPS requests. By default, SSL certificates are verified. | _bool_ | `false` |
| ssl_certs_file | Path to a CA certs file. By default, uses bundled Letsencrypt CA cert along with system ca certs. | _filepath_ | |
| timeout | Connection timeout in seconds when communicating with the api. | _int_ | `120` |
| hostname | Optional name of local machine. By default, auto-detects the local machine’s hostname. | _string_ | |
| log_file | Optional log file path. | _filepath_ | `~/.wakatime/wakatime.log` |
| import_cfg | Optional path to another wakatime.cfg file to import. If set it will overwrite values loaded from $WAKATIME_HOME/.wakatime.cfg file. | _filepath_ | |
| metrics | When set, collects metrics usage in `~/.wakatime/metrics` folder. For further reference visit <https://go.dev/blog/pprof>. | _bool_ | `false` |
| guess_language | When `true`, enables detecting programming language from file contents. | _bool_ | `false` |

### Project Map Section

Expand Down Expand Up @@ -142,9 +144,9 @@ However, if an api key exists in your `~/.wakatime.cfg` file then it takes prece

### Git Section

| option | description | type | default value |
| --- | --- | --- | --- |
| submodules_disabled | It will be matched against the submodule path and if matching, will skip it. | _bool_;_list_ | false |
| option | description | type | default value |
| ------------------- | ---------------------------------------------------------------------------- | ------------- | ------------- |
| submodules_disabled | It will be matched against the submodule path and if matching, will skip it. | _bool_;_list_ | false |

### Git Submodule Project Map Section

Expand Down
9 changes: 5 additions & 4 deletions cmd/fileexperts/fileexperts.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,11 @@ func initHandleOptions(params paramscmd.Params) []heartbeat.HandleOption {
ExcludeUnknownProject: params.Heartbeat.Filter.ExcludeUnknownProject,
}),
heartbeat.WithSanitization(heartbeat.SanitizeConfig{
BranchPatterns: params.Heartbeat.Sanitize.HideBranchNames,
FilePatterns: params.Heartbeat.Sanitize.HideFileNames,
HideProjectFolder: params.Heartbeat.Sanitize.HideProjectFolder,
ProjectPatterns: params.Heartbeat.Sanitize.HideProjectNames,
BranchPatterns: params.Heartbeat.Sanitize.HideBranchNames,
DependencyPatterns: params.Heartbeat.Sanitize.HideDependencies,

Check failure on line 135 in cmd/fileexperts/fileexperts.go

View workflow job for this annotation

GitHub Actions / Unit Tests

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig

Check failure on line 135 in cmd/fileexperts/fileexperts.go

View workflow job for this annotation

GitHub Actions / Unit Tests

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig

Check failure on line 135 in cmd/fileexperts/fileexperts.go

View workflow job for this annotation

GitHub Actions / Integration Tests

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig

Check failure on line 135 in cmd/fileexperts/fileexperts.go

View workflow job for this annotation

GitHub Actions / Integration Tests macOS

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig

Check failure on line 135 in cmd/fileexperts/fileexperts.go

View workflow job for this annotation

GitHub Actions / Integration Tests Windows

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig

Check failure on line 135 in cmd/fileexperts/fileexperts.go

View workflow job for this annotation

GitHub Actions / Unit Tests macOS

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig

Check failure on line 135 in cmd/fileexperts/fileexperts.go

View workflow job for this annotation

GitHub Actions / Unit Tests macOS

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig

Check failure on line 135 in cmd/fileexperts/fileexperts.go

View workflow job for this annotation

GitHub Actions / Unit Tests Windows

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig

Check failure on line 135 in cmd/fileexperts/fileexperts.go

View workflow job for this annotation

GitHub Actions / Unit Tests Windows

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig
FilePatterns: params.Heartbeat.Sanitize.HideFileNames,
HideProjectFolder: params.Heartbeat.Sanitize.HideProjectFolder,
ProjectPatterns: params.Heartbeat.Sanitize.HideProjectNames,
}),
fileexperts.WithValidation(),
filter.WithLengthValidator(),
Expand Down
9 changes: 5 additions & 4 deletions cmd/heartbeat/heartbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,11 @@ func initHandleOptions(params paramscmd.Params) []heartbeat.HandleOption {
ExcludeUnknownProject: params.Heartbeat.Filter.ExcludeUnknownProject,
}),
heartbeat.WithSanitization(heartbeat.SanitizeConfig{
BranchPatterns: params.Heartbeat.Sanitize.HideBranchNames,
FilePatterns: params.Heartbeat.Sanitize.HideFileNames,
HideProjectFolder: params.Heartbeat.Sanitize.HideProjectFolder,
ProjectPatterns: params.Heartbeat.Sanitize.HideProjectNames,
BranchPatterns: params.Heartbeat.Sanitize.HideBranchNames,
DependencyPatterns: params.Heartbeat.Sanitize.HideDependencies,
FilePatterns: params.Heartbeat.Sanitize.HideFileNames,
HideProjectFolder: params.Heartbeat.Sanitize.HideProjectFolder,
ProjectPatterns: params.Heartbeat.Sanitize.HideProjectNames,
}),
remote.WithCleanup(),
filter.WithLengthValidator(),
Expand Down
9 changes: 5 additions & 4 deletions cmd/offline/offline.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,11 @@ func initHandleOptions(params paramscmd.Params) []heartbeat.HandleOption {
ExcludeUnknownProject: params.Heartbeat.Filter.ExcludeUnknownProject,
}),
heartbeat.WithSanitization(heartbeat.SanitizeConfig{
BranchPatterns: params.Heartbeat.Sanitize.HideBranchNames,
FilePatterns: params.Heartbeat.Sanitize.HideFileNames,
HideProjectFolder: params.Heartbeat.Sanitize.HideProjectFolder,
ProjectPatterns: params.Heartbeat.Sanitize.HideProjectNames,
BranchPatterns: params.Heartbeat.Sanitize.HideBranchNames,
DependencyPatterns: params.Heartbeat.Sanitize.HideDependencies,

Check failure on line 170 in cmd/offline/offline.go

View workflow job for this annotation

GitHub Actions / Unit Tests

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig

Check failure on line 170 in cmd/offline/offline.go

View workflow job for this annotation

GitHub Actions / Unit Tests

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig

Check failure on line 170 in cmd/offline/offline.go

View workflow job for this annotation

GitHub Actions / Unit Tests

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig

Check failure on line 170 in cmd/offline/offline.go

View workflow job for this annotation

GitHub Actions / Integration Tests

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig

Check failure on line 170 in cmd/offline/offline.go

View workflow job for this annotation

GitHub Actions / Integration Tests macOS

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig

Check failure on line 170 in cmd/offline/offline.go

View workflow job for this annotation

GitHub Actions / Integration Tests Windows

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig

Check failure on line 170 in cmd/offline/offline.go

View workflow job for this annotation

GitHub Actions / Unit Tests macOS

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig

Check failure on line 170 in cmd/offline/offline.go

View workflow job for this annotation

GitHub Actions / Unit Tests macOS

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig

Check failure on line 170 in cmd/offline/offline.go

View workflow job for this annotation

GitHub Actions / Unit Tests macOS

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig

Check failure on line 170 in cmd/offline/offline.go

View workflow job for this annotation

GitHub Actions / Unit Tests Windows

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig

Check failure on line 170 in cmd/offline/offline.go

View workflow job for this annotation

GitHub Actions / Unit Tests Windows

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig

Check failure on line 170 in cmd/offline/offline.go

View workflow job for this annotation

GitHub Actions / Unit Tests Windows

unknown field DependencyPatterns in struct literal of type heartbeat.SanitizeConfig
FilePatterns: params.Heartbeat.Sanitize.HideFileNames,
HideProjectFolder: params.Heartbeat.Sanitize.HideProjectFolder,
ProjectPatterns: params.Heartbeat.Sanitize.HideProjectNames,
}),
remote.WithCleanup(),
filter.WithLengthValidator(),
Expand Down
20 changes: 19 additions & 1 deletion cmd/params/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ type (
// SanitizeParams params for heartbeat sanitization.
SanitizeParams struct {
HideBranchNames []regex.Regex
HideDependencies []regex.Regex
HideFileNames []regex.Regex
HideProjectFolder bool
HideProjectNames []regex.Regex
Expand Down Expand Up @@ -555,6 +556,21 @@ func loadSanitizeParams(ctx context.Context, v *viper.Viper) (SanitizeParams, er
)
}

hideDependenciesStr := vipertools.FirstNonEmptyString(
v,
"hide-dependencies",
"settings.hide_dependencies",
)

hideDependenciesPatterns, err := parseBoolOrRegexList(ctx, hideDependenciesStr)
if err != nil {
return SanitizeParams{}, fmt.Errorf(
"failed to parse regex hide dependencies param %q: %s",
hideDependenciesStr,
err,
)
}

// hide project names
hideProjectNamesStr := vipertools.FirstNonEmptyString(
v,
Expand Down Expand Up @@ -595,6 +611,7 @@ func loadSanitizeParams(ctx context.Context, v *viper.Viper) (SanitizeParams, er

return SanitizeParams{
HideBranchNames: hideBranchNamesPatterns,
HideDependencies: hideDependenciesPatterns,
HideFileNames: hideFileNamesPatterns,
HideProjectFolder: vipertools.FirstNonEmptyBool(v, "hide-project-folder", "settings.hide_project_folder"),
HideProjectNames: hideProjectNamesPatterns,
Expand Down Expand Up @@ -1146,11 +1163,12 @@ func (p ProjectParams) String() string {
func (p SanitizeParams) String() string {
return fmt.Sprintf(
"hide branch names: '%s', hide project folder: %t, hide file names: '%s',"+
" hide project names: '%s', project path override: '%s'",
" hide project names: '%s', hide dependencies: '%s', project path override: '%s'",
p.HideBranchNames,
p.HideProjectFolder,
p.HideFileNames,
p.HideProjectNames,
p.HideDependencies,
p.ProjectPathOverride,
)
}
Expand Down
Loading

0 comments on commit f73a076

Please sign in to comment.