itly-plugin-mixpanel 0.1.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/.rspec +1 -0
- data/Gemfile +17 -0
- data/Steepfile +9 -0
- data/bin/console +15 -0
- data/bin/rspec +18 -0
- data/bin/setup +8 -0
- data/itly-plugin-mixpanel.gemspec +32 -0
- data/lib/itly/plugin-mixpanel.rb +12 -0
- data/lib/itly/plugin/mixpanel/call_options.rb +26 -0
- data/lib/itly/plugin/mixpanel/error_handler.rb +21 -0
- data/lib/itly/plugin/mixpanel/mixpanel.rb +133 -0
- data/lib/itly/plugin/mixpanel/options.rb +17 -0
- data/lib/itly/plugin/mixpanel/version.rb +9 -0
- data/sig/call_options.rbs +23 -0
- data/sig/error_handler.rbs +7 -0
- data/sig/lib/mixpanel_error_handler.rbs +5 -0
- data/sig/lib/mixpanel_tracker.rbs +13 -0
- data/sig/lib/mixpanel_tracker_people.rbs +8 -0
- data/sig/lib/monitor_mixin.rbs +3 -0
- data/sig/mixpanel.rbs +19 -0
- data/sig/options.rbs +8 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e3d00fe05fc92ea65d0c280a313d3e96a461f1eea1e87c3c8c88a267f7f19789
|
4
|
+
data.tar.gz: 942e907363c69b46375c5c4cdf46071cf6300e34170a2ac86714e3ab721be5ee
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 82e21945dd10ee74ca764701e6740e5291ae80f166553ff486de8d32bdb8282b4440a1ccb6c2b2250c76ac992dfe2c54a838656f2b493d7eefc2f5460c105d6f
|
7
|
+
data.tar.gz: 13e1e33189bb30be5c0f0ce9c4d5971f84bd41798c7563b97f898f2adce8efa51fcaaa1baccad488733b7f539624dd4994ccef4b6a7376399f5248617beb573d
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in itly-plugin-mixpanel.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem 'rake', '~> 13.0'
|
9
|
+
|
10
|
+
if ENV['LOCAL_ITLY_GEM']
|
11
|
+
# TODO: before publication to RubyGems, switch to version 1
|
12
|
+
gem 'itly-sdk', '~> 0.1', path: '../sdk'
|
13
|
+
end
|
14
|
+
|
15
|
+
gem 'rbs', '~> 1.0'
|
16
|
+
gem 'rspec'
|
17
|
+
gem 'steep', '~> 0.41'
|
data/Steepfile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'itly/plugin-mixpanel'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/rspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Configure and load RBS
|
5
|
+
unless ENV['DISABLE_TYPE_CHECKING']
|
6
|
+
ENV['RBS_TEST_TARGET'] = 'Itly::*'
|
7
|
+
ENV['RBS_TEST_LOGLEVEL'] = 'warn'
|
8
|
+
ENV['RBS_TEST_DOUBLE_SUITE'] = 'rspec'
|
9
|
+
ENV['RBS_TEST_OPT'] = '-I./sig -I../sdk/sig'
|
10
|
+
|
11
|
+
require 'rbs/test/setup'
|
12
|
+
end
|
13
|
+
|
14
|
+
# Start RSpec
|
15
|
+
require 'rspec/core'
|
16
|
+
|
17
|
+
ENV['RSPEC_RUN_FROM_SCRIPT'] = 'true'
|
18
|
+
RSpec::Core::Runner.invoke
|
data/bin/setup
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/itly/plugin/mixpanel/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'itly-plugin-mixpanel'
|
7
|
+
spec.version = Itly::Plugin::Mixpanel::VERSION
|
8
|
+
spec.authors = ['Iteratively', 'Benjamin Bouchet', 'Justin Fiedler', 'Andrey Sokolov']
|
9
|
+
spec.email = ['support@iterative.ly']
|
10
|
+
|
11
|
+
spec.summary = 'Mixpanel plugin for Iteratively SDK for Ruby'
|
12
|
+
spec.description = 'Track and validate analytics with a unified, extensible interface ' \
|
13
|
+
'that works with all your 3rd party analytics providers.'
|
14
|
+
spec.homepage = 'https://github.com/iterativelyhq/itly-sdk-ruby'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
|
17
|
+
|
18
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org/'
|
19
|
+
|
20
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
21
|
+
spec.metadata['source_code_uri'] = 'https://github.com/iterativelyhq/itly-sdk-ruby/plugin-mixpanel'
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
27
|
+
end
|
28
|
+
spec.require_paths = ['lib']
|
29
|
+
|
30
|
+
spec.add_dependency 'itly-sdk', '~> 0.1'
|
31
|
+
spec.add_dependency 'mixpanel-ruby', '~> 2.2'
|
32
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
if ENV['LOCAL_ITLY_GEM']
|
4
|
+
lib = File.expand_path('../../../sdk/lib', File.dirname(__FILE__))
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
end
|
7
|
+
|
8
|
+
require_relative 'plugin/mixpanel/mixpanel'
|
9
|
+
require_relative 'plugin/mixpanel/options'
|
10
|
+
require_relative 'plugin/mixpanel/call_options'
|
11
|
+
require_relative 'plugin/mixpanel/error_handler'
|
12
|
+
require_relative 'plugin/mixpanel/version'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Itly
|
4
|
+
class Plugin
|
5
|
+
# Mixpanel plugin class for Itly SDK
|
6
|
+
class Mixpanel
|
7
|
+
##
|
8
|
+
# Mixpanel specific plugin options class
|
9
|
+
#
|
10
|
+
class CallOptions < Itly::PluginCallOptions
|
11
|
+
end
|
12
|
+
|
13
|
+
##
|
14
|
+
# Mixpanel specific plugin options class for calls to plugin methods
|
15
|
+
#
|
16
|
+
%w[Identify Group Page Track Alias].each do |name|
|
17
|
+
class_eval(
|
18
|
+
<<-EVAL, __FILE__, __LINE__ + 1
|
19
|
+
class #{name}Options < CallOptions # class IdentifyOptions < CallOptions
|
20
|
+
end # end
|
21
|
+
EVAL
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'itly-sdk'
|
4
|
+
require 'mixpanel-ruby'
|
5
|
+
|
6
|
+
class Itly
|
7
|
+
class Plugin
|
8
|
+
class Mixpanel
|
9
|
+
##
|
10
|
+
# Error handler class used by Mixpanel::Tracker
|
11
|
+
#
|
12
|
+
# Raise an +Itly::RemoteError+ error in case of error
|
13
|
+
#
|
14
|
+
class ErrorHandler < ::Mixpanel::ErrorHandler
|
15
|
+
def handle(error)
|
16
|
+
raise Itly::RemoteError, "The client returned an error: #{error}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'itly-sdk'
|
4
|
+
require 'mixpanel-ruby'
|
5
|
+
|
6
|
+
class Itly
|
7
|
+
class Plugin
|
8
|
+
##
|
9
|
+
# Mixpanel plugin class for Itly SDK
|
10
|
+
#
|
11
|
+
# Automatically loaded at runtime in any new +Itly+ object
|
12
|
+
#
|
13
|
+
class Mixpanel < Plugin
|
14
|
+
attr_reader :client, :disabled
|
15
|
+
|
16
|
+
##
|
17
|
+
# Instantiate a new Plugin::Mixpanel
|
18
|
+
#
|
19
|
+
# @param [String] project_token: specify the Mixpanel project token
|
20
|
+
# @param [TrueClass/FalseClass] disabled: set to true to disable the plugin. Default to false
|
21
|
+
#
|
22
|
+
def initialize(project_token:, disabled: false)
|
23
|
+
super()
|
24
|
+
@project_token = project_token
|
25
|
+
@disabled = disabled
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Initialize Mixpanel::Tracker client
|
30
|
+
#
|
31
|
+
# @param [Itly::PluginOptions] options: plugin options
|
32
|
+
#
|
33
|
+
def load(options:)
|
34
|
+
super
|
35
|
+
# Get options
|
36
|
+
@logger = options.logger
|
37
|
+
|
38
|
+
# Log
|
39
|
+
@logger&.info "#{id}: load()"
|
40
|
+
|
41
|
+
if @disabled
|
42
|
+
@logger&.info "#{id}: plugin is disabled!"
|
43
|
+
return
|
44
|
+
end
|
45
|
+
|
46
|
+
# Configure client
|
47
|
+
@client = ::Mixpanel::Tracker.new @project_token, ErrorHandler.new
|
48
|
+
end
|
49
|
+
|
50
|
+
##
|
51
|
+
# Identify a user
|
52
|
+
#
|
53
|
+
# Raise an error if the client fails
|
54
|
+
#
|
55
|
+
# @param [String] user_id: the id of the user in your application
|
56
|
+
# @param [Hash] properties: the properties containing user's traits to pass to your application
|
57
|
+
# @param [Itly::Plugin::Mixpanel::IdentifyOptions] options: the plugin specific options
|
58
|
+
#
|
59
|
+
def identify(user_id:, properties: nil, options: nil)
|
60
|
+
super
|
61
|
+
return unless enabled?
|
62
|
+
|
63
|
+
# Log
|
64
|
+
log = Itly::Loggers.vars_to_log user_id: user_id, properties: properties, options: options
|
65
|
+
@logger&.info "#{id}: identify(#{log})"
|
66
|
+
|
67
|
+
# Send through the client
|
68
|
+
@client.people.set user_id, properties
|
69
|
+
end
|
70
|
+
|
71
|
+
##
|
72
|
+
# Track an event
|
73
|
+
#
|
74
|
+
# Raise an error if the client fails
|
75
|
+
#
|
76
|
+
# @param [String] user_id: the id of the user in your application
|
77
|
+
# @param [Event] event: the Event object to pass to your application
|
78
|
+
# @param [Itly::Plugin::Mixpanel::TrackOptions] options: the plugin specific options
|
79
|
+
#
|
80
|
+
def track(user_id:, event:, options: nil)
|
81
|
+
super
|
82
|
+
return unless enabled?
|
83
|
+
|
84
|
+
# Log
|
85
|
+
log = Itly::Loggers.vars_to_log(
|
86
|
+
user_id: user_id, event: event&.name, properties: event&.properties, options: options
|
87
|
+
)
|
88
|
+
@logger&.info "#{id}: track(#{log})"
|
89
|
+
|
90
|
+
# Send through the client
|
91
|
+
@client.track user_id, event.name, event.properties
|
92
|
+
end
|
93
|
+
|
94
|
+
##
|
95
|
+
# Associate one user ID with another (typically a known user ID with an anonymous one).
|
96
|
+
#
|
97
|
+
# Raise an error if the client fails
|
98
|
+
#
|
99
|
+
# @param [String] user_id: The ID that the user will be identified by going forward. This is
|
100
|
+
# typically the user's database ID (as opposed to an anonymous ID), or their updated ID
|
101
|
+
# (for example, if the ID is an email address which the user just updated).
|
102
|
+
# @param [String] previous_id: The ID the user has been identified by so far.
|
103
|
+
# @param [Itly::Plugin::Mixpanel::AliasOptions] options: the plugin specific options
|
104
|
+
#
|
105
|
+
def alias(user_id:, previous_id:, options: nil)
|
106
|
+
super
|
107
|
+
return unless enabled?
|
108
|
+
|
109
|
+
# Log
|
110
|
+
log = Itly::Loggers.vars_to_log user_id: user_id, previous_id: previous_id, options: options
|
111
|
+
@logger&.info "#{id}: alias(#{log})"
|
112
|
+
|
113
|
+
# Send through the client
|
114
|
+
@client.alias user_id, previous_id
|
115
|
+
end
|
116
|
+
|
117
|
+
##
|
118
|
+
# Get the plugin ID
|
119
|
+
#
|
120
|
+
# @return [String] plugin id
|
121
|
+
#
|
122
|
+
def id
|
123
|
+
'mixpanel'
|
124
|
+
end
|
125
|
+
|
126
|
+
private
|
127
|
+
|
128
|
+
def enabled?
|
129
|
+
!@disabled
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'itly-sdk'
|
4
|
+
|
5
|
+
class Itly
|
6
|
+
class Plugin
|
7
|
+
class Mixpanel
|
8
|
+
##
|
9
|
+
# Options for the Mixpanel plugin class
|
10
|
+
#
|
11
|
+
# rubocop:disable Lint/EmptyClass
|
12
|
+
class Options
|
13
|
+
end
|
14
|
+
# rubocop:enable Lint/EmptyClass
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Itly
|
2
|
+
class Plugin
|
3
|
+
class Mixpanel
|
4
|
+
class CallOptions < Itly::PluginCallOptions
|
5
|
+
end
|
6
|
+
|
7
|
+
class IdentifyOptions < CallOptions
|
8
|
+
end
|
9
|
+
|
10
|
+
class GroupOptions < CallOptions
|
11
|
+
end
|
12
|
+
|
13
|
+
class PageOptions < CallOptions
|
14
|
+
end
|
15
|
+
|
16
|
+
class TrackOptions < CallOptions
|
17
|
+
end
|
18
|
+
|
19
|
+
class AliasOptions < CallOptions
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Part of the gems
|
2
|
+
class Mixpanel
|
3
|
+
class Tracker
|
4
|
+
attr_reader people: Mixpanel::Tracker::People
|
5
|
+
|
6
|
+
def track: (String user_id, String event_name, propertiesHash properties) -> void
|
7
|
+
def alias: (String user_id, String previoud_id) -> void
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def initialize: (String project_token, Mixpanel::ErrorHandler error_handler) -> void
|
12
|
+
end
|
13
|
+
end
|
data/sig/mixpanel.rbs
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
class Itly
|
2
|
+
class Plugin::Mixpanel < Plugin
|
3
|
+
VERSION: String
|
4
|
+
|
5
|
+
attr_reader client: Mixpanel::Tracker?
|
6
|
+
attr_reader disabled: bool
|
7
|
+
|
8
|
+
def load: (options: Itly::PluginOptions options) -> void
|
9
|
+
def identify: (user_id: String user_id, ?properties: propertiesHash? properties, ?options: Itly::Plugin::Mixpanel::IdentifyOptions? options) -> void
|
10
|
+
def track: (user_id: String user_id, event: Itly::Event event, ?options: Itly::Plugin::Mixpanel::TrackOptions? options) -> void
|
11
|
+
def alias: (user_id: String user_id, previous_id: String previous_id, ?options: Itly::Plugin::Mixpanel::AliasOptions? options) -> void
|
12
|
+
def id: () -> String
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def initialize: (project_token: String project_token, ?disabled: bool disabled) -> void
|
17
|
+
def enabled?: () -> bool
|
18
|
+
end
|
19
|
+
end
|
data/sig/options.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: itly-plugin-mixpanel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Iteratively
|
8
|
+
- Benjamin Bouchet
|
9
|
+
- Justin Fiedler
|
10
|
+
- Andrey Sokolov
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
date: 2021-06-15 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: itly-sdk
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - "~>"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0.1'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.1'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: mixpanel-ruby
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - "~>"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '2.2'
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.2'
|
44
|
+
description: Track and validate analytics with a unified, extensible interface that
|
45
|
+
works with all your 3rd party analytics providers.
|
46
|
+
email:
|
47
|
+
- support@iterative.ly
|
48
|
+
executables: []
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- ".rspec"
|
53
|
+
- Gemfile
|
54
|
+
- Steepfile
|
55
|
+
- bin/console
|
56
|
+
- bin/rspec
|
57
|
+
- bin/setup
|
58
|
+
- itly-plugin-mixpanel.gemspec
|
59
|
+
- lib/itly/plugin-mixpanel.rb
|
60
|
+
- lib/itly/plugin/mixpanel/call_options.rb
|
61
|
+
- lib/itly/plugin/mixpanel/error_handler.rb
|
62
|
+
- lib/itly/plugin/mixpanel/mixpanel.rb
|
63
|
+
- lib/itly/plugin/mixpanel/options.rb
|
64
|
+
- lib/itly/plugin/mixpanel/version.rb
|
65
|
+
- sig/call_options.rbs
|
66
|
+
- sig/error_handler.rbs
|
67
|
+
- sig/lib/mixpanel_error_handler.rbs
|
68
|
+
- sig/lib/mixpanel_tracker.rbs
|
69
|
+
- sig/lib/mixpanel_tracker_people.rbs
|
70
|
+
- sig/lib/monitor_mixin.rbs
|
71
|
+
- sig/mixpanel.rbs
|
72
|
+
- sig/options.rbs
|
73
|
+
homepage: https://github.com/iterativelyhq/itly-sdk-ruby
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata:
|
77
|
+
allowed_push_host: https://rubygems.org/
|
78
|
+
homepage_uri: https://github.com/iterativelyhq/itly-sdk-ruby
|
79
|
+
source_code_uri: https://github.com/iterativelyhq/itly-sdk-ruby/plugin-mixpanel
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 2.6.0
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubygems_version: 3.0.3.1
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Mixpanel plugin for Iteratively SDK for Ruby
|
99
|
+
test_files: []
|