cuoral-ionic 0.0.6 → 0.0.8
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/android/build/.transforms/bb54161301273cf9b5b94a21c0fb3f23/transformed/classes/classes_dex/classes.dex +0 -0
- package/android/build/.transforms/f1aabffcd8b03aa664e77a79b3e1de5d/transformed/debug/debug_dex/com/cuoral/ionic/CuoralPlugin$1.dex +0 -0
- package/android/build/.transforms/f1aabffcd8b03aa664e77a79b3e1de5d/transformed/debug/debug_dex/com/cuoral/ionic/CuoralPlugin$2.dex +0 -0
- package/android/build/.transforms/f1aabffcd8b03aa664e77a79b3e1de5d/transformed/debug/debug_dex/com/cuoral/ionic/CuoralPlugin$3.dex +0 -0
- package/android/build/.transforms/f1aabffcd8b03aa664e77a79b3e1de5d/transformed/debug/debug_dex/com/cuoral/ionic/CuoralPlugin$4.dex +0 -0
- package/android/build/.transforms/f1aabffcd8b03aa664e77a79b3e1de5d/transformed/debug/debug_dex/com/cuoral/ionic/CuoralPlugin$5.dex +0 -0
- package/android/build/.transforms/f1aabffcd8b03aa664e77a79b3e1de5d/transformed/debug/debug_dex/com/cuoral/ionic/CuoralPlugin$6.dex +0 -0
- package/android/build/.transforms/f1aabffcd8b03aa664e77a79b3e1de5d/transformed/debug/debug_dex/com/cuoral/ionic/CuoralPlugin$InitiateCallback.dex +0 -0
- package/android/build/.transforms/f1aabffcd8b03aa664e77a79b3e1de5d/transformed/debug/debug_dex/com/cuoral/ionic/CuoralPlugin$UploadCallback.dex +0 -0
- package/android/build/.transforms/f1aabffcd8b03aa664e77a79b3e1de5d/transformed/debug/debug_dex/com/cuoral/ionic/CuoralPlugin.dex +0 -0
- package/android/build/.transforms/f1aabffcd8b03aa664e77a79b3e1de5d/transformed/debug/desugar_graph.bin +0 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/javac/debug/classes/com/cuoral/ionic/CuoralPlugin$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/cuoral/ionic/CuoralPlugin$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/cuoral/ionic/CuoralPlugin$3.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/cuoral/ionic/CuoralPlugin$4.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/cuoral/ionic/CuoralPlugin$5.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/cuoral/ionic/CuoralPlugin$6.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/cuoral/ionic/CuoralPlugin$InitiateCallback.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/cuoral/ionic/CuoralPlugin$UploadCallback.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/cuoral/ionic/CuoralPlugin.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/cuoral/ionic/CuoralPlugin$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/cuoral/ionic/CuoralPlugin$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/cuoral/ionic/CuoralPlugin$3.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/cuoral/ionic/CuoralPlugin$4.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/cuoral/ionic/CuoralPlugin$5.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/cuoral/ionic/CuoralPlugin$6.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/cuoral/ionic/CuoralPlugin$InitiateCallback.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/cuoral/ionic/CuoralPlugin$UploadCallback.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/cuoral/ionic/CuoralPlugin.class +0 -0
- package/android/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/{CuoralPlugin$1.class.uniqueId1 → CuoralPlugin$1.class.uniqueId2} +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/{CuoralPlugin$2.class.uniqueId2 → CuoralPlugin$2.class.uniqueId5} +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/CuoralPlugin$3.class.uniqueId3 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/CuoralPlugin$4.class.uniqueId6 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/CuoralPlugin$5.class.uniqueId4 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/CuoralPlugin$6.class.uniqueId8 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/CuoralPlugin$InitiateCallback.class.uniqueId0 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/CuoralPlugin$UploadCallback.class.uniqueId7 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/CuoralPlugin.class.uniqueId1 +0 -0
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build.gradle +1 -0
- package/android/src/main/java/com/cuoral/ionic/CuoralPlugin.java +209 -6
- package/dist/bridge.d.ts.map +1 -1
- package/dist/cuoral.d.ts +15 -1
- package/dist/cuoral.d.ts.map +1 -1
- package/dist/cuoral.js +141 -12
- package/dist/index.esm.js +218 -46
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +218 -46
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +4 -0
- package/dist/intelligence.d.ts.map +1 -1
- package/dist/intelligence.js +19 -0
- package/dist/plugin.d.ts +16 -3
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +53 -36
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -0
- package/ios/Plugin/CuoralPlugin.swift +249 -13
- package/package.json +1 -1
- package/src/bridge.ts +1 -0
- package/src/cuoral.ts +158 -14
- package/src/intelligence.ts +23 -0
- package/src/plugin.ts +70 -37
- package/src/types.ts +4 -0
- package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/CuoralPlugin.class.uniqueId0 +0 -0
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ exports.CuoralMessageType = void 0;
|
|
|
32
32
|
CuoralMessageType["STOP_RECORDING"] = "CUORAL_STOP_RECORDING";
|
|
33
33
|
CuoralMessageType["RECORDING_STARTED"] = "CUORAL_RECORDING_STARTED";
|
|
34
34
|
CuoralMessageType["RECORDING_STOPPED"] = "CUORAL_RECORDING_STOPPED";
|
|
35
|
+
CuoralMessageType["RECORDING_UPLOADED"] = "CUORAL_RECORDING_UPLOADED";
|
|
35
36
|
CuoralMessageType["RECORDING_ERROR"] = "CUORAL_RECORDING_ERROR";
|
|
36
37
|
// Screenshot
|
|
37
38
|
CuoralMessageType["TAKE_SCREENSHOT"] = "CUORAL_TAKE_SCREENSHOT";
|
|
@@ -40,6 +41,9 @@ exports.CuoralMessageType = void 0;
|
|
|
40
41
|
// Widget Communication
|
|
41
42
|
CuoralMessageType["WIDGET_READY"] = "CUORAL_WIDGET_READY";
|
|
42
43
|
CuoralMessageType["WIDGET_CLOSED"] = "CUORAL_WIDGET_CLOSED";
|
|
44
|
+
CuoralMessageType["SESSION_UPDATED"] = "CUORAL_SESSION_UPDATED";
|
|
45
|
+
CuoralMessageType["REQUEST_SESSION_ID"] = "CUORAL_REQUEST_SESSION_ID";
|
|
46
|
+
CuoralMessageType["SESSION_ID_RESPONSE"] = "CUORAL_SESSION_ID_RESPONSE";
|
|
43
47
|
// File Upload
|
|
44
48
|
CuoralMessageType["UPLOAD_FILE"] = "CUORAL_UPLOAD_FILE";
|
|
45
49
|
CuoralMessageType["UPLOAD_PROGRESS"] = "CUORAL_UPLOAD_PROGRESS";
|
|
@@ -61,7 +65,7 @@ class CuoralRecorder {
|
|
|
61
65
|
/**
|
|
62
66
|
* Start recording with automatic permission handling
|
|
63
67
|
*/
|
|
64
|
-
async startRecording(options) {
|
|
68
|
+
async startRecording(options, sendMessages = true) {
|
|
65
69
|
try {
|
|
66
70
|
// Check if already recording
|
|
67
71
|
if (this.isRecording) {
|
|
@@ -83,20 +87,24 @@ class CuoralRecorder {
|
|
|
83
87
|
if (result.success) {
|
|
84
88
|
this.isRecording = true;
|
|
85
89
|
this.recordingStartTime = Date.now();
|
|
86
|
-
// Post message to widget
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
// Post message to widget only if enabled (disabled when called from widget handler)
|
|
91
|
+
if (sendMessages) {
|
|
92
|
+
this.postMessage({
|
|
93
|
+
type: exports.CuoralMessageType.RECORDING_STARTED,
|
|
94
|
+
payload: { timestamp: this.recordingStartTime },
|
|
95
|
+
});
|
|
96
|
+
}
|
|
91
97
|
}
|
|
92
98
|
else {
|
|
93
99
|
// Recording failed - reset state and notify widget
|
|
94
100
|
this.isRecording = false;
|
|
95
101
|
this.recordingStartTime = undefined;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
102
|
+
if (sendMessages) {
|
|
103
|
+
this.postMessage({
|
|
104
|
+
type: exports.CuoralMessageType.RECORDING_ERROR,
|
|
105
|
+
payload: { error: 'Failed to start recording' },
|
|
106
|
+
});
|
|
107
|
+
}
|
|
100
108
|
}
|
|
101
109
|
return result.success;
|
|
102
110
|
}
|
|
@@ -104,58 +112,71 @@ class CuoralRecorder {
|
|
|
104
112
|
// Exception occurred - reset state and notify widget
|
|
105
113
|
this.isRecording = false;
|
|
106
114
|
this.recordingStartTime = undefined;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
if (sendMessages) {
|
|
116
|
+
this.postMessage({
|
|
117
|
+
type: exports.CuoralMessageType.RECORDING_ERROR,
|
|
118
|
+
payload: { error: error.message },
|
|
119
|
+
});
|
|
120
|
+
}
|
|
111
121
|
return false;
|
|
112
122
|
}
|
|
113
123
|
}
|
|
114
124
|
/**
|
|
115
125
|
* Stop recording
|
|
116
126
|
*/
|
|
117
|
-
async stopRecording() {
|
|
127
|
+
async stopRecording(options, sendMessages = true) {
|
|
118
128
|
try {
|
|
119
129
|
if (!this.isRecording) {
|
|
120
130
|
// Send error message to widget so it can exit "stopping" state
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
131
|
+
if (sendMessages) {
|
|
132
|
+
this.postMessage({
|
|
133
|
+
type: exports.CuoralMessageType.RECORDING_ERROR,
|
|
134
|
+
payload: { error: 'Not recording' },
|
|
135
|
+
});
|
|
136
|
+
}
|
|
125
137
|
return null;
|
|
126
138
|
}
|
|
127
|
-
const result = await CuoralPlugin$1.stopRecording();
|
|
139
|
+
const result = await CuoralPlugin$1.stopRecording(options);
|
|
128
140
|
if (result.success) {
|
|
129
141
|
this.isRecording = false;
|
|
130
142
|
const duration = this.recordingStartTime
|
|
131
143
|
? Math.floor((Date.now() - this.recordingStartTime) / 1000)
|
|
132
144
|
: 0;
|
|
133
|
-
//
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
145
|
+
// Send RECORDING_STOPPED message only if enabled
|
|
146
|
+
if (sendMessages) {
|
|
147
|
+
this.postMessage({
|
|
148
|
+
type: exports.CuoralMessageType.RECORDING_STOPPED,
|
|
149
|
+
payload: {
|
|
150
|
+
filePath: result.filePath,
|
|
151
|
+
duration: result.duration || duration,
|
|
152
|
+
uploaded: result.uploaded,
|
|
153
|
+
uploadedToBackend: result.uploaded,
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
}
|
|
141
157
|
return {
|
|
142
158
|
filePath: result.filePath,
|
|
143
159
|
duration: result.duration || duration,
|
|
160
|
+
uploaded: result.uploaded,
|
|
144
161
|
};
|
|
145
162
|
}
|
|
146
163
|
// If result.success is false, send error to widget
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
164
|
+
if (sendMessages) {
|
|
165
|
+
this.postMessage({
|
|
166
|
+
type: exports.CuoralMessageType.RECORDING_ERROR,
|
|
167
|
+
payload: { error: 'Failed to stop recording' },
|
|
168
|
+
});
|
|
169
|
+
}
|
|
151
170
|
return null;
|
|
152
171
|
}
|
|
153
172
|
catch (error) {
|
|
154
173
|
console.error('[Cuoral] Failed to stop recording:', error);
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
174
|
+
if (sendMessages) {
|
|
175
|
+
this.postMessage({
|
|
176
|
+
type: exports.CuoralMessageType.RECORDING_ERROR,
|
|
177
|
+
payload: { error: error.message },
|
|
178
|
+
});
|
|
179
|
+
}
|
|
159
180
|
return null;
|
|
160
181
|
}
|
|
161
182
|
}
|
|
@@ -657,6 +678,24 @@ class CuoralIntelligence {
|
|
|
657
678
|
this.rageClickWindowMs = 2000; // Within 2 seconds
|
|
658
679
|
this.sessionId = sessionId;
|
|
659
680
|
}
|
|
681
|
+
/**
|
|
682
|
+
* Update the session ID (e.g., when user logs in)
|
|
683
|
+
*/
|
|
684
|
+
updateSessionId(newSessionId) {
|
|
685
|
+
console.log('[Cuoral Intelligence] Updating session ID from', this.sessionId, 'to', newSessionId);
|
|
686
|
+
this.sessionId = newSessionId;
|
|
687
|
+
// Flush any pending events with the old session before switching
|
|
688
|
+
this.flush();
|
|
689
|
+
// Update native error capture with new session ID
|
|
690
|
+
if (core.Capacitor.isNativePlatform()) {
|
|
691
|
+
CuoralPlugin.setupNativeErrorCapture({
|
|
692
|
+
backendUrl: this.config.consoleErrorBackendUrl,
|
|
693
|
+
sessionId: newSessionId
|
|
694
|
+
}).catch(error => {
|
|
695
|
+
console.warn('[Cuoral Intelligence] Failed to update native error capture:', error);
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
}
|
|
660
699
|
/**
|
|
661
700
|
* Initialize intelligence tracking
|
|
662
701
|
*/
|
|
@@ -986,6 +1025,7 @@ class CuoralIntelligence {
|
|
|
986
1025
|
url: window.location.href,
|
|
987
1026
|
data,
|
|
988
1027
|
};
|
|
1028
|
+
console.log(`[Intelligence] Enqueuing ${type} event with session:`, this.sessionId);
|
|
989
1029
|
queue.push(event);
|
|
990
1030
|
// Flush immediately for critical errors
|
|
991
1031
|
const shouldFlushImmediately = type === 'api_call' && (data.status_code === 0 || data.status_code >= 400);
|
|
@@ -1415,6 +1455,7 @@ class CuoralIntelligence {
|
|
|
1415
1455
|
*/
|
|
1416
1456
|
class Cuoral {
|
|
1417
1457
|
constructor(options) {
|
|
1458
|
+
console.log('[Cuoral] Constructor called with options:', options);
|
|
1418
1459
|
// Check if running on a mobile platform
|
|
1419
1460
|
if (!core.Capacitor.isNativePlatform()) {
|
|
1420
1461
|
throw new Error('Cuoral Ionic library only works on native mobile platforms (iOS/Android). Web is not supported.');
|
|
@@ -1424,6 +1465,7 @@ class Cuoral {
|
|
|
1424
1465
|
useModal: true,
|
|
1425
1466
|
...options
|
|
1426
1467
|
};
|
|
1468
|
+
console.log('[Cuoral] Merged options:', this.options);
|
|
1427
1469
|
// Determine widget base URL
|
|
1428
1470
|
const baseUrl = options.widgetBaseUrl || Cuoral.PRODUCTION_WIDGET_URL;
|
|
1429
1471
|
const params = new URLSearchParams({
|
|
@@ -1431,6 +1473,11 @@ class Cuoral {
|
|
|
1431
1473
|
key: options.publicKey,
|
|
1432
1474
|
_t: Date.now().toString(),
|
|
1433
1475
|
});
|
|
1476
|
+
// Add session_id if available (for widget to use existing session)
|
|
1477
|
+
const existingSessionId = localStorage.getItem('__x_loadID');
|
|
1478
|
+
if (existingSessionId) {
|
|
1479
|
+
params.set('cuoral_mobile_session_id', existingSessionId);
|
|
1480
|
+
}
|
|
1434
1481
|
if (options.email)
|
|
1435
1482
|
params.set('email', options.email);
|
|
1436
1483
|
if (options.firstName)
|
|
@@ -1448,25 +1495,36 @@ class Cuoral {
|
|
|
1448
1495
|
debug: options.debug || false
|
|
1449
1496
|
});
|
|
1450
1497
|
this.recorder = new CuoralRecorder();
|
|
1498
|
+
// Expose bridge on window for widget detection and debugging
|
|
1499
|
+
window.CuoralCapacitorBridge = true;
|
|
1500
|
+
window.__cuoralBridge = this.bridge; // For debugging
|
|
1501
|
+
window.__cuoralRecorder = this.recorder; // For debugging
|
|
1502
|
+
console.log('[Cuoral] Bridge and recorder created, exposed on window');
|
|
1451
1503
|
// Setup automatic message handlers
|
|
1452
1504
|
this.setupMessageHandlers();
|
|
1505
|
+
console.log('[Cuoral] Constructor complete');
|
|
1453
1506
|
}
|
|
1454
1507
|
/**
|
|
1455
1508
|
* Initialize Cuoral
|
|
1456
1509
|
*/
|
|
1457
1510
|
async initialize() {
|
|
1511
|
+
// Fetch session configuration and initialize intelligence if enabled by backend
|
|
1512
|
+
await this.initializeIntelligence();
|
|
1513
|
+
console.log('[Cuoral] Initialize - Session ID:', localStorage.getItem('__x_loadID'));
|
|
1514
|
+
// Setup localStorage listener to detect when widget changes session
|
|
1515
|
+
this.setupStorageListener();
|
|
1458
1516
|
this.bridge.initialize();
|
|
1459
1517
|
// Recreate modal if it was destroyed (e.g., after clearSession)
|
|
1460
1518
|
if (this.options.useModal && !this.modal) {
|
|
1461
1519
|
const widgetUrl = this.getWidgetUrl();
|
|
1462
1520
|
this.modal = new CuoralModal(widgetUrl, this.options.showFloatingButton);
|
|
1463
1521
|
}
|
|
1464
|
-
//
|
|
1522
|
+
// Update modal URL with session ID
|
|
1465
1523
|
if (this.modal) {
|
|
1524
|
+
const widgetUrl = this.getWidgetUrl();
|
|
1525
|
+
this.modal.updateWidgetUrl(widgetUrl);
|
|
1466
1526
|
this.modal.initialize();
|
|
1467
1527
|
}
|
|
1468
|
-
// Fetch session configuration and initialize intelligence if enabled by backend
|
|
1469
|
-
await this.initializeIntelligence();
|
|
1470
1528
|
}
|
|
1471
1529
|
/**
|
|
1472
1530
|
* Initialize intelligence based on backend configuration
|
|
@@ -1498,9 +1556,13 @@ class Cuoral {
|
|
|
1498
1556
|
}
|
|
1499
1557
|
// Only initialize intelligence if customer_intelligence is enabled in backend
|
|
1500
1558
|
if (config && config.customer_intelligence === true) {
|
|
1559
|
+
console.log('[Cuoral] Initializing intelligence with session:', sessionId);
|
|
1501
1560
|
this.intelligence = new CuoralIntelligence(sessionId);
|
|
1502
1561
|
this.intelligence.init();
|
|
1503
1562
|
}
|
|
1563
|
+
else {
|
|
1564
|
+
console.log('[Cuoral] Intelligence not enabled or no config for session:', sessionId);
|
|
1565
|
+
}
|
|
1504
1566
|
}
|
|
1505
1567
|
catch (error) {
|
|
1506
1568
|
console.warn('[Cuoral] Failed to initialize intelligence:', error);
|
|
@@ -1557,6 +1619,48 @@ class Cuoral {
|
|
|
1557
1619
|
this.intelligence.trackError(message, stackTrace, metadata);
|
|
1558
1620
|
}
|
|
1559
1621
|
}
|
|
1622
|
+
/**
|
|
1623
|
+
* Update user profile for the current session
|
|
1624
|
+
* Call this after user logs in to update the intelligence session with their profile
|
|
1625
|
+
* @param email - User's email address
|
|
1626
|
+
* @param name - User's full name
|
|
1627
|
+
*/
|
|
1628
|
+
async updateUserProfile(email, name) {
|
|
1629
|
+
try {
|
|
1630
|
+
const sessionId = localStorage.getItem('__x_loadID');
|
|
1631
|
+
if (!sessionId) {
|
|
1632
|
+
console.warn('[Cuoral] No session ID found, cannot update profile');
|
|
1633
|
+
return false;
|
|
1634
|
+
}
|
|
1635
|
+
console.log('[Cuoral] Updating user profile for session:', sessionId);
|
|
1636
|
+
const response = await fetch('https://api.cuoral.com/conversation/set-profile', {
|
|
1637
|
+
method: 'POST',
|
|
1638
|
+
headers: { 'Content-Type': 'application/json' },
|
|
1639
|
+
body: JSON.stringify({
|
|
1640
|
+
session_id: sessionId,
|
|
1641
|
+
email: email,
|
|
1642
|
+
name: name,
|
|
1643
|
+
}),
|
|
1644
|
+
});
|
|
1645
|
+
if (!response.ok) {
|
|
1646
|
+
console.error('[Cuoral] Failed to update profile:', response.statusText);
|
|
1647
|
+
return false;
|
|
1648
|
+
}
|
|
1649
|
+
console.log('[Cuoral] ✓ User profile updated successfully for session:', sessionId);
|
|
1650
|
+
// Store user info locally
|
|
1651
|
+
this.options.email = email;
|
|
1652
|
+
const nameParts = name.split(' ');
|
|
1653
|
+
if (nameParts.length > 0) {
|
|
1654
|
+
this.options.firstName = nameParts[0];
|
|
1655
|
+
this.options.lastName = nameParts.slice(1).join(' ');
|
|
1656
|
+
}
|
|
1657
|
+
return true;
|
|
1658
|
+
}
|
|
1659
|
+
catch (error) {
|
|
1660
|
+
console.error('[Cuoral] Error updating user profile:', error);
|
|
1661
|
+
return false;
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1560
1664
|
/**
|
|
1561
1665
|
* Start native screen recording programmatically
|
|
1562
1666
|
* @returns Promise<boolean> - true if recording started successfully
|
|
@@ -1572,11 +1676,19 @@ class Cuoral {
|
|
|
1572
1676
|
}
|
|
1573
1677
|
/**
|
|
1574
1678
|
* Stop native screen recording programmatically
|
|
1575
|
-
*
|
|
1679
|
+
* Recording will be automatically uploaded to the portal
|
|
1680
|
+
* @returns Promise<{filePath?: string; duration?: number; uploaded?: boolean} | null> - Recording result or null if failed
|
|
1576
1681
|
*/
|
|
1577
1682
|
async stopRecording() {
|
|
1578
1683
|
try {
|
|
1579
|
-
|
|
1684
|
+
const sessionId = localStorage.getItem('__x_loadID');
|
|
1685
|
+
const customerId = localStorage.getItem('cuoralCustomerId');
|
|
1686
|
+
return await this.recorder.stopRecording({
|
|
1687
|
+
autoUpload: true,
|
|
1688
|
+
sessionId: sessionId || undefined,
|
|
1689
|
+
publicKey: this.options.publicKey,
|
|
1690
|
+
customerId: customerId || undefined,
|
|
1691
|
+
});
|
|
1580
1692
|
}
|
|
1581
1693
|
catch (error) {
|
|
1582
1694
|
console.error('[Cuoral] Failed to stop recording:', error);
|
|
@@ -1622,7 +1734,7 @@ class Cuoral {
|
|
|
1622
1734
|
// Add session_id if available
|
|
1623
1735
|
const sessionId = localStorage.getItem('__x_loadID');
|
|
1624
1736
|
if (sessionId) {
|
|
1625
|
-
params.set('
|
|
1737
|
+
params.set('cuoral_mobile_session_id', sessionId);
|
|
1626
1738
|
}
|
|
1627
1739
|
if (this.options.email)
|
|
1628
1740
|
params.set('email', this.options.email);
|
|
@@ -1676,6 +1788,28 @@ class Cuoral {
|
|
|
1676
1788
|
}
|
|
1677
1789
|
}
|
|
1678
1790
|
}
|
|
1791
|
+
/**
|
|
1792
|
+
* Setup localStorage listener for session changes
|
|
1793
|
+
* Widget updates localStorage when creating new session, SDK detects and syncs
|
|
1794
|
+
*/
|
|
1795
|
+
setupStorageListener() {
|
|
1796
|
+
// Poll localStorage every 2 seconds to detect session changes
|
|
1797
|
+
// (storage event doesn't fire for same-window changes)
|
|
1798
|
+
let lastKnownSession = localStorage.getItem('__x_loadID');
|
|
1799
|
+
setInterval(() => {
|
|
1800
|
+
const currentSession = localStorage.getItem('__x_loadID');
|
|
1801
|
+
if (currentSession && currentSession !== lastKnownSession) {
|
|
1802
|
+
console.log('[Cuoral] 🔄 Session changed in localStorage');
|
|
1803
|
+
console.log('[Cuoral] Old session:', lastKnownSession);
|
|
1804
|
+
console.log('[Cuoral] New session:', currentSession);
|
|
1805
|
+
lastKnownSession = currentSession;
|
|
1806
|
+
// Update intelligence to use new session
|
|
1807
|
+
if (this.intelligence) {
|
|
1808
|
+
this.intelligence.updateSessionId(currentSession);
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
}, 2000);
|
|
1812
|
+
}
|
|
1679
1813
|
/**
|
|
1680
1814
|
* Clean up resources
|
|
1681
1815
|
*/
|
|
@@ -1763,13 +1897,51 @@ class Cuoral {
|
|
|
1763
1897
|
setupMessageHandlers() {
|
|
1764
1898
|
// Handle start recording requests from widget
|
|
1765
1899
|
this.bridge.on(exports.CuoralMessageType.START_RECORDING, async () => {
|
|
1766
|
-
|
|
1900
|
+
// Pass sendMessages: false to prevent duplicate messages
|
|
1901
|
+
const success = await this.recorder.startRecording(undefined, false);
|
|
1902
|
+
if (success) {
|
|
1903
|
+
// Send RECORDING_STARTED back to widget
|
|
1904
|
+
this.bridge.sendToWidget({
|
|
1905
|
+
type: exports.CuoralMessageType.RECORDING_STARTED,
|
|
1906
|
+
payload: {
|
|
1907
|
+
timestamp: Date.now()
|
|
1908
|
+
}
|
|
1909
|
+
});
|
|
1910
|
+
}
|
|
1911
|
+
else {
|
|
1912
|
+
this.bridge.sendToWidget({
|
|
1913
|
+
type: exports.CuoralMessageType.RECORDING_ERROR,
|
|
1914
|
+
payload: {
|
|
1915
|
+
error: 'Failed to start recording'
|
|
1916
|
+
}
|
|
1917
|
+
});
|
|
1918
|
+
}
|
|
1767
1919
|
});
|
|
1768
1920
|
// Handle stop recording requests from widget
|
|
1769
1921
|
this.bridge.on(exports.CuoralMessageType.STOP_RECORDING, async () => {
|
|
1770
|
-
const
|
|
1771
|
-
|
|
1772
|
-
|
|
1922
|
+
const sessionId = localStorage.getItem('__x_loadID');
|
|
1923
|
+
const customerId = localStorage.getItem('cuoralCustomerId');
|
|
1924
|
+
// Pass sendMessages: false to prevent duplicate messages
|
|
1925
|
+
const result = await this.recorder.stopRecording({
|
|
1926
|
+
autoUpload: true,
|
|
1927
|
+
sessionId: sessionId || undefined,
|
|
1928
|
+
publicKey: this.options.publicKey,
|
|
1929
|
+
customerId: customerId || undefined,
|
|
1930
|
+
}, false);
|
|
1931
|
+
if (result && result.uploaded) {
|
|
1932
|
+
// Video was automatically uploaded, notify widget with RECORDING_STOPPED
|
|
1933
|
+
this.bridge.sendToWidget({
|
|
1934
|
+
type: exports.CuoralMessageType.RECORDING_STOPPED,
|
|
1935
|
+
payload: {
|
|
1936
|
+
duration: result.duration,
|
|
1937
|
+
uploaded: true,
|
|
1938
|
+
uploadedToBackend: true,
|
|
1939
|
+
timestamp: Date.now()
|
|
1940
|
+
}
|
|
1941
|
+
});
|
|
1942
|
+
}
|
|
1943
|
+
else if (result) {
|
|
1944
|
+
// Upload failed or was disabled, send video data to widget (old behavior)
|
|
1773
1945
|
const capacitorUrl = result.filePath ? core.Capacitor.convertFileSrc(result.filePath) : '';
|
|
1774
1946
|
try {
|
|
1775
1947
|
// Fetch the video blob from the capacitor URL
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/intelligence.d.ts
CHANGED
|
@@ -17,6 +17,10 @@ export declare class CuoralIntelligence {
|
|
|
17
17
|
private rageClickThreshold;
|
|
18
18
|
private rageClickWindowMs;
|
|
19
19
|
constructor(sessionId: string);
|
|
20
|
+
/**
|
|
21
|
+
* Update the session ID (e.g., when user logs in)
|
|
22
|
+
*/
|
|
23
|
+
updateSessionId(newSessionId: string): void;
|
|
20
24
|
/**
|
|
21
25
|
* Initialize intelligence tracking
|
|
22
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intelligence.d.ts","sourceRoot":"","sources":["../src/intelligence.ts"],"names":[],"mappings":"AA0EA,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAWZ;IAEF,OAAO,CAAC,MAAM,CAKZ;IAEF,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,qBAAqB,CAAc;IAC3C,OAAO,CAAC,kBAAkB,CAAM;IAChC,OAAO,CAAC,aAAa,CAAa;IAGlC,OAAO,CAAC,aAAa,CAAa;IAClC,OAAO,CAAC,sBAAsB,CAAa;IAG3C,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,YAAY,CAAyB;IAC7C,OAAO,CAAC,kBAAkB,CAAa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BpC;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAe1B;;OAEG;IACH,OAAO,CAAC,WAAW;CAOpB"}
|
package/dist/intelligence.js
CHANGED
|
@@ -42,6 +42,24 @@ export class CuoralIntelligence {
|
|
|
42
42
|
this.rageClickWindowMs = 2000; // Within 2 seconds
|
|
43
43
|
this.sessionId = sessionId;
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Update the session ID (e.g., when user logs in)
|
|
47
|
+
*/
|
|
48
|
+
updateSessionId(newSessionId) {
|
|
49
|
+
console.log('[Cuoral Intelligence] Updating session ID from', this.sessionId, 'to', newSessionId);
|
|
50
|
+
this.sessionId = newSessionId;
|
|
51
|
+
// Flush any pending events with the old session before switching
|
|
52
|
+
this.flush();
|
|
53
|
+
// Update native error capture with new session ID
|
|
54
|
+
if (Capacitor.isNativePlatform()) {
|
|
55
|
+
CuoralPlugin.setupNativeErrorCapture({
|
|
56
|
+
backendUrl: this.config.consoleErrorBackendUrl,
|
|
57
|
+
sessionId: newSessionId
|
|
58
|
+
}).catch(error => {
|
|
59
|
+
console.warn('[Cuoral Intelligence] Failed to update native error capture:', error);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
45
63
|
/**
|
|
46
64
|
* Initialize intelligence tracking
|
|
47
65
|
*/
|
|
@@ -371,6 +389,7 @@ export class CuoralIntelligence {
|
|
|
371
389
|
url: window.location.href,
|
|
372
390
|
data,
|
|
373
391
|
};
|
|
392
|
+
console.log(`[Intelligence] Enqueuing ${type} event with session:`, this.sessionId);
|
|
374
393
|
queue.push(event);
|
|
375
394
|
// Flush immediately for critical errors
|
|
376
395
|
const shouldFlushImmediately = type === 'api_call' && (data.status_code === 0 || data.status_code >= 400);
|
package/dist/plugin.d.ts
CHANGED
|
@@ -12,10 +12,17 @@ export interface CuoralPluginInterface {
|
|
|
12
12
|
/**
|
|
13
13
|
* Stop screen recording
|
|
14
14
|
*/
|
|
15
|
-
stopRecording(
|
|
15
|
+
stopRecording(options?: {
|
|
16
|
+
autoUpload?: boolean;
|
|
17
|
+
sessionId?: string;
|
|
18
|
+
publicKey?: string;
|
|
19
|
+
customerId?: string;
|
|
20
|
+
}): Promise<{
|
|
16
21
|
success: boolean;
|
|
17
22
|
filePath?: string;
|
|
18
23
|
duration?: number;
|
|
24
|
+
uploaded?: boolean;
|
|
25
|
+
uploadError?: string;
|
|
19
26
|
}>;
|
|
20
27
|
/**
|
|
21
28
|
* Get recording state
|
|
@@ -52,13 +59,19 @@ export declare class CuoralRecorder {
|
|
|
52
59
|
/**
|
|
53
60
|
* Start recording with automatic permission handling
|
|
54
61
|
*/
|
|
55
|
-
startRecording(options?: RecordingOptions): Promise<boolean>;
|
|
62
|
+
startRecording(options?: RecordingOptions, sendMessages?: boolean): Promise<boolean>;
|
|
56
63
|
/**
|
|
57
64
|
* Stop recording
|
|
58
65
|
*/
|
|
59
|
-
stopRecording(
|
|
66
|
+
stopRecording(options?: {
|
|
67
|
+
autoUpload?: boolean;
|
|
68
|
+
sessionId?: string;
|
|
69
|
+
publicKey?: string;
|
|
70
|
+
customerId?: string;
|
|
71
|
+
}, sendMessages?: boolean): Promise<{
|
|
60
72
|
filePath?: string;
|
|
61
73
|
duration?: number;
|
|
74
|
+
uploaded?: boolean;
|
|
62
75
|
} | null>;
|
|
63
76
|
/**
|
|
64
77
|
* Take screenshot
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACf,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,cAAc,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAE1E;;OAEG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