@@ -122,7 +122,10 @@ export default function IdentityAPIClient(
122122 case HTTP_ACCEPTED :
123123 case HTTP_OK :
124124
125- // 400 error will has a body and will go through the happy path to report the error
125+ // Our Identity API will return a 400 error if there is an issue with the requeest body
126+ // such as if the body is empty or one of the attirbutes is missing or malformed
127+ // A 400 will return an error in the response body and will go through the happy path to report the error
128+ // Any unhandled errors, such as 500 or 429, will be caught here as well
126129 case HTTP_BAD_REQUEST :
127130
128131 // FetchUploader returns the response as a JSON object that we have to await
@@ -145,11 +148,10 @@ export default function IdentityAPIClient(
145148 ? JSON . parse ( xhrResponse . responseText )
146149 : '' ;
147150
148- // https://go.mparticle.com/work/SQDSDKS-6670
149- message =
150- 'Successfully sent forwarding stats to mParticle Servers' ;
151151 }
152152
153+ // https://go.mparticle.com/work/SQDSDKS-6670
154+ message = 'Successfully sent alias request to mParticle Servers' ;
153155
154156 if ( response . status === HTTP_BAD_REQUEST ) {
155157 // 400 has an error message, but 403 doesn't
@@ -168,7 +170,11 @@ export default function IdentityAPIClient(
168170
169171 break ;
170172
171- // 401 and 403 have no bodies and should be rejected outright
173+ // Our Identity API will return:
174+ // - 401 if the `x-mp-key` is incorrect or missing
175+ // - 403 if the there is a permission or account issue related to the `x-mp-key`
176+ // 401 and 403 have no response bodies and should be rejected outright
177+ // Any unhandled errors, such as 500 or 429, will be caught here as well
172178 default : {
173179 throw new Error ( 'Received HTTP Code of ' + response . status ) ;
174180 }
@@ -245,7 +251,9 @@ export default function IdentityAPIClient(
245251 case HTTP_ACCEPTED :
246252 case HTTP_OK :
247253
248- // 400 error will has a body and will go through the happy path to report the error
254+ // Our Identity API will return a 400 error if there is an issue with the requeest body
255+ // such as if the body is empty or one of the attirbutes is missing or malformed
256+ // A 400 will return an error in the response body and will go through the happy path to report the error
249257 case HTTP_BAD_REQUEST :
250258
251259 // FetchUploader returns the response as a JSON object that we have to await
@@ -280,7 +288,10 @@ export default function IdentityAPIClient(
280288
281289 break ;
282290
283- // 401 and 403 have no bodies and should be rejected outright
291+ // Our Identity API will return:
292+ // - 401 if the `x-mp-key` is incorrect or missing
293+ // - 403 if the there is a permission or account issue related to the `x-mp-key`
294+ // 401 and 403 have no response bodies and should be rejected outright
284295 default : {
285296 throw new Error ( 'Received HTTP Code of ' + response . status ) ;
286297 }
0 commit comments