Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

[POA-41] Update analytics functions to support amplitude functions #246

Merged
merged 6 commits into from
Dec 18, 2023

Conversation

mudit-postman
Copy link
Contributor

@mudit-postman mudit-postman commented Nov 15, 2023

  • Replace Segment related keys and mentioned with Amplitude Keys and configs
  • Updated few event names to make them consistent in Amplitude

@@ -114,7 +114,7 @@ func getDistinctID() string {
// Otherwise use the configured API Key.
// Failing that, try to use the user name and host name?

id := os.Getenv("AKITA_SEGMENT_DISTINCT_ID")
id := os.Getenv("POSTMAN_ANALYTICS_DISTINCT_ID")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we need to do any changes for this in documentations?
cc @mgritter @liujed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One place is in the integration test L7

Copy link
Contributor

Choose a reason for hiding this comment

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

No, this is not a documented feature. The ability to disable analytics is more important.

@mudit-postman mudit-postman marked this pull request as ready for review November 20, 2023 11:01
@@ -24,7 +24,7 @@ var (
analyticsEnabled bool

// Client key; set at link-time with -X flag
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs a corresponding change in superstar/cli-postman and superstar/cli-akita

Comment on lines -96 to -97
// IsMixpanelEnabled: false, -- irrelevant for us, leaving at default value
BatchSize: 1, // disable batching
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't recall precisely why I disabled batching, but I think it had to do with catching errors during command-line execution, or maybe other abnormal exits. I think that should still be part of our use of Amplitude, if batching can be disabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can disable batching we can use FlushQueueSize config for this.

@@ -114,7 +114,7 @@ func getDistinctID() string {
// Otherwise use the configured API Key.
// Failing that, try to use the user name and host name?

id := os.Getenv("AKITA_SEGMENT_DISTINCT_ID")
id := os.Getenv("POSTMAN_ANALYTICS_DISTINCT_ID")
Copy link
Contributor

Choose a reason for hiding this comment

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

No, this is not a documented feature. The ability to disable analytics is more important.

func Failure(message string) {
analyticsClient.Track(distinctID(),
message,
fmt.Sprintf("Unknown Error: %s", message),
Copy link
Contributor

Choose a reason for hiding this comment

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

I am unsure about the need to add the prefixes as you have done here. I don't think we really felt their absence using Mixpanel, and the "type" field could be used to filter. Is this an Amplitude or Postman best practice that we should understand?

We should not use "Unknown Error" here, though, because the failures can be known errors that simply don't come with a Go "error".

Copy link
Contributor Author

@mudit-postman mudit-postman Nov 21, 2023

Choose a reason for hiding this comment

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

I have just added these prefixes to follow a convention with the event names, also it can help us in the easier resolution of new events that might be added in the Amplitude.
Amplitude doesn't automatically start tracking a new event, we need to tell Amplitude to start tracking the event. Like in the attached image, events that are not being tracked are marked as Unexpected we need to add them to the list to make them live.
https://app.amplitude.com/data/postman/Postman/events/POA-41-migrate-to-amplitude/latest?view=All

PS: Events in image are before adding prefixes to event names

image

@@ -268,7 +268,7 @@ func Failure(message string) {
// Report success of an operation
func Success(message string) {
analyticsClient.Track(distinctID(),
message,
fmt.Sprintf("Success in %s", message),
Copy link
Contributor

Choose a reason for hiding this comment

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

For example, in this case we have only two instances:

"Success in rotate learn session"
"Success in Add to ECS"

which is inconsistent capitalization :) and I don't think the success adds much?

@mudit-postman
Copy link
Contributor Author

Fixed backend_collector_test.go test case.
We have updated the akita-libs version here which has changes related to obfuscation PR, due to which test case was failing

@mudit-postman mudit-postman merged commit 332ff31 into main Dec 18, 2023
1 check passed
@mudit-postman mudit-postman deleted the feature/POA-41 branch December 18, 2023 05:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants