mandlix-sdk-rightnow-for-temp 1.0.0

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 (37) hide show
  1. package/README.md +215 -0
  2. package/lib/commonjs/capture.js +64 -0
  3. package/lib/commonjs/capture.js.map +1 -0
  4. package/lib/commonjs/config.js +70 -0
  5. package/lib/commonjs/config.js.map +1 -0
  6. package/lib/commonjs/index.js +143 -0
  7. package/lib/commonjs/index.js.map +1 -0
  8. package/lib/commonjs/session.js +72 -0
  9. package/lib/commonjs/session.js.map +1 -0
  10. package/lib/commonjs/uploader.js +192 -0
  11. package/lib/commonjs/uploader.js.map +1 -0
  12. package/lib/module/capture.js +57 -0
  13. package/lib/module/capture.js.map +1 -0
  14. package/lib/module/config.js +61 -0
  15. package/lib/module/config.js.map +1 -0
  16. package/lib/module/index.js +132 -0
  17. package/lib/module/index.js.map +1 -0
  18. package/lib/module/session.js +61 -0
  19. package/lib/module/session.js.map +1 -0
  20. package/lib/module/uploader.js +182 -0
  21. package/lib/module/uploader.js.map +1 -0
  22. package/lib/typescript/src/capture.d.ts +27 -0
  23. package/lib/typescript/src/capture.d.ts.map +1 -0
  24. package/lib/typescript/src/config.d.ts +24 -0
  25. package/lib/typescript/src/config.d.ts.map +1 -0
  26. package/lib/typescript/src/index.d.ts +63 -0
  27. package/lib/typescript/src/index.d.ts.map +1 -0
  28. package/lib/typescript/src/session.d.ts +25 -0
  29. package/lib/typescript/src/session.d.ts.map +1 -0
  30. package/lib/typescript/src/uploader.d.ts +42 -0
  31. package/lib/typescript/src/uploader.d.ts.map +1 -0
  32. package/package.json +100 -0
  33. package/src/capture.ts +80 -0
  34. package/src/config.ts +63 -0
  35. package/src/index.ts +168 -0
  36. package/src/session.ts +62 -0
  37. package/src/uploader.ts +209 -0
package/README.md ADDED
@@ -0,0 +1,215 @@
1
+ # Mandlix SDK
2
+
3
+ A lightweight React Native SDK for capturing app screenshots, tracking sessions, and uploading data to a backend API asynchronously.
4
+
5
+ ## Features
6
+
7
+ - 📸 **Screenshot Capture** - Capture screens using react-native-view-shot
8
+ - 📝 **Session Tracking** - UUID-based session management
9
+ - 📤 **Async Uploads** - Non-blocking upload queue with retry logic
10
+ - ⚡ **Throttling** - Prevents duplicate rapid captures
11
+ - 🔒 **Type Safe** - Full TypeScript support
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install mandlix-sdk
17
+ # or
18
+ yarn add mandlix-sdk
19
+ ```
20
+
21
+ ### Required Dependencies
22
+
23
+ The SDK requires the following peer dependencies:
24
+
25
+ ```bash
26
+ npm install react-native-view-shot react-native-uuid
27
+ # or
28
+ yarn add react-native-view-shot react-native-uuid
29
+ ```
30
+
31
+ #### iOS Setup
32
+
33
+ ```bash
34
+ cd ios && pod install
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ ### Basic Setup
40
+
41
+ ```typescript
42
+ import Mandlix from 'mandlix-sdk';
43
+
44
+ // Initialize the SDK
45
+ Mandlix.init({
46
+ apiKey: 'your-api-key-here',
47
+ endpoint: 'https://api.mandlix.com', // optional, uses default if not provided
48
+ });
49
+
50
+ // Set user information (optional)
51
+ Mandlix.setUser({
52
+ id: 'user-123',
53
+ email: 'user@example.com',
54
+ name: 'John Doe',
55
+ });
56
+ ```
57
+
58
+ ### Capturing Screens
59
+
60
+ ```typescript
61
+ import Mandlix from 'mandlix-sdk';
62
+
63
+ // In your component
64
+ const handleScreenCapture = async () => {
65
+ // This will capture the screen and queue it for upload
66
+ await Mandlix.capture('HomeScreen');
67
+ };
68
+
69
+ // Call when screen mounts or user interacts
70
+ useEffect(() => {
71
+ Mandlix.capture('HomeScreen');
72
+ }, []);
73
+ ```
74
+
75
+ ### Capturing Specific Components
76
+
77
+ ```typescript
78
+ import { useRef } from 'react';
79
+ import Mandlix from 'mandlix-sdk';
80
+
81
+ function MyComponent() {
82
+ const viewRef = useRef(null);
83
+
84
+ const captureComponent = async () => {
85
+ // Note: For component capture, you'd extend the SDK
86
+ // Current implementation captures full screen
87
+ await Mandlix.capture('MyComponent');
88
+ };
89
+
90
+ return (
91
+ <View ref={viewRef}>
92
+ {/* Your content */}
93
+ </View>
94
+ );
95
+ }
96
+ ```
97
+
98
+ ### SDK Status & Utilities
99
+
100
+ ```typescript
101
+ import Mandlix from 'mandlix-sdk';
102
+
103
+ // Get current status
104
+ const status = Mandlix.getStatus();
105
+ console.log(status);
106
+ // {
107
+ // initialized: true,
108
+ // sessionId: 'uuid-string',
109
+ // queueSize: 3,
110
+ // lastScreen: 'HomeScreen',
111
+ // user: { id: 'user-123', ... }
112
+ // }
113
+
114
+ // Flush pending uploads (call before app goes to background)
115
+ await Mandlix.flush();
116
+
117
+ // Reset SDK (useful on logout)
118
+ Mandlix.reset();
119
+ ```
120
+
121
+ ## API Reference
122
+
123
+ ### `Mandlix.init(options: MandlixOptions)`
124
+
125
+ Initialize the SDK with your API key.
126
+
127
+ **Parameters:**
128
+ - `options.apiKey` (string, required) - Your Mandlix API key
129
+ - `options.endpoint` (string, optional) - API endpoint URL (default: https://api.mandlix.com)
130
+
131
+ ### `Mandlix.capture(screenName: string)`
132
+
133
+ Capture a screenshot and queue it for upload.
134
+
135
+ **Parameters:**
136
+ - `screenName` (string) - Name identifier for the screen
137
+
138
+ **Features:**
139
+ - Automatic throttling (500ms between duplicate captures)
140
+ - Duplicate prevention (same screen name)
141
+ - Async non-blocking operation
142
+
143
+ ### `Mandlix.setUser(user: UserInfo)`
144
+
145
+ Associate user information with the session.
146
+
147
+ **Parameters:**
148
+ - `user` (object) - User data object with id, email, name, or custom fields
149
+
150
+ ### `Mandlix.getUser()`
151
+
152
+ Get the current user information.
153
+
154
+ **Returns:** `UserInfo | null`
155
+
156
+ ### `Mandlix.getStatus()`
157
+
158
+ Get SDK status information.
159
+
160
+ **Returns:**
161
+ ```typescript
162
+ {
163
+ initialized: boolean;
164
+ sessionId: string | null;
165
+ queueSize: number;
166
+ lastScreen: string | null;
167
+ user: UserInfo | null;
168
+ }
169
+ ```
170
+
171
+ ### `Mandlix.flush()`
172
+
173
+ Ensure all pending uploads are processed. Call before app goes to background.
174
+
175
+ ### `Mandlix.reset()`
176
+
177
+ Reset SDK state. Useful for logout scenarios.
178
+
179
+ ## Configuration
180
+
181
+ ### Upload Behavior
182
+
183
+ - **Max Queue Size:** 100 items (oldest dropped when exceeded)
184
+ - **Max Retries:** 3 attempts per upload
185
+ - **Retry Delay:** 2 seconds (increases with each retry)
186
+ - **Throttling:** 500ms minimum between duplicate captures
187
+ - **Image Quality:** 60% JPEG compression
188
+
189
+ ### API Endpoints
190
+
191
+ The SDK sends screenshots to:
192
+ ```
193
+ POST {endpoint}/upload
194
+ ```
195
+
196
+ With multipart/form-data containing:
197
+ - `screen_name` - Screen identifier
198
+ - `session_id` - UUID session identifier
199
+ - `timestamp` - Capture timestamp
200
+ - `file` - JPEG image file
201
+
202
+ ## Architecture
203
+
204
+ ```
205
+ src/
206
+ ├── index.ts # Public API
207
+ ├── config.ts # Global configuration store
208
+ ├── session.ts # UUID session management
209
+ ├── capture.ts # Screenshot capture (react-native-view-shot)
210
+ └── uploader.ts # Async upload queue with retry logic
211
+ ```
212
+
213
+ ## License
214
+
215
+ MIT
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.compressImage = compressImage;
7
+ exports.takeScreenshot = takeScreenshot;
8
+ var _reactNativeViewShot = require("react-native-view-shot");
9
+ const defaultCaptureOptions = {
10
+ quality: 0.6,
11
+ format: 'jpg',
12
+ result: 'tmpfile',
13
+ snapshotContentContainer: false
14
+ };
15
+
16
+ /**
17
+ * Take a screenshot of the current screen
18
+ * @param ref - Optional React ref to capture specific component
19
+ * @param options - Capture options
20
+ * @returns Capture result with URI or error
21
+ */
22
+ async function takeScreenshot(ref, options = {}) {
23
+ const captureOptions = {
24
+ ...defaultCaptureOptions,
25
+ ...options
26
+ };
27
+ try {
28
+ console.log('[Mandlix] Starting screenshot capture...');
29
+ let uri;
30
+ if (ref && ref.current) {
31
+ uri = await (0, _reactNativeViewShot.captureRef)(ref, captureOptions);
32
+ } else {
33
+ uri = await (0, _reactNativeViewShot.captureScreen)(captureOptions);
34
+ }
35
+ console.log('[Mandlix] Screenshot captured successfully');
36
+ return {
37
+ uri,
38
+ success: true
39
+ };
40
+ } catch (error) {
41
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
42
+ console.error('[Mandlix] Screenshot capture failed:', errorMessage);
43
+ return {
44
+ uri: '',
45
+ success: false,
46
+ error: errorMessage
47
+ };
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Compress an image (placeholder for additional compression if needed)
53
+ * react-native-view-shot already handles compression via quality option
54
+ * @param uri - Image URI
55
+ * @param quality - Compression quality (0-1)
56
+ * @returns Compressed image URI
57
+ */
58
+ async function compressImage(uri, _quality = 0.6) {
59
+ // react-native-view-shot already compresses during capture
60
+ // This function serves as an extension point for additional compression
61
+ console.log(`[Mandlix] Image compression skipped (handled by view-shot): ${uri}`);
62
+ return uri;
63
+ }
64
+ //# sourceMappingURL=capture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNativeViewShot","require","defaultCaptureOptions","quality","format","result","snapshotContentContainer","takeScreenshot","ref","options","captureOptions","console","log","uri","current","captureRef","captureScreen","success","error","errorMessage","Error","message","compressImage","_quality"],"sourceRoot":"..\\..\\src","sources":["capture.ts"],"mappings":";;;;;;;AACA,IAAAA,oBAAA,GAAAC,OAAA;AAeA,MAAMC,qBAAqC,GAAG;EAC5CC,OAAO,EAAE,GAAG;EACZC,MAAM,EAAE,KAAK;EACbC,MAAM,EAAE,SAAS;EACjBC,wBAAwB,EAAE;AAC5B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACO,eAAeC,cAAcA,CAClCC,GAAS,EACTC,OAAuB,GAAG,CAAC,CAAC,EACJ;EACxB,MAAMC,cAAc,GAAG;IAAE,GAAGR,qBAAqB;IAAE,GAAGO;EAAQ,CAAC;EAE/D,IAAI;IACFE,OAAO,CAACC,GAAG,CAAC,0CAA0C,CAAC;IAEvD,IAAIC,GAAW;IAEf,IAAIL,GAAG,IAAIA,GAAG,CAACM,OAAO,EAAE;MACtBD,GAAG,GAAG,MAAM,IAAAE,+BAAU,EAACP,GAAG,EAAEE,cAAc,CAAC;IAC7C,CAAC,MAAM;MACLG,GAAG,GAAG,MAAM,IAAAG,kCAAa,EAACN,cAAc,CAAC;IAC3C;IAEAC,OAAO,CAACC,GAAG,CAAC,4CAA4C,CAAC;IAEzD,OAAO;MACLC,GAAG;MACHI,OAAO,EAAE;IACX,CAAC;EACH,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd,MAAMC,YAAY,GAAGD,KAAK,YAAYE,KAAK,GAAGF,KAAK,CAACG,OAAO,GAAG,eAAe;IAC7EV,OAAO,CAACO,KAAK,CAAC,sCAAsC,EAAEC,YAAY,CAAC;IAEnE,OAAO;MACLN,GAAG,EAAE,EAAE;MACPI,OAAO,EAAE,KAAK;MACdC,KAAK,EAAEC;IACT,CAAC;EACH;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeG,aAAaA,CACjCT,GAAW,EACXU,QAAgB,GAAG,GAAG,EACL;EACjB;EACA;EACAZ,OAAO,CAACC,GAAG,CAAC,+DAA+DC,GAAG,EAAE,CAAC;EACjF,OAAOA,GAAG;AACZ","ignoreList":[]}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getConfig = getConfig;
7
+ exports.initConfig = initConfig;
8
+ exports.isConfigInitialized = isConfigInitialized;
9
+ exports.resetConfig = resetConfig;
10
+ const defaultConfig = {
11
+ apiKey: '',
12
+ endpoint: 'https://api.mandlix.com'
13
+ };
14
+ let globalConfig = {
15
+ ...defaultConfig
16
+ };
17
+ let isInitialized = false;
18
+
19
+ /**
20
+ * Initialize the SDK configuration
21
+ * @param options - Configuration options
22
+ */
23
+ function initConfig(options) {
24
+ if (isInitialized) {
25
+ console.warn('[Mandlix] Config already initialized, skipping re-initialization');
26
+ return;
27
+ }
28
+ if (!options.apiKey) {
29
+ throw new Error('[Mandlix] API key is required');
30
+ }
31
+ globalConfig = {
32
+ ...defaultConfig,
33
+ ...options
34
+ };
35
+ isInitialized = true;
36
+ console.log('[Mandlix] Configuration initialized');
37
+ }
38
+
39
+ /**
40
+ * Get the current configuration
41
+ * @returns Current configuration object
42
+ */
43
+ function getConfig() {
44
+ if (!isInitialized) {
45
+ throw new Error('[Mandlix] SDK not initialized. Call init() first.');
46
+ }
47
+ return {
48
+ ...globalConfig
49
+ };
50
+ }
51
+
52
+ /**
53
+ * Check if the SDK has been initialized
54
+ * @returns True if initialized
55
+ */
56
+ function isConfigInitialized() {
57
+ return isInitialized;
58
+ }
59
+
60
+ /**
61
+ * Reset configuration (useful for testing)
62
+ */
63
+ function resetConfig() {
64
+ globalConfig = {
65
+ ...defaultConfig
66
+ };
67
+ isInitialized = false;
68
+ console.log('[Mandlix] Configuration reset');
69
+ }
70
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["defaultConfig","apiKey","endpoint","globalConfig","isInitialized","initConfig","options","console","warn","Error","log","getConfig","isConfigInitialized","resetConfig"],"sourceRoot":"..\\..\\src","sources":["config.ts"],"mappings":";;;;;;;;;AAKA,MAAMA,aAA4B,GAAG;EACnCC,MAAM,EAAE,EAAE;EACVC,QAAQ,EAAE;AACZ,CAAC;AAED,IAAIC,YAA2B,GAAG;EAAE,GAAGH;AAAc,CAAC;AACtD,IAAII,aAAa,GAAG,KAAK;;AAEzB;AACA;AACA;AACA;AACO,SAASC,UAAUA,CAACC,OAA+B,EAAQ;EAChE,IAAIF,aAAa,EAAE;IACjBG,OAAO,CAACC,IAAI,CAAC,kEAAkE,CAAC;IAChF;EACF;EAEA,IAAI,CAACF,OAAO,CAACL,MAAM,EAAE;IACnB,MAAM,IAAIQ,KAAK,CAAC,+BAA+B,CAAC;EAClD;EAEAN,YAAY,GAAG;IACb,GAAGH,aAAa;IAChB,GAAGM;EACL,CAAC;EAEDF,aAAa,GAAG,IAAI;EACpBG,OAAO,CAACG,GAAG,CAAC,qCAAqC,CAAC;AACpD;;AAEA;AACA;AACA;AACA;AACO,SAASC,SAASA,CAAA,EAAkB;EACzC,IAAI,CAACP,aAAa,EAAE;IAClB,MAAM,IAAIK,KAAK,CAAC,mDAAmD,CAAC;EACtE;EACA,OAAO;IAAE,GAAGN;EAAa,CAAC;AAC5B;;AAEA;AACA;AACA;AACA;AACO,SAASS,mBAAmBA,CAAA,EAAY;EAC7C,OAAOR,aAAa;AACtB;;AAEA;AACA;AACA;AACO,SAASS,WAAWA,CAAA,EAAS;EAClCV,YAAY,GAAG;IAAE,GAAGH;EAAc,CAAC;EACnCI,aAAa,GAAG,KAAK;EACrBG,OAAO,CAACG,GAAG,CAAC,+BAA+B,CAAC;AAC9C","ignoreList":[]}
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.capture = capture;
7
+ exports.default = void 0;
8
+ exports.flush = flush;
9
+ exports.getStatus = getStatus;
10
+ exports.getUser = getUser;
11
+ exports.init = init;
12
+ exports.reset = reset;
13
+ exports.setUser = setUser;
14
+ var _config = require("./config");
15
+ var _session = require("./session");
16
+ var _capture = require("./capture");
17
+ var _uploader = require("./uploader");
18
+ let currentUser = null;
19
+ let lastScreen = null;
20
+ let lastCaptureTime = 0;
21
+ const THROTTLE_MS = 500; // Minimum time between captures
22
+
23
+ /**
24
+ * Initialize the Mandlix SDK
25
+ * @param options - SDK initialization options
26
+ */
27
+ function init(options) {
28
+ console.log('[Mandlix] Initializing SDK...');
29
+ (0, _config.initConfig)({
30
+ apiKey: options.apiKey,
31
+ endpoint: options.endpoint
32
+ });
33
+ (0, _session.startSession)();
34
+ console.log('[Mandlix] SDK initialized successfully');
35
+ }
36
+
37
+ /**
38
+ * Capture a screenshot of the current screen
39
+ * @param screenName - Name of the screen being captured
40
+ */
41
+ async function capture(screenName) {
42
+ try {
43
+ if (screenName === lastScreen) {
44
+ const now = Date.now();
45
+ if (now - lastCaptureTime < THROTTLE_MS) {
46
+ console.log(`[Mandlix] Throttled: duplicate capture of "${screenName}"`);
47
+ return;
48
+ }
49
+ }
50
+ const sessionId = (0, _session.getSessionId)();
51
+ if (!sessionId) {
52
+ console.error('[Mandlix] No active session. Call init() first.');
53
+ return;
54
+ }
55
+ console.log(`[Mandlix] Capturing screen: ${screenName}`);
56
+ const captureResult = await (0, _capture.takeScreenshot)();
57
+ if (!captureResult.success || !captureResult.uri) {
58
+ console.error('[Mandlix] Capture failed:', captureResult.error);
59
+ return;
60
+ }
61
+ (0, _uploader.add)({
62
+ screenName,
63
+ sessionId,
64
+ imageUri: captureResult.uri
65
+ });
66
+ lastScreen = screenName;
67
+ lastCaptureTime = Date.now();
68
+ console.log(`[Mandlix] Capture queued: ${screenName}`);
69
+ } catch (error) {
70
+ console.error('[Mandlix] Capture error:', error);
71
+ }
72
+ }
73
+
74
+ /**
75
+ * Set user information for the session
76
+ * @param user - User information object
77
+ */
78
+ function setUser(user) {
79
+ currentUser = {
80
+ ...user
81
+ };
82
+ console.log('[Mandlix] User set:', user.id || 'anonymous');
83
+ }
84
+
85
+ /**
86
+ * Get current user information
87
+ * @returns Current user or null
88
+ */
89
+ function getUser() {
90
+ return currentUser;
91
+ }
92
+
93
+ /**
94
+ * Get SDK status information
95
+ * @returns Status object
96
+ */
97
+ function getStatus() {
98
+ return {
99
+ initialized: !!(0, _session.getSessionId)(),
100
+ sessionId: (0, _session.getSessionId)(),
101
+ queueSize: (0, _uploader.getQueueSize)(),
102
+ lastScreen,
103
+ user: currentUser
104
+ };
105
+ }
106
+
107
+ /**
108
+ * Flush the upload queue
109
+ * Useful before app backgrounding/closing
110
+ */
111
+ async function flush() {
112
+ console.log('[Mandlix] Flushing upload queue...');
113
+ // The queue processes automatically, but this ensures we wait
114
+ console.log(`[Mandlix] Queue size: ${(0, _uploader.getQueueSize)()}`);
115
+ }
116
+
117
+ /**
118
+ * Reset the SDK state
119
+ * Useful for testing or logout scenarios
120
+ */
121
+ function reset() {
122
+ (0, _uploader.clearQueue)();
123
+ currentUser = null;
124
+ lastScreen = null;
125
+ lastCaptureTime = 0;
126
+ console.log('[Mandlix] SDK reset');
127
+ }
128
+
129
+ // Main SDK object
130
+ const Mandlix = {
131
+ init,
132
+ capture,
133
+ setUser,
134
+ getUser,
135
+ getStatus,
136
+ flush,
137
+ reset
138
+ };
139
+
140
+ // Named exports
141
+ // Default export
142
+ var _default = exports.default = Mandlix;
143
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_config","require","_session","_capture","_uploader","currentUser","lastScreen","lastCaptureTime","THROTTLE_MS","init","options","console","log","initConfig","apiKey","endpoint","startSession","capture","screenName","now","Date","sessionId","getSessionId","error","captureResult","takeScreenshot","success","uri","add","imageUri","setUser","user","id","getUser","getStatus","initialized","queueSize","getQueueSize","flush","reset","clearQueue","Mandlix","_default","exports","default"],"sourceRoot":"..\\..\\src","sources":["index.ts"],"mappings":"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","ignoreList":[]}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.endSession = endSession;
7
+ exports.getSessionDuration = getSessionDuration;
8
+ exports.getSessionId = getSessionId;
9
+ exports.isSessionActive = isSessionActive;
10
+ exports.startSession = startSession;
11
+ var _reactNativeUuid = _interopRequireDefault(require("react-native-uuid"));
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ let sessionId = null;
14
+ let sessionStartTime = null;
15
+
16
+ /**
17
+ * @returns UUID string
18
+ */
19
+ function generateSessionId() {
20
+ return _reactNativeUuid.default.v4();
21
+ }
22
+
23
+ /**
24
+ * Start a new session
25
+ * @returns The new session ID
26
+ */
27
+ function startSession() {
28
+ sessionId = generateSessionId();
29
+ sessionStartTime = Date.now();
30
+ console.log(`[Mandlix] Session started: ${sessionId}`);
31
+ return sessionId;
32
+ }
33
+
34
+ /**
35
+ * Get the current session ID
36
+ * @returns Current session ID or null if no session active
37
+ */
38
+ function getSessionId() {
39
+ return sessionId;
40
+ }
41
+
42
+ /**
43
+ * Get session duration in milliseconds
44
+ * @returns Duration in ms or 0 if no session
45
+ */
46
+ function getSessionDuration() {
47
+ if (!sessionStartTime) {
48
+ return 0;
49
+ }
50
+ return Date.now() - sessionStartTime;
51
+ }
52
+
53
+ /**
54
+ * End the current session
55
+ */
56
+ function endSession() {
57
+ if (sessionId) {
58
+ const duration = getSessionDuration();
59
+ console.log(`[Mandlix] Session ended: ${sessionId} (duration: ${duration}ms)`);
60
+ }
61
+ sessionId = null;
62
+ sessionStartTime = null;
63
+ }
64
+
65
+ /**
66
+ * Check if a session is currently active
67
+ * @returns True if session is active
68
+ */
69
+ function isSessionActive() {
70
+ return sessionId !== null;
71
+ }
72
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNativeUuid","_interopRequireDefault","require","e","__esModule","default","sessionId","sessionStartTime","generateSessionId","uuid","v4","startSession","Date","now","console","log","getSessionId","getSessionDuration","endSession","duration","isSessionActive"],"sourceRoot":"..\\..\\src","sources":["session.ts"],"mappings":";;;;;;;;;;AACA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAqC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAErC,IAAIG,SAAwB,GAAG,IAAI;AACnC,IAAIC,gBAA+B,GAAG,IAAI;;AAE1C;AACA;AACA;AACA,SAASC,iBAAiBA,CAAA,EAAW;EACnC,OAAOC,wBAAI,CAACC,EAAE,CAAC,CAAC;AAClB;;AAEA;AACA;AACA;AACA;AACO,SAASC,YAAYA,CAAA,EAAW;EACrCL,SAAS,GAAGE,iBAAiB,CAAC,CAAC;EAC/BD,gBAAgB,GAAGK,IAAI,CAACC,GAAG,CAAC,CAAC;EAC7BC,OAAO,CAACC,GAAG,CAAC,8BAA8BT,SAAS,EAAE,CAAC;EACtD,OAAOA,SAAS;AAClB;;AAEA;AACA;AACA;AACA;AACO,SAASU,YAAYA,CAAA,EAAkB;EAC5C,OAAOV,SAAS;AAClB;;AAEA;AACA;AACA;AACA;AACO,SAASW,kBAAkBA,CAAA,EAAW;EAC3C,IAAI,CAACV,gBAAgB,EAAE;IACrB,OAAO,CAAC;EACV;EACA,OAAOK,IAAI,CAACC,GAAG,CAAC,CAAC,GAAGN,gBAAgB;AACtC;;AAEA;AACA;AACA;AACO,SAASW,UAAUA,CAAA,EAAS;EACjC,IAAIZ,SAAS,EAAE;IACb,MAAMa,QAAQ,GAAGF,kBAAkB,CAAC,CAAC;IACrCH,OAAO,CAACC,GAAG,CAAC,4BAA4BT,SAAS,eAAea,QAAQ,KAAK,CAAC;EAChF;EACAb,SAAS,GAAG,IAAI;EAChBC,gBAAgB,GAAG,IAAI;AACzB;;AAEA;AACA;AACA;AACA;AACO,SAASa,eAAeA,CAAA,EAAY;EACzC,OAAOd,SAAS,KAAK,IAAI;AAC3B","ignoreList":[]}