Commit Graph

9 Commits

Author SHA1 Message Date
Zach Wily 5955051e5f send interaction_seconds updates in response headers
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>
2015-11-18 03:20:51 +00:00
Cody Cutrer 4b9d76bb92 improve handling of logout issues
refs CNVS-14595

quit pinging the server with requests that will fail after you've
been logged out

test plan:
 * enable page views
 * log in, and go to an assignment page. enable request monitoring
 * be constantly moving your mouse while on this page
 * notice a request to /ping every 3 minutes, and /page_views every
   5
 * stop your server
 * go back and continue moving your mouse
 * requests to /ping and /page_views should fail, but continue
 * restart your server
 * requests should now succeed
 * in another browser, or an incognito window, log in as the same
   user, then log out
 * in the first window, the request to /ping should fail with
   a 401, and the request to /page_views should fail with a 422
 * continue moving your mouse - requests should stop

note that it's easiest to reduce the 3/5 minute times by adjusting
them in app/coffeescripts/behaviors/ping.coffee and
public/javascripts/page_views.js

Change-Id: Id558504f940af51df8bb410d1d88668cd95fdb38
Reviewed-on: https://gerrit.instructure.com/38733
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
Reviewed-by: Jacob Fugal <jacob@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2014-08-05 21:38:31 +00:00
Brian Palmer 02fba1e3d0 remove page_views.contributed
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>
2014-03-10 21:23:52 +00:00
Ryan Florence a1e31c8c9a AMD Conversion
"Trivial" JavaScript / CoffeeScript changes
--------------------------------------------------

For the most part, all javascript was simply
wrapped in `require` or `define`. The dependencies
were found with a script that matched regexes in
the files, it errs on the side of listing too many
dependencies, so its worth double checking each
file's dependencies (over time, anyway).

i18n API changes
--------------------------------------------------

No longer have to do I18n.scoped calls, just
list i18n as a dependency with the scope and it's
imported already scoped

  require ['i18n!some_scope'], (I18n) ->
    I18n.t 'im_scoped', 'I'm scoped!'

JS bundling now done with r.js, not Jammit
--------------------------------------------------

We don't use jammit to bundle JS anymore. Simply
list dependencies for your JS modules in the file
and RequireJS handles the rest.

To optimize the JavaScript, first make sure you
have node.js 0.4.12+ installed and then run:

  $ rake js:build

The app defaults to the optimized build in
production. You can use non-optimized in
production by putting ?debug_assets=true in the
url just like before.

You can also test the optimized JavaScript in
development with ?optimized_js=true.

Significant changes
--------------------------------------------------

These files have "real" changes to them (unlike
the JavaScript that is simply wrapped in require
and define).  Worth taking a really close look at:

- app/helpers/application_helper.rb
- app/views/layouts/application.html.erb
- config/assets.yml
- config/build.js
- lib/handlebars/handlebars.rb
- lib/i18n_extraction/js_extractor.rb
- lib/tasks/canvas.rake
- lib/tasks/i18n.rake
- lib/tasks/js.rake

Change-Id: I4bc5ecb1231f331aaded0fef2bcc1f3a9fe482a7
Reviewed-on: https://gerrit.instructure.com/6986
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Ryan Florence <ryanf@instructure.com>
2012-02-06 16:41:40 -07:00
Ryan Shaw 71cac7d832 fix js files to not error when minified
when minified and concatenated together these did:
I18n.scoped(…page_view_stuff…)(…next_file)

Change-Id: I8b4714e3c4932b795735b740c7c1244d704a7a16
Reviewed-on: https://gerrit.instructure.com/7736
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Ryan Florence <ryanf@instructure.com>
2012-01-03 11:08:09 -07:00
JT Olds d32988b7fd s/recieved/received/g
Change-Id: I194065ece59fab32ec6391dacd890d23cc0cb7f6
Reviewed-on: https://gerrit.instructure.com/7509
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
2011-12-30 15:04:42 -07:00
Brian Palmer 3487da255b s/JSON.parse/$.parseJSON in javascript
Now that we're adding the prefix to our JSON responses, we need to be
sure to go through our modified jquery json parser function.

testplan:
  * make sure that conversations paging now works again
  * check other actions that use pageless, like user page views

this fixes some existing selenium specs, like in conversations.

refs #6459

Change-Id: I2652fc7a7acef099fe163a63e6b3933ddb2e9360
Reviewed-on: https://gerrit.instructure.com/7188
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
2011-11-29 12:45:50 -07:00
Jacob Fugal 69d13cb200 localize PageViews
Change-Id: I22451fe3adedbd893aa3b1a70b21954f9e64b928
Reviewed-on: https://gerrit.instructure.com/4257
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
2011-06-24 10:40:14 -06:00
Brian Whitmer 8b8173dcc9 Initial commit.
closes #6988138
2011-01-31 18:57:29 -07:00