@wonderwhy-er/desktop-commander 0.2.26 → 0.2.27
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/dist/config-manager.d.ts +4 -0
- package/dist/config-manager.js +12 -0
- package/dist/utils/ab-test.js +1 -1
- package/dist/utils/capture.js +1 -19
- package/dist/utils/welcome-onboarding.js +11 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/config-manager.d.ts
CHANGED
|
@@ -62,6 +62,10 @@ declare class ConfigManager {
|
|
|
62
62
|
* Check if this is the first run (config file was just created)
|
|
63
63
|
*/
|
|
64
64
|
isFirstRun(): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Get or create a persistent client ID for analytics and A/B tests
|
|
67
|
+
*/
|
|
68
|
+
getOrCreateClientId(): Promise<string>;
|
|
65
69
|
}
|
|
66
70
|
export declare const configManager: ConfigManager;
|
|
67
71
|
export {};
|
package/dist/config-manager.js
CHANGED
|
@@ -193,6 +193,18 @@ class ConfigManager {
|
|
|
193
193
|
isFirstRun() {
|
|
194
194
|
return this._isFirstRun;
|
|
195
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Get or create a persistent client ID for analytics and A/B tests
|
|
198
|
+
*/
|
|
199
|
+
async getOrCreateClientId() {
|
|
200
|
+
let clientId = await this.getValue('clientId');
|
|
201
|
+
if (!clientId) {
|
|
202
|
+
const { randomUUID } = await import('crypto');
|
|
203
|
+
clientId = randomUUID();
|
|
204
|
+
await this.setValue('clientId', clientId);
|
|
205
|
+
}
|
|
206
|
+
return clientId;
|
|
207
|
+
}
|
|
196
208
|
}
|
|
197
209
|
// Export singleton instance
|
|
198
210
|
export const configManager = new ConfigManager();
|
package/dist/utils/ab-test.js
CHANGED
|
@@ -28,7 +28,7 @@ async function getVariant(experimentName) {
|
|
|
28
28
|
return existing;
|
|
29
29
|
}
|
|
30
30
|
// New assignment based on clientId
|
|
31
|
-
const clientId = await configManager.
|
|
31
|
+
const clientId = await configManager.getOrCreateClientId();
|
|
32
32
|
const hash = hashCode(clientId + experimentName);
|
|
33
33
|
const variantIndex = hash % experiment.variants.length;
|
|
34
34
|
const variant = experiment.variants[variantIndex];
|
package/dist/utils/capture.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { platform } from 'os';
|
|
2
|
-
import { randomUUID } from 'crypto';
|
|
3
2
|
import * as https from 'https';
|
|
4
3
|
import { configManager } from '../config-manager.js';
|
|
5
4
|
import { currentClient } from '../server.js';
|
|
@@ -13,23 +12,6 @@ catch {
|
|
|
13
12
|
}
|
|
14
13
|
// Will be initialized when needed
|
|
15
14
|
let uniqueUserId = 'unknown';
|
|
16
|
-
// Function to get or create a persistent UUID
|
|
17
|
-
async function getOrCreateUUID() {
|
|
18
|
-
try {
|
|
19
|
-
// Try to get the UUID from the config
|
|
20
|
-
let clientId = await configManager.getValue('clientId');
|
|
21
|
-
// If it doesn't exist, create a new one and save it
|
|
22
|
-
if (!clientId) {
|
|
23
|
-
clientId = randomUUID();
|
|
24
|
-
await configManager.setValue('clientId', clientId);
|
|
25
|
-
}
|
|
26
|
-
return clientId;
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
// Fallback to a random UUID if config operations fail
|
|
30
|
-
return randomUUID();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
15
|
/**
|
|
34
16
|
* Sanitizes error objects to remove potentially sensitive information like file paths
|
|
35
17
|
* @param error Error object or string to sanitize
|
|
@@ -76,7 +58,7 @@ export const captureBase = async (captureURL, event, properties) => {
|
|
|
76
58
|
}
|
|
77
59
|
// Get or create the client ID if not already initialized
|
|
78
60
|
if (uniqueUserId === 'unknown') {
|
|
79
|
-
uniqueUserId = await
|
|
61
|
+
uniqueUserId = await configManager.getOrCreateClientId();
|
|
80
62
|
}
|
|
81
63
|
// Get current client information for all events
|
|
82
64
|
let clientContext = {};
|
|
@@ -3,6 +3,7 @@ import { hasFeature } from './ab-test.js';
|
|
|
3
3
|
import { featureFlagManager } from './feature-flags.js';
|
|
4
4
|
import { openWelcomePage } from './open-browser.js';
|
|
5
5
|
import { logToStderr } from './logger.js';
|
|
6
|
+
import { capture } from './capture.js';
|
|
6
7
|
/**
|
|
7
8
|
* Handle welcome page display for new users (A/B test controlled)
|
|
8
9
|
*
|
|
@@ -16,15 +17,22 @@ export async function handleWelcomePageOnboarding() {
|
|
|
16
17
|
if (!configManager.isFirstRun()) {
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
20
|
+
// Track that we have a first-run user attempting onboarding
|
|
21
|
+
const loadedFromCache = featureFlagManager.wasLoadedFromCache();
|
|
19
22
|
// For new users, we need to wait for feature flags to load from network
|
|
20
23
|
// since they won't have a cache file yet. Without this, hasFeature() would
|
|
21
24
|
// return false (no experiments defined) and all new users go to control.
|
|
22
|
-
if (!
|
|
25
|
+
if (!loadedFromCache) {
|
|
23
26
|
logToStderr('debug', 'Waiting for feature flags to load...');
|
|
24
27
|
await featureFlagManager.waitForFreshFlags();
|
|
25
28
|
}
|
|
26
29
|
// Check A/B test assignment
|
|
27
30
|
const shouldShow = await hasFeature('showOnboardingPage');
|
|
31
|
+
// Track the A/B decision
|
|
32
|
+
capture('server_welcome_page_ab_decision', {
|
|
33
|
+
variant: shouldShow ? 'treatment' : 'control',
|
|
34
|
+
loaded_from_cache: loadedFromCache
|
|
35
|
+
});
|
|
28
36
|
if (!shouldShow) {
|
|
29
37
|
logToStderr('debug', 'Welcome page skipped (A/B: noOnboardingPage)');
|
|
30
38
|
return;
|
|
@@ -37,9 +45,11 @@ export async function handleWelcomePageOnboarding() {
|
|
|
37
45
|
try {
|
|
38
46
|
await openWelcomePage();
|
|
39
47
|
await configManager.setValue('sawOnboardingPage', true);
|
|
48
|
+
capture('server_welcome_page_opened', { success: true });
|
|
40
49
|
logToStderr('info', 'Welcome page opened');
|
|
41
50
|
}
|
|
42
51
|
catch (e) {
|
|
52
|
+
capture('server_welcome_page_opened', { success: false, error: e instanceof Error ? e.message : String(e) });
|
|
43
53
|
logToStderr('warning', `Failed to open welcome page: ${e instanceof Error ? e.message : e}`);
|
|
44
54
|
}
|
|
45
55
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.2.
|
|
1
|
+
export declare const VERSION = "0.2.27";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.2.
|
|
1
|
+
export const VERSION = '0.2.27';
|
package/package.json
CHANGED