tealium 1.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 +7 -0
- data/lib/tealium.rb +24 -0
- data/lib/tealium_collect.rb +34 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 86f222b3ecfed442dab500f3b9d25b4d2364c606d259ab7ac6e7e3c3cbe06f08
|
4
|
+
data.tar.gz: 95ddd26ea3ffedcc8e9f79c833acad54a702ab10128eba47da1776f74475e95a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: db7698180543c70d65f867091acaf7aa14905718301abeedf6e47658075664bebfdb86527e9f797a5daa98bd553b7b6b44be2929ad41f0715a228819188b3d19
|
7
|
+
data.tar.gz: c04a834fb37b373ea7ce872cc5835757a87423e4effac3eec260072ac306d971046e188b2cad2b8ab334285b604b6748d32d6eb253633267cf34f8d433de5065
|
data/lib/tealium.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'tealium_collect'
|
2
|
+
|
3
|
+
class Tealium
|
4
|
+
attr_accessor :account, :profile, :datasource
|
5
|
+
def initialize(account, profile, datasource = nil)
|
6
|
+
@account = account
|
7
|
+
@profile = profile
|
8
|
+
@datasource = datasource
|
9
|
+
end
|
10
|
+
|
11
|
+
def track(event_name, custom_data = {})
|
12
|
+
data = Hash.new
|
13
|
+
data[:tealium_account] = @account
|
14
|
+
data[:tealium_profile] = @profile
|
15
|
+
|
16
|
+
if (!@datasource.nil?)
|
17
|
+
data[:tealium_datasource]
|
18
|
+
end
|
19
|
+
|
20
|
+
data[:tealium_event] = event_name
|
21
|
+
payload = data.merge(custom_data)
|
22
|
+
TealiumCollect.collect(payload)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
class TealiumCollect
|
6
|
+
LIBRARY_NAME = "ruby"
|
7
|
+
LIBRARY_VERSION = "1.0.0"
|
8
|
+
|
9
|
+
def self.collect(payload)
|
10
|
+
uri = URI.parse("https://collect.tealiumiq.com/event")
|
11
|
+
header = {'Content-type': 'application/json'}
|
12
|
+
http = Net::HTTP.new(uri.host)
|
13
|
+
request = Net::HTTP::Post.new(uri.request_uri, header)
|
14
|
+
payload[:tealium_library_name] = LIBRARY_NAME
|
15
|
+
payload[:tealium_library_version] = LIBRARY_VERSION
|
16
|
+
|
17
|
+
request.body = payload.to_json
|
18
|
+
response = http.request(request)
|
19
|
+
|
20
|
+
#uncomment the line below for debugging
|
21
|
+
#checkRequestResponse(response)
|
22
|
+
end
|
23
|
+
|
24
|
+
def checkRequestResponse(response)
|
25
|
+
case response
|
26
|
+
when Net::HTTPOK
|
27
|
+
puts "Data sent to Tealum: " + response.message
|
28
|
+
|
29
|
+
else
|
30
|
+
puts "Error sending data: " + response.message
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tealium
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tealium
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-01-31 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Tealium gem sends json payload to Tealium's HTTP API
|
14
|
+
email:
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/tealium.rb
|
20
|
+
- lib/tealium_collect.rb
|
21
|
+
homepage: https://github.com/Tealium/tealium-ruby
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.7.8
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Tealium Collect for Ruby
|
45
|
+
test_files: []
|