girder-google-analytics 3.2.3.dev23__tar.gz → 3.2.4.dev5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/PKG-INFO +1 -1
  2. girder-google-analytics-3.2.4.dev5/girder_google_analytics/web_client/main.js +63 -0
  3. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/girder_google_analytics/web_client/views/ConfigView.js +2 -0
  4. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/girder_google_analytics.egg-info/PKG-INFO +1 -1
  5. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/girder_google_analytics.egg-info/SOURCES.txt +0 -1
  6. girder-google-analytics-3.2.3.dev23/girder_google_analytics/web_client/lib/backbone.analytics.js +0 -71
  7. girder-google-analytics-3.2.3.dev23/girder_google_analytics/web_client/main.js +0 -43
  8. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/girder_google_analytics/__init__.py +0 -0
  9. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/girder_google_analytics/rest.py +0 -0
  10. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/girder_google_analytics/settings.py +0 -0
  11. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/girder_google_analytics/web_client/package.json +0 -0
  12. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/girder_google_analytics/web_client/routes.js +0 -0
  13. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/girder_google_analytics/web_client/stylesheets/configView.styl +0 -0
  14. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/girder_google_analytics/web_client/templates/configView.pug +0 -0
  15. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/girder_google_analytics.egg-info/dependency_links.txt +0 -0
  16. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/girder_google_analytics.egg-info/entry_points.txt +0 -0
  17. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/girder_google_analytics.egg-info/not-zip-safe +0 -0
  18. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/girder_google_analytics.egg-info/requires.txt +0 -0
  19. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/girder_google_analytics.egg-info/top_level.txt +0 -0
  20. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/plugin.cmake +0 -0
  21. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/plugin_tests/__init__.py +0 -0
  22. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/plugin_tests/google_analytics_test.py +0 -0
  23. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/setup.cfg +0 -0
  24. {girder-google-analytics-3.2.3.dev23 → girder-google-analytics-3.2.4.dev5}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: girder-google-analytics
3
- Version: 3.2.3.dev23
3
+ Version: 3.2.4.dev5
4
4
  Summary: Allow the tracking of page views via Google Analytics.
5
5
  Home-page: http://girder.readthedocs.io/en/latest/plugins.html#google-analytics
6
6
  Author: Kitware, Inc.
@@ -0,0 +1,63 @@
1
+ import $ from 'jquery';
2
+
3
+ import events from '@girder/core/events';
4
+ import { restRequest } from '@girder/core/rest';
5
+
6
+ import './routes';
7
+
8
+ function initGoogleAnalytics() {
9
+ restRequest({
10
+ method: 'GET',
11
+ url: 'google_analytics/id'
12
+ }).done((resp) => {
13
+ if (resp.google_analytics_id) {
14
+ const googleAnalyticsId = resp.google_analytics_id;
15
+
16
+ $.getScript({
17
+ url: `https://www.googletagmanager.com/gtag/js?id=${googleAnalyticsId}`,
18
+ success: function () {
19
+ window.dataLayer = window.dataLayer || [];
20
+ function gtag() {
21
+ dataLayer.push(arguments); // eslint-disable-line no-undef
22
+ }
23
+ gtag('js', new Date());
24
+ gtag('config', googleAnalyticsId);
25
+ window.gtag = gtag;
26
+ }
27
+ });
28
+ }
29
+ });
30
+ }
31
+
32
+ events.on('g:appload.after', function () {
33
+ var dnt = navigator.doNotTrack || window.doNotTrack;
34
+ if (dnt !== '1' && dnt !== 'yes') {
35
+ initGoogleAnalytics();
36
+ }
37
+ });
38
+
39
+ events.on('g:google_analytics.save', function () {
40
+ initGoogleAnalytics();
41
+ });
42
+
43
+ /**
44
+ * Add analytics for the hierarchy widget specifically since it routes without
45
+ * triggering (calling navigate without {trigger: true}).
46
+ */
47
+ events.on('g:hierarchy.route', function (args) {
48
+ let curRoute = args.route;
49
+ if (!/^\//.test(curRoute)) {
50
+ curRoute = '/' + curRoute;
51
+ }
52
+ if (window.gtag) {
53
+ window.gtag('event', 'page_view', { girder_route: curRoute });
54
+ }
55
+ });
56
+
57
+ events.on('g:navigateTo', function (args) {
58
+ let curRoute = location.hash;
59
+ curRoute = curRoute.replace(/^#/, '');
60
+ if (window.gtag) {
61
+ window.gtag('event', 'page_view', { girder_route: curRoute });
62
+ }
63
+ });
@@ -56,6 +56,8 @@ var ConfigView = View.extend({
56
56
  },
57
57
  error: null
58
58
  }).done(() => {
59
+ events.trigger('g:google_analytics.save');
60
+
59
61
  events.trigger('g:alert', {
60
62
  icon: 'ok',
61
63
  text: 'Settings saved.',
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: girder-google-analytics
3
- Version: 3.2.3.dev23
3
+ Version: 3.2.4.dev5
4
4
  Summary: Allow the tracking of page views via Google Analytics.
5
5
  Home-page: http://girder.readthedocs.io/en/latest/plugins.html#google-analytics
6
6
  Author: Kitware, Inc.
@@ -13,7 +13,6 @@ girder_google_analytics.egg-info/top_level.txt
13
13
  girder_google_analytics/web_client/main.js
14
14
  girder_google_analytics/web_client/package.json
15
15
  girder_google_analytics/web_client/routes.js
16
- girder_google_analytics/web_client/lib/backbone.analytics.js
17
16
  girder_google_analytics/web_client/stylesheets/configView.styl
18
17
  girder_google_analytics/web_client/templates/configView.pug
19
18
  girder_google_analytics/web_client/views/ConfigView.js
@@ -1,71 +0,0 @@
1
- // Copyright (C) 2013 by Kendall Buchanan
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
20
- /* eslint-disable */
21
- (function(factory) {
22
-
23
- 'use strict';
24
-
25
- if (typeof define === 'function' && define.amd) {
26
- define(['backbone'], factory);
27
- } else if (typeof exports === 'object') {
28
- module.exports = factory(require('backbone'));
29
- } else {
30
- factory(window.Backbone);
31
- }
32
- })(function(Backbone) {
33
-
34
- 'use strict';
35
-
36
- var loadUrl = Backbone.History.prototype.loadUrl;
37
-
38
- Backbone.History.prototype.loadUrl = function(fragmentOverride) {
39
- var matched = loadUrl.apply(this, arguments),
40
- gaFragment = this.fragment;
41
-
42
- if (!this.options.silent) {
43
- this.options.silent = true;
44
- return matched;
45
- }
46
-
47
- if (!/^\//.test(gaFragment)) {
48
- gaFragment = '/' + gaFragment;
49
- }
50
-
51
- // legacy version
52
- if (typeof window._gaq !== "undefined") {
53
- window._gaq.push(['_trackPageview', gaFragment]);
54
- }
55
-
56
- // Analytics.js
57
- var ga;
58
- if (window.GoogleAnalyticsObject && window.GoogleAnalyticsObject !== 'ga') {
59
- ga = window.GoogleAnalyticsObject;
60
- } else {
61
- ga = window.ga;
62
- }
63
-
64
- if (typeof ga !== 'undefined') {
65
- ga('set', 'page', gaFragment);
66
- ga('send', 'pageview');
67
- }
68
- return matched;
69
- };
70
-
71
- });
@@ -1,43 +0,0 @@
1
- import events from '@girder/core/events';
2
- import { restRequest } from '@girder/core/rest';
3
-
4
- import './lib/backbone.analytics';
5
- import './routes';
6
-
7
- events.on('g:appload.after', function () {
8
- var dnt = navigator.doNotTrack || window.doNotTrack;
9
- if (dnt !== '1' && dnt !== 'yes') {
10
- /* eslint-disable */
11
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
12
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
13
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
14
- })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
15
- /* eslint-enable */
16
-
17
- restRequest({
18
- method: 'GET',
19
- url: 'google_analytics/id'
20
- }).done((resp) => {
21
- if (resp.google_analytics_id) {
22
- if (typeof ga !== 'undefined') {
23
- ga('create', resp.google_analytics_id, 'none');
24
- }
25
- }
26
- });
27
- }
28
- });
29
-
30
- /**
31
- * Add analytics for the hierarchy widget specifically since it routes without
32
- * triggering (calling navigate without {trigger: true}).
33
- */
34
- events.on('g:hierarchy.route', function (args) {
35
- var curRoute = args.route;
36
- if (!/^\//.test(curRoute)) {
37
- curRoute = '/' + curRoute;
38
- }
39
- if (typeof ga !== 'undefined') {
40
- /* global ga:false */
41
- ga('send', 'pageview', curRoute);
42
- }
43
- });