fixes CNVS-39916
test plan:
* enable page views (repeat once each for db, cassandra, pv4)
* have a user associated with multiple root accounts
* as that user, browse around both accounts
* as a site admin, view the user; you should see all page views
* as an admin in only one of the accounts, you should see only
the page views from the same account
Change-Id: I79c5788c30ef87c7ff6a2ad31a909f9947e7b35c
Reviewed-on: https://gerrit.instructure.com/129850
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
refs CNVS-36051
we often want to cache an object built from the config we got, so
move that up so we don't keep repeating ourselves
Change-Id: I9c58993b6142cec41f4514dcb1a74dd5d5582234
Reviewed-on: https://gerrit.instructure.com/107166
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
refs #CNVS-32574
Change-Id: I3ba018a7110a7530c9af4a59c97422f626a749b6
Reviewed-on: https://gerrit.instructure.com/99260
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: James Williams <jamesw@instructure.com>
QA-Review: James Williams <jamesw@instructure.com>
refs #CNVS-32574
Change-Id: Ic3cd179a7cfb22e3b25a72500313f1baa8f96bb9
Reviewed-on: https://gerrit.instructure.com/94680
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
QA-Review: James Williams <jamesw@instructure.com>
Tested-by: Jenkins
Change-Id: If6f6aa70734be8e53d77044ce2f26d949fc825a1
Reviewed-on: https://gerrit.instructure.com/90330
Tested-by: Jenkins
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
QA-Review: James Williams <jamesw@instructure.com>
closes CNVS-28788
test plan:
* enable page views
* use an app (such as Canvas for iOS) to interact with your
Canvas, and record page view (particularly ones that count
as "participations")
* look at the page views for the user
* instead of listing a browser for the user agent, it should
list the name of the developer key for the app
Change-Id: Id07b293db333e44db7110fc2620409535927f915
Reviewed-on: https://gerrit.instructure.com/77409
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
test plan
- specs should pass
Change-Id: Ib3f102b53d947198625e3118820d22e77a005dd6
Reviewed-on: https://gerrit.instructure.com/77249
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
refs CNVS-27294
test plan:
* Setting.set('enable_page_views', 'pv4')
* navigate around canvas
* existing pageview instructure should continue to work, including
interaction seconds updates, and pv data in response headers
Change-Id: Ifa9dd60f244c3b2b3e4274da2301db5b736f03df
Reviewed-on: https://gerrit.instructure.com/73555
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Jenkins
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
refs #CNVS-26056
Change-Id: Ia94ee2fcfded1ec66cb77a19085b005c81304800
Reviewed-on: https://gerrit.instructure.com/70251
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: James Williams <jamesw@instructure.com>
QA-Review: James Williams <jamesw@instructure.com>
leftover from rails 3 transition
Change-Id: I085b9bb9cdeeac38d0f94690e514fba58322233c
Reviewed-on: https://gerrit.instructure.com/69425
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: James Williams <jamesw@instructure.com>
QA-Review: James Williams <jamesw@instructure.com>
Closes CNVS-23363
Closes CNVS-24692
Include interaction_seconds updates to previous requests in
request metadata.
Instead of passing around a page view id, we are now passing around the
URL used to update the current page view. This URL includes a page_view
token, which is a JWT including the page view id, user id, and page view
creation time.
Previously the DOM was used to store the page view id of the current
page and the update URL. The update URL now is sent via js_env. The
DOM node with the page_view_id is left in place in case any 3rd party
javascript is querying it (but nothing in Canvas should be).
This change also logs in metadata the page view creation time. This
is so we can correctly correlate the updated page view with the original
page view (using its id and creation time).
There is also a mechanism to send a new update URL in AJAX requests,
which is preserved with this change.
Some code to send the page view id with every ajaxJSON request was
removed, as it appears completely unused.
Also fixed a bug that was preventing the "store page view info
in cookie on pageunload so the next request can send the update"
code from working. When setting the cookie, it was not specifying
a Path, so the cookie only got set on the current path. Now it
will always be handled on the next request.
test plan:
* Open Network Inspector to see requests being made
* Open a page that constitutes a "page view" (like a course's
discussion page)
* Note the X-Request-Context-Id response header for the request you
just made. This is your current page view id.
* Move your mouse around a whole bunch on the page you're on. This
generates "interaction time".
* Eventually, you'll see a new request pop up to /page_views. Look
at the response headers for X-Canvas-Meta. It should have a field
r=<guid>|<timestamp>|<seconds>. The `guid` field should match the
page view id from the original page you loaded, and `seconds`
should be about how long you've been moving your mouse around.
Change-Id: I7c418c1c690e7c2384fbcae86f21f5081b834a7e
Reviewed-on: https://gerrit.instructure.com/63818
QA-Review: August Thornton <august@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
Product-Review: Zach Wily <zach@instructure.com>
fixes CNVS-24219, CNVS-24220, CNVS-24221
test plan:
* configure pv4.yml with a uri and an access_token
* Setting.set('read_from_pv4', 'true')
* load a users profile; you should see page views
with all fields and can scroll through them
Change-Id: If5dfcb1596eba8e9da6f46b6a19fbb88ba422f0e
Reviewed-on: https://gerrit.instructure.com/66545
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
refs #CNVS-21596
Change-Id: Iee7997b0f22c26b3393b08506b0b46ec4f0e8620
Reviewed-on: https://gerrit.instructure.com/58204
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
QA-Review: James Williams <jamesw@instructure.com>
especially when it's flat out wrong and causes it to not work
even when run in a sharded environment, it's run per-shard anyway
Change-Id: I6f568b44a6fe636468372e708cfcdcb329d4a733
Reviewed-on: https://gerrit.instructure.com/46744
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
test plan:
* enable page views in rails 3
* using the api, retrieve the page views for a user
* the 'controller' and 'action' fields should not be null
fixes #CNVS-13769
Change-Id: I19748f0f4bb455c8932283adf2a04b2f7d445554
Reviewed-on: https://gerrit.instructure.com/36886
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
QA-Review: James Williams <jamesw@instructure.com>
fixes CNVS-13451
test plan:
* enable page view storage in cassandra
* open Canvas
* click "Settings", in the top right
* verify that the page renders successfully
Change-Id: Ia4193f59e41f6993b61a05bbb853a8e601285d8f
Reviewed-on: https://gerrit.instructure.com/35950
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Anthus Williams <awilliams@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Braden Anderson <banderson@instructure.com>
fixes CNVS-13024
test plan:
* configure cassandra page views
* as a user from shard 1, visit a course on shard 2
* go to /users/self on shard 2, and watch the network requests for
page views. in the response, the context should be a local id, and
the user should be a global id
Change-Id: I6bbc54d9b055aff74b81441b2449c4548fd96816
Reviewed-on: https://gerrit.instructure.com/35056
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Nick Cloward <ncloward@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
fixes: CNVS-10477
Test Plan:
Make sure auditing still works.
Change-Id: I021c0772ad0cf337d452b55bf690d15ce1a61a09
Reviewed-on: https://gerrit.instructure.com/31494
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Nick Cloward <ncloward@instructure.com>
instead of passing an :exportable option to
ActiveRecord::Associations, simply define a constant
on the class containing exportable associations and
attributes. This is due to :exportable breaking
ActiveRecord, and we can't simply monkey-patch in
config/initializers because models are included in
migrations before the initializers are run
Change-Id: I11f1a6b4570c397d8e01010c517bc6efdac7afca
Reviewed-on: https://gerrit.instructure.com/33235
Reviewed-by: Braden Anderson <banderson@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Anthus Williams <awilliams@instructure.com>
QA-Review: Anthus Williams <awilliams@instructure.com>
An audit of the related code revealed that this column is unused
test plan: After running the drop migrations, ensure that page views are
still logged correctly and can be viewed via the UI/API/CSV
Change-Id: I9141661440513d0c21ec0fdb5f0bd80dbb7c1c55
Reviewed-on: https://gerrit.instructure.com/30743
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
We attempted to make this backwards compatible when removing the cache
queue support, but the old setting was "cache" not "queue"
Change-Id: I7f419365089a1d99dae5dec3e3f7cb18a92ae05f
Reviewed-on: https://gerrit.instructure.com/31030
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
QA-Review: Brian Palmer <brianp@instructure.com>
* small fix for creating - need to set created_at
* override finder methods more directly (in rails 3, they all go
through relation, which we can't override just for PageView)
Change-Id: I33476eaf67180a45c26b70110ca1f9801dff8f44
Change-Id: I783618bc5457ea53a9d59ab36d3ccf7b7fde7b2e
Reviewed-on: https://gerrit.instructure.com/29595
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
QA-Review: James Williams <jamesw@instructure.com>
Change-Id: If87f098435b873074295586a112734a7ce6087a1
Reviewed-on: https://gerrit.instructure.com/29038
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: James Williams <jamesw@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
in rails 3, request.method returns "POST" but in
rails 2, the result is "post".
Change-Id: Ia751b4db5f516bd3e62f15215d7918465fd7c418
Reviewed-on: https://gerrit.instructure.com/28543
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Anthus Williams <awilliams@instructure.com>
Product-Review: Anthus Williams <awilliams@instructure.com>
QA-Review: Anthus Williams <awilliams@instructure.com>
in order to avoid rails 3 deprecation warnings
Change-Id: If4c6ece9496e1161718770420384003de23f0421
Reviewed-on: https://gerrit.instructure.com/28206
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
QA-Review: James Williams <jamesw@instructure.com>
The idea was to have a generic solution so
if we add fields to be tracked and exported
or displayed to users, we don't forget to force
the encoding and thus end up with an obscure
bug we only see in production.
Fixes CNVS-9528
Test plan
- in production environment
- Go to a users account details page where they
have page views.
- Download the CSV file from the top right corner
of the page views listing.
- Open the CSV file and check the "Remote IP"
column to the far right.
Change-Id: I83250f218936c8af0b3a7ae2ff69e777034e731c
Reviewed-on: https://gerrit.instructure.com/26798
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Anthus Williams <awilliams@instructure.com>
fixes: CNVS-348
This adds grade change auditing functionality. It uses cassandra and is built
after the authenication auditing. A new API endpoint was created to query these
logs. Permissions for this is a domain account. The logs can be quiried by
assignment, course, student, and grader.
Refer to: https://gollum.instructure.com/grade-auditor-implementation
Test Case:
Setup:
- Create a course with a student and an assignment.
1. Grade an assignment for a student.
2. The auditor should create a record in cassandra.
3. Query the endpoint should return the audit event.
- Query by Assignment
- Query by Course
- Query by Student
- Query by Grader
4. Ensure permissions are valid by querying with a non root account admin.
5. Permissions should be changable by site_admin under account permissions.
Change-Id: I0a1cf867d5d1b5bfbdeacc7eac81747f8732025a
Reviewed-on: https://gerrit.instructure.com/25961
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Product-Review: Nick Cloward <ncloward@instructure.com>
This wasn't working because we weren't loading the existing page view
from cassandra, so the user_id nil check was failing.
Also add the Setting to this codepath in case we need to turn off page
view updates for performance reasons.
fixes CNVS-2129
test plan:
* visit a course interaction page such as viewing a discussion topic
* turn on your web inspector
* spend some time on the page, scrolling around, clicking, doing things
that register as activity
* eventually you'll see an ajax request to /page_views to update the
interaction_seconds timer. this can take more than 5 minutes though --
the faster way to trigger it is to "interact" with the page for at least
30 seconds, and then navigate to another canvas page. that'll trigger
the page view update ajax call when the next page loads.
* visit /users/self and look at your page view history, the page view
should have the updated interaction seconds value. same with the csv
download of page view history.
Change-Id: I35a67450c0f3360720ff0c18fe9730ead607d5e0
Reviewed-on: https://gerrit.instructure.com/25871
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
This has been phased out, so is just needless complexity.
refs CNVS-2129
test plan:
* page views should still be stored and queried via cassandra or postgres
Change-Id: I0e5580086c912396b7e4cdfb139eb3a1acc4f67c
Reviewed-on: https://gerrit.instructure.com/25859
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
now that we have SIGHUP, we were changing everything to it anyway,
so just let caching in-proc be the default
Change-Id: Id1b44722522ac9693b17695da7107c99a359d5ac
Reviewed-on: https://gerrit.instructure.com/25020
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
refs CNVS-8392
also update the page view API documentation
test plan:
* with this commit applied, page views will now log the remote
ip of requests, and return that ip in the api and csv downloads
* regenerate api docs with rake doc:api, and verify that the user
section now has expanded information on the api response
Change-Id: If463e211515881db6ce1f75c9bbca8c7fbcf7589
Reviewed-on: https://gerrit.instructure.com/24880
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
Sometimes these pieces of data coming from the request are marked as
binary (ascii-8bit) encoded, which causes the cassandra-cql gem to
hex-encode them before sending them to cassandra.
We never noticed before because the round-trip JSON encode/decode
through redis was forcing utf-8 encoding.
refs CNVS-7551
test-plan:
Without this commit, page views would show the user agent as unrecognzed
in the /users/X page views UI. However, depending on your test
environment this might not happen, it depends on the encoding of your
web/rack server. With this commit, it should be fixed regardless.
Change-Id: I85d6dc9eabe0052e9cc5e6b9e690b318d1a4d72b
Reviewed-on: https://gerrit.instructure.com/23381
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
QA-Review: Brian Palmer <brianp@instructure.com>
fixes CNVS-7551
unless specifically told otherwise, write cassandra page views straight
to cassandra without putting them through the redis queue first. can
still cause them to go through redis queue by setting
'page_view_cassandra_uses_redis' to 'true'.
test-plan:
- have cassandra page views enabled and set up
- turn off delayed jobs
- navigate to some pages
- generated page views still show up
- set 'page_view_cassandra_uses_redis' setting to 'true'
- navigate to some more pages
- generated page views don't show up (yet)
- restart delayed jobs
- generated page views show up
Change-Id: I66a2991d41e18e1440e5eb68db6aa3d217577f41
Reviewed-on: https://gerrit.instructure.com/23325
Reviewed-by: Brian Palmer <brianp@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Product-Review: Brian Palmer <brianp@instructure.com>
Tested-by: Brian Palmer <brianp@instructure.com>