reparty 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.5.1
2
+
3
+ - Refactor the Mixpanel report to support different types
4
+ - Add Mixpanel engagement report
5
+
1
6
  ## 0.5.0
2
7
 
3
8
  - Weekly emails (hack-ish for now...)
data/README.md CHANGED
@@ -10,7 +10,7 @@ Custom modules can be created within your app. The currently bundled modules are
10
10
 
11
11
  * ActiveRecord, including arbitrary sum/count columns
12
12
  * SendGrid
13
- * Mixpanel (just funnels for now)
13
+ * Mixpanel (funnels and engagement for now)
14
14
 
15
15
  Other modules will be added over time. This is in use in production at my company, SalesLoft,
16
16
  so focus will be on the modules that best suit our needs. Feel free to submit a pull request
@@ -0,0 +1,10 @@
1
+ <table width="100%" cellpadding="0" cellspacing="3" border="0" class="list">
2
+ <% report.engage_data.each do |person| %>
3
+ <tr>
4
+ <td><img src="<%= "http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(person["$properties"]["$email"].downcase)}?s=20&d=mm" %>" /></td>
5
+ <td align="left">
6
+ <%= person["$properties"]["$first_name"] %> <%= person["$properties"]["$last_name"] %> (<%= mail_to person["$properties"]["$email"] %>)
7
+ </td>
8
+ </tr>
9
+ <% end %>
10
+ </table>
@@ -0,0 +1,20 @@
1
+ <% (report.funnel_data.first[1]["steps"].size+1).times.each do |i| %>
2
+ <% if i == 0 %>
3
+ <thead><tr>
4
+ <th width="100"></th>
5
+ <% report.funnel_data.each do |data| %>
6
+ <th><%= Date.parse(data[0]).strftime("%b %-d") %></th>
7
+ <% end %>
8
+ </tr></thead>
9
+ <% else %>
10
+ <tr>
11
+ <% report.funnel_data.each_with_index do |data, j| %>
12
+ <% if j == 0 %><td class="first"><%= data[1]["steps"][i-1]["goal"] %></td><% end %>
13
+ <td>
14
+ <%= number_to_percentage data[1]["steps"][i-1]["step_conv_ratio"]*100, precision: 2 %>
15
+ (<%= data[1]["steps"][i-1]["count"] %>)
16
+ </td>
17
+ <% end %>
18
+ </tr>
19
+ <% end %>
20
+ <% end %>
@@ -0,0 +1,14 @@
1
+ <table width="100%" cellpadding="0" cellspacing="25" border="0">
2
+ <tr>
3
+ <td align="left">
4
+ <h3 style="margin:0"><%= report.title %></h3>
5
+ </td>
6
+ </tr>
7
+ <tr>
8
+ <td align="center">
9
+ <table class="data" cellpadding="5" cellspacing="0" border="0">
10
+ <%= render partial: "mixpanel/#{report.report}", locals:{report:report} %>
11
+ </table>
12
+ </td>
13
+ </tr>
14
+ </table>
@@ -15,6 +15,8 @@
15
15
  .data th { font-size: 14px; text-align: center; }
16
16
  .data td { font-size: 13px; text-align: center; }
17
17
  .data td.first { background-color: #ecedee; color: #666666; font-size: 11px; text-align: left; }
18
+
19
+ .list td { font-size: 13px; }
18
20
  </style>
19
21
  </head>
20
22
  <body bgcolor="#eeeeee" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
@@ -15,6 +15,8 @@
15
15
  .data th { font-size: 14px; text-align: center; }
16
16
  .data td { font-size: 13px; text-align: center; }
17
17
  .data td.first { background-color: #ecedee; color: #666666; font-size: 11px; text-align: left; }
18
+
19
+ .list td { font-size: 13px; }
18
20
  </style>
19
21
  </head>
20
22
  <body bgcolor="#eeeeee" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
@@ -6,7 +6,7 @@ require "reparty/email"
6
6
  require "reparty/report"
7
7
  require "reparty/report/active_record"
8
8
  require "reparty/report/sendgrid"
9
- require "reparty/report/mixpanel_funnel"
9
+ require "reparty/report/mixpanel"
10
10
 
11
11
  require "reparty/engine"
12
12
 
@@ -2,21 +2,26 @@ require 'mixpanel_client'
2
2
 
3
3
  module Reparty
4
4
  class Report
5
- class MixpanelFunnel < Report
6
- attr_reader :funnel_id, :api_key, :api_secret
5
+ class Mixpanel < Report
6
+ attr_reader :api_key, :api_secret, :report
7
7
 
8
8
  def initialize(*args, &block)
9
9
  super(args.shift, args.shift)
10
10
 
11
- @funnel_id = args.shift
12
11
  @api_key = args.shift
13
12
  @api_secret = args.shift
14
13
 
14
+ @report = args.shift
15
+ case @report
16
+ when :funnel
17
+ @funnel_id = args.shift
18
+ end
19
+
15
20
  @color = "#7548a2"
16
21
  end
17
22
 
18
23
  def client
19
- @client ||= Mixpanel::Client.new({api_key: api_key, api_secret: api_secret})
24
+ @client ||= ::Mixpanel::Client.new({api_key: api_key, api_secret: api_secret})
20
25
  end
21
26
 
22
27
  def funnel_data
@@ -26,13 +31,22 @@ module Reparty
26
31
  @funnel_data ||= Hash[client.request(
27
32
  "funnels",
28
33
  {
29
- funnel_id: funnel_id,
34
+ funnel_id: @funnel_id,
30
35
  interval: interval,
31
36
  from_date: from_date,
32
37
  to_date: to_date
33
38
  }
34
39
  )["data"].sort.reverse]
35
40
  end
41
+
42
+ def engage_data
43
+ @engage_data ||= client.request(
44
+ "engage",
45
+ {
46
+ where: "properties[\"$last_seen\"] > \"#{1.day.ago.strftime("%Y-%m-%dT%H:%M:%S")}\""
47
+ }
48
+ )["results"]
49
+ end
36
50
  end
37
51
  end
38
52
  end
@@ -1,3 +1,3 @@
1
1
  module Reparty
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -142,4 +142,45 @@ http_interactions:
142
142
  1588, "steps": 2, "worst": 1}}}}'
143
143
  http_version:
144
144
  recorded_at: Wed, 19 Jun 2013 15:22:39 GMT
145
+ - request:
146
+ method: get
147
+ uri: https://mixpanel.com/api/2.0/engage?api_key=<MIXPANEL_KEY>&expire=1371678036&format=json&sig=a8b7467cf6d394ac8cd336500a55be4b&where=properties%5B%22$last_seen%22%5D%20%3E%20%222013-06-18T17:30:36%22
148
+ body:
149
+ encoding: US-ASCII
150
+ string: ''
151
+ headers:
152
+ Accept:
153
+ - ! '*/*'
154
+ User-Agent:
155
+ - Ruby
156
+ response:
157
+ status:
158
+ code: 200
159
+ message: OK
160
+ headers:
161
+ Server:
162
+ - nginx/1.1.19
163
+ Date:
164
+ - Wed, 19 Jun 2013 21:30:36 GMT
165
+ Content-Type:
166
+ - application/json
167
+ Transfer-Encoding:
168
+ - chunked
169
+ Connection:
170
+ - keep-alive
171
+ Vary:
172
+ - Accept-Encoding
173
+ Cache-Control:
174
+ - no-cache, no-store
175
+ body:
176
+ encoding: US-ASCII
177
+ string: ! '{"status":"ok","session_id":"1371677436-EHunku","page":0,"page_size":1000,"total":54,"results":[{"$distinct_id":"user.linkedin:river$3752","$properties":{"$email":"darren@radius.com","$first_name":"Darren","$last_name":"Waddell","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T14:34:48"}},{"$distinct_id":"user.linkedin:river$1143","$properties":{"$email":"bjones@keyconnections.co.za","$first_name":"Brett","$last_name":"Jones","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T08:14:40"}},{"$distinct_id":"user.linkedin:river$3735","$properties":{"$email":"ed@kentlyons.com","$first_name":"Edward","$last_name":"Smallman","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T04:59:32"}},{"$distinct_id":"user.linkedin:river$1801","$properties":{"$email":"asmoller@achieveit.com","$first_name":"Adam","$last_name":"Smoller","crm":null,"pro":false,"send_emails":false,"$last_seen":"2013-06-19T08:05:53"}},{"$distinct_id":"user.linkedin:river$3484","$properties":{"$email":"jgradt@demandforesight.com","$first_name":"June","$last_name":"Shaw","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-18T19:53:14"}},{"$distinct_id":"user.linkedin:river$3599","$properties":{"$email":"rob.forman@<SENDGRID_USER>.com","$first_name":"Rob","$last_name":"Forman","crm":true,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T16:19:21"}},{"$distinct_id":"user.linkedin:river$3733","$properties":{"$email":"jaci@brandrusso.com","$first_name":"Jaci","$last_name":"Russo","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T00:40:06"}},{"$distinct_id":"user.linkedin:river$3756","$properties":{"$email":"audrey.brasuell@cbeyond.com","$first_name":"Audrey","$last_name":"Brasuell","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T15:42:54"}},{"$distinct_id":"user.linkedin:river$3743","$properties":{"$email":"e.rideout@ehrideout.com","$first_name":"Earl
178
+ H.","$last_name":"Rideout","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T10:15:49"}},{"$distinct_id":"user.linkedin:river$3489","$properties":{"$email":"rmadden@sibex.com","$first_name":"Robert","$last_name":"Madden","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T08:27:14"}},{"$distinct_id":"user.linkedin:river$2051","$properties":{"$email":"cdavis@hornsolutions.net","$first_name":"Cyndy","$last_name":"Davis
179
+ SPHR (281-207-7702)","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-18T17:43:13"}},{"$distinct_id":"user.linkedin:river$3051","$properties":{"$email":"brandt@launchleads.com","$first_name":"Brandt
180
+ ''Bubba''","$last_name":"Page","crm":true,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T08:42:55"}},{"$distinct_id":"user.linkedin:river$3737","$properties":{"$email":"linkedin3@<SENDGRID_USER>.com","$first_name":"K","$last_name":"P","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T09:20:08"}},{"$distinct_id":"user.linkedin:river$1809","$properties":{"$email":"chris.heaton@engeniusmicro.com","$first_name":"Chris","$last_name":"Heaton","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T08:05:53"}},{"$distinct_id":"user.linkedin:river$580","$properties":{"$email":"wpridgen@mdigroup.com","$first_name":"Windham","$last_name":"Pridgen","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T11:21:03"}},{"$distinct_id":"user.linkedin:river$3704","$properties":{"$email":"bbornancin@fathomdelivers.com","$first_name":"Brandon","$last_name":"Bornancin","crm":true,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T08:10:03"}},{"$distinct_id":"user.linkedin:river$115","$properties":{"$email":"athaker@neomarketing.com","$first_name":"Anand","$last_name":"Thaker","crm":true,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T11:05:03"}},{"$distinct_id":"user.linkedin:river$3673","$properties":{"$email":"jon@thegood.com","$first_name":"Jon","$last_name":"MacDonald","crm":true,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T12:24:46"}},{"$distinct_id":"user.linkedin:river$3425","$properties":{"$email":"pat.piket@salesintegrity.com","$first_name":"Patrick","$last_name":"Piket","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T11:37:25"}},{"$distinct_id":"user.linkedin:river$3708","$properties":{"$email":"linman@liaison.com","$first_name":"Lyndsey","$last_name":"Inman","crm":true,"pro":true,"send_emails":true,"$last_seen":"2013-06-19T15:55:32"}},{"$distinct_id":"user.linkedin:river$3739","$properties":{"$email":"ruths@energistuk.co.uk","$first_name":"Ruth","$last_name":"Savage","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T07:47:24"}},{"$distinct_id":"user.linkedin:river$808","$properties":{"$email":"luke.miller@oracle.com","$first_name":"Luke","$last_name":"Miller","crm":null,"pro":false,"send_emails":false,"$last_seen":"2013-06-19T12:06:15"}},{"$distinct_id":"user.linkedin:river$3749","$properties":{"$email":"krishna@intonenetworks.com","$first_name":"KRISHNA","$last_name":"NELLUTLA","crm":false,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T14:00:05"}},{"$distinct_id":"user.linkedin:river$71","$properties":{"$email":"reubeno@anteogroup.com","$first_name":"Reuben","$last_name":"Obaidullah","crm":true,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T08:08:56"}},{"$distinct_id":"user.linkedin:river$841","$properties":{"$email":"mmatsuoka@corus360.com","$first_name":"Maclane","$last_name":"Matsuoka","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T09:46:45"}},{"$distinct_id":"user.linkedin:river$3740","$properties":{"$email":"jsterns@insitemanagedsolutions.com","$first_name":"Jason","$last_name":"Sterns","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T11:55:10"}},{"$distinct_id":"user.linkedin:river$3758","$properties":{"$email":"pschnelle@stackoverflow.com","$first_name":"Peter","$last_name":"Schnelle","crm":true,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T16:32:29"}},{"$distinct_id":"user.linkedin:river$3742","$properties":{"$email":"frank.villarroel1@randstadusa.com","$first_name":"Frank","$last_name":"Villarroel","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T10:03:35"}},{"$distinct_id":"user.linkedin:river$70","$properties":{"$email":"vmayers@anteogroup.com","$first_name":"Vincent","$last_name":"Mayers","crm":true,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T08:07:18"}},{"$distinct_id":"user.linkedin:river$3730","$properties":{"$email":"glehman@hornsolutions.net","$first_name":"Gary","$last_name":"Lehman","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T01:09:16"}},{"$distinct_id":"user.linkedin:river$3380","$properties":{"$email":"william@bitium.com","$first_name":"William","$last_name":"McCullough","crm":true,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T11:18:43"}},{"$distinct_id":"user.linkedin:river$3736","$properties":{"$email":"peter@voluntarybenefitprograms.com","$first_name":"Peter","$last_name":"Toth","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T07:25:12"}},{"$distinct_id":"user.linkedin:river$3741","$properties":{"$email":"alex@dynamicsignal.com","$first_name":"Alex","$last_name":"Cramer","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T09:57:29"}},{"$distinct_id":"user.linkedin:river$2254","$properties":{"$email":"mwolffe@bullhorn.com","$first_name":"Michael","$last_name":"Wolffe","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T09:18:21"}},{"$distinct_id":"user.linkedin:river$2278","$properties":{"$email":"ehirsh@anteogroup.com","$first_name":"Evin","$last_name":"Hirsh","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T09:21:37"}},{"$distinct_id":"user.linkedin:river$3757","$properties":{"$email":"ely@elyrosenstock.com","$first_name":"Ely","$last_name":"Rosenstock","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T16:09:09"}},{"$distinct_id":"user.linkedin:river$3100","$properties":{"$email":"kyle@<SENDGRID_USER>.com","$first_name":"Kyle","$last_name":"Porter","crm":true,"pro":true,"send_emails":true,"$last_seen":"2013-06-19T16:32:28"}},{"$distinct_id":"user.linkedin:river$3753","$properties":{"$email":"jredlus@argyleforum.com","$first_name":"Jason","$last_name":"Redlus","crm":true,"pro":true,"send_emails":true,"$last_seen":"2013-06-19T16:26:44"}},{"$distinct_id":"user.linkedin:river$1270","$properties":{"$email":"terristark@technisource.com","$first_name":"Terri","$last_name":"Stark","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T10:42:10"}},{"$distinct_id":"user.linkedin:river$3751","$properties":{"$email":"cmaultsby@pardot.com","$first_name":"Carrie","$last_name":"Maultsby,
181
+ MBA","crm":true,"pro":true,"send_emails":true,"$last_seen":"2013-06-19T14:34:09"}},{"$distinct_id":"user.linkedin:river$3738","$properties":{"$email":"adrienneh@energistuk.co.uk","$first_name":"Adrienne","$last_name":"Harries","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T07:41:59"}},{"$distinct_id":"user.linkedin:river$3744","$properties":{"$email":"kevin.pagan@randstadusa.com","$first_name":"Kevin","$last_name":"Pagan","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T10:35:16"}},{"$distinct_id":"user.linkedin:river$3727","$properties":{"$email":"sandy.frisch@pccwteleservices.com","$first_name":"Sandy","$last_name":"Frisch","crm":true,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T16:25:29"}},{"$distinct_id":"user.linkedin:river$121","$properties":{"$email":"charles@charleslumpkin.com","$first_name":"Charles","$last_name":"Lumpkin","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T17:28:44"}},{"$distinct_id":"user.linkedin:river$3750","$properties":{"$email":"joe.rhoton@genpact.com","$first_name":"Joe","$last_name":"Rhoton","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T14:25:49"}},{"$distinct_id":"user.linkedin:river$160","$properties":{"$email":"guy.swain@questus.ca","$first_name":"Guy
182
+ D.","$last_name":"Swain","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T13:24:56"}},{"$distinct_id":"user.linkedin:river$3732","$properties":{"$email":"ian_gallagher@onesource.com","$first_name":"Ian","$last_name":"Gallagher","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T06:18:20"}},{"$distinct_id":"user.linkedin:river$602","$properties":{"$email":"dbankmann@cigital.com","$first_name":"Dan","$last_name":"Bankmann","crm":true,"pro":true,"send_emails":true,"$last_seen":"2013-06-19T14:49:40"}},{"$distinct_id":"user.linkedin:river$3748","$properties":{"$email":"lauren.reese@readytalk.com","$first_name":"Lauren","$last_name":"Reese,
183
+ MBA","crm":true,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T13:10:06"}},{"$distinct_id":"user.linkedin:river$317","$properties":{"$email":"j_cohane@yahoo.com","$first_name":"James","$last_name":"Cohane","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T09:41:17"}},{"$distinct_id":"user.linkedin:river$3747","$properties":{"$email":"bcampbell@mergeagency.com","$first_name":"Brent","$last_name":"Campbell","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T11:58:31"}},{"$distinct_id":"user.linkedin:river$3243","$properties":{"$email":"dmurphy@directworks.com","$first_name":"Dan","$last_name":"Murphy","crm":true,"pro":true,"send_emails":true,"$last_seen":"2013-06-19T08:44:07"}},{"$distinct_id":"user.linkedin:river$3734","$properties":{"$email":"pratik.shevade@euromonitor.com","$first_name":"Pratik","$last_name":"Shevade","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T06:34:05"}},{"$distinct_id":"user.linkedin:river$462","$properties":{"$email":"nkristy@preparis.com","$first_name":"Nate","$last_name":"Kristy","crm":null,"pro":false,"send_emails":true,"$last_seen":"2013-06-19T07:24:15"}}]}'
184
+ http_version:
185
+ recorded_at: Wed, 19 Jun 2013 21:30:36 GMT
145
186
  recorded_with: VCR 2.4.0
@@ -4,20 +4,20 @@ interval_matcher = lambda do |request_made, request_stored|
4
4
  CGI.parse(URI(request_made.uri).query).fetch("interval",nil) == CGI.parse(URI(request_stored.uri).query).fetch("interval",nil)
5
5
  end
6
6
 
7
- describe Reparty::Report::MixpanelFunnel, vcr: { cassette_name: "mixpanel", match_requests_on: [:method, :host, :path, interval_matcher] } do
7
+ describe Reparty::Report::Mixpanel, vcr: { cassette_name: "mixpanel", match_requests_on: [:method, :host, :path, interval_matcher] } do
8
8
  let(:funnel_id) { ENV.fetch("MIXPANEL_FUNNEL", 123456) }
9
9
  let(:mixpanel_key) { ENV.fetch("MIXPANEL_KEY", "abc123") }
10
10
  let(:mixpanel_secret) { ENV.fetch("MIXPANEL_SECRET", "cba321") }
11
11
 
12
12
  subject do
13
13
  Reparty.config do |config|
14
- config.add_report Reparty::Report::MixpanelFunnel, "Mixpanel Funnel", funnel_id, mixpanel_key, mixpanel_secret
14
+ config.add_report Reparty::Report::Mixpanel, "Mixpanel Funnel", mixpanel_key, mixpanel_secret, :funnel, funnel_id
15
15
  end
16
16
  Reparty.reports.last
17
17
  end
18
18
 
19
- it { should be_kind_of(Reparty::Report::MixpanelFunnel) }
20
- its(:funnel_id) { should == funnel_id }
19
+ it { should be_kind_of(Reparty::Report::Mixpanel) }
20
+ its(:report) { should == :funnel }
21
21
  its(:api_key) { should == mixpanel_key }
22
22
  its(:api_secret) { should == mixpanel_secret }
23
23
  its(:color) { should == "#7548a2" }
@@ -25,14 +25,25 @@ describe Reparty::Report::MixpanelFunnel, vcr: { cassette_name: "mixpanel", matc
25
25
 
26
26
  its("funnel_data.size") { should == 7 }
27
27
 
28
- describe "weekly interval" do
28
+ describe "weekly interval support" do
29
29
  subject do
30
30
  Reparty.config do |config|
31
- config.add_weekly_report Reparty::Report::MixpanelFunnel, "Mixpanel Funnel", funnel_id, mixpanel_key, mixpanel_secret
31
+ config.add_weekly_report Reparty::Report::Mixpanel, "Mixpanel Funnel", mixpanel_key, mixpanel_secret, :funnel, funnel_id
32
32
  end
33
33
  Reparty.weekly_reports.last
34
34
  end
35
35
 
36
36
  its("funnel_data.size") { should == 7 }
37
37
  end
38
+
39
+ describe "engagement report" do
40
+ subject do
41
+ Reparty.config do |config|
42
+ config.add_weekly_report Reparty::Report::Mixpanel, "Mixpanel Funnel", mixpanel_key, mixpanel_secret, :engage
43
+ end
44
+ Reparty.weekly_reports.last
45
+ end
46
+
47
+ its("engage_data.size") { should == 54 }
48
+ end
38
49
  end
@@ -42,7 +42,8 @@ describe "reparty:email" do
42
42
  ].each{|u| User.create!(u) }
43
43
 
44
44
  Reparty.config do |config|
45
- config.add_report Reparty::Report::MixpanelFunnel, "Mixpanel Funnel", ENV["MIXPANEL_FUNNEL"], ENV["MIXPANEL_KEY"], ENV["MIXPANEL_SECRET"]
45
+ config.add_report Reparty::Report::Mixpanel, "Mixpanel Engagement", ENV["MIXPANEL_KEY"], ENV["MIXPANEL_SECRET"], :engage
46
+ config.add_report Reparty::Report::Mixpanel, "Mixpanel Funnel", ENV["MIXPANEL_KEY"], ENV["MIXPANEL_SECRET"], :funnel, ENV["MIXPANEL_FUNNEL"]
46
47
  config.add_report Reparty::Report::ActiveRecord, "New User Signups", :user
47
48
  config.add_report Reparty::Report::Sendgrid, "Sendgrid Emails", ENV["SENDGRID_USER"], ENV["SENDGRID_PASSWORD"]
48
49
  end
@@ -81,7 +82,7 @@ describe "reparty:weekly_email" do
81
82
  ActionMailer::Base.delivery_method = :letter_opener
82
83
 
83
84
  Reparty.config do |config|
84
- config.add_weekly_report Reparty::Report::MixpanelFunnel, "Mixpanel Funnel", ENV["MIXPANEL_FUNNEL"], ENV["MIXPANEL_KEY"], ENV["MIXPANEL_SECRET"]
85
+ config.add_weekly_report Reparty::Report::Mixpanel, "Mixpanel Funnel", ENV["MIXPANEL_KEY"], ENV["MIXPANEL_SECRET"], :funnel, ENV["MIXPANEL_FUNNEL"]
85
86
  end
86
87
 
87
88
  subject.invoke("test@test.com")
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: reparty
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.0
5
+ version: 0.5.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Tim Dorr
@@ -269,8 +269,10 @@ files:
269
269
  - Rakefile
270
270
  - app/assets/images/spacer.gif
271
271
  - app/mailers/report_mailer.rb
272
+ - app/views/mixpanel/_engage.html.erb
273
+ - app/views/mixpanel/_funnel.html.erb
272
274
  - app/views/report_mailer/_active_record.html.erb
273
- - app/views/report_mailer/_mixpanel_funnel.html.erb
275
+ - app/views/report_mailer/_mixpanel.html.erb
274
276
  - app/views/report_mailer/_sendgrid.html.erb
275
277
  - app/views/report_mailer/daily.html.erb
276
278
  - app/views/report_mailer/weekly.html.erb
@@ -280,7 +282,7 @@ files:
280
282
  - lib/reparty/engine.rb
281
283
  - lib/reparty/report.rb
282
284
  - lib/reparty/report/active_record.rb
283
- - lib/reparty/report/mixpanel_funnel.rb
285
+ - lib/reparty/report/mixpanel.rb
284
286
  - lib/reparty/report/sendgrid.rb
285
287
  - lib/reparty/version.rb
286
288
  - lib/tasks/reparty.rake
@@ -290,7 +292,7 @@ files:
290
292
  - spec/email_spec.rb
291
293
  - spec/reparty_spec.rb
292
294
  - spec/report/active_record_spec.rb
293
- - spec/report/mixpanel_funnel_spec.rb
295
+ - spec/report/mixpanel_spec.rb
294
296
  - spec/report/sendgrid_spec.rb
295
297
  - spec/report_spec.rb
296
298
  - spec/spec_helper.rb
@@ -310,7 +312,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
310
312
  - !ruby/object:Gem::Version
311
313
  segments:
312
314
  - 0
313
- hash: 1358861647946779491
315
+ hash: -1842516575616401576
314
316
  version: '0'
315
317
  none: false
316
318
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -319,7 +321,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
319
321
  - !ruby/object:Gem::Version
320
322
  segments:
321
323
  - 0
322
- hash: 1358861647946779491
324
+ hash: -1842516575616401576
323
325
  version: '0'
324
326
  none: false
325
327
  requirements: []
@@ -334,7 +336,7 @@ test_files:
334
336
  - spec/email_spec.rb
335
337
  - spec/reparty_spec.rb
336
338
  - spec/report/active_record_spec.rb
337
- - spec/report/mixpanel_funnel_spec.rb
339
+ - spec/report/mixpanel_spec.rb
338
340
  - spec/report/sendgrid_spec.rb
339
341
  - spec/report_spec.rb
340
342
  - spec/spec_helper.rb
@@ -1,33 +0,0 @@
1
- <table width="100%" cellpadding="0" cellspacing="25" border="0">
2
- <tr>
3
- <td align="left">
4
- <h3 style="margin:0"><%= report.title %></h3>
5
- </td>
6
- </tr>
7
- <tr>
8
- <td align="center">
9
- <table class="data" cellpadding="5" cellspacing="0" border="0">
10
- <% (report.funnel_data.first[1]["steps"].size+1).times.each do |i| %>
11
- <% if i == 0 %>
12
- <thead><tr>
13
- <th width="100"></th>
14
- <% report.funnel_data.each do |data| %>
15
- <th><%= Date.parse(data[0]).strftime("%b %-d") %></th>
16
- <% end %>
17
- </tr></thead>
18
- <% else %>
19
- <tr>
20
- <% report.funnel_data.each_with_index do |data, j| %>
21
- <% if j == 0 %><td class="first"><%= data[1]["steps"][i-1]["goal"] %></td><% end %>
22
- <td>
23
- <%= number_to_percentage data[1]["steps"][i-1]["step_conv_ratio"]*100, precision: 2 %>
24
- (<%= data[1]["steps"][i-1]["count"] %>)
25
- </td>
26
- <% end %>
27
- </tr>
28
- <% end %>
29
- <% end %>
30
- </table>
31
- </td>
32
- </tr>
33
- </table>