-
Notifications
You must be signed in to change notification settings - Fork 1
/
http_types.go
159 lines (137 loc) · 6.49 KB
/
http_types.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
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
package main
import (
"encoding/base64"
"github.com/gofiber/fiber/v2"
)
const (
nginxXAccelExpires = "X-Accel-Expires"
collectorURLReplacement = "__COLLECTOR_URL__"
)
const (
mimetypeJS = "text/javascript"
mimetypeJSON = "application/json"
mimetypeText = "text/plain"
mimetypeGIF = "image/gif"
)
const (
recordQueryMode = "m"
recordQueryPublicInstanceID = "i"
recordQueryURL = "u"
recordQueryCanonicalURL = "cu"
recordQueryRefererURL = "r"
recordQueryTitle = "t"
recordQueryLang = "l"
recordQueryEntityID = "ei"
recordQueryEntityModule = "em"
recordQueryEntityTaxonomyID = "et"
recordQueryErrorVeryLegacy = "err"
)
type errorMessage struct {
code int
msg string
debug string
}
type postRequestEvent struct {
Category string `json:"c,omitempty"`
Action string `json:"a,omitempty"`
Label string `json:"l,omitempty"`
Ident string `json:"id,omitempty"`
Value int64 `json:"v,omitempty"`
}
type postRequestAPI struct {
PrivateInstanceKey string `json:"i_p,omitempty"`
ClientIP string `json:"c_ip,omitempty"`
ClientUserAgent string `json:"c_ua,omitempty"`
ClientTime int64 `json:"c_t,omitempty"`
}
type postRequestGeographyData struct {
Lat float64 `json:"lat,omitempty"`
Lon float64 `json:"lon,omitempty"`
}
type postRequestBreadcrumb struct {
N1 string `json:"n1,omitempty"`
N2 string `json:"n2,omitempty"`
N3 string `json:"n3,omitempty"`
N4 string `json:"n4,omitempty"`
N5 string `json:"n5,omitempty"`
U1 string `json:"u1,omitempty"`
U2 string `json:"u2,omitempty"`
U3 string `json:"u3,omitempty"`
U4 string `json:"u4,omitempty"`
U5 string `json:"u5,omitempty"`
}
type postRequestPerformanceData struct {
PerfPageLoadTime string `json:"plt,omitempty"`
PerfDomainLookupTime string `json:"dlt,omitempty"`
PerfTCPConnectTime string `json:"tct,omitempty"`
PerfServerResponseTime string `json:"srt,omitempty"`
PerfPageDownloadTime string `json:"pdt,omitempty"`
PerfRedirectTime string `json:"rt,omitempty"`
PerfDOMInteractiveTime string `json:"dit,omitempty"`
PerfContentLoadTime string `json:"clt,omitempty"`
PerfResource uint16 `json:"r,omitempty"`
}
type postRequestSegment struct {
S1N string `json:"s1n,omitempty"`
S2N string `json:"s2n,omitempty"`
S3N string `json:"s3n,omitempty"`
S4N string `json:"s4n,omitempty"`
S5N string `json:"s5n,omitempty"`
S1V string `json:"s1v,omitempty"`
S2V string `json:"s2v,omitempty"`
S3V string `json:"s3v,omitempty"`
S4V string `json:"s4v,omitempty"`
S5V string `json:"s5v,omitempty"`
}
type postRequestPage struct {
URL string `json:"u,omitempty"`
CanonicalURL string `json:"cu,omitempty"`
RefererURL string `json:"r,omitempty"`
Title string `json:"t,omitempty"`
Lang string `json:"l,omitempty"`
MainEntityID string `json:"ei,omitempty"`
MainEntityModule string `json:"em,omitempty"`
MainEntityTaxonomyID string `json:"et,omitempty"`
ScreenSize string `json:"scr,omitempty"`
ViewportSize string `json:"vps,omitempty"`
ColorDepth string `json:"cd,omitempty"`
DevicePixelRatio string `json:"dpr,omitempty"`
ScreenOrientationType string `json:"sot,omitempty"`
PageKeywords string `json:"k,omitempty"`
IsIframe bool `json:"if,omitempty"`
IsTouchSupport bool `json:"ts,omitempty"`
RefererSessionURL string `json:"rs,omitempty"`
PageBreadcrumbObject *postRequestBreadcrumb `json:"bc,omitempty"`
PerformanceData *postRequestPerformanceData `json:"prf,omitempty"`
GeographyData *postRequestGeographyData `json:"geo,omitempty"`
Seg *postRequestSegment `json:"seg,omitempty"`
}
type postRequest struct {
ClientErrorMessage string `json:"msg,omitempty"`
ClientErrorObject string `json:"err,omitempty"`
CIDStd string `json:"cid_std,omitempty"`
CIDAmp string `json:"cid_amp,omitempty"`
Page *postRequestPage `json:"p,omitempty"`
Events *[]postRequestEvent `json:"ev,omitempty"`
API *postRequestAPI `json:"ar,omitempty"`
}
var singleGifImage, _ = base64.StdEncoding.DecodeString("R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")
var (
// errorRecordNotValid errorMessage = errorMessage{code: fiber.StatusMethodNotAllowed, msg: "RecordNotValid"}
// errorRecordCIDNotProcessed errorMessage = errorMessage{code: fiber.StatusBadRequest, msg: "RecordCIDNotProcessed"}
// errorProjectNotDefined errorMessage = errorMessage{code: fiber.StatusPreconditionFailed, msg: "ProjectNotDefined"}
errorInternalServerError errorMessage = errorMessage{code: fiber.StatusInternalServerError, msg: "InternalServerError"}
errorInternalDependencyFailed errorMessage = errorMessage{code: fiber.StatusNotImplemented, msg: "InternalDependencyFailed"}
errorRecordNotProcessedYet errorMessage = errorMessage{code: fiber.StatusConflict, msg: "RecordNotProcessedYet"}
errorProjectPublicIDAndURLDidNotMatched errorMessage = errorMessage{code: fiber.StatusForbidden, msg: "ProjectPublicIDAndURLDidNotMatched"}
errorInvalidModeOrProjectPublicID errorMessage = errorMessage{code: fiber.StatusTeapot, msg: "InvalidModeOrProjectPublicID"}
errorURLRequiredAndMustBeValid errorMessage = errorMessage{code: fiber.StatusFailedDependency, msg: "URLRequiredAndMustBeValid"}
errorAPIFieldsAreMissing errorMessage = errorMessage{code: fiber.StatusFailedDependency, msg: "APIFieldsAreMissing"}
errorAPIPrivateKeyFailed errorMessage = errorMessage{code: fiber.StatusFailedDependency, msg: "APIPrivateKeyFailed"}
errorAPIClientIPNotValid errorMessage = errorMessage{code: fiber.StatusFailedDependency, msg: "APIClientIPNotValid"}
errorAPIClientUserAgentNotValid errorMessage = errorMessage{code: fiber.StatusFailedDependency, msg: "APIClientUserAgentNotValid"}
errorQueryStringDisabled errorMessage = errorMessage{code: fiber.StatusGone, msg: "QueryStringDisabled"}
errorAssetsVersionFailed errorMessage = errorMessage{code: fiber.StatusGone, msg: "AssetsVersionFailed"}
errorEventsAreEmpty errorMessage = errorMessage{code: fiber.StatusFailedDependency, msg: "EventsAreEmpty"}
errorBadPOSTBody errorMessage = errorMessage{code: fiber.StatusUnprocessableEntity, msg: "BadPOSTBody"}
)