react-native-my-survey-sdk 2.2.22 → 2.2.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -366,11 +366,18 @@ export async function submitResponse(
|
|
|
366
366
|
if (meta.userData.city) customVariables.city = meta.userData.city;
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
+
// time_spent in whole seconds, derived from netTimeDuration (minutes)
|
|
370
|
+
const timeTakenSecs = meta?.qualityFlags
|
|
371
|
+
? Math.round(meta.qualityFlags.data.survey.netTimeDuration * 60)
|
|
372
|
+
: undefined;
|
|
373
|
+
|
|
369
374
|
const payload: Record<string, unknown> = {
|
|
370
375
|
collector_id: collectorUUID,
|
|
376
|
+
...(meta?.deviceInfo && { deviceInfo: meta.deviceInfo }),
|
|
371
377
|
responses: [
|
|
372
378
|
{
|
|
373
379
|
response_status: 'complete',
|
|
380
|
+
...(timeTakenSecs !== undefined && { time_spent: timeTakenSecs }),
|
|
374
381
|
...(Object.keys(customVariables).length > 0 && { custom_variables: customVariables }),
|
|
375
382
|
questions: filteredAnswers.map(a => ({
|
|
376
383
|
uuid: a.questionId,
|
|
@@ -382,7 +389,7 @@ export async function submitResponse(
|
|
|
382
389
|
})),
|
|
383
390
|
...(meta?.qualityFlags && { qualityFlags: meta.qualityFlags }),
|
|
384
391
|
...(meta?.deviceInfo && { deviceInfo: meta.deviceInfo }),
|
|
385
|
-
...(meta?.geolocation && {
|
|
392
|
+
...(meta?.geolocation && { geoLocation: meta.geolocation }),
|
|
386
393
|
},
|
|
387
394
|
],
|
|
388
395
|
};
|
|
@@ -395,9 +402,20 @@ export async function submitResponse(
|
|
|
395
402
|
console.log('Question count:', filteredAnswers.length);
|
|
396
403
|
console.log('Payload:', JSON.stringify(payload, null, 2));
|
|
397
404
|
|
|
405
|
+
// Send a mobile User-Agent so the backend parses deviceInfo, geoLocation, and qualityFlags
|
|
406
|
+
// the same way it does for type-17 browser-based submissions.
|
|
407
|
+
const osVersion = (meta?.osVersion ?? '').replace(/^(ios|android)\s*/i, '');
|
|
408
|
+
const userAgent = meta?.platform === 'ios'
|
|
409
|
+
? `Mozilla/5.0 (iPhone; CPU iPhone OS ${osVersion.replace(/\./g, '_')} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148`
|
|
410
|
+
: `Mozilla/5.0 (Linux; Android ${osVersion}; Mobile) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36`;
|
|
411
|
+
|
|
398
412
|
const res = await fetch(url, {
|
|
399
413
|
method: 'POST',
|
|
400
|
-
headers: {
|
|
414
|
+
headers: {
|
|
415
|
+
'x-api-key': apiKey,
|
|
416
|
+
'Content-Type': 'application/json',
|
|
417
|
+
'User-Agent': userAgent,
|
|
418
|
+
},
|
|
401
419
|
body: JSON.stringify(payload),
|
|
402
420
|
});
|
|
403
421
|
|
package/src/models/XeboModels.ts
CHANGED
|
@@ -127,7 +127,7 @@ export interface XeboDeviceInfo {
|
|
|
127
127
|
|
|
128
128
|
export interface XeboGeolocation {
|
|
129
129
|
type: string;
|
|
130
|
-
coordinates:
|
|
130
|
+
coordinates: (number | null)[];
|
|
131
131
|
country: string | null;
|
|
132
132
|
city: string | null;
|
|
133
133
|
region: string | null;
|