Skip to content

Allow anonymous_id in alias and group#188

Merged
rohitpaulk merged 11 commits into
masterfrom
rohitpaulk/allow-anonymous-id-in-alias
Apr 15, 2019
Merged

Allow anonymous_id in alias and group#188
rohitpaulk merged 11 commits into
masterfrom
rohitpaulk/allow-anonymous-id-in-alias

Conversation

@rohitpaulk

@rohitpaulk rohitpaulk commented Mar 30, 2019

Copy link
Copy Markdown
Collaborator

Fixes #181.

This PR refactors the handling of common fields, extracts a FieldParser that adheres to the Segment spec.

This will result in the following behaviour changes:

  • alias will now accept anonymous_id
  • group will now accept anonymous_id
  • page will now validate that name is non-empty

As I refactored this to adhere to the Segment spec, I found a couple of deviations from the spec:

  • options is accepted in every call, but not mentioned in the spec
  • screen takes a category parameter, which is not mentioned in the spec

I've retained these for backwards compatibility.

@rohitpaulk rohitpaulk force-pushed the rohitpaulk/allow-anonymous-id-in-alias branch 3 times, most recently from fdb7569 to 7cf11d0 Compare March 30, 2019 11:34
@f2prateek

Copy link
Copy Markdown
Contributor

options is mostly a convenience for the library to accept common fields (so that each declaration doesn't have to have a massive list for integrations, context, timestamp, etc.)

@rohitpaulk rohitpaulk force-pushed the rohitpaulk/allow-anonymous-id-in-alias branch 2 times, most recently from 131e281 to 3a1a89e Compare April 6, 2019 08:08
@rohitpaulk rohitpaulk force-pushed the rohitpaulk/allow-anonymous-id-in-alias branch from 3a1a89e to 5f78817 Compare April 6, 2019 08:31
@codecov-io

This comment has been minimized.

@codecov-io

codecov-io commented Apr 6, 2019

Copy link
Copy Markdown

Codecov Report

Merging #188 into master will increase coverage by 0.67%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #188      +/-   ##
==========================================
+ Coverage   98.37%   99.04%   +0.67%     
==========================================
  Files          10       11       +1     
  Lines         430      419      -11     
==========================================
- Hits          423      415       -8     
+ Misses          7        4       -3
Impacted Files Coverage Δ
lib/segment/analytics.rb 95.23% <100%> (+0.23%) ⬆️
lib/segment/analytics/client.rb 100% <100%> (+2.05%) ⬆️
lib/segment/analytics/field_parser.rb 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cfc197d...e2336c2. Read the comment docs.

@rohitpaulk rohitpaulk force-pushed the rohitpaulk/allow-anonymous-id-in-alias branch from 5f78817 to 153bc46 Compare April 6, 2019 08:46
@rohitpaulk rohitpaulk marked this pull request as ready for review April 6, 2019 08:50
@rohitpaulk rohitpaulk requested a review from f2prateek April 6, 2019 08:50
@rohitpaulk

Copy link
Copy Markdown
Collaborator Author

options is mostly a convenience for the library to accept common fields (so that each declaration doesn't have to have a massive list for integrations, context, timestamp, etc.)

Ah, okay. What is the intended usage here?

Is this:

client.track(event: "something", context: { a: "b" })

the same as this?

client.track(event: "something", options: { context: { a: "b" } })

@rohitpaulk rohitpaulk force-pushed the rohitpaulk/allow-anonymous-id-in-alias branch from 8294fa9 to e2336c2 Compare April 6, 2019 09:08
@rohitpaulk

Copy link
Copy Markdown
Collaborator Author

#188 (comment)

@f2prateek reminder, there's an open question here 🙂

@f2prateek

Copy link
Copy Markdown
Contributor

@rohitpaulk ah missed this. correct, they should be considered similar. I would prefer if the library provided only one way for this though (rather than offering both)!

What's more natural for Ruby developers to use?

@rohitpaulk

Copy link
Copy Markdown
Collaborator Author

What's more natural for Ruby developers to use?

The natural way is to have different top-level keys for each parameter. i.e.

client.track(event: "something", context: { a: "b" })

rather than:

client.track(event: "something", options: { context: { a: "b" } })

I'm going to merge this PR as it retains backward compatibility. If we agree that options should be removed, I'll work on a deprecation notice that we can then remove in a minor release.

@rohitpaulk rohitpaulk merged commit f6a70b9 into master Apr 15, 2019
rohitpaulk added a commit that referenced this pull request Apr 19, 2019
This was a bug, introduced in #188
rohitpaulk added a commit that referenced this pull request Apr 19, 2019
This was a bug, introduced in #188
@rohitpaulk rohitpaulk deleted the rohitpaulk/allow-anonymous-id-in-alias branch April 19, 2019 07:43
@rohitpaulk rohitpaulk changed the title Allow anonymous_id in alias Allow anonymous_id in alias and group May 9, 2019
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.

Alias anonymous_id?

3 participants