File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
src/connections/functions Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -113,18 +113,25 @@ async function onAlias(event) {
113
113
}
114
114
115
115
async function onTrack (event ) {
116
+ let res
116
117
try {
117
- await fetch (' http://example-service.com/api' , {
118
+ res = await fetch (' http://example-service.com/api' , {
118
119
method: ' POST' ,
119
120
headers: {
120
121
' Content-Type' : ' application/json'
121
- }
122
+ },
122
123
body: JSON .stringify ({ event })
123
124
})
124
125
} catch (err) {
126
+ // Retry on connection error
125
127
throw new RetryError (err .message )
126
128
}
129
+ if (res .status >= 500 || res .status === 429 ) {
130
+ // Retry on 5xx and 429s (ratelimits)
131
+ throw new RetryError (` HTTP Status ${ res .status } ` )
132
+ }
127
133
}
134
+
128
135
```
129
136
If you do not supply a function for an event type, Segment throws an ` EventNotSupported ` error by default.
130
137
You can’t perform that action at this time.
0 commit comments