Skip to content

feat: add instrument package for Segment #226

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 8 commits into from
Mar 26, 2021
Merged

feat: add instrument package for Segment #226

merged 8 commits into from
Mar 26, 2021

Conversation

keiko713
Copy link
Contributor

@keiko713 keiko713 commented Mar 25, 2021

This PR adds the instrument package for Segment. You can enable this by having the following in the config file:

INSTRUMENT_ENABLED=true
INSTRUMENT_KEY=segment_api_key

Then, you can use this like the following:

instrument.Track("user_id", "my-event", properties)

If enabled is false (default false), you can still use this, but instead of the events sent out to Segment, it'll be logged to the logger.

@keiko713 keiko713 added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Mar 25, 2021
@keiko713 keiko713 requested a review from a team as a code owner March 25, 2021 19:36
@pandemicsyn
Copy link

I think it might be worth including some docs pointing netlify folks to https://github.com/netlify/segment-events to make sure internal users follow the processes and conventions mentioned there?

I like the visibility of having this package in netlify-commons, because this is probably the first place folks would look for it, but I wonder if this shouldn't be a package in the internal segment events repo?

@keiko713
Copy link
Contributor Author

I think it might be worth including some docs pointing netlify folks to https://github.com/netlify/segment-events to make sure internal users follow the processes and conventions mentioned there?

In general, I like the idea of pointing to the doc. I think we can also improve our README to explain how to use each package too, and pointing to that repo is something we can do in there. How does that sound? I'm honestly little hesitate to add it to the codebase as a comment, so feels better if it was in README.

I like the visibility of having this package in netlify-commons, because this is probably the first place folks would look for it, but I wonder if this shouldn't be a package in the internal segment events repo?

Sooooo I'd disagree with having this package in segment-events repo. netlify-commons repo is providing the basic common features of our services and the instrumentation can be count as a basic feature, was my reasoning having this here. For example, we could implements more instrumentation client potentially in the future and swap out as the project needs.
The netlify/segment-events is also not really fitting to have the code/library in it, I feel like. It is really more of the documentation.
I see this instrument package a very similar to the featureflag package. We are providing the basic feature in the netlify-commons library, then we have documented our own rule for how to use it elsewhere.

@keiko713
Copy link
Contributor Author

uhmm re: doc, actually maybe I should be adding more in the README but more in the code (as you can see it in https://pkg.go.dev/github.com/netlify/netlify-commons@v0.51.2/metriks).
I'll actually add more doc in the code and I'll see how it turns out

@keiko713
Copy link
Contributor Author

doc output:
image

Comment on lines 10 to 16
type Client interface {
identify(userID string, traits analytics.Traits) error
track(userID string, event string, properties analytics.Properties) error
page(userID string, name string, properties analytics.Properties) error
group(userID string, groupID string, traits analytics.Traits) error
alias(previousID string, userID string) error
}
Copy link
Member

Choose a reason for hiding this comment

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

if you don't export these methods then you effectively have an interface you can't implement in a different client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤦 yes

@keiko713 keiko713 merged commit 9ae9a6d into master Mar 26, 2021
@keiko713 keiko713 deleted the instrumentation branch March 26, 2021 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants