Repository navigation
Expand file tree
/
Copy pathstats.go
More file actions
400 lines (357 loc) · 14.5 KB
/
Copy pathstats.go
File metadata and controls
400 lines (357 loc) · 14.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
package postmark
import (
"context"
)
// OutboundStats - a brief overview of statistics for all of your outbound email.
type OutboundStats struct {
// Sent - Number of sent emails
Sent int64
// Bounced - Number of bounced emails
Bounced int64
// SMTPApiErrors - Number of SMTP errors
SMTPApiErrors int64
// BounceRate - Bounce rate percentage calculated by total sent.
BounceRate float64
// SpamComplaints - Number of spam complaints received
SpamComplaints int64
// SpamComplaintsRate - Spam complaints percentage calculated by total sent.
SpamComplaintsRate float64
// Opens - Number of opens
Opens int64
// UniqueOpens - Number of unique opens
UniqueOpens int64
// Tracked - Number of tracked emails sent
Tracked int64
// WithClientRecorded - Number of emails where the client was successfully tracked.
WithClientRecorded int64
// WithPlatformRecorded - Number of emails where platform was successfully tracked.
WithPlatformRecorded int64
// WithReadTimeRecorded - Number of emails where read time was successfully tracked.
WithReadTimeRecorded int64
}
// GetOutboundStats - Gets a brief overview of statistics for all of your outbound email.
// Available options: http://developer.postmarkapp.com/developer-api-stats.html#overview
func (client *Client) GetOutboundStats(ctx context.Context, options map[string]interface{}) (OutboundStats, error) {
res := OutboundStats{}
err := client.get(ctx, buildURL("stats/outbound", options), &res)
return res, err
}
// SendDay - send stats for a specific day
type SendDay struct {
// Date - self-explanatory
Date string
// Sent - number of emails sent
Sent int64
}
// SendCounts - send stats for a period
type SendCounts struct {
// Days - List of objects that each represent sent counts by date.
Days []SendDay
// Sent - Indicates the number of total sent emails returned.
Sent int64
}
// GetSentCounts - Gets a total count of emails you’ve sent out.
// Available options: http://developer.postmarkapp.com/developer-api-stats.html#sent-counts
func (client *Client) GetSentCounts(ctx context.Context, options map[string]interface{}) (SendCounts, error) {
res := SendCounts{}
err := client.get(ctx, buildURL("stats/outbound/sends", options), &res)
return res, err
}
// BounceDay - bounce stats for a specific day
type BounceDay struct {
// Date - self-explanatory
Date string
// HardBounce - number of hard bounces
HardBounce int64
// SoftBounce - number of soft bounces
SoftBounce int64
// SMTPApiError - number of SMTP errors
SMTPApiError int64
// Transient - number of transient bounces.
Transient int64
}
// BounceCounts - bounce stats for a period
type BounceCounts struct {
// Days - List of objects that each represent sent counts by date.
Days []BounceDay
// HardBounce - total number of hard bounces
HardBounce int64
// SoftBounce - total number of soft bounces
SoftBounce int64
// SMTPApiError - total number of SMTP errors
SMTPApiError int64
// Transient - total number of transient bounces.
Transient int64
}
// GetBounceCounts - Gets total counts of emails you’ve sent out that have been returned as bounced.
// Available options: http://developer.postmarkapp.com/developer-api-stats.html#bounce-counts
func (client *Client) GetBounceCounts(ctx context.Context, options map[string]interface{}) (BounceCounts, error) {
res := BounceCounts{}
err := client.get(ctx, buildURL("stats/outbound/bounces", options), &res)
return res, err
}
// SpamDay - spam complaints for a specific day
type SpamDay struct {
// Date - self-explanatory
Date string
// SpamComplaint - number of spam complaints received
SpamComplaint int64
}
// SpamCounts - spam complaints for a period
type SpamCounts struct {
// Days - List of objects that each represent spam complaint counts by date.
Days []SpamDay
// SpamComplaint - Indicates total number of spam complaints.
SpamComplaint int64
}
// GetSpamCounts - Gets a total count of recipients who have marked your email as spam.
// Days that did not produce statistics won’t appear in the JSON response.
// Available options: http://developer.postmarkapp.com/developer-api-stats.html#spam-complaints
func (client *Client) GetSpamCounts(ctx context.Context, options map[string]interface{}) (SpamCounts, error) {
res := SpamCounts{}
err := client.get(ctx, buildURL("stats/outbound/spam", options), &res)
return res, err
}
// TrackedDay - tracked emails sent on a specific day
type TrackedDay struct {
// Date - self-explanatory
Date string
// Tracked - number of emails tracked sent
Tracked int64
}
// TrackedCounts - tracked emails sent for a period
type TrackedCounts struct {
// Days - List of objects that each represent tracked email counts by date.
Days []TrackedDay
// Tracked - Indicates total number of tracked emails sent.
Tracked int64
}
// GetTrackedCounts - Gets a total count of emails you’ve sent with open tracking enabled.
// Available options: http://developer.postmarkapp.com/developer-api-stats.html#email-tracked-count
func (client *Client) GetTrackedCounts(ctx context.Context, options map[string]interface{}) (TrackedCounts, error) {
res := TrackedCounts{}
err := client.get(ctx, buildURL("stats/outbound/tracked", options), &res)
return res, err
}
// OpenedDay - opened outbound emails sent on a specific day
type OpenedDay struct {
// Date - self-explanatory
Date string
// Opens - Indicates total number of opened emails. This total includes recipients who opened your email multiple times.
Opens int64
// Unique - Indicates total number of uniquely opened emails.
Unique int64
}
// OpenCounts - opened outbound emails for a period
type OpenCounts struct {
// Days - List of objects that each represent opens by date.
Days []OpenedDay
// Opens - Indicates total number of opened emails. This total includes recipients who opened your email multiple times.
Opens int64
// Unique int64 - Indicates total number of uniquely opened emails.
Unique int64
}
// GetOpenCounts - Gets total counts of recipients who opened your emails. This is only recorded when open tracking is enabled for that email.
// Available options: http://developer.postmarkapp.com/developer-api-stats.html#email-opens-count
func (client *Client) GetOpenCounts(ctx context.Context, options map[string]interface{}) (OpenCounts, error) {
res := OpenCounts{}
err := client.get(ctx, buildURL("stats/outbound/opens", options), &res)
return res, err
}
// PlatformCounts contains day-to-day usages, along with totals of email usages by platform
type PlatformCounts struct {
// Days - List of objects that each represent email platform usages by date
Days []PlatformDay
// Desktop - The total number of email platform usages by Desktop
Desktop int64
// Mobile - The total number of email platform usages by Mobile
Mobile int64
// Unknown - The total number of email platform usages by others
Unknown int64
// WebMail - The total number of email platform usages by WebMail
WebMail int64
}
// PlatformDay contains the totals of email usages by platform for a specific date
type PlatformDay struct {
// Date - the date in question
Date string
// Desktop - The total number of email platform usages by Desktop for this date
Desktop int64
// Mobile - The total number of email platform usages by Mobile for this date
Mobile int64
// Unknown - The total number of email platform usages by others for this date
Unknown int64
// WebMail - The total number of email platform usages by WebMail for this date
WebMail int64
}
// GetPlatformCounts gets the email platform usage
func (client *Client) GetPlatformCounts(ctx context.Context, options map[string]interface{}) (PlatformCounts, error) {
res := PlatformCounts{}
err := client.get(ctx, buildURL("stats/outbound/platform", options), &res)
return res, err
}
// ClickDay - click stats for a specific day
type ClickDay struct {
// Date - self-explanatory
Date string
// Clicks - number of total clicks
Clicks int64
// Unique - number of unique clicks
Unique int64
}
// ClickCounts - click stats for a period
type ClickCounts struct {
// Days - List of objects that each represent click counts by date.
Days []ClickDay
// Clicks - Indicates total number of clicks. This total includes recipients who clicked your links multiple times.
Clicks int64
// Unique - Indicates total number of uniquely clicked links.
Unique int64
}
// GetClickCounts - Gets total counts of recipients who clicked links in your emails. This is only recorded when link tracking is enabled for that email.
// Available options: http://developer.postmarkapp.com/developer-api-stats.html#click-counts
func (client *Client) GetClickCounts(ctx context.Context, options map[string]interface{}) (ClickCounts, error) {
res := ClickCounts{}
err := client.get(ctx, buildURL("stats/outbound/clicks", options), &res)
return res, err
}
// BrowserFamilyDay - browser family usage stats for a specific day
type BrowserFamilyDay struct {
// Date - self-explanatory
Date string
// Chrome - number of clicks from Chrome browser
Chrome int64
// Safari - number of clicks from Safari browser
Safari int64
// Firefox - number of clicks from Firefox browser
Firefox int64
// InternetExplorer - number of clicks from Internet Explorer browser
InternetExplorer int64
// Opera - number of clicks from Opera browser
Opera int64
// Unknown - number of clicks from unknown browsers
Unknown int64
}
// BrowserFamilyCounts - browser family usage stats for a period
type BrowserFamilyCounts struct {
// Days - List of objects that each represent browser family usage by date.
Days []BrowserFamilyDay
// Chrome - total number of clicks from Chrome browser
Chrome int64
// Safari - total number of clicks from Safari browser
Safari int64
// Firefox - total number of clicks from Firefox browser
Firefox int64
// InternetExplorer - total number of clicks from Internet Explorer browser
InternetExplorer int64
// Opera - total number of clicks from Opera browser
Opera int64
// Unknown - total number of clicks from unknown browsers
Unknown int64
}
// GetBrowserFamilyCounts - Gets total counts of clicks by browser family. This is only recorded when link tracking is enabled for that email.
// Available options: http://developer.postmarkapp.com/developer-api-stats.html#browser-usage
func (client *Client) GetBrowserFamilyCounts(ctx context.Context, options map[string]interface{}) (BrowserFamilyCounts, error) {
res := BrowserFamilyCounts{}
err := client.get(ctx, buildURL("stats/outbound/clicks/browserfamilies", options), &res)
return res, err
}
// ClickLocationDay - click location stats for a specific day
type ClickLocationDay struct {
// Date - self-explanatory
Date string
// HTML - number of clicks from HTML part of the email
HTML int64
// Text - number of clicks from text part of the email
Text int64
}
// ClickLocationCounts - click location stats for a period
type ClickLocationCounts struct {
// Days - List of objects that each represent click location counts by date.
Days []ClickLocationDay
// HTML - total number of clicks from HTML part of the email
HTML int64
// Text - total number of clicks from text part of the email
Text int64
}
// GetClickLocationCounts - Gets total counts of clicks by email format. This is only recorded when link tracking is enabled for that email.
// Available options: http://developer.postmarkapp.com/developer-api-stats.html#click-location
func (client *Client) GetClickLocationCounts(ctx context.Context, options map[string]interface{}) (ClickLocationCounts, error) {
res := ClickLocationCounts{}
err := client.get(ctx, buildURL("stats/outbound/clicks/location", options), &res)
return res, err
}
// ClickPlatformDay - click platform usage stats for a specific day
type ClickPlatformDay struct {
// Date - self-explanatory
Date string
// Desktop - number of clicks from Desktop platforms
Desktop int64
// Mobile - number of clicks from Mobile platforms
Mobile int64
// Unknown - number of clicks from unknown platforms
Unknown int64
// WebMail - number of clicks from WebMail platforms
WebMail int64
}
// ClickPlatformCounts - click platform usage stats for a period
type ClickPlatformCounts struct {
// Days - List of objects that each represent click platform usage by date.
Days []ClickPlatformDay
// Desktop - total number of clicks from Desktop platforms
Desktop int64
// Mobile - total number of clicks from Mobile platforms
Mobile int64
// Unknown - total number of clicks from unknown platforms
Unknown int64
// WebMail - total number of clicks from WebMail platforms
WebMail int64
}
// GetClickPlatformCounts - Gets total counts of clicks by platform. This is only recorded when link tracking is enabled for that email.
// Available options: http://developer.postmarkapp.com/developer-api-stats.html#browser-platform-usage
func (client *Client) GetClickPlatformCounts(ctx context.Context, options map[string]interface{}) (ClickPlatformCounts, error) {
res := ClickPlatformCounts{}
err := client.get(ctx, buildURL("stats/outbound/clicks/platforms", options), &res)
return res, err
}
// EmailClientDay - email client usage stats for a specific day
type EmailClientDay struct {
// Date - self-explanatory
Date string
// Outlook - number of opens from Outlook email client
Outlook int64
// Gmail - number of opens from Gmail email client
Gmail int64
// AppleMail - number of opens from Apple Mail email client
AppleMail int64
// Thunderbird - number of opens from Thunderbird email client
Thunderbird int64
// Yahoo - number of opens from Yahoo email client
Yahoo int64
// Unknown - number of opens from unknown email clients
Unknown int64
}
// EmailClientCounts - email client usage stats for a period
type EmailClientCounts struct {
// Days - List of objects that each represent email client usage by date.
Days []EmailClientDay
// Outlook - total number of opens from Outlook email client
Outlook int64
// Gmail - total number of opens from Gmail email client
Gmail int64
// AppleMail - total number of opens from Apple Mail email client
AppleMail int64
// Thunderbird - total number of opens from Thunderbird email client
Thunderbird int64
// Yahoo - total number of opens from Yahoo email client
Yahoo int64
// Unknown - total number of opens from unknown email clients
Unknown int64
}
// GetEmailClientCounts - Gets total counts of opens by email client. This is only recorded when open tracking is enabled for that email.
// Available options: http://developer.postmarkapp.com/developer-api-stats.html#email-client-usage
func (client *Client) GetEmailClientCounts(ctx context.Context, options map[string]interface{}) (EmailClientCounts, error) {
res := EmailClientCounts{}
err := client.get(ctx, buildURL("stats/outbound/opens/emailclients", options), &res)
return res, err
}