react-native-my-survey-sdk 2.2.38 → 3.0.1

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.
Files changed (75) hide show
  1. package/dist/components/XeboDropdownView.d.ts +10 -0
  2. package/dist/components/XeboDropdownView.d.ts.map +1 -0
  3. package/dist/components/XeboDropdownView.js +190 -0
  4. package/dist/components/XeboIntroView.d.ts +9 -0
  5. package/dist/components/XeboIntroView.d.ts.map +1 -0
  6. package/dist/components/XeboIntroView.js +54 -0
  7. package/dist/components/XeboMultiNPSView.d.ts +10 -0
  8. package/dist/components/XeboMultiNPSView.d.ts.map +1 -0
  9. package/dist/components/XeboMultiNPSView.js +170 -0
  10. package/dist/components/XeboMultiRatingView.d.ts +10 -0
  11. package/dist/components/XeboMultiRatingView.d.ts.map +1 -0
  12. package/dist/components/XeboMultiRatingView.js +154 -0
  13. package/dist/components/XeboMultipleChoiceView.d.ts +10 -0
  14. package/dist/components/XeboMultipleChoiceView.d.ts.map +1 -0
  15. package/dist/components/XeboMultipleChoiceView.js +188 -0
  16. package/dist/components/XeboNPSView.d.ts +10 -0
  17. package/dist/components/XeboNPSView.d.ts.map +1 -0
  18. package/dist/components/XeboNPSView.js +269 -0
  19. package/dist/components/XeboRatingView.d.ts +10 -0
  20. package/dist/components/XeboRatingView.d.ts.map +1 -0
  21. package/dist/components/XeboRatingView.js +248 -0
  22. package/dist/components/XeboSingleChoiceView.d.ts +10 -0
  23. package/dist/components/XeboSingleChoiceView.d.ts.map +1 -0
  24. package/dist/components/XeboSingleChoiceView.js +172 -0
  25. package/dist/components/XeboSurveyModal.d.ts +3 -0
  26. package/dist/components/XeboSurveyModal.d.ts.map +1 -0
  27. package/dist/components/XeboSurveyModal.js +345 -0
  28. package/dist/components/XeboTextBoxView.d.ts +10 -0
  29. package/dist/components/XeboTextBoxView.d.ts.map +1 -0
  30. package/dist/components/XeboTextBoxView.js +176 -0
  31. package/dist/components/XeboThankYouView.d.ts +9 -0
  32. package/dist/components/XeboThankYouView.d.ts.map +1 -0
  33. package/dist/components/XeboThankYouView.js +115 -0
  34. package/dist/core/XeboNetworkService.d.ts +34 -0
  35. package/dist/core/XeboNetworkService.d.ts.map +1 -0
  36. package/dist/core/XeboNetworkService.js +367 -0
  37. package/dist/core/XeboOfflineQueue.d.ts +8 -0
  38. package/dist/core/XeboOfflineQueue.d.ts.map +1 -0
  39. package/dist/core/XeboOfflineQueue.js +35 -0
  40. package/dist/core/XeboSurveyManager.d.ts +59 -0
  41. package/dist/core/XeboSurveyManager.d.ts.map +1 -0
  42. package/dist/core/XeboSurveyManager.js +351 -0
  43. package/dist/index.d.ts +5 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +12 -0
  46. package/dist/models/XeboAPIModels.d.ts +82 -0
  47. package/dist/models/XeboAPIModels.d.ts.map +1 -0
  48. package/dist/models/XeboAPIModels.js +4 -0
  49. package/dist/models/XeboModels.d.ts +141 -0
  50. package/dist/models/XeboModels.d.ts.map +1 -0
  51. package/dist/models/XeboModels.js +17 -0
  52. package/dist/theme/XeboTheme.d.ts +11 -0
  53. package/dist/theme/XeboTheme.d.ts.map +1 -0
  54. package/dist/theme/XeboTheme.js +25 -0
  55. package/package.json +10 -3
  56. package/babel.config.js +0 -4
  57. package/src/components/XeboDropdownView.tsx +0 -197
  58. package/src/components/XeboIntroView.tsx +0 -68
  59. package/src/components/XeboMultiNPSView.tsx +0 -166
  60. package/src/components/XeboMultiRatingView.tsx +0 -165
  61. package/src/components/XeboMultipleChoiceView.tsx +0 -183
  62. package/src/components/XeboNPSView.tsx +0 -315
  63. package/src/components/XeboRatingView.tsx +0 -267
  64. package/src/components/XeboSingleChoiceView.tsx +0 -168
  65. package/src/components/XeboSurveyModal.tsx +0 -360
  66. package/src/components/XeboTextBoxView.tsx +0 -188
  67. package/src/components/XeboThankYouView.tsx +0 -100
  68. package/src/core/XeboNetworkService.ts +0 -476
  69. package/src/core/XeboOfflineQueue.ts +0 -33
  70. package/src/core/XeboSurveyManager.ts +0 -422
  71. package/src/index.ts +0 -23
  72. package/src/models/XeboAPIModels.ts +0 -80
  73. package/src/models/XeboModels.ts +0 -169
  74. package/src/theme/XeboTheme.ts +0 -33
  75. package/tsconfig.json +0 -17
@@ -1,422 +0,0 @@
1
- import NetInfo from '@react-native-community/netinfo';
2
- import DeviceInfo from 'react-native-device-info';
3
- import { Platform } from 'react-native';
4
-
5
- // Minimal inline event emitter — no external 'events' package needed
6
- type Listener = (...args: any[]) => void;
7
- class SimpleEventEmitter {
8
- private _listeners: Map<string, Listener[]> = new Map();
9
- emit(event: string, ...args: any[]): boolean {
10
- const fns = this._listeners.get(event) ?? [];
11
- fns.forEach(fn => fn(...args));
12
- return fns.length > 0;
13
- }
14
- on(event: string, listener: Listener): this {
15
- this._listeners.set(event, [...(this._listeners.get(event) ?? []), listener]);
16
- return this;
17
- }
18
- off(event: string, listener: Listener): this {
19
- this._listeners.set(event, (this._listeners.get(event) ?? []).filter(l => l !== listener));
20
- return this;
21
- }
22
- removeAllListeners(event?: string): this {
23
- event ? this._listeners.delete(event) : this._listeners.clear();
24
- return this;
25
- }
26
- }
27
-
28
- const uuidv4 = () =>
29
- 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
30
- const r = (Math.random() * 16) | 0;
31
- return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
32
- });
33
-
34
- import {
35
- XeboSurvey,
36
- XeboAnswer,
37
- XeboConfig,
38
- XeboThemeConfig,
39
- XeboQueuedResponse,
40
- XeboUserData,
41
- XeboQualityFlags,
42
- XeboGeolocation,
43
- } from '../models/XeboModels';
44
- import {
45
- buildBaseURL,
46
- buildFeedbackBaseURL,
47
- buildVerifyURL,
48
- verifyApiKey,
49
- fetchCollector,
50
- fetchSurvey,
51
- submitResponse,
52
- } from './XeboNetworkService';
53
- import { XeboOfflineQueue } from './XeboOfflineQueue';
54
- import { configureTheme } from '../theme/XeboTheme';
55
-
56
- // ─── Event names ──────────────────────────────────────────────────────────────
57
-
58
- export const XEBO_EVENTS = {
59
- SURVEY_LOADED: 'survey_loaded',
60
- QUESTION_CHANGED: 'question_changed',
61
- SURVEY_VISIBLE: 'survey_visible',
62
- SURVEY_DISMISSED: 'survey_dismissed',
63
- } as const;
64
-
65
- // ─── Singleton class ──────────────────────────────────────────────────────────
66
-
67
- class XeboSurveyManagerClass extends SimpleEventEmitter {
68
- // Config
69
- private apiKey = '';
70
- private collectorId = '';
71
- private resolvedZone = '';
72
- private baseURL = '';
73
- private feedbackBaseURL = '';
74
- private verifyURL = '';
75
- private bearerToken = '';
76
-
77
- // User / eData
78
- private userData: XeboUserData | null = null;
79
- private deviceModel = '';
80
- private osVersion = '';
81
-
82
- // State
83
- survey: XeboSurvey | null = null;
84
- currentAnswers: XeboAnswer[] = [];
85
- currentQuestionIndex = 0;
86
- surveyStartTime = '';
87
- resolvedCollectorUUID = '';
88
- resolvedCollectorMongoId = '';
89
- surveyVisible = false;
90
-
91
- // Timing / quality
92
- private surveyStartEpoch = 0;
93
- private questionStartEpoch = 0;
94
- private timePerQues: Record<string, number> = {};
95
- private backTrackCount = 0;
96
-
97
- // Network monitoring unsubscribe handle
98
- private netInfoUnsubscribe: (() => void) | null = null;
99
-
100
- // ─── Configure ─────────────────────────────────────────────────────────────
101
-
102
- configure(config: XeboConfig): void {
103
- this.apiKey = config.apiKey;
104
- this.collectorId = config.collectorId;
105
-
106
- this.resolvedZone = config.zone;
107
- this.baseURL = buildBaseURL(this.resolvedZone);
108
- this.feedbackBaseURL = buildFeedbackBaseURL(this.resolvedZone);
109
- this.verifyURL = buildVerifyURL();
110
-
111
- // Capture device info once at configure time
112
- this.deviceModel = `${DeviceInfo.getModel()} (${DeviceInfo.getSystemName()})`;
113
- this.osVersion = `${Platform.OS} ${DeviceInfo.getSystemVersion()}`;
114
-
115
- this._startNetworkMonitoring();
116
- // Pre-fetch survey in background so it's ready instantly when button is tapped
117
- this._prefetchSurvey();
118
- }
119
-
120
- configureTheme(config: XeboThemeConfig): void {
121
- configureTheme(config);
122
- }
123
-
124
- // ─── User identity ─────────────────────────────────────────────────────────
125
-
126
- setUser(data: XeboUserData): void {
127
- this.userData = data;
128
- }
129
-
130
- clearUser(): void {
131
- this.userData = null;
132
- }
133
-
134
- // ─── Network monitoring ────────────────────────────────────────────────────
135
-
136
- private _startNetworkMonitoring(): void {
137
- if (this.netInfoUnsubscribe) {
138
- this.netInfoUnsubscribe();
139
- }
140
-
141
- let wasOffline = false;
142
-
143
- this.netInfoUnsubscribe = NetInfo.addEventListener((state: { isConnected: boolean | null }) => {
144
- const isConnected = state.isConnected ?? false;
145
- if (wasOffline && isConnected) {
146
- console.log('[Xebo] Network restored — flushing offline queue');
147
- this.flushQueue();
148
- }
149
- wasOffline = !isConnected;
150
- });
151
- }
152
-
153
- // ─── Step 0: Verify API key → bearer token ────────────────────────────────
154
-
155
- private async _verifyAndGetToken(): Promise<void> {
156
- this.bearerToken = await verifyApiKey(this.verifyURL, this.resolvedZone, this.apiKey);
157
- }
158
-
159
- // ─── Background pre-fetch ──────────────────────────────────────────────────
160
-
161
- private async _prefetchSurvey(): Promise<void> {
162
- try {
163
- console.log('[Xebo] Pre-fetching survey in background...');
164
- await this._verifyAndGetToken();
165
- const collector = await fetchCollector(this.baseURL, this.collectorId, this.bearerToken);
166
- this.resolvedCollectorUUID = collector.uuid;
167
- this.resolvedCollectorMongoId = collector.mongoId;
168
- const survey = await fetchSurvey(this.baseURL, collector.surveyId, this.bearerToken);
169
- this.survey = survey;
170
- this.emit(XEBO_EVENTS.SURVEY_LOADED, survey);
171
- console.log('[Xebo] Pre-fetch done —', survey.questions.length, 'questions ready');
172
- } catch (err) {
173
- console.warn('[Xebo] Pre-fetch failed (will retry on fetchAndPresentSurvey):', err);
174
- }
175
- }
176
-
177
- // ─── Main flow ─────────────────────────────────────────────────────────────
178
-
179
- async fetchAndPresentSurvey(): Promise<void> {
180
- try {
181
- // If already pre-fetched, show instantly
182
- if (this.survey && this.resolvedCollectorUUID) {
183
- console.log('[Xebo] Survey already cached — showing instantly');
184
- this.currentAnswers = [];
185
- this.currentQuestionIndex = 0;
186
- this.surveyStartTime = new Date().toISOString();
187
- this.surveyStartEpoch = Date.now();
188
- this.questionStartEpoch = Date.now();
189
- this.timePerQues = {};
190
- this.backTrackCount = 0;
191
- this.emit(XEBO_EVENTS.SURVEY_LOADED, this.survey);
192
- this._setVisible(true);
193
- return;
194
- }
195
-
196
- // Not cached yet — verify + fetch now
197
- console.log('[Xebo] Step 0: verifyApiKey');
198
- await this._verifyAndGetToken();
199
-
200
- console.log('[Xebo] Step 1: fetchCollector');
201
- const collector = await fetchCollector(this.baseURL, this.collectorId, this.bearerToken);
202
- this.resolvedCollectorUUID = collector.uuid;
203
- this.resolvedCollectorMongoId = collector.mongoId;
204
-
205
- console.log('[Xebo] Step 2: fetchSurvey');
206
- const survey = await fetchSurvey(this.baseURL, collector.surveyId, this.bearerToken);
207
- this.survey = survey;
208
- this.currentAnswers = [];
209
- this.currentQuestionIndex = 0;
210
- this.surveyStartTime = new Date().toISOString();
211
- this.surveyStartEpoch = Date.now();
212
- this.questionStartEpoch = Date.now();
213
- this.timePerQues = {};
214
- this.backTrackCount = 0;
215
-
216
- this.emit(XEBO_EVENTS.SURVEY_LOADED, survey);
217
- this._setVisible(true);
218
- } catch (err) {
219
- console.error('[Xebo] fetchAndPresentSurvey failed:', err);
220
- }
221
- }
222
-
223
- // ─── Answer recording ──────────────────────────────────────────────────────
224
-
225
- recordAnswer(answer: XeboAnswer): void {
226
- const idx = this.currentAnswers.findIndex(a => a.questionId === answer.questionId);
227
- if (idx >= 0) {
228
- this.currentAnswers[idx] = answer;
229
- } else {
230
- this.currentAnswers.push(answer);
231
- }
232
- }
233
-
234
- // ─── Navigation ────────────────────────────────────────────────────────────
235
-
236
- nextQuestion(): void {
237
- if (!this.survey) return;
238
-
239
- // Record time spent on the current question before advancing
240
- const currentQ = this.survey.questions[this.currentQuestionIndex];
241
- if (currentQ && currentQ.id !== 'thank_you_auto') {
242
- this.timePerQues[currentQ.id] = (Date.now() - this.questionStartEpoch) / 1000;
243
- }
244
-
245
- const next = this.currentQuestionIndex + 1;
246
- if (next < this.survey.questions.length) {
247
- this.currentQuestionIndex = next;
248
- this.questionStartEpoch = Date.now();
249
- this.emit(XEBO_EVENTS.QUESTION_CHANGED, this.currentQuestionIndex);
250
-
251
- // If this is the thank-you question, submit in the background
252
- const q = this.survey.questions[this.currentQuestionIndex];
253
- if (q?.id === 'thank_you_auto') {
254
- this._submitCurrentSession();
255
- }
256
- }
257
- }
258
-
259
- // ─── Submission ────────────────────────────────────────────────────────────
260
-
261
- private _buildQualityFlags(): XeboQualityFlags {
262
- const endEpoch = Date.now();
263
- const totalMinutes = (endEpoch - this.surveyStartEpoch) / 60000;
264
- const now = new Date();
265
- const curTime = `${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}`;
266
- return {
267
- data: {
268
- timePerQues: Object.fromEntries(
269
- Object.entries(this.timePerQues).map(([qId, secs]) => [qId, { timeOnQues: secs }])
270
- ),
271
- survey: {
272
- totalTimeDuration: totalMinutes,
273
- netTimeDuration: totalMinutes,
274
- curTime,
275
- startTime: this.surveyStartEpoch,
276
- backTrackCount: this.backTrackCount,
277
- },
278
- },
279
- straightLining: { questionList: [] },
280
- };
281
- }
282
-
283
- private _buildGeolocation(): XeboGeolocation {
284
- return {
285
- type: 'point',
286
- coordinates: [null, null],
287
- country: this.userData?.country ?? null,
288
- city: this.userData?.city ?? null,
289
- region: this.userData?.region ?? null,
290
- };
291
- }
292
-
293
- private async _submitCurrentSession(): Promise<void> {
294
- if (!this.survey) return;
295
-
296
- const endTime = new Date().toISOString();
297
-
298
- try {
299
- const result = await submitResponse(
300
- this.feedbackBaseURL,
301
- this.survey.id,
302
- this.resolvedCollectorUUID,
303
- this.bearerToken,
304
- this.currentAnswers,
305
- {
306
- userData: this.userData ?? undefined,
307
- deviceModel: this.deviceModel,
308
- platform: Platform.OS,
309
- osVersion: this.osVersion,
310
- startTime: this.surveyStartTime,
311
- endTime,
312
- qualityFlags: this._buildQualityFlags(),
313
- geolocation: this._buildGeolocation(),
314
- deviceInfo: {
315
- type: 'mobile',
316
- os: Platform.OS === 'ios' ? 'ios' : 'android',
317
- browser: Platform.OS === 'ios' ? 'safari' : 'chrome',
318
- },
319
- },
320
- );
321
-
322
- if (!result.ok) {
323
- throw new Error(`HTTP ${result.status}`);
324
- }
325
-
326
- const respData = result.responseJson as { data?: { responseId?: string; created?: string } };
327
- console.log('[Xebo] Response data:', {
328
- responseId: respData?.data?.responseId,
329
- created: respData?.data?.created,
330
- });
331
- } catch (err) {
332
- console.error('[Xebo] Submission failed — queuing offline:', err);
333
- await this._enqueueOffline(endTime);
334
- }
335
- }
336
-
337
- private async _enqueueOffline(endTime: string): Promise<void> {
338
- if (!this.survey) return;
339
-
340
- const queued: XeboQueuedResponse = {
341
- responseId: uuidv4(),
342
- surveyId: this.survey.id,
343
- collectorUUID: this.resolvedCollectorUUID,
344
- mode: 'React Native SDK',
345
- status: 'complete',
346
- startTime: this.surveyStartTime,
347
- endTime,
348
- answers: [...this.currentAnswers],
349
- userData: this.userData ?? undefined,
350
- deviceModel: this.deviceModel,
351
- platform: Platform.OS,
352
- osVersion: this.osVersion,
353
- qualityFlags: this._buildQualityFlags(),
354
- geolocation: this._buildGeolocation(),
355
- deviceInfo: {
356
- type: 'other',
357
- os: Platform.OS === 'ios' ? 'ios' : 'android',
358
- browser: Platform.OS === 'ios' ? 'safari' : 'chrome',
359
- },
360
- };
361
-
362
- await XeboOfflineQueue.enqueue(queued);
363
- }
364
-
365
- // ─── Flush queue ───────────────────────────────────────────────────────────
366
-
367
- async flushQueue(): Promise<void> {
368
- const all = await XeboOfflineQueue.getAll();
369
- if (all.length === 0) return;
370
-
371
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
372
- console.log(`[Xebo Offline] Flushing ${all.length} queued response(s)`);
373
-
374
- const failed: XeboQueuedResponse[] = [];
375
-
376
- for (const queued of all) {
377
- try {
378
- const result = await submitResponse(
379
- this.feedbackBaseURL,
380
- queued.surveyId,
381
- queued.collectorUUID,
382
- this.bearerToken,
383
- queued.answers,
384
- {
385
- userData: queued.userData,
386
- deviceModel: queued.deviceModel,
387
- platform: queued.platform,
388
- osVersion: queued.osVersion,
389
- startTime: queued.startTime,
390
- endTime: queued.endTime,
391
- qualityFlags: queued.qualityFlags,
392
- geolocation: queued.geolocation,
393
- deviceInfo: queued.deviceInfo,
394
- },
395
- );
396
- if (!result.ok) throw new Error(`HTTP ${result.status}`);
397
- console.log('[Xebo Offline] Flushed response:', queued.responseId);
398
- } catch (err) {
399
- console.error('[Xebo Offline] Retry failed for:', queued.responseId, err);
400
- failed.push(queued);
401
- }
402
- }
403
-
404
- await XeboOfflineQueue.saveAll(failed);
405
- console.log(`[Xebo Offline] Flush complete — ${failed.length} still pending`);
406
- console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
407
- }
408
-
409
- // ─── Modal visibility ──────────────────────────────────────────────────────
410
-
411
- private _setVisible(visible: boolean): void {
412
- this.surveyVisible = visible;
413
- this.emit(XEBO_EVENTS.SURVEY_VISIBLE, visible);
414
- }
415
-
416
- dismissSurvey(): void {
417
- this._setVisible(false);
418
- this.emit(XEBO_EVENTS.SURVEY_DISMISSED);
419
- }
420
- }
421
-
422
- export const XeboSurveyManager = new XeboSurveyManagerClass();
package/src/index.ts DELETED
@@ -1,23 +0,0 @@
1
- // ─── Core ─────────────────────────────────────────────────────────────────────
2
- export { XeboSurveyManager, XEBO_EVENTS } from './core/XeboSurveyManager';
3
-
4
- // ─── Components ───────────────────────────────────────────────────────────────
5
- export { XeboSurveyModal } from './components/XeboSurveyModal';
6
-
7
- // ─── Types ────────────────────────────────────────────────────────────────────
8
- export type {
9
- XeboSurvey,
10
- XeboQuestion,
11
- XeboAnswer,
12
- XeboAnswerValue,
13
- XeboQueuedResponse,
14
- XeboConfig,
15
- XeboThemeConfig,
16
- XeboChoice,
17
- XeboNPSLabels,
18
- XeboConditionalFollowUp,
19
- XeboSurveyPage,
20
- XeboUserData,
21
- } from './models/XeboModels';
22
-
23
- export { XeboQuestionType } from './models/XeboModels';
@@ -1,80 +0,0 @@
1
- // ─── Raw API response shapes ──────────────────────────────────────────────────
2
- // These mirror the exact JSON returned by the Xebo backend.
3
-
4
- export interface APICollectorResponse {
5
- data: {
6
- _id: string;
7
- uuid: string;
8
- surveyId: string;
9
- [key: string]: unknown;
10
- };
11
- }
12
-
13
- export interface APIOptionItem {
14
- uuid: string;
15
- text: string;
16
- }
17
-
18
- export interface APIConfigScale {
19
- uuid: string;
20
- scale: { min: number; max: number };
21
- enabled: boolean;
22
- qId: string[];
23
- }
24
-
25
- export interface APIQuestionSettings {
26
- nps?: {
27
- colors?: {
28
- detractor?: string;
29
- passive?: string;
30
- promoter?: string;
31
- };
32
- leftLabel?: string;
33
- rightLabel?: string;
34
- };
35
- configScale?: APIConfigScale[];
36
- rating?: {
37
- type?: string;
38
- colLabel?: boolean;
39
- color?: string;
40
- };
41
- }
42
-
43
- export interface APIQuestion {
44
- uuid: string;
45
- title: string;
46
- quesType: string;
47
- helperText?: { text?: string };
48
- required?: { enabled?: boolean };
49
- options?: {
50
- row?: APIOptionItem[];
51
- col?: APIOptionItem[];
52
- };
53
- settings?: APIQuestionSettings;
54
- placeholder?: { text?: string };
55
- }
56
-
57
- export interface APIBlock {
58
- questions: Array<{ question: APIQuestion }>;
59
- }
60
-
61
- export interface APISurveyData {
62
- uuid: string;
63
- displayTitle: string;
64
- projectId?: string;
65
- blocks: APIBlock[];
66
- introPage?: {
67
- enabled?: boolean;
68
- content?: string;
69
- buttonText?: string;
70
- };
71
- thankYouPage?: {
72
- enabled?: boolean;
73
- content?: string;
74
- links?: string;
75
- };
76
- }
77
-
78
- export interface APISurveyResponse {
79
- data: APISurveyData;
80
- }
@@ -1,169 +0,0 @@
1
- // ─── Enums ───────────────────────────────────────────────────────────────────
2
-
3
- export enum XeboQuestionType {
4
- singleChoice = 'singleChoice',
5
- multipleChoice = 'multipleChoice',
6
- dropdown = 'dropdown',
7
- singleTextBox = 'singleTextBox',
8
- multipleTextBox = 'multipleTextBox',
9
- nps = 'nps',
10
- multiNps = 'multiNps',
11
- rating = 'rating',
12
- multiRating = 'multiRating',
13
- thankYou = 'thankYou',
14
- }
15
-
16
- // ─── Sub-models ───────────────────────────────────────────────────────────────
17
-
18
- export interface XeboChoice {
19
- id: string;
20
- text: string;
21
- value: string;
22
- }
23
-
24
- export interface XeboNPSLabels {
25
- lower?: string;
26
- upper?: string;
27
- detractorColor?: string;
28
- passiveColor?: string;
29
- promoterColor?: string;
30
- }
31
-
32
- export interface XeboConditionalFollowUp {
33
- minRating: number;
34
- maxRating: number;
35
- followUpQuestion: string;
36
- followUpType: string;
37
- followUpOptions: XeboChoice[];
38
- questionId: string;
39
- }
40
-
41
- // ─── Question ─────────────────────────────────────────────────────────────────
42
-
43
- export interface XeboQuestion {
44
- id: string;
45
- type: XeboQuestionType;
46
- title: string;
47
- subtitle?: string;
48
- placeholder?: string;
49
- isRequired: boolean;
50
- options?: XeboChoice[]; // rows
51
- columns?: XeboChoice[]; // cols (for NPS / Rating scale labels)
52
- npsLabels?: XeboNPSLabels;
53
- followUpQuestion?: string;
54
- conditionalFollowUps?: XeboConditionalFollowUp[];
55
- redirectURL?: string;
56
- ratingStyle?: string;
57
- showColLabels?: boolean;
58
- ratingColor?: string;
59
- }
60
-
61
- // ─── Survey Page ──────────────────────────────────────────────────────────────
62
-
63
- export interface XeboSurveyPage {
64
- enabled: boolean;
65
- content?: string;
66
- buttonText?: string;
67
- links?: string;
68
- }
69
-
70
- // ─── Survey ───────────────────────────────────────────────────────────────────
71
-
72
- export interface XeboSurvey {
73
- id: string;
74
- name: string;
75
- projectId?: string;
76
- questions: XeboQuestion[];
77
- introPage?: XeboSurveyPage;
78
- thankYouPage?: XeboSurveyPage;
79
- }
80
-
81
- // ─── Answers ──────────────────────────────────────────────────────────────────
82
-
83
- export interface XeboAnswerValue {
84
- rowId: string;
85
- colId?: string;
86
- text?: string;
87
- }
88
-
89
- export interface XeboAnswer {
90
- questionId: string;
91
- value: XeboAnswerValue[];
92
- }
93
-
94
- // ─── User / eData ─────────────────────────────────────────────────────────────
95
-
96
- export interface XeboUserData {
97
- name?: string;
98
- email?: string;
99
- phone?: string;
100
- uniqueId?: string;
101
- country?: string;
102
- city?: string;
103
- region?: string;
104
- eData?: Record<string, string>;
105
- }
106
-
107
- export interface XeboQualityFlags {
108
- data: {
109
- timePerQues: Record<string, { timeOnQues: number }>;
110
- survey: {
111
- totalTimeDuration: number;
112
- netTimeDuration: number;
113
- curTime: string;
114
- startTime: number;
115
- backTrackCount: number;
116
- };
117
- };
118
- straightLining: { questionList: string[] };
119
- }
120
-
121
- export interface XeboDeviceInfo {
122
- type: string;
123
- os: string;
124
- browser: string;
125
- }
126
-
127
- export interface XeboGeolocation {
128
- type: string;
129
- coordinates: (number | null)[];
130
- country: string | null;
131
- city: string | null;
132
- region: string | null;
133
- }
134
-
135
- // ─── Offline Queue ────────────────────────────────────────────────────────────
136
-
137
- export interface XeboQueuedResponse {
138
- responseId: string;
139
- surveyId: string;
140
- collectorUUID: string;
141
- mode: string;
142
- status: 'complete' | 'incomplete';
143
- startTime: string;
144
- endTime: string;
145
- answers: XeboAnswer[];
146
- userData?: XeboUserData;
147
- deviceModel?: string;
148
- platform?: string;
149
- osVersion?: string;
150
- qualityFlags?: XeboQualityFlags;
151
- geolocation?: XeboGeolocation;
152
- deviceInfo?: XeboDeviceInfo;
153
- }
154
-
155
- // ─── Config ───────────────────────────────────────────────────────────────────
156
-
157
- export interface XeboConfig {
158
- apiKey: string;
159
- collectorId: string;
160
- zone: string;
161
- }
162
-
163
- export interface XeboThemeConfig {
164
- primaryColor?: string;
165
- backgroundColor?: string;
166
- textColor?: string;
167
- cornerRadius?: number;
168
- fontFamily?: string;
169
- }