Skip to content
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

feat: Client #5

Merged
merged 9 commits into from
Jul 18, 2022
Merged

feat: Client #5

merged 9 commits into from
Jul 18, 2022

Conversation

Mercy811
Copy link
Contributor

@Mercy811 Mercy811 commented Jul 14, 2022

Summary

  • Implemented Client component and related structs and methods
  • Added Amplitude interface and NewAmplitude as the init function for amplitude struct

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?:

Questions & Request for review

  1. Since APIs of Client are exposed to users, I use value receiver at the most of the time. But for Add, Remove, and Shutdown which updates plugins and changes the client instance itself, I use pointer receiver there. I am wondering if that is right.
  2. When initialize a new BaseEvent, linter says some fields are missing. As for Go standard, do I need to explicitly assign empty value to the fields of BaseEvent when I init it?

@Mercy811 Mercy811 requested a review from falconandy July 14, 2022 18:42
amplitude/client.go Outdated Show resolved Hide resolved
amplitude/client.go Outdated Show resolved Hide resolved
timeline Timeline
type Amplitude interface {
Track(event BaseEvent)
Identify(identifyObj Identify, eventOptions EventOptions, eventProperties map[string]interface{})
Copy link
Contributor

Choose a reason for hiding this comment

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

I saw in the version 1.18, we can use any to replace empty interface interface{}, see golang/go#49884.

1.18 is a major release in Q1 this year, are we considering upgrade to use it? I saw we are using 1.17: https://github.com/amplitude/Amplitude-Go/blob/main/go.mod#L3.

Copy link
Contributor

Choose a reason for hiding this comment

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

Bumping up a major version might become a blocker for some customers for adopting the SDK. I wonder if we can create an alias in the meantime to call interface{} as any

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Put this to slack discussion

amplitude/client.go Outdated Show resolved Hide resolved
amplitude/client.go Outdated Show resolved Hide resolved
amplitude/client.go Outdated Show resolved Hide resolved
amplitude/client.go Outdated Show resolved Hide resolved
amplitude/client.go Outdated Show resolved Hide resolved
amplitude/client.go Show resolved Hide resolved
},
}

identifyEvent.loadEventOptions(eventOptions)
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need a separate method for this of can we use pass it to BaseEvent{}?

Copy link
Contributor Author

@Mercy811 Mercy811 Jul 15, 2022

Choose a reason for hiding this comment

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

Since Go doesn't have init function for class, and child class can't inherit init function from parent class. If I use init function, I have to write three similar functions for GroupIdentifyEvent, IdentifyEvent, and RevenueEvent. But if I use loadEventOptions, I only need to write one.

Do you have any other idea to implement this without loadEventOptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed here, removed IdentifyEvent, GroupIdentifyEvent and RevenueEvent, and set specific event properties like eventType directly when creating them.

amplitude/client.go Outdated Show resolved Hide resolved
1. rename Amplitude to Client
2. remove Add() and Remove() return value
3. update to pointer receiver
amplitude/client.go Outdated Show resolved Hide resolved
amplitude/constants.go Outdated Show resolved Hide resolved
@Mercy811 Mercy811 requested a review from falconandy July 18, 2022 16:29
@Mercy811 Mercy811 merged commit 3253364 into main Jul 18, 2022
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.

None yet

5 participants