-
Notifications
You must be signed in to change notification settings - Fork 581
feat: Posthog events #6618
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
Merged
Merged
feat: Posthog events #6618
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a26a28c
boiler plate
prkhrkat abd3b1c
app count
prkhrkat e791c53
app count
prkhrkat d389839
refact
prkhrkat 22ee1c9
fix
prkhrkat 2824505
fix
prkhrkat cd2741a
active users in last30
prkhrkat 062278e
gitops pipeline
prkhrkat 64ef5d0
helm pipeline
prkhrkat 0db6568
refact
prkhrkat c2831be
error handling
prkhrkat e55b783
review comment
prkhrkat 3051c3d
review comments
prkhrkat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package telemetry | ||
|
|
||
| // EA-mode compatible telemetry queries - no imports needed for current methods | ||
|
|
||
| func (impl *TelemetryEventClientImpl) getHelmAppCount() int { | ||
| if impl.installedAppReadService == nil { | ||
| impl.logger.Warnw("installedAppReadService not available for helm app count") | ||
| return -1 | ||
| } | ||
| count, err := impl.installedAppReadService.GetActiveInstalledAppCount() | ||
| if err != nil { | ||
| impl.logger.Errorw("error getting helm app count", "err", err) | ||
| return -1 | ||
| } | ||
| return count | ||
| } | ||
|
|
||
| // EA-mode compatible telemetry methods | ||
|
|
||
| func (impl *TelemetryEventClientImpl) getClusterCounts() (physicalCount int, isolatedCount int) { | ||
| clusters, err := impl.clusterService.FindAllActive() | ||
| if err != nil { | ||
| impl.logger.Errorw("error getting cluster counts", "err", err) | ||
| return -1, -1 | ||
| } | ||
|
|
||
| physicalCount = 0 | ||
| isolatedCount = 0 | ||
|
|
||
| for _, cluster := range clusters { | ||
| if cluster.IsVirtualCluster { | ||
| isolatedCount++ | ||
| } else { | ||
| physicalCount++ | ||
| } | ||
| } | ||
|
|
||
| return physicalCount, isolatedCount | ||
| } | ||
|
|
||
| // Note: FULL-mode specific methods like getDevtronAppCount, getJobCount, etc. | ||
| // are now implemented in TelemetryEventClientImplExtended in telemetryQueriesExtended.go | ||
|
|
||
| func (impl *TelemetryEventClientImpl) getActiveUsersLast30Days() int { | ||
| if impl.userAuditService == nil { | ||
| impl.logger.Warnw("userAuditService not available for active users count") | ||
| return -1 | ||
| } | ||
|
|
||
| count, err := impl.userAuditService.GetActiveUsersCountInLast30Days() | ||
| if err != nil { | ||
| impl.logger.Errorw("error getting active users count in last 30 days", "err", err) | ||
| return -1 | ||
| } | ||
|
|
||
| impl.logger.Debugw("counted active users in last 30 days", "count", count) | ||
| return count | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| package telemetry | ||
|
|
||
| import ( | ||
| "github.com/devtron-labs/devtron/pkg/build/pipeline/bean/common" | ||
| pluginRepository "github.com/devtron-labs/devtron/pkg/plugin/repository" | ||
| ) | ||
|
|
||
| // FULL-mode specific telemetry methods for TelemetryEventClientImplExtended | ||
|
|
||
| func (impl *TelemetryEventClientImplExtended) getDevtronAppCount() int { | ||
| devtronAppCount, err := impl.appRepository.FindDevtronAppCount() | ||
| if err != nil { | ||
| impl.logger.Errorw("error getting all apps for devtron app count", "err", err) | ||
| return -1 | ||
| } | ||
| return devtronAppCount | ||
| } | ||
|
|
||
| func (impl *TelemetryEventClientImplExtended) getJobCount() int { | ||
| jobCount, err := impl.appRepository.FindJobCount() | ||
| if err != nil { | ||
| impl.logger.Errorw("error getting all apps for job count", "err", err) | ||
| return -1 | ||
| } | ||
| return jobCount | ||
| } | ||
|
|
||
| func (impl *TelemetryEventClientImplExtended) getJobPipelineTriggeredLast24h() int { | ||
| // Get build type and status data for the last 24 hours | ||
| buildTypeStatusData, err := impl.ciWorkflowRepository.FindBuildTypeAndStatusDataOfLast1Day() | ||
| if err != nil { | ||
| impl.logger.Warnw("no build type status data available for last 24 hours") | ||
| return -1 | ||
| } | ||
|
|
||
| // Count job pipeline triggers | ||
| // Job pipelines have build type "CI_JOB" | ||
| jobTriggeredCount := 0 | ||
| for _, data := range buildTypeStatusData { | ||
| if data.Type == string(common.CI_JOB) { | ||
| jobTriggeredCount += data.Count | ||
| } | ||
| } | ||
|
|
||
| return jobTriggeredCount | ||
| } | ||
|
|
||
| func (impl *TelemetryEventClientImplExtended) getJobPipelineSucceededLast24h() int { | ||
| // Get build type and status data for the last 24 hours | ||
| buildTypeStatusData, err := impl.ciWorkflowRepository.FindBuildTypeAndStatusDataOfLast1Day() | ||
| if err != nil { | ||
| impl.logger.Warnw("no build type status data available for last 24 hours") | ||
| return -1 | ||
| } | ||
|
|
||
| // Count successful job pipeline runs | ||
| // Job pipelines have build type "CI_JOB" | ||
| successfulJobCount := 0 | ||
| for _, data := range buildTypeStatusData { | ||
| if data.Type == "CI_JOB" && data.Status == "Succeeded" { | ||
| successfulJobCount += data.Count | ||
| } | ||
| } | ||
|
|
||
| impl.logger.Debugw("counted successful job pipeline runs in last 24h", "count", successfulJobCount) | ||
| return successfulJobCount | ||
| } | ||
|
|
||
| func (impl *TelemetryEventClientImplExtended) getUserCreatedPluginCount() int { | ||
| // Get all user-created plugins (SHARED type) | ||
| plugins, err := impl.pluginRepository.GetAllPluginMinDataByType(string(pluginRepository.PLUGIN_TYPE_SHARED)) | ||
| if err != nil { | ||
| impl.logger.Errorw("error getting user created plugin count", "err", err) | ||
| return -1 | ||
| } | ||
|
|
||
| return len(plugins) | ||
| } | ||
|
|
||
| func (impl *TelemetryEventClientImplExtended) getPolicyCount() int { | ||
| // Get global policies | ||
| globalPolicies, err := impl.cvePolicyRepository.GetGlobalPolicies() | ||
| if err != nil { | ||
| impl.logger.Errorw("error getting global CVE policies", "err", err) | ||
| return -1 | ||
| } | ||
| return len(globalPolicies) | ||
| } | ||
|
|
||
| func (impl *TelemetryEventClientImplExtended) getGitOpsPipelineCount() int { | ||
| var count int | ||
| query := ` | ||
| SELECT COUNT(DISTINCT p.id) | ||
| FROM pipeline p | ||
| WHERE p.deleted = false AND p.deployment_app_type = 'argo_cd' | ||
| ` | ||
|
|
||
| dbConnection := impl.cdWorkflowRepository.GetConnection() | ||
| _, err := dbConnection.Query(&count, query) | ||
| if err != nil { | ||
| impl.logger.Errorw("error getting GitOps pipeline count", "err", err) | ||
| return -1 | ||
| } | ||
|
|
||
| impl.logger.Debugw("counted GitOps pipelines", "count", count) | ||
| return count | ||
| } | ||
|
|
||
| func (impl *TelemetryEventClientImplExtended) helmPipelineCount() int { | ||
| // Get the pipeline repository from cdWorkflowRepository connection | ||
| var count int | ||
| query := ` | ||
| SELECT COUNT(DISTINCT p.id) | ||
| FROM pipeline p | ||
| WHERE p.deleted = false AND p.deployment_app_type = 'helm' | ||
| ` | ||
|
|
||
| dbConnection := impl.cdWorkflowRepository.GetConnection() | ||
| _, err := dbConnection.Query(&count, query) | ||
| if err != nil { | ||
| impl.logger.Errorw("error getting No-GitOps pipeline count", "err", err) | ||
| return -1 | ||
| } | ||
|
|
||
| impl.logger.Debugw("counted No-GitOps pipelines", "count", count) | ||
| return count | ||
| } | ||
|
|
||
| // getJobPipelineCount returns 0 for now as implementation is not yet available | ||
| func (impl *TelemetryEventClientImplExtended) getJobPipelineCount() int { | ||
| return -1 | ||
| } | ||
|
|
||
| // getAppliedPolicyRowCount returns 0 for now as implementation is not yet available | ||
| func (impl *TelemetryEventClientImplExtended) getAppliedPolicyRowCount() int { | ||
| return -1 | ||
| } | ||
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.