gosquared 2.0.3 → 3.0.0
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.
- checksums.yaml +4 -4
- data/README.md +1 -20
- data/lib/gosquared.rb +5 -5
- metadata +2 -10
- data/lib/compatibility.rb +0 -3
- data/lib/config.rb +0 -16
- data/lib/rails/generators/gosquared/config/config_generator.rb +0 -16
- data/lib/rails/generators/gosquared/config/templates/gosquared.rb.erb +0 -3
- data/lib/tracker_inject/injector.rb +0 -45
- data/lib/tracker_inject/railtie.rb +0 -8
- data/spec/tracker_inject_spec.rb +0 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a28ba573c7c4ac3be32473ccc6df89546b1c5e0
|
4
|
+
data.tar.gz: c1b82ddea06097342afda3f559959710fafabe6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16972501f8547234d8da365bd7fe7a70e82141498645ae7a037a9fe18c4ab2cdea87d0a53643c3b43449227312088321b2d7deec100be3beb96178cbe01f51af
|
7
|
+
data.tar.gz: bdbd18ffd887c741987dba375eb35a2962abbd0866be972b1f990f4d22d9212bb56c6337e81de157297383c000cb5bb6249f0780f407f65a25fc3615fd0b4592
|
data/README.md
CHANGED
@@ -69,7 +69,7 @@ This method is useful for importing existing user profiles into GoSquared people
|
|
69
69
|
|
70
70
|
It's highly recommended that you also implement the front end [javascript 'identify' method](https://www.gosquared.com/docs/api/javascript-tracking-code/identify-users) on your site. This enables us to track a the user's session activity and browser information against their People profile.
|
71
71
|
|
72
|
-
We also recommend using an email address for the `person_id`. To do this, the email address needs to be prefixed with `email:` like in the example below.
|
72
|
+
We also recommend using an email address for the `person_id`. To do this, the email address needs to be prefixed with `email:` like in the example below.
|
73
73
|
|
74
74
|
```ruby
|
75
75
|
gs = Gosquared::RubyLibrary.new("your_API_key","your_project_token")
|
@@ -194,25 +194,6 @@ gs.account.sites.fetch
|
|
194
194
|
|
195
195
|
```
|
196
196
|
|
197
|
-
|
198
|
-
### Optional install of Analytics and Chat
|
199
|
-
|
200
|
-
While it is not required to make use of our library to interact with our Tracking and Reporting API's, you can also quickly install GoSquared's tracking code on your app. GoSquared uses a javascript code snippet to track pageviews and optionally load the GoSquared Live Chat widget.
|
201
|
-
|
202
|
-
If you don't currently have a GoSquared tracking code on your site, you can quickly add the the code to all of your Rails’ views by running this:
|
203
|
-
|
204
|
-
```ruby
|
205
|
-
rails generate gosquared:config 'your_project_token'
|
206
|
-
```
|
207
|
-
|
208
|
-
This will insert a `<script>` tag automatically before the closing `</body>` tag on each view rendered.
|
209
|
-
|
210
|
-
After generating your config file, if there are any controllers you would prefer not to have the tracking code automatically inserted in, you'll just need to add the following to that specific controller:
|
211
|
-
|
212
|
-
```ruby
|
213
|
-
skip_after_action :add_gosquared_script
|
214
|
-
```
|
215
|
-
|
216
197
|
#Tests
|
217
198
|
|
218
199
|
```ruby
|
data/lib/gosquared.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
|
-
require 'tracker_inject/railtie' if defined? (Rails)
|
2
1
|
require_relative "gosquared/trends"
|
3
2
|
require_relative "gosquared/tracking"
|
4
3
|
require_relative "gosquared/people"
|
5
4
|
require_relative "gosquared/now"
|
6
5
|
require_relative "gosquared/account"
|
7
|
-
require_relative "config"
|
8
|
-
require_relative "compatibility"
|
9
6
|
|
10
7
|
module Gosquared
|
11
8
|
|
@@ -14,8 +11,8 @@ module Gosquared
|
|
14
11
|
def initialize api_key, site_id
|
15
12
|
@api_key = api_key
|
16
13
|
@site_id = site_id
|
17
|
-
|
18
|
-
|
14
|
+
raise 'api key cannot be empty/nil' if api_key.nil? || api_key.empty?
|
15
|
+
raise 'site_token cannot be empty/nil' if site_id.nil? || site_id.empty?
|
19
16
|
end
|
20
17
|
|
21
18
|
def trends
|
@@ -39,5 +36,8 @@ module Gosquared
|
|
39
36
|
end
|
40
37
|
|
41
38
|
end
|
39
|
+
end
|
42
40
|
|
41
|
+
module GoSquared
|
42
|
+
include Gosquared
|
43
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gosquared
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Russell Vaughan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -50,8 +50,6 @@ files:
|
|
50
50
|
- Gemfile
|
51
51
|
- LICENSE
|
52
52
|
- README.md
|
53
|
-
- lib/compatibility.rb
|
54
|
-
- lib/config.rb
|
55
53
|
- lib/gosquared.rb
|
56
54
|
- lib/gosquared/account.rb
|
57
55
|
- lib/gosquared/client.rb
|
@@ -59,16 +57,11 @@ files:
|
|
59
57
|
- lib/gosquared/people.rb
|
60
58
|
- lib/gosquared/tracking.rb
|
61
59
|
- lib/gosquared/trends.rb
|
62
|
-
- lib/rails/generators/gosquared/config/config_generator.rb
|
63
|
-
- lib/rails/generators/gosquared/config/templates/gosquared.rb.erb
|
64
|
-
- lib/tracker_inject/injector.rb
|
65
|
-
- lib/tracker_inject/railtie.rb
|
66
60
|
- spec/account_spec.rb
|
67
61
|
- spec/client_spec.rb
|
68
62
|
- spec/now_spec.rb
|
69
63
|
- spec/people_spec.rb
|
70
64
|
- spec/spec_helper.rb
|
71
|
-
- spec/tracker_inject_spec.rb
|
72
65
|
- spec/tracking_spec.rb
|
73
66
|
- spec/trends_spec.rb
|
74
67
|
homepage: https://github.com/gosquared/ruby-client
|
@@ -101,6 +94,5 @@ test_files:
|
|
101
94
|
- spec/now_spec.rb
|
102
95
|
- spec/people_spec.rb
|
103
96
|
- spec/spec_helper.rb
|
104
|
-
- spec/tracker_inject_spec.rb
|
105
97
|
- spec/tracking_spec.rb
|
106
98
|
- spec/trends_spec.rb
|
data/lib/compatibility.rb
DELETED
data/lib/config.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module Gosquared
|
2
|
-
|
3
|
-
class << self
|
4
|
-
attr_accessor :configuration
|
5
|
-
end
|
6
|
-
|
7
|
-
def self.configure
|
8
|
-
self.configuration ||= Configuration.new
|
9
|
-
block_given? ? yield(configuration) : configuration
|
10
|
-
end
|
11
|
-
|
12
|
-
class Configuration
|
13
|
-
attr_accessor :site_token
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'rails/generators/base'
|
2
|
-
|
3
|
-
module Gosquared
|
4
|
-
module Generators
|
5
|
-
class ConfigGenerator < Rails::Generators::Base
|
6
|
-
source_root File.expand_path("../templates", __FILE__)
|
7
|
-
|
8
|
-
argument :site_token
|
9
|
-
|
10
|
-
def copy_initializer_file
|
11
|
-
@site_token = site_token
|
12
|
-
template("gosquared.rb.erb", File.join("config/initializers/gosquared.rb"))
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
class Injector
|
2
|
-
module Filter
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
included do
|
5
|
-
append_after_filter :add_gosquared_script, :if => :html_response?
|
6
|
-
|
7
|
-
CLOSING_HEAD_TAG = %r{</body>}
|
8
|
-
|
9
|
-
def add_gosquared_script
|
10
|
-
response.body = response.body.gsub(CLOSING_HEAD_TAG, "<script type='text/javascript' async='true'>
|
11
|
-
var trackingCode = function(){
|
12
|
-
!function(g,s,q,r,d){r=g[r]=g[r]||function(){(r.q=r.q||[]).push(
|
13
|
-
arguments)};d=s.createElement(q);q=s.getElementsByTagName(q)[0];
|
14
|
-
d.src='//d1l6p2sc9645hc.cloudfront.net/tracker.js';q.parentNode.
|
15
|
-
insertBefore(d,q)}(window,document,'script','_gs');
|
16
|
-
_gs('GSN-589158-M'); _gs('set', 'trackLocal', true);
|
17
|
-
_gs('event', '#{request.headers["PATH_INFO"]}', {
|
18
|
-
extra: 'event',
|
19
|
-
details: true
|
20
|
-
});
|
21
|
-
};
|
22
|
-
|
23
|
-
var loadTracker;
|
24
|
-
loadTracker=function(){
|
25
|
-
if(!window._gs) {
|
26
|
-
trackingCode();
|
27
|
-
} else {
|
28
|
-
delete _gs;
|
29
|
-
trackingCode();
|
30
|
-
}
|
31
|
-
};
|
32
|
-
$(document).on('page:load', loadTracker)
|
33
|
-
$(document).on('turbolinks:load', loadTracker);
|
34
|
-
</script>" + "\n </body>"
|
35
|
-
)
|
36
|
-
end
|
37
|
-
|
38
|
-
def html_response?
|
39
|
-
response.content_type == "text/html"
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
data/spec/tracker_inject_spec.rb
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
if defined?(Rails)
|
4
|
-
|
5
|
-
class ApplicationController < ActionController::Base
|
6
|
-
|
7
|
-
after_filter :add_gosquared_script, :if => :html_response?
|
8
|
-
|
9
|
-
def add_gosquared_script
|
10
|
-
response.body = response.body.gsub(CLOSING_HEAD_TAG, "<script type='text/javascript' async='true'>
|
11
|
-
var trackingCode = function(){
|
12
|
-
!function(g,s,q,r,d){r=g[r]=g[r]||function(){(r.q=r.q||[]).push(
|
13
|
-
arguments)};d=s.createElement(q);q=s.getElementsByTagName(q)[0];
|
14
|
-
d.src='//d1l6p2sc9645hc.cloudfront.net/tracker.js';q.parentNode.
|
15
|
-
insertBefore(d,q)}(window,document,'script','_gs');
|
16
|
-
_gs('GSN-589158-M'); _gs('set', 'trackLocal', true);
|
17
|
-
_gs('event', '#{request.headers["PATH_INFO"]}', {
|
18
|
-
extra: 'event',
|
19
|
-
details: true
|
20
|
-
});
|
21
|
-
};
|
22
|
-
|
23
|
-
var loadTracker;
|
24
|
-
loadTracker=function(){
|
25
|
-
if(!window._gs) {
|
26
|
-
trackingCode();
|
27
|
-
} else {
|
28
|
-
delete _gs;
|
29
|
-
trackingCode();
|
30
|
-
}
|
31
|
-
};
|
32
|
-
$(document).on('page:load', loadTracker)
|
33
|
-
$(document).on('turbolinks:load', loadTracker);
|
34
|
-
</script>" + "\n </body>"
|
35
|
-
)
|
36
|
-
end
|
37
|
-
|
38
|
-
def html_response?
|
39
|
-
response.content_type == "text/html"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe ApplicationController, :type => :controller do
|
44
|
-
controller do
|
45
|
-
def index
|
46
|
-
render :html => true
|
47
|
-
end
|
48
|
-
|
49
|
-
def new
|
50
|
-
render :json => true
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
it "adds the GoSquared tracking code if response HTML" do
|
55
|
-
expect(controller).to receive(:add_gosquared_script)
|
56
|
-
get :index
|
57
|
-
end
|
58
|
-
|
59
|
-
it "does not add the GoSquared tracking code if response not HTML" do
|
60
|
-
expect(controller).not_to receive(:add_gosquared_script)
|
61
|
-
get :new
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
end
|