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

WOC: Implement utm* params of a login UserAction stored in the DB feature #2212 #2359 #2378

Merged
merged 2 commits into from
Nov 8, 2018

Conversation

unclebean
Copy link
Contributor

Description

The 3rd times create same pull request...

This PR is for saving utm* params to DB for data analysis, relevant story is 2212.
Whenever user access gitcoin with "utm_medum, utm_source, utm_campaign" will store them in cookie, after user login or user logout will store to dashboard_useraction table.

Checklist
  • linter status: 100% pass
  • changes don't break existing behavior
  • commit message follows commit guidelines
Affected core subsystem(s)

UserAction data model.

Testing

Test with below 3 scenarios.

Scenario: Record utm* in Cookie
Give: utm_medum, utm_source, utm_campaign in URL
When: User open gitcoin
Then: Should record utm* in Cookie

Scenario: Record utm* in DB
Give: utm* in Cookie
When: User click "LOG IN" button
Then: Should record utm* in DB

Scenario: Record utm* in DB
Give: utm* in Cookie
When: User click "Log Out" button
Then: Should record utm* in DB

Refers/Fixes

@codecov
Copy link

codecov bot commented Oct 8, 2018

Codecov Report

Merging #2378 into master will decrease coverage by 0.19%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #2378     +/-   ##
=========================================
- Coverage   29.47%   29.27%   -0.2%     
=========================================
  Files         146      148      +2     
  Lines       11777    11946    +169     
  Branches     1599     1621     +22     
=========================================
+ Hits         3471     3497     +26     
- Misses       8188     8324    +136     
- Partials      118      125      +7
Impacted Files Coverage Δ
app/dashboard/models.py 52.82% <ø> (+0.03%) ⬆️
app/dashboard/utils.py 41.6% <100%> (+6.58%) ⬆️
app/bounty_requests/views.py 33.33% <0%> (-5.38%) ⬇️
app/dashboard/embed.py 28.16% <0%> (-3.45%) ⬇️
app/retail/utils.py 11.37% <0%> (-0.81%) ⬇️
app/avatar/models.py 26.31% <0%> (-0.47%) ⬇️
app/retail/emails.py 19.76% <0%> (-0.36%) ⬇️
app/marketing/utils.py 31.2% <0%> (-0.26%) ⬇️
app/retail/views.py 29.88% <0%> (-0.12%) ⬇️
...keting/management/commands/send_quarterly_stats.py 0% <0%> (ø) ⬆️
... and 7 more

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 fe4693e...74237b5. Read the comment docs.

@frankchen07
Copy link
Contributor

@owocki I believe this is ready for a reviewer.

owocki
owocki previously approved these changes Oct 10, 2018
Copy link
Contributor

@owocki owocki left a comment

Choose a reason for hiding this comment

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

code LGTM.. didnt test tho..

cc @mbeacom

@unclebean
Copy link
Contributor Author

hi @mbeacom
May I know the status of merging this PR? I want to pick another task once this one is done.

Copy link
Contributor

@timborden timborden left a comment

Choose a reason for hiding this comment

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

Looks good! ...nice work. Couple comments/questions.


return {key, value};
})
.filter((param) => [ 'utm_medium', 'utm_source', 'utm_campaign' ].indexOf(param.key) !== -1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit - can we use includes here?

Suggested change
.filter((param) => [ 'utm_medium', 'utm_source', 'utm_campaign' ].indexOf(param.key) !== -1)
.filter((param) => [ 'utm_medium', 'utm_source', 'utm_campaign' ].includes(param.key))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you no need to support IE?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm....I can see babel in the devDependencies...and it looks like it's used in the Webpack config (but I'm not a Webpack expert, TBH) so I think IE should be supported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahhh....fair enough. Suppose babel config could be updated...but likely out of scope for this PR.

@staticmethod
@patch('dashboard.utils.UserAction.objects')
def test_create_user_action_without_cookie(mockUserAction):
"""Test the giving utm* in cookie should store in DB."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit - comment needs updating

@staticmethod
@patch('dashboard.utils.UserAction.objects')
def test_create_user_action_campaign_not_json(mockUserAction):
"""Test the giving utm* in cookie should store in DB."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit - comment needs updating


@staticmethod
@patch('dashboard.utils.UserAction.objects')
def test_create_user_action_campaign_not_json(mockUserAction):
Copy link
Contributor

Choose a reason for hiding this comment

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

How is this test different then test_create_user_action_with_cookie?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I want to test partial value in cookie scenario...

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha.

Does it make sense to rename the test method to something like test_create_user_action_with_partial_cookie?

@owocki owocki merged commit 04146d2 into gitcoinco:master Nov 8, 2018
@unclebean unclebean deleted the utm-branch branch November 9, 2018 13:38
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.

6 participants