Class: Posthubify::InsightsResource

Inherits:
Object
  • Object
show all
Defined in:
lib/posthubify/resources/analytics.rb

Overview

Derived insights (Node sdk .insights) — from stored history, no live platform call.

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ InsightsResource

Returns a new instance of InsightsResource.



6
7
8
# File 'lib/posthubify/resources/analytics.rb', line 6

def initialize(http)
  @http = http
end

Instance Method Details

#best_time(days: nil, platform: nil, account_id: nil) ⇒ Object

Best posting times (slots sorted by average engagement; dayOfWeek 1=Mon..7=Sun, UTC).



11
12
13
14
# File 'lib/posthubify/resources/analytics.rb', line 11

def best_time(days: nil, platform: nil, account_id: nil)
  @http.data('GET', '/analytics/best-time',
             query: { 'days' => days, 'platform' => platform, 'accountId' =>  })
end

#content_decay(days: nil, platform: nil, account_id: nil) ⇒ Object

Content lifetime curve (day buckets; avgPctOfFinal = average % reached by end of bucket).



17
18
19
20
# File 'lib/posthubify/resources/analytics.rb', line 17

def content_decay(days: nil, platform: nil, account_id: nil)
  @http.data('GET', '/analytics/content-decay',
             query: { 'days' => days, 'platform' => platform, 'accountId' =>  })
end

#post_timeline(post_id, days: nil) ⇒ Object

Daily metric timeline for a post (cumulative + delta; post_id = platform post id).



29
30
31
# File 'lib/posthubify/resources/analytics.rb', line 29

def post_timeline(post_id, days: nil)
  @http.data('GET', "/analytics/posts/#{post_id}/timeline", query: { 'days' => days })
end

#posting_frequency(days: nil, platform: nil, account_id: nil) ⇒ Object

Weekly posting frequency ↔ engagement correlation (Pearson; <2 weeks → null).



23
24
25
26
# File 'lib/posthubify/resources/analytics.rb', line 23

def posting_frequency(days: nil, platform: nil, account_id: nil)
  @http.data('GET', '/analytics/posting-frequency',
             query: { 'days' => days, 'platform' => platform, 'accountId' =>  })
end