-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy patheventdefs.go
68 lines (60 loc) · 2.43 KB
/
eventdefs.go
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
package sparkypmtatracking
import "time"
// TrackEvent is the augmented info passed from "tracker" via the Redis event queue to "feeder"
type TrackEvent struct {
WD WrapperData
TimeStamp string `json:"ts"`
UserAgent string `json:"ua"`
IPAddress string `json:"ip"`
}
// SparkPostEvent structure for SparkPost Ingest API. Note the nesting. There are some fields we're not populating here,
// as they will automatically be "enriched" by SparkPost, providing there is a injection event matching for this message_id.
//
// ab_test_id, ab_test_version, amp_enabled, binding, binding_group, campaign_id, click_tracking,
// friendly_from, initial_pixel, injection_time, ip_pool, ip_pool_raw, msg_from, msg_size, open_tracking,
// rcpt_meta, rcpt_tags, rcpt_type, recv_method, routing_domain, sending_ip, subject, template_id, template_version, transactional,
// transmission_id
//
// We are also not populating: num_retries, queue_time, raw_rcpt_to, target_link_name
// A future implementation could usefully populate target_link_name, geo_ip if desired.
type SparkPostEvent struct {
EventWrapper struct {
EventGrouping struct {
Type string `json:"type"`
DelvMethod string `json:"delv_method"`
EventID string `json:"event_id"`
IPAddress string `json:"ip_address"`
GeoIP GeoIP `json:"geo_ip"`
MessageID string `json:"message_id"`
RcptTo string `json:"rcpt_to"`
TimeStamp string `json:"timestamp"`
TargetLinkURL string `json:"target_link_url"`
UserAgent string `json:"user_agent"`
SubaccountID int `json:"subaccount_id"`
} `json:"track_event"`
} `json:"msys"`
}
// Send a batch periodically, or every X MB, whichever comes first.
// SparkPostIngestMaxPayload set in accord with https://developers.sparkpost.com/api/events-ingest/#header-event-format
const SparkPostIngestMaxPayload = 5 * 1024 * 1024
// SparkPostIngestBatchMaxAge sets the maximum time we wait before forwarding a batch of events
const SparkPostIngestBatchMaxAge = 30 * time.Second
// IngestResult object coming back from SparkPost
type IngestResult struct {
Results struct {
ID string `json:"id"`
} `json:"results"`
Errors []struct {
Message string `json:"message"`
} `json:"errors"`
}
// GeoIP data expected by SparkPost .. will be blank for now
type GeoIP struct {
Country string
Region string
City string
Latitude float64
Longitude float64
Zip int
PostalCode string
}