Skip to content

Conversation

@snehith57624
Copy link
Contributor

@snehith57624 snehith57624 commented Feb 8, 2022

Description

Sending installation event and summary for EA mode also

Cause: For EA mode there is no inception which handles and pushes this events to PostHog server
CounterMeasure: We have added events which will be called on installation, periodically(for summary events)

Fixes # (issue) 1122

Type of change

  • [ Yes] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Test case A: Tested it by installing EA mode (Updated PostHog API key value to send events to mine) and have seen the events send to my PostHog server and also checked again re-running the pod which will not send the event as we store the value in config map and ignore if it is already sent

Test case B: Tested by sending Summary Events also, those events were also sent to the server

Checklist:

  • [yes ] The title of the PR states what changed and the related issues number (used for the release note).
  • [ no] Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have tested it for all user roles

EventMessage string `json:"eventMessage,omitempty"`
EventType TelemetryEventType `json:"eventType"`
Summary *SummaryDto `json:"summary,omitempty"`
Summary SummaryEA `json:"summary,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

use pointer

return nil, err
}

client, err := impl.K8sUtil.GetClientForInCluster()
Copy link
Contributor

Choose a reason for hiding this comment

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

fix it for local dev


if impl.PosthogClient.Client == nil {
impl.logger.Warn("no posthog client found, creating new")
client, err := impl.retryPosthogClient(PosthogApiKey, PosthogEndpoint)
Copy link
Contributor

Choose a reason for hiding this comment

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

add error handling

if err != nil {
impl.logger.Warnw("config map update failed for install event", "err", err)
}
if err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

use else

dashboard.DashboardWireSet,
client.HelmAppWireSet,
k8s.K8sApplicationWireSet,
//telemetry.NewTelemetryEventClientWireSet,
Copy link
Contributor

Choose a reason for hiding this comment

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

create wire set

if err != nil {
return nil
}
kubeconfig := flag.String("kubeconfig-authenticator-xyz", filepath.Join(usr.HomeDir, ".kube", "config"), "(optional) absolute path to the kubeconfig file")
Copy link
Contributor

Choose a reason for hiding this comment

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

create kubeconfig only when runTimeConfig is localDev


server *http.Server
server *http.Server
telemetry *telemetry.TelemetryEventClientImpl
Copy link
Contributor

Choose a reason for hiding this comment

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

use interface as dependency not the impl

_, err := app.telemetry.SendTelemtryInstallEventEA()

if err != nil {
app.Logger.Infow("telemetry installation success event failed", "err", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

log it as warn

type SummaryEA struct {
UserCount int `json:"userCount,omitempty"`
ClusterCount int `json:"clusterCount,omitempty"`
DevtronVersion string `json:"devtronVersion,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

DevtronVersion and DevtronMode are more suitable in outer object

@snehith57624 snehith57624 linked an issue Feb 16, 2022 that may be closed by this pull request
nishant-d
nishant-d previously approved these changes Feb 16, 2022
@nishant-d nishant-d merged commit f9af5a8 into main Feb 16, 2022
@nishant-d nishant-d deleted the issue_1122_fix branch February 16, 2022 11:40
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.

[Hyperion] Add Telemetry data

3 participants