Class: Mpql::CLI
- Inherits:
-
Thor
- Object
- Thor
- Mpql::CLI
- Defined in:
- lib/mpql/cli.rb
Class Method Summary collapse
-
.exit_on_failure? ⇒ Boolean
Exit with non-zero status on errors.
Instance Method Summary collapse
- #cohorts ⇒ Object
- #engage ⇒ Object
- #export ⇒ Object
- #funnels ⇒ Object
- #insights ⇒ Object
- #retention ⇒ Object
- #segmentation ⇒ Object
- #version ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
Exit with non-zero status on errors
12 13 14 |
# File 'lib/mpql/cli.rb', line 12 def self.exit_on_failure? true end |
Instance Method Details
#cohorts ⇒ Object
145 146 147 148 149 150 |
# File 'lib/mpql/cli.rb', line 145 def cohorts result = client.cohorts(**optional_params) output(result) rescue Mpql::Error => e error_exit(e) end |
#engage ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/mpql/cli.rb', line 170 def engage params = optional_params(:where, :page, :session_id) distinct_ids = [:distinct_id] if distinct_ids && distinct_ids.length == 1 params[:distinct_id] = distinct_ids.first elsif distinct_ids && distinct_ids.length > 1 conditions = distinct_ids.map { |id| %(properties["$distinct_id"] == "#{id}") } where_clause = conditions.join(" or ") params[:where] = params[:where] ? "(#{params[:where]}) and (#{where_clause})" : where_clause end result = client.engage(**params) output(result) rescue Mpql::Error => e error_exit(e) end |
#export ⇒ Object
199 200 201 202 203 204 205 206 207 208 |
# File 'lib/mpql/cli.rb', line 199 def export result = client.export( event: [:event], from_date: parse_date([:from]), to_date: parse_date([:to]) ) output(result) rescue Mpql::Error => e error_exit(e) end |
#funnels ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/mpql/cli.rb', line 75 def funnels result = client.funnels( funnel_id: [:funnel_id], from_date: parse_date([:from]), to_date: parse_date([:to]), **optional_params(:on, :where, :limit) ) output(result) rescue Mpql::Error => e error_exit(e) end |
#insights ⇒ Object
125 126 127 128 129 130 131 132 133 |
# File 'lib/mpql/cli.rb', line 125 def insights result = client.insights( bookmark_id: [:bookmark_id], **optional_params ) output(result) rescue Mpql::Error => e error_exit(e) end |
#retention ⇒ Object
105 106 107 108 109 110 111 112 113 114 |
# File 'lib/mpql/cli.rb', line 105 def retention result = client.retention( from_date: parse_date([:from]), to_date: parse_date([:to]), **optional_params(:born_event, :event, :retention_type, :on, :unit, :interval) ) output(result) rescue Mpql::Error => e error_exit(e) end |
#segmentation ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/mpql/cli.rb', line 47 def segmentation result = client.segmentation( event: [:event], from_date: parse_date([:from]), to_date: parse_date([:to]), **optional_params(:on, :unit, :where, :type, :limit) ) output(result) rescue Mpql::Error => e error_exit(e) end |