Adding upstream version 1.34.4.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
e393c3af3f
commit
4978089aab
4963 changed files with 677545 additions and 0 deletions
80
plugins/inputs/mailchimp/README.md
Normal file
80
plugins/inputs/mailchimp/README.md
Normal file
|
@ -0,0 +1,80 @@
|
|||
# Mailchimp Input Plugin
|
||||
|
||||
This plugin gathers metrics from the [Mailchimp][mailchimp] service using the
|
||||
[Mailchimp API][api].
|
||||
|
||||
⭐ Telegraf v0.2.4
|
||||
🏷️ cloud, web
|
||||
💻 all
|
||||
|
||||
[mailchimp]: https://mailchimp.com
|
||||
[api]: https://developer.mailchimp.com/
|
||||
|
||||
## Global configuration options <!-- @/docs/includes/plugin_config.md -->
|
||||
|
||||
In addition to the plugin-specific configuration settings, plugins support
|
||||
additional global and plugin configuration settings. These settings are used to
|
||||
modify metrics, tags, and field or create aliases and configure ordering, etc.
|
||||
See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
||||
|
||||
[CONFIGURATION.md]: ../../../docs/CONFIGURATION.md#plugins
|
||||
|
||||
## Configuration
|
||||
|
||||
```toml @sample.conf
|
||||
# Gathers metrics from the /3.0/reports MailChimp API
|
||||
[[inputs.mailchimp]]
|
||||
## MailChimp API key
|
||||
## get from https://admin.mailchimp.com/account/api/
|
||||
api_key = "" # required
|
||||
|
||||
## Reports for campaigns sent more than days_old ago will not be collected.
|
||||
## 0 means collect all and is the default value.
|
||||
days_old = 0
|
||||
|
||||
## Campaign ID to get, if empty gets all campaigns, this option overrides days_old
|
||||
# campaign_id = ""
|
||||
```
|
||||
|
||||
## Metrics
|
||||
|
||||
- mailchimp
|
||||
- tags:
|
||||
- id
|
||||
- campaign_title
|
||||
- fields:
|
||||
- emails_sent (integer, emails)
|
||||
- abuse_reports (integer, reports)
|
||||
- unsubscribed (integer, unsubscribes)
|
||||
- hard_bounces (integer, emails)
|
||||
- soft_bounces (integer, emails)
|
||||
- syntax_errors (integer, errors)
|
||||
- forwards_count (integer, emails)
|
||||
- forwards_opens (integer, emails)
|
||||
- opens_total (integer, emails)
|
||||
- unique_opens (integer, emails)
|
||||
- open_rate (double, percentage)
|
||||
- clicks_total (integer, clicks)
|
||||
- unique_clicks (integer, clicks)
|
||||
- unique_subscriber_clicks (integer, clicks)
|
||||
- click_rate (double, percentage)
|
||||
- facebook_recipient_likes (integer, likes)
|
||||
- facebook_unique_likes (integer, likes)
|
||||
- facebook_likes (integer, likes)
|
||||
- industry_type (string, type)
|
||||
- industry_open_rate (double, percentage)
|
||||
- industry_click_rate (double, percentage)
|
||||
- industry_bounce_rate (double, percentage)
|
||||
- industry_unopen_rate (double, percentage)
|
||||
- industry_unsub_rate (double, percentage)
|
||||
- industry_abuse_rate (double, percentage)
|
||||
- list_stats_sub_rate (double, percentage)
|
||||
- list_stats_unsub_rate (double, percentage)
|
||||
- list_stats_open_rate (double, percentage)
|
||||
- list_stats_click_rate (double, percentage)
|
||||
|
||||
## Example Output
|
||||
|
||||
```text
|
||||
mailchimp,campaign_title=Freddie's\ Jokes\ Vol.\ 1,id=42694e9e57 abuse_reports=0i,click_rate=42,clicks_total=42i,emails_sent=200i,facebook_likes=42i,facebook_recipient_likes=5i,facebook_unique_likes=8i,forwards_count=0i,forwards_opens=0i,hard_bounces=0i,industry_abuse_rate=0.00021111996110887,industry_bounce_rate=0.0063767751251474,industry_click_rate=0.027431311866951,industry_open_rate=0.17076777144396,industry_type="Social Networks and Online Communities",industry_unopen_rate=0.82285545343089,industry_unsub_rate=0.001436957032815,list_stats_click_rate=42,list_stats_open_rate=42,list_stats_sub_rate=10,list_stats_unsub_rate=20,open_rate=42,opens_total=186i,soft_bounces=2i,syntax_errors=0i,unique_clicks=400i,unique_opens=100i,unique_subscriber_clicks=42i,unsubscribed=2i 1741188555526302348
|
||||
```
|
248
plugins/inputs/mailchimp/chimp_api.go
Normal file
248
plugins/inputs/mailchimp/chimp_api.go
Normal file
|
@ -0,0 +1,248 @@
|
|||
package mailchimp
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
)
|
||||
|
||||
const (
|
||||
reportsEndpoint string = "/3.0/reports"
|
||||
reportsEndpointCampaign string = "/3.0/reports/%s"
|
||||
)
|
||||
|
||||
var mailchimpDatacenter = regexp.MustCompile("[a-z]+[0-9]+$")
|
||||
|
||||
type chimpAPI struct {
|
||||
transport http.RoundTripper
|
||||
debug bool
|
||||
|
||||
sync.Mutex
|
||||
|
||||
url *url.URL
|
||||
log telegraf.Logger
|
||||
}
|
||||
|
||||
type reportsParams struct {
|
||||
count string
|
||||
offset string
|
||||
sinceSendTime string
|
||||
beforeSendTime string
|
||||
}
|
||||
|
||||
func (p *reportsParams) String() string {
|
||||
v := url.Values{}
|
||||
if p.count != "" {
|
||||
v.Set("count", p.count)
|
||||
}
|
||||
if p.offset != "" {
|
||||
v.Set("offset", p.offset)
|
||||
}
|
||||
if p.beforeSendTime != "" {
|
||||
v.Set("before_send_time", p.beforeSendTime)
|
||||
}
|
||||
if p.sinceSendTime != "" {
|
||||
v.Set("since_send_time", p.sinceSendTime)
|
||||
}
|
||||
return v.Encode()
|
||||
}
|
||||
|
||||
func newChimpAPI(apiKey string, log telegraf.Logger) *chimpAPI {
|
||||
u := &url.URL{}
|
||||
u.Scheme = "https"
|
||||
u.Host = mailchimpDatacenter.FindString(apiKey) + ".api.mailchimp.com"
|
||||
u.User = url.UserPassword("", apiKey)
|
||||
return &chimpAPI{url: u, log: log}
|
||||
}
|
||||
|
||||
type apiError struct {
|
||||
Status int `json:"status"`
|
||||
Type string `json:"type"`
|
||||
Title string `json:"title"`
|
||||
Detail string `json:"detail"`
|
||||
Instance string `json:"instance"`
|
||||
}
|
||||
|
||||
func (e apiError) Error() string {
|
||||
return fmt.Sprintf("ERROR %v: %v. See %v", e.Status, e.Title, e.Type)
|
||||
}
|
||||
|
||||
func chimpErrorCheck(body []byte) error {
|
||||
var e apiError
|
||||
if err := json.Unmarshal(body, &e); err != nil {
|
||||
return err
|
||||
}
|
||||
if e.Title != "" || e.Status != 0 {
|
||||
return e
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *chimpAPI) getReports(params reportsParams) (reportsResponse, error) {
|
||||
a.Lock()
|
||||
defer a.Unlock()
|
||||
a.url.Path = reportsEndpoint
|
||||
|
||||
var response reportsResponse
|
||||
rawjson, err := a.runChimp(params)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(rawjson, &response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (a *chimpAPI) getReport(campaignID string) (report, error) {
|
||||
a.Lock()
|
||||
defer a.Unlock()
|
||||
a.url.Path = fmt.Sprintf(reportsEndpointCampaign, campaignID)
|
||||
|
||||
var response report
|
||||
rawjson, err := a.runChimp(reportsParams{})
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(rawjson, &response)
|
||||
if err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (a *chimpAPI) runChimp(params reportsParams) ([]byte, error) {
|
||||
client := &http.Client{
|
||||
Transport: a.transport,
|
||||
Timeout: 4 * time.Second,
|
||||
}
|
||||
|
||||
var b bytes.Buffer
|
||||
req, err := http.NewRequest("GET", a.url.String(), &b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.URL.RawQuery = params.String()
|
||||
req.Header.Set("User-Agent", "Telegraf-MailChimp-Plugin")
|
||||
if a.debug {
|
||||
a.log.Debugf("request URL: %s", req.URL.String())
|
||||
}
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
//nolint:errcheck // LimitReader returns io.EOF and we're not interested in read errors.
|
||||
body, _ := io.ReadAll(io.LimitReader(resp.Body, 200))
|
||||
return nil, fmt.Errorf("%s returned HTTP status %s: %q", a.url.String(), resp.Status, body)
|
||||
}
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if a.debug {
|
||||
a.log.Debugf("response Body: %q", string(body))
|
||||
}
|
||||
|
||||
if err := chimpErrorCheck(body); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return body, nil
|
||||
}
|
||||
|
||||
type reportsResponse struct {
|
||||
Reports []report `json:"reports"`
|
||||
TotalItems int `json:"total_items"`
|
||||
}
|
||||
|
||||
type report struct {
|
||||
ID string `json:"id"`
|
||||
CampaignTitle string `json:"campaign_title"`
|
||||
Type string `json:"type"`
|
||||
EmailsSent int `json:"emails_sent"`
|
||||
AbuseReports int `json:"abuse_reports"`
|
||||
Unsubscribed int `json:"unsubscribed"`
|
||||
SendTime string `json:"send_time"`
|
||||
|
||||
TimeSeries []timeSeries
|
||||
Bounces bounces `json:"bounces"`
|
||||
Forwards forwards `json:"forwards"`
|
||||
Opens opens `json:"opens"`
|
||||
Clicks clicks `json:"clicks"`
|
||||
FacebookLikes facebookLikes `json:"facebook_likes"`
|
||||
IndustryStats industryStats `json:"industry_stats"`
|
||||
ListStats listStats `json:"list_stats"`
|
||||
}
|
||||
|
||||
type bounces struct {
|
||||
HardBounces int `json:"hard_bounces"`
|
||||
SoftBounces int `json:"soft_bounces"`
|
||||
SyntaxErrors int `json:"syntax_errors"`
|
||||
}
|
||||
|
||||
type forwards struct {
|
||||
ForwardsCount int `json:"forwards_count"`
|
||||
ForwardsOpens int `json:"forwards_opens"`
|
||||
}
|
||||
|
||||
type opens struct {
|
||||
OpensTotal int `json:"opens_total"`
|
||||
UniqueOpens int `json:"unique_opens"`
|
||||
OpenRate float64 `json:"open_rate"`
|
||||
LastOpen string `json:"last_open"`
|
||||
}
|
||||
|
||||
type clicks struct {
|
||||
ClicksTotal int `json:"clicks_total"`
|
||||
UniqueClicks int `json:"unique_clicks"`
|
||||
UniqueSubscriberClicks int `json:"unique_subscriber_clicks"`
|
||||
ClickRate float64 `json:"click_rate"`
|
||||
LastClick string `json:"last_click"`
|
||||
}
|
||||
|
||||
type facebookLikes struct {
|
||||
RecipientLikes int `json:"recipient_likes"`
|
||||
UniqueLikes int `json:"unique_likes"`
|
||||
FacebookLikes int `json:"facebook_likes"`
|
||||
}
|
||||
|
||||
type industryStats struct {
|
||||
Type string `json:"type"`
|
||||
OpenRate float64 `json:"open_rate"`
|
||||
ClickRate float64 `json:"click_rate"`
|
||||
BounceRate float64 `json:"bounce_rate"`
|
||||
UnopenRate float64 `json:"unopen_rate"`
|
||||
UnsubRate float64 `json:"unsub_rate"`
|
||||
AbuseRate float64 `json:"abuse_rate"`
|
||||
}
|
||||
|
||||
type listStats struct {
|
||||
SubRate float64 `json:"sub_rate"`
|
||||
UnsubRate float64 `json:"unsub_rate"`
|
||||
OpenRate float64 `json:"open_rate"`
|
||||
ClickRate float64 `json:"click_rate"`
|
||||
}
|
||||
|
||||
type timeSeries struct {
|
||||
TimeStamp string `json:"timestamp"`
|
||||
EmailsSent int `json:"emails_sent"`
|
||||
UniqueOpens int `json:"unique_opens"`
|
||||
RecipientsClick int `json:"recipients_click"`
|
||||
}
|
112
plugins/inputs/mailchimp/mailchimp.go
Normal file
112
plugins/inputs/mailchimp/mailchimp.go
Normal file
|
@ -0,0 +1,112 @@
|
|||
//go:generate ../../../tools/readme_config_includer/generator
|
||||
package mailchimp
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/influxdata/telegraf/plugins/inputs"
|
||||
)
|
||||
|
||||
//go:embed sample.conf
|
||||
var sampleConfig string
|
||||
|
||||
type MailChimp struct {
|
||||
APIKey string `toml:"api_key"`
|
||||
DaysOld int `toml:"days_old"`
|
||||
CampaignID string `toml:"campaign_id"`
|
||||
Log telegraf.Logger `toml:"-"`
|
||||
|
||||
api *chimpAPI
|
||||
}
|
||||
|
||||
func (*MailChimp) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
||||
func (m *MailChimp) Init() error {
|
||||
m.api = newChimpAPI(m.APIKey, m.Log)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MailChimp) Gather(acc telegraf.Accumulator) error {
|
||||
if m.CampaignID == "" {
|
||||
since := ""
|
||||
if m.DaysOld > 0 {
|
||||
now := time.Now()
|
||||
d, err := time.ParseDuration(fmt.Sprintf("%dh", 24*m.DaysOld))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
since = now.Add(-d).Format(time.RFC3339)
|
||||
}
|
||||
|
||||
reports, err := m.api.getReports(reportsParams{
|
||||
sinceSendTime: since,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
now := time.Now()
|
||||
|
||||
for _, report := range reports.Reports {
|
||||
gatherReport(acc, report, now)
|
||||
}
|
||||
} else {
|
||||
report, err := m.api.getReport(m.CampaignID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
now := time.Now()
|
||||
gatherReport(acc, report, now)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func gatherReport(acc telegraf.Accumulator, report report, now time.Time) {
|
||||
tags := make(map[string]string)
|
||||
tags["id"] = report.ID
|
||||
tags["campaign_title"] = report.CampaignTitle
|
||||
fields := map[string]interface{}{
|
||||
"emails_sent": report.EmailsSent,
|
||||
"abuse_reports": report.AbuseReports,
|
||||
"unsubscribed": report.Unsubscribed,
|
||||
"hard_bounces": report.Bounces.HardBounces,
|
||||
"soft_bounces": report.Bounces.SoftBounces,
|
||||
"syntax_errors": report.Bounces.SyntaxErrors,
|
||||
"forwards_count": report.Forwards.ForwardsCount,
|
||||
"forwards_opens": report.Forwards.ForwardsOpens,
|
||||
"opens_total": report.Opens.OpensTotal,
|
||||
"unique_opens": report.Opens.UniqueOpens,
|
||||
"open_rate": report.Opens.OpenRate,
|
||||
"clicks_total": report.Clicks.ClicksTotal,
|
||||
"unique_clicks": report.Clicks.UniqueClicks,
|
||||
"unique_subscriber_clicks": report.Clicks.UniqueSubscriberClicks,
|
||||
"click_rate": report.Clicks.ClickRate,
|
||||
"facebook_recipient_likes": report.FacebookLikes.RecipientLikes,
|
||||
"facebook_unique_likes": report.FacebookLikes.UniqueLikes,
|
||||
"facebook_likes": report.FacebookLikes.FacebookLikes,
|
||||
"industry_type": report.IndustryStats.Type,
|
||||
"industry_open_rate": report.IndustryStats.OpenRate,
|
||||
"industry_click_rate": report.IndustryStats.ClickRate,
|
||||
"industry_bounce_rate": report.IndustryStats.BounceRate,
|
||||
"industry_unopen_rate": report.IndustryStats.UnopenRate,
|
||||
"industry_unsub_rate": report.IndustryStats.UnsubRate,
|
||||
"industry_abuse_rate": report.IndustryStats.AbuseRate,
|
||||
"list_stats_sub_rate": report.ListStats.SubRate,
|
||||
"list_stats_unsub_rate": report.ListStats.UnsubRate,
|
||||
"list_stats_open_rate": report.ListStats.OpenRate,
|
||||
"list_stats_click_rate": report.ListStats.ClickRate,
|
||||
}
|
||||
acc.AddFields("mailchimp", fields, tags, now)
|
||||
}
|
||||
|
||||
func init() {
|
||||
inputs.Add("mailchimp", func() telegraf.Input {
|
||||
return &MailChimp{}
|
||||
})
|
||||
}
|
788
plugins/inputs/mailchimp/mailchimp_test.go
Normal file
788
plugins/inputs/mailchimp/mailchimp_test.go
Normal file
|
@ -0,0 +1,788 @@
|
|||
package mailchimp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/influxdata/telegraf/testutil"
|
||||
)
|
||||
|
||||
func TestMailChimpGatherReports(t *testing.T) {
|
||||
ts := httptest.NewServer(
|
||||
http.HandlerFunc(
|
||||
func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
if _, err := fmt.Fprintln(w, sampleReports); err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
},
|
||||
))
|
||||
defer ts.Close()
|
||||
|
||||
u, err := url.ParseRequestURI(ts.URL)
|
||||
require.NoError(t, err)
|
||||
|
||||
api := &chimpAPI{
|
||||
url: u,
|
||||
debug: true,
|
||||
log: testutil.Logger{},
|
||||
}
|
||||
m := MailChimp{
|
||||
api: api,
|
||||
}
|
||||
|
||||
var acc testutil.Accumulator
|
||||
err = m.Gather(&acc)
|
||||
require.NoError(t, err)
|
||||
|
||||
tags := make(map[string]string)
|
||||
tags["id"] = "42694e9e57"
|
||||
tags["campaign_title"] = "Freddie's Jokes Vol. 1"
|
||||
|
||||
fields := map[string]interface{}{
|
||||
"emails_sent": 200,
|
||||
"abuse_reports": 0,
|
||||
"unsubscribed": 2,
|
||||
"hard_bounces": 0,
|
||||
"soft_bounces": 2,
|
||||
"syntax_errors": 0,
|
||||
"forwards_count": 0,
|
||||
"forwards_opens": 0,
|
||||
"opens_total": 186,
|
||||
"unique_opens": 100,
|
||||
"clicks_total": 42,
|
||||
"unique_clicks": 400,
|
||||
"unique_subscriber_clicks": 42,
|
||||
"facebook_recipient_likes": 5,
|
||||
"facebook_unique_likes": 8,
|
||||
"facebook_likes": 42,
|
||||
"open_rate": float64(42),
|
||||
"click_rate": float64(42),
|
||||
"industry_open_rate": float64(0.17076777144396),
|
||||
"industry_click_rate": float64(0.027431311866951),
|
||||
"industry_bounce_rate": float64(0.0063767751251474),
|
||||
"industry_unopen_rate": float64(0.82285545343089),
|
||||
"industry_unsub_rate": float64(0.001436957032815),
|
||||
"industry_abuse_rate": float64(0.00021111996110887),
|
||||
"list_stats_sub_rate": float64(10),
|
||||
"list_stats_unsub_rate": float64(20),
|
||||
"list_stats_open_rate": float64(42),
|
||||
"list_stats_click_rate": float64(42),
|
||||
"industry_type": "Social Networks and Online Communities",
|
||||
}
|
||||
acc.AssertContainsTaggedFields(t, "mailchimp", fields, tags)
|
||||
}
|
||||
|
||||
func TestMailChimpGatherReport(t *testing.T) {
|
||||
ts := httptest.NewServer(
|
||||
http.HandlerFunc(
|
||||
func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
if _, err := fmt.Fprintln(w, sampleReport); err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
},
|
||||
))
|
||||
defer ts.Close()
|
||||
|
||||
u, err := url.ParseRequestURI(ts.URL)
|
||||
require.NoError(t, err)
|
||||
|
||||
api := &chimpAPI{
|
||||
url: u,
|
||||
debug: true,
|
||||
log: testutil.Logger{},
|
||||
}
|
||||
m := MailChimp{
|
||||
api: api,
|
||||
CampaignID: "test",
|
||||
}
|
||||
|
||||
var acc testutil.Accumulator
|
||||
err = m.Gather(&acc)
|
||||
require.NoError(t, err)
|
||||
|
||||
tags := make(map[string]string)
|
||||
tags["id"] = "42694e9e57"
|
||||
tags["campaign_title"] = "Freddie's Jokes Vol. 1"
|
||||
|
||||
fields := map[string]interface{}{
|
||||
"emails_sent": int(200),
|
||||
"abuse_reports": int(0),
|
||||
"unsubscribed": int(2),
|
||||
"hard_bounces": int(0),
|
||||
"soft_bounces": int(2),
|
||||
"syntax_errors": int(0),
|
||||
"forwards_count": int(0),
|
||||
"forwards_opens": int(0),
|
||||
"opens_total": int(186),
|
||||
"unique_opens": int(100),
|
||||
"clicks_total": int(42),
|
||||
"unique_clicks": int(400),
|
||||
"unique_subscriber_clicks": int(42),
|
||||
"facebook_recipient_likes": int(5),
|
||||
"facebook_unique_likes": int(8),
|
||||
"facebook_likes": int(42),
|
||||
"open_rate": float64(42),
|
||||
"click_rate": float64(42),
|
||||
"industry_open_rate": float64(0.17076777144396),
|
||||
"industry_click_rate": float64(0.027431311866951),
|
||||
"industry_bounce_rate": float64(0.0063767751251474),
|
||||
"industry_unopen_rate": float64(0.82285545343089),
|
||||
"industry_unsub_rate": float64(0.001436957032815),
|
||||
"industry_abuse_rate": float64(0.00021111996110887),
|
||||
"list_stats_sub_rate": float64(10),
|
||||
"list_stats_unsub_rate": float64(20),
|
||||
"list_stats_open_rate": float64(42),
|
||||
"list_stats_click_rate": float64(42),
|
||||
"industry_type": "Social Networks and Online Communities",
|
||||
}
|
||||
acc.AssertContainsTaggedFields(t, "mailchimp", fields, tags)
|
||||
}
|
||||
|
||||
func TestMailChimpGatherError(t *testing.T) {
|
||||
ts := httptest.NewServer(
|
||||
http.HandlerFunc(
|
||||
func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
if _, err := fmt.Fprintln(w, sampleError); err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
},
|
||||
))
|
||||
defer ts.Close()
|
||||
|
||||
u, err := url.ParseRequestURI(ts.URL)
|
||||
require.NoError(t, err)
|
||||
|
||||
api := &chimpAPI{
|
||||
url: u,
|
||||
debug: true,
|
||||
log: testutil.Logger{},
|
||||
}
|
||||
m := MailChimp{
|
||||
api: api,
|
||||
CampaignID: "test",
|
||||
}
|
||||
|
||||
var acc testutil.Accumulator
|
||||
err = m.Gather(&acc)
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
var sampleReports = `
|
||||
{
|
||||
"reports": [
|
||||
{
|
||||
"id": "42694e9e57",
|
||||
"campaign_title": "Freddie's Jokes Vol. 1",
|
||||
"type": "regular",
|
||||
"emails_sent": 200,
|
||||
"abuse_reports": 0,
|
||||
"unsubscribed": 2,
|
||||
"send_time": "2015-09-15T19:05:51+00:00",
|
||||
"bounces": {
|
||||
"hard_bounces": 0,
|
||||
"soft_bounces": 2,
|
||||
"syntax_errors": 0
|
||||
},
|
||||
"forwards": {
|
||||
"forwards_count": 0,
|
||||
"forwards_opens": 0
|
||||
},
|
||||
"opens": {
|
||||
"opens_total": 186,
|
||||
"unique_opens": 100,
|
||||
"open_rate": 42,
|
||||
"last_open": "2015-09-15T19:15:47+00:00"
|
||||
},
|
||||
"clicks": {
|
||||
"clicks_total": 42,
|
||||
"unique_clicks": 400,
|
||||
"unique_subscriber_clicks": 42,
|
||||
"click_rate": 42,
|
||||
"last_click": "2015-09-15T19:15:47+00:00"
|
||||
},
|
||||
"facebook_likes": {
|
||||
"recipient_likes": 5,
|
||||
"unique_likes": 8,
|
||||
"facebook_likes": 42
|
||||
},
|
||||
"industry_stats": {
|
||||
"type": "Social Networks and Online Communities",
|
||||
"open_rate": 0.17076777144396,
|
||||
"click_rate": 0.027431311866951,
|
||||
"bounce_rate": 0.0063767751251474,
|
||||
"unopen_rate": 0.82285545343089,
|
||||
"unsub_rate": 0.001436957032815,
|
||||
"abuse_rate": 0.00021111996110887
|
||||
},
|
||||
"list_stats": {
|
||||
"sub_rate": 10,
|
||||
"unsub_rate": 20,
|
||||
"open_rate": 42,
|
||||
"click_rate": 42
|
||||
},
|
||||
"timeseries": [
|
||||
{
|
||||
"timestamp": "2015-09-15T19:00:00+00:00",
|
||||
"emails_sent": 198,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-15T20:00:00+00:00",
|
||||
"emails_sent": 2,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-15T21:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-15T22:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-15T23:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T00:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T01:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T02:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T03:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T04:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T05:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T06:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T07:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T08:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T09:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T10:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T11:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T12:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T13:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T14:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T15:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T16:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T17:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T18:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
}
|
||||
],
|
||||
"share_report": {
|
||||
"share_url": "http://usX.vip-reports.net/reports/summary?u=xxxx&id=xxxx",
|
||||
"share_password": "freddielikesjokes"
|
||||
},
|
||||
"delivery_status": {
|
||||
"enabled": false
|
||||
},
|
||||
"_links": [
|
||||
{
|
||||
"rel": "parent",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/Collection.json",
|
||||
"schema": "https://api.mailchimp.com/schema/3.0/CollectionLinks/Reports.json"
|
||||
},
|
||||
{
|
||||
"rel": "self",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/Instance.json"
|
||||
},
|
||||
{
|
||||
"rel": "campaign",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/campaigns/42694e9e57",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Campaigns/Instance.json"
|
||||
},
|
||||
{
|
||||
"rel": "sub-reports",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/sub-reports",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/Sub/Collection.json"
|
||||
},
|
||||
{
|
||||
"rel": "abuse-reports",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/abuse-reports",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/Abuse/Collection.json"
|
||||
},
|
||||
{
|
||||
"rel": "advice",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/advice",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/Advice/Collection.json"
|
||||
},
|
||||
{
|
||||
"rel": "click-details",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/click-details",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/ClickDetails/Collection.json"
|
||||
},
|
||||
{
|
||||
"rel": "domain-performance",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/domain-performance",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/DomainPerformance/Collection.json"
|
||||
},
|
||||
{
|
||||
"rel": "eepurl",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/eepurl",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/Eepurl/Collection.json"
|
||||
},
|
||||
{
|
||||
"rel": "email-activity",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/email-activity",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/EmailActivity/Collection.json"
|
||||
},
|
||||
{
|
||||
"rel": "locations",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/locations",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/Locations/Collection.json"
|
||||
},
|
||||
{
|
||||
"rel": "sent-to",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/sent-to",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/SentTo/Collection.json"
|
||||
},
|
||||
{
|
||||
"rel": "unsubscribed",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/unsubscribed",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/Unsubs/Collection.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"_links": [
|
||||
{
|
||||
"rel": "parent",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Root.json"
|
||||
},
|
||||
{
|
||||
"rel": "self",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/Collection.json",
|
||||
"schema": "https://api.mailchimp.com/schema/3.0/CollectionLinks/Reports.json"
|
||||
}
|
||||
],
|
||||
"total_items": 1
|
||||
}
|
||||
`
|
||||
|
||||
var sampleReport = `
|
||||
{
|
||||
"id": "42694e9e57",
|
||||
"campaign_title": "Freddie's Jokes Vol. 1",
|
||||
"type": "regular",
|
||||
"emails_sent": 200,
|
||||
"abuse_reports": 0,
|
||||
"unsubscribed": 2,
|
||||
"send_time": "2015-09-15T19:05:51+00:00",
|
||||
"bounces": {
|
||||
"hard_bounces": 0,
|
||||
"soft_bounces": 2,
|
||||
"syntax_errors": 0
|
||||
},
|
||||
"forwards": {
|
||||
"forwards_count": 0,
|
||||
"forwards_opens": 0
|
||||
},
|
||||
"opens": {
|
||||
"opens_total": 186,
|
||||
"unique_opens": 100,
|
||||
"open_rate": 42,
|
||||
"last_open": "2015-09-15T19:15:47+00:00"
|
||||
},
|
||||
"clicks": {
|
||||
"clicks_total": 42,
|
||||
"unique_clicks": 400,
|
||||
"unique_subscriber_clicks": 42,
|
||||
"click_rate": 42,
|
||||
"last_click": "2015-09-15T19:15:47+00:00"
|
||||
},
|
||||
"facebook_likes": {
|
||||
"recipient_likes": 5,
|
||||
"unique_likes": 8,
|
||||
"facebook_likes": 42
|
||||
},
|
||||
"industry_stats": {
|
||||
"type": "Social Networks and Online Communities",
|
||||
"open_rate": 0.17076777144396,
|
||||
"click_rate": 0.027431311866951,
|
||||
"bounce_rate": 0.0063767751251474,
|
||||
"unopen_rate": 0.82285545343089,
|
||||
"unsub_rate": 0.001436957032815,
|
||||
"abuse_rate": 0.00021111996110887
|
||||
},
|
||||
"list_stats": {
|
||||
"sub_rate": 10,
|
||||
"unsub_rate": 20,
|
||||
"open_rate": 42,
|
||||
"click_rate": 42
|
||||
},
|
||||
"timeseries": [
|
||||
{
|
||||
"timestamp": "2015-09-15T19:00:00+00:00",
|
||||
"emails_sent": 198,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-15T20:00:00+00:00",
|
||||
"emails_sent": 2,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-15T21:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-15T22:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-15T23:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T00:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T01:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T02:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T03:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T04:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T05:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T06:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T07:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T08:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T09:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T10:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T11:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T12:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T13:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T14:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T15:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T16:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T17:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
},
|
||||
{
|
||||
"timestamp": "2015-09-16T18:00:00+00:00",
|
||||
"emails_sent": 0,
|
||||
"unique_opens": 0,
|
||||
"recipients_clicks": 0
|
||||
}
|
||||
],
|
||||
"share_report": {
|
||||
"share_url": "http://usX.vip-reports.net/reports/summary?u=xxxx&id=xxxx",
|
||||
"share_password": "freddielikesjokes"
|
||||
},
|
||||
"delivery_status": {
|
||||
"enabled": false
|
||||
},
|
||||
"_links": [
|
||||
{
|
||||
"rel": "parent",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/Collection.json",
|
||||
"schema": "https://api.mailchimp.com/schema/3.0/CollectionLinks/Reports.json"
|
||||
},
|
||||
{
|
||||
"rel": "self",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/Instance.json"
|
||||
},
|
||||
{
|
||||
"rel": "campaign",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/campaigns/42694e9e57",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Campaigns/Instance.json"
|
||||
},
|
||||
{
|
||||
"rel": "sub-reports",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/sub-reports",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/Sub/Collection.json"
|
||||
},
|
||||
{
|
||||
"rel": "abuse-reports",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/abuse-reports",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/Abuse/Collection.json"
|
||||
},
|
||||
{
|
||||
"rel": "advice",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/advice",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/Advice/Collection.json"
|
||||
},
|
||||
{
|
||||
"rel": "click-details",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/click-details",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/ClickDetails/Collection.json"
|
||||
},
|
||||
{
|
||||
"rel": "domain-performance",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/domain-performance",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/DomainPerformance/Collection.json"
|
||||
},
|
||||
{
|
||||
"rel": "eepurl",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/eepurl",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/Eepurl/Collection.json"
|
||||
},
|
||||
{
|
||||
"rel": "email-activity",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/email-activity",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/EmailActivity/Collection.json"
|
||||
},
|
||||
{
|
||||
"rel": "locations",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/locations",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/Locations/Collection.json"
|
||||
},
|
||||
{
|
||||
"rel": "sent-to",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/sent-to",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/SentTo/Collection.json"
|
||||
},
|
||||
{
|
||||
"rel": "unsubscribed",
|
||||
"href": "https://usX.api.mailchimp.com/3.0/reports/42694e9e57/unsubscribed",
|
||||
"method": "GET",
|
||||
"targetSchema": "https://api.mailchimp.com/schema/3.0/Reports/Unsubs/Collection.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
`
|
||||
|
||||
var sampleError = `
|
||||
{
|
||||
"type": "http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/",
|
||||
"title": "API Key Invalid",
|
||||
"status": 401,
|
||||
"detail": "Your API key may be invalid, or you've attempted to access the wrong datacenter.",
|
||||
"instance": ""
|
||||
}
|
||||
`
|
12
plugins/inputs/mailchimp/sample.conf
Normal file
12
plugins/inputs/mailchimp/sample.conf
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Gathers metrics from the /3.0/reports MailChimp API
|
||||
[[inputs.mailchimp]]
|
||||
## MailChimp API key
|
||||
## get from https://admin.mailchimp.com/account/api/
|
||||
api_key = "" # required
|
||||
|
||||
## Reports for campaigns sent more than days_old ago will not be collected.
|
||||
## 0 means collect all and is the default value.
|
||||
days_old = 0
|
||||
|
||||
## Campaign ID to get, if empty gets all campaigns, this option overrides days_old
|
||||
# campaign_id = ""
|
Loading…
Add table
Add a link
Reference in a new issue