Commit Graph

7 Commits

Author SHA1 Message Date
Cody Cutrer c2cba46851 RuboCop: Style/StringLiterals, Style/StringLiteralsInInterpolation
[skip-stages=Flakey]

auto-corrected

Change-Id: I4a0145abfd50f126669b20f3deaeae8377bac24d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279535
Tested-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Migration-Review: Cody Cutrer <cody@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
2021-11-25 14:03:06 +00:00
Cody Cutrer afa38f2686 RuboCop: Style/RedundantArgument
[skip-stages=Flakey]

auto-corrected

Change-Id: Iedf7b23931d0aaa43d2b649d07ad6117621ed839
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278792
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-18 21:38:20 +00:00
Cody Cutrer c65d57737a RuboCop: Layout lib
Change-Id: I0655d9a9d750f2debd6378b03d8ddc1403ebc31b
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274158
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-09-22 20:01:52 +00:00
Cody Cutrer 06763dd519 add # frozen_string_literal: true for lib
Change-Id: I59b751cac52367a89e03f572477f0cf1d607b405
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/251155
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2020-10-27 20:49:50 +00:00
Ahmad Amireh f0284c9f1c tell GA what kind of account it is
fixes KNO-392
flag  = none

the org type that was introduced in g/236404 and g/236535 is now
submitted to GA pageviews as a new dimension (4). These are the current
org types and their account counts, which you can get from Salesforce:

- Corporate                   (1206)
- Further Education           (359)
- Government                  (29)
- Higher Ed                   (2468)
- K12                         (3807)
- Other                       (15)
- RTO/Training                (86)
- RTO                         (1)
- Internal Use Only           (1)
- Regional Training Provider  (1)
- Training Org                (1)

|
| TEST PLAN
|

- make sure you have GA enabled if you don't already:

    Setting.set('google_analytics_key', 'foo')

- visit any page, then look for the GA snippet[1] and verify that
  "dimension4" is set to null

- now mark your account as "K12":

    Account.default.external_integration_keys.create!(
      key_type: 'salesforce_org_type',
      key_value: 'K12'
    )

- reload the page and verify that "dimension4" is set to "K12" in the GA
  snippet

- unmark the account and verify the dimension is back to null:

    Account.default.external_integration_keys.where(
      key_type: 'salesforce_org_type'
    ).destroy_all

[1]: do "view source" in browser then jump to the term "window.ga", or
     you can use this query in the console and inspect the element:

         Array.prototype.find.call(
           document.head.querySelectorAll('script'),
           x => x.innerHTML.match(/window.ga/)
         )

Change-Id: I505bf1ee2a8347a21d691e2fa4ef04cb07c9a48e
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/238656
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Davis Hyer <dhyer@instructure.com>
QA-Review: Davis Hyer <dhyer@instructure.com>
Product-Review: Davis Hyer <dhyer@instructure.com>
2020-05-29 20:48:16 +00:00
Ahmad Amireh 3578d5b053 give GA an illegible user id
fixes KNO-391
flag  = none

Page views sent to GA are now identified with a value that is unique to
the user but is also not their Canvas ID (to preserve anonymity.) To
avoid further bloat in the User model, I chose to compute this id from
the user id directly by means of a digest as opposed to introducing
another field like User#lti_id.

  ---------
\ TEST PLAN /
 /         \
  \-/---\-/

- without being logged in, visit canvas and inspect the page source for
  the GA snippet:
  * verify "userId"[1] is not being set

- now log in and inspect the source again:

  * verify the "userId" is being set to a value that is _not_ the Canvas
    user id
  * reload the page and verify the value does not change

- (optional) log in as a different user and verify the userId value is
  different from the one given to the first user

[1]: https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#userId

Change-Id: Iaec342c3631e689d754ab35663f4b9c6ac397257
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/233416
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Davis Hyer <dhyer@instructure.com>
QA-Review: Davis Hyer <dhyer@instructure.com>
Product-Review: Davis Hyer <dhyer@instructure.com>
2020-04-14 15:19:43 +00:00
Ahmad Amireh 7fb52f899b track user roles & masquerades in Google Analytics
fixes KNO-355
flag  = none

this is an attempt at making it possible to segment the stats available
on GA by metrics relevant to product... the goal is to be able to tell
which flows are popular among students versus those among teachers, for
example

we now supply every pageview hit with 3 types of additional information:

1. enrollments (student? teacher? observer?)
2. admin status (admin? site admin?)
3. masquerading?

this information is tracked in "custom dimensions"[1] and the submission
is still anonymous; we're not tracking userId

  . . . . .
\ TEST PLAN /
  ---- ----

- create yourself a google analytics account, because if not now, when?
  this is your chance

- inside GA, create "Custom Dimensions" for each of the dimensions[2]
  implemented in this patch:

    1. Enrollments
    2. Admin
    3. Masquerading

- use a Rails console to set your tracker id:

    Setting.set('google_analytics_key', TRACKER_ID)

- now browse around Canvas and keep an eye on the GA dashboard; you
  should see points tracked after some time (could take up to an hour
  really...) with the dimensions populated

[1]: https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#customs
[2]: from User#user_roles - https://gerrit.instructure.com/plugins/gitiles/canvas-lms/+/refs/heads/master/app/models/user.rb#2877

Change-Id: I1d797e6c500d3d60da36da3b50339bab649e57de
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/230360
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
2020-03-23 23:54:41 +00:00