pinme 2.0.4 → 2.0.5

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 (3) hide show
  1. package/README.md +200 -867
  2. package/dist/index.js +940 -200
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -103,9 +103,9 @@ var require_package = __commonJS({
103
103
  // node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/main.js
104
104
  var require_main = __commonJS({
105
105
  "node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/main.js"(exports2, module2) {
106
- var fs16 = require("fs");
107
- var path17 = require("path");
108
- var os5 = require("os");
106
+ var fs17 = require("fs");
107
+ var path18 = require("path");
108
+ var os6 = require("os");
109
109
  var crypto3 = require("crypto");
110
110
  var packageJson = require_package();
111
111
  var version2 = packageJson.version;
@@ -207,7 +207,7 @@ var require_main = __commonJS({
207
207
  if (options && options.path && options.path.length > 0) {
208
208
  if (Array.isArray(options.path)) {
209
209
  for (const filepath of options.path) {
210
- if (fs16.existsSync(filepath)) {
210
+ if (fs17.existsSync(filepath)) {
211
211
  possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
212
212
  }
213
213
  }
@@ -215,15 +215,15 @@ var require_main = __commonJS({
215
215
  possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
216
216
  }
217
217
  } else {
218
- possibleVaultPath = path17.resolve(process.cwd(), ".env.vault");
218
+ possibleVaultPath = path18.resolve(process.cwd(), ".env.vault");
219
219
  }
220
- if (fs16.existsSync(possibleVaultPath)) {
220
+ if (fs17.existsSync(possibleVaultPath)) {
221
221
  return possibleVaultPath;
222
222
  }
223
223
  return null;
224
224
  }
225
225
  function _resolveHome(envPath) {
226
- return envPath[0] === "~" ? path17.join(os5.homedir(), envPath.slice(1)) : envPath;
226
+ return envPath[0] === "~" ? path18.join(os6.homedir(), envPath.slice(1)) : envPath;
227
227
  }
228
228
  function _configVault(options) {
229
229
  const debug = Boolean(options && options.debug);
@@ -239,7 +239,7 @@ var require_main = __commonJS({
239
239
  return { parsed };
240
240
  }
241
241
  function configDotenv(options) {
242
- const dotenvPath = path17.resolve(process.cwd(), ".env");
242
+ const dotenvPath = path18.resolve(process.cwd(), ".env");
243
243
  let encoding = "utf8";
244
244
  const debug = Boolean(options && options.debug);
245
245
  if (options && options.encoding) {
@@ -262,13 +262,13 @@ var require_main = __commonJS({
262
262
  }
263
263
  let lastError;
264
264
  const parsedAll = {};
265
- for (const path18 of optionPaths) {
265
+ for (const path19 of optionPaths) {
266
266
  try {
267
- const parsed = DotenvModule.parse(fs16.readFileSync(path18, { encoding }));
267
+ const parsed = DotenvModule.parse(fs17.readFileSync(path19, { encoding }));
268
268
  DotenvModule.populate(parsedAll, parsed, options);
269
269
  } catch (e) {
270
270
  if (debug) {
271
- _debug(`Failed to load ${path18} ${e.message}`);
271
+ _debug(`Failed to load ${path19} ${e.message}`);
272
272
  }
273
273
  lastError = e;
274
274
  }
@@ -828,9 +828,9 @@ function isVisitable(thing) {
828
828
  function removeBrackets(key) {
829
829
  return utils_default.endsWith(key, "[]") ? key.slice(0, -2) : key;
830
830
  }
831
- function renderKey(path17, key, dots) {
832
- if (!path17) return key;
833
- return path17.concat(key).map(function each(token, i) {
831
+ function renderKey(path18, key, dots) {
832
+ if (!path18) return key;
833
+ return path18.concat(key).map(function each(token, i) {
834
834
  token = removeBrackets(token);
835
835
  return !dots && i ? "[" + token + "]" : token;
836
836
  }).join(dots ? "." : "");
@@ -872,9 +872,9 @@ function toFormData(obj, formData, options) {
872
872
  }
873
873
  return value;
874
874
  }
875
- function defaultVisitor(value, key, path17) {
875
+ function defaultVisitor(value, key, path18) {
876
876
  let arr = value;
877
- if (value && !path17 && typeof value === "object") {
877
+ if (value && !path18 && typeof value === "object") {
878
878
  if (utils_default.endsWith(key, "{}")) {
879
879
  key = metaTokens ? key : key.slice(0, -2);
880
880
  value = JSON.stringify(value);
@@ -893,7 +893,7 @@ function toFormData(obj, formData, options) {
893
893
  if (isVisitable(value)) {
894
894
  return true;
895
895
  }
896
- formData.append(renderKey(path17, key, dots), convertValue(value));
896
+ formData.append(renderKey(path18, key, dots), convertValue(value));
897
897
  return false;
898
898
  }
899
899
  const stack = [];
@@ -902,10 +902,10 @@ function toFormData(obj, formData, options) {
902
902
  convertValue,
903
903
  isVisitable
904
904
  });
905
- function build(value, path17) {
905
+ function build(value, path18) {
906
906
  if (utils_default.isUndefined(value)) return;
907
907
  if (stack.indexOf(value) !== -1) {
908
- throw Error("Circular reference detected in " + path17.join("."));
908
+ throw Error("Circular reference detected in " + path18.join("."));
909
909
  }
910
910
  stack.push(value);
911
911
  utils_default.forEach(value, function each(el, key) {
@@ -913,11 +913,11 @@ function toFormData(obj, formData, options) {
913
913
  formData,
914
914
  el,
915
915
  utils_default.isString(key) ? key.trim() : key,
916
- path17,
916
+ path18,
917
917
  exposedHelpers
918
918
  );
919
919
  if (result === true) {
920
- build(el, path17 ? path17.concat(key) : [key]);
920
+ build(el, path18 ? path18.concat(key) : [key]);
921
921
  }
922
922
  });
923
923
  stack.pop();
@@ -1137,7 +1137,7 @@ var init_platform = __esm({
1137
1137
  // node_modules/.pnpm/axios@1.3.2/node_modules/axios/lib/helpers/toURLEncodedForm.js
1138
1138
  function toURLEncodedForm(data, options) {
1139
1139
  return toFormData_default(data, new node_default.classes.URLSearchParams(), Object.assign({
1140
- visitor: function(value, key, path17, helpers) {
1140
+ visitor: function(value, key, path18, helpers) {
1141
1141
  if (node_default.isNode && utils_default.isBuffer(value)) {
1142
1142
  this.append(key, value.toString("base64"));
1143
1143
  return false;
@@ -1174,10 +1174,10 @@ function arrayToObject(arr) {
1174
1174
  return obj;
1175
1175
  }
1176
1176
  function formDataToJSON(formData) {
1177
- function buildPath(path17, value, target, index) {
1178
- let name = path17[index++];
1177
+ function buildPath(path18, value, target, index) {
1178
+ let name = path18[index++];
1179
1179
  const isNumericKey = Number.isFinite(+name);
1180
- const isLast = index >= path17.length;
1180
+ const isLast = index >= path18.length;
1181
1181
  name = !name && utils_default.isArray(target) ? target.length : name;
1182
1182
  if (isLast) {
1183
1183
  if (utils_default.hasOwnProp(target, name)) {
@@ -1190,7 +1190,7 @@ function formDataToJSON(formData) {
1190
1190
  if (!target[name] || !utils_default.isObject(target[name])) {
1191
1191
  target[name] = [];
1192
1192
  }
1193
- const result = buildPath(path17, value, target[name], index);
1193
+ const result = buildPath(path18, value, target[name], index);
1194
1194
  if (result && utils_default.isArray(target[name])) {
1195
1195
  target[name] = arrayToObject(target[name]);
1196
1196
  }
@@ -2165,7 +2165,7 @@ var require_has_flag = __commonJS({
2165
2165
  var require_supports_color = __commonJS({
2166
2166
  "node_modules/.pnpm/supports-color@5.5.0/node_modules/supports-color/index.js"(exports2, module2) {
2167
2167
  "use strict";
2168
- var os5 = require("os");
2168
+ var os6 = require("os");
2169
2169
  var hasFlag = require_has_flag();
2170
2170
  var env = process.env;
2171
2171
  var forceColor;
@@ -2203,7 +2203,7 @@ var require_supports_color = __commonJS({
2203
2203
  }
2204
2204
  const min = forceColor ? 1 : 0;
2205
2205
  if (process.platform === "win32") {
2206
- const osRelease = os5.release().split(".");
2206
+ const osRelease = os6.release().split(".");
2207
2207
  if (Number(process.versions.node.split(".")[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
2208
2208
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
2209
2209
  }
@@ -3516,9 +3516,9 @@ var init_http = __esm({
3516
3516
  auth = urlUsername + ":" + urlPassword;
3517
3517
  }
3518
3518
  auth && headers.delete("authorization");
3519
- let path17;
3519
+ let path18;
3520
3520
  try {
3521
- path17 = buildURL(
3521
+ path18 = buildURL(
3522
3522
  parsed.pathname + parsed.search,
3523
3523
  config.params,
3524
3524
  config.paramsSerializer
@@ -3536,7 +3536,7 @@ var init_http = __esm({
3536
3536
  false
3537
3537
  );
3538
3538
  const options = {
3539
- path: path17,
3539
+ path: path18,
3540
3540
  method,
3541
3541
  headers: headers.toJSON(),
3542
3542
  agents: { http: config.httpAgent, https: config.httpsAgent },
@@ -3763,14 +3763,14 @@ var init_cookies = __esm({
3763
3763
  // Standard browser envs support document.cookie
3764
3764
  /* @__PURE__ */ function standardBrowserEnv() {
3765
3765
  return {
3766
- write: function write(name, value, expires, path17, domain, secure) {
3766
+ write: function write(name, value, expires, path18, domain, secure) {
3767
3767
  const cookie = [];
3768
3768
  cookie.push(name + "=" + encodeURIComponent(value));
3769
3769
  if (utils_default.isNumber(expires)) {
3770
3770
  cookie.push("expires=" + new Date(expires).toGMTString());
3771
3771
  }
3772
- if (utils_default.isString(path17)) {
3773
- cookie.push("path=" + path17);
3772
+ if (utils_default.isString(path18)) {
3773
+ cookie.push("path=" + path18);
3774
3774
  }
3775
3775
  if (utils_default.isString(domain)) {
3776
3776
  cookie.push("domain=" + domain);
@@ -5707,10 +5707,11 @@ async function getRootDomain(forceRefresh = false) {
5707
5707
  }
5708
5708
  async function checkDomainAvailable(domainName) {
5709
5709
  var _a2, _b;
5710
- if (isDnsDomain(domainName))
5710
+ if (isDnsDomain(domainName)) {
5711
5711
  return await {
5712
5712
  is_valid: true
5713
5713
  };
5714
+ }
5714
5715
  const client = createPinmeApiClient();
5715
5716
  const configured = APP_CONFIG.pinmeCheckDomainPath;
5716
5717
  const fallbacks = [configured];
@@ -5977,14 +5978,14 @@ var import_chalk26 = __toESM(require("chalk"));
5977
5978
  var import_figlet5 = __toESM(require("figlet"));
5978
5979
 
5979
5980
  // package.json
5980
- var version = "2.0.4";
5981
+ var version = "2.0.5";
5981
5982
 
5982
5983
  // bin/upload.ts
5983
- var import_path6 = __toESM(require("path"));
5984
+ var import_path7 = __toESM(require("path"));
5984
5985
  var import_chalk7 = __toESM(require("chalk"));
5985
5986
  var import_inquirer = __toESM(require("inquirer"));
5986
5987
  var import_figlet = __toESM(require("figlet"));
5987
- var import_fs2 = __toESM(require("fs"));
5988
+ var import_fs3 = __toESM(require("fs"));
5988
5989
  init_pinmeApi();
5989
5990
  init_webLogin();
5990
5991
  init_config();
@@ -6024,7 +6025,7 @@ function getUid() {
6024
6025
  // bin/utils/uploadToIpfsSplit.ts
6025
6026
  init_axios2();
6026
6027
  var import_fs_extra4 = __toESM(require("fs-extra"));
6027
- var import_path5 = __toESM(require("path"));
6028
+ var import_path6 = __toESM(require("path"));
6028
6029
  var import_form_data2 = __toESM(require("form-data"));
6029
6030
  var import_ora = __toESM(require("ora"));
6030
6031
  var crypto2 = __toESM(require("crypto"));
@@ -6076,13 +6077,326 @@ init_cliError();
6076
6077
 
6077
6078
  // bin/utils/history.ts
6078
6079
  var import_fs_extra3 = __toESM(require("fs-extra"));
6079
- var import_path4 = __toESM(require("path"));
6080
- var import_os3 = __toESM(require("os"));
6080
+ var import_path5 = __toESM(require("path"));
6081
+ var import_os4 = __toESM(require("os"));
6081
6082
  var import_dayjs = __toESM(require("dayjs"));
6082
6083
  var import_chalk5 = __toESM(require("chalk"));
6083
6084
  init_pinmeApi();
6084
- var HISTORY_DIR = import_path4.default.join(import_os3.default.homedir(), ".pinme");
6085
- var HISTORY_FILE = import_path4.default.join(HISTORY_DIR, "upload-history.json");
6085
+
6086
+ // bin/utils/tracker.ts
6087
+ var import_os3 = __toESM(require("os"));
6088
+ var import_fs2 = __toESM(require("fs"));
6089
+ var import_path4 = __toESM(require("path"));
6090
+ var import_child_process2 = require("child_process");
6091
+ var REQUEST_TIMEOUT_MS = 1500;
6092
+ var DEFAULT_GATEWAY = "https://pinme.dev";
6093
+ var DEFAULT_PRODUCT = "pinme-cli";
6094
+ var ACTION_OVERRIDES = {
6095
+ cli_login_success: "success",
6096
+ cli_login_failed: "fail",
6097
+ appkey_set_success: "success",
6098
+ appkey_set_failed: "fail",
6099
+ appkey_shown_success: "view",
6100
+ appkey_shown_failed: "fail",
6101
+ my_domains_success: "view",
6102
+ my_domains_failed: "fail",
6103
+ wallet_balance_success: "view",
6104
+ wallet_balance_failed: "fail",
6105
+ upload_history_viewed: "view",
6106
+ upload_history_cleared: "click",
6107
+ upload_history_failed: "fail"
6108
+ };
6109
+ var TRACK_CHILD_SCRIPT = `
6110
+ const rawUrl = process.argv[1];
6111
+ if (!rawUrl) process.exit(0);
6112
+ try {
6113
+ const transport = rawUrl.startsWith('https:') ? require('https') : require('http');
6114
+ const req = transport.get(rawUrl, {
6115
+ headers: {
6116
+ 'User-Agent': 'Pinme-CLI-Tracker'
6117
+ }
6118
+ }, (res) => {
6119
+ res.resume();
6120
+ res.on('end', () => process.exit(0));
6121
+ });
6122
+ req.setTimeout(${REQUEST_TIMEOUT_MS}, () => req.destroy());
6123
+ req.on('error', () => process.exit(0));
6124
+ req.on('close', () => process.exit(0));
6125
+ } catch (_) {
6126
+ process.exit(0);
6127
+ }
6128
+ `;
6129
+ function trimTrailingSlash2(value) {
6130
+ return value.replace(/\/+$/, "");
6131
+ }
6132
+ function shouldDisableTracking() {
6133
+ return process.env.PINME_TRACKING_DISABLED === "1" || process.env.DO_NOT_TRACK === "1";
6134
+ }
6135
+ function sanitizeTrackValue(value) {
6136
+ if (value === void 0 || value === null) {
6137
+ return void 0;
6138
+ }
6139
+ return String(value).trim().slice(0, 200);
6140
+ }
6141
+ function getTrackErrorReason(error) {
6142
+ var _a2, _b, _c, _d, _e;
6143
+ const candidate = ((_b = (_a2 = error == null ? void 0 : error.response) == null ? void 0 : _a2.data) == null ? void 0 : _b.msg) || ((_d = (_c = error == null ? void 0 : error.response) == null ? void 0 : _c.data) == null ? void 0 : _d.message) || (error == null ? void 0 : error.message) || ((_e = error == null ? void 0 : error.toString) == null ? void 0 : _e.call(error)) || "unknown_error";
6144
+ return sanitizeTrackValue(candidate) || "unknown_error";
6145
+ }
6146
+ function resolveTrackAction(event, data = {}) {
6147
+ const explicitAction = data.a;
6148
+ if (typeof explicitAction === "string" && explicitAction.trim()) {
6149
+ return explicitAction.trim();
6150
+ }
6151
+ if (ACTION_OVERRIDES[event]) {
6152
+ return ACTION_OVERRIDES[event];
6153
+ }
6154
+ if (event.endsWith("_success")) {
6155
+ return "success";
6156
+ }
6157
+ if (event.endsWith("_failed") || event.endsWith("_fail")) {
6158
+ return "fail";
6159
+ }
6160
+ if (event.includes("click") || event.includes("copied")) {
6161
+ return "click";
6162
+ }
6163
+ if (event.includes("exposure")) {
6164
+ return "exposure";
6165
+ }
6166
+ if (event.includes("view")) {
6167
+ return "view";
6168
+ }
6169
+ if (event.endsWith("_started") || event.endsWith("_submit")) {
6170
+ return "submit";
6171
+ }
6172
+ return "view";
6173
+ }
6174
+ var cachedProjectContext = null;
6175
+ var cachedProjectContextCwd = null;
6176
+ function resolveProjectContext() {
6177
+ const cwd = process.cwd();
6178
+ if (cachedProjectContext && cachedProjectContextCwd === cwd) {
6179
+ return cachedProjectContext;
6180
+ }
6181
+ const context = {};
6182
+ const configPath = import_path4.default.join(cwd, "pinme.toml");
6183
+ if (import_fs2.default.existsSync(configPath)) {
6184
+ try {
6185
+ const configContent = import_fs2.default.readFileSync(configPath, "utf8");
6186
+ const projectNameMatch = configContent.match(
6187
+ /project_name\s*=\s*"([^"]+)"/
6188
+ );
6189
+ context.projectName = sanitizeTrackValue(projectNameMatch == null ? void 0 : projectNameMatch[1]) || sanitizeTrackValue(process.env.PINME_PROJECT_NAME);
6190
+ context.projectDir = sanitizeTrackValue(import_path4.default.basename(cwd));
6191
+ } catch (_) {
6192
+ context.projectName = sanitizeTrackValue(process.env.PINME_PROJECT_NAME);
6193
+ }
6194
+ } else {
6195
+ context.projectName = sanitizeTrackValue(process.env.PINME_PROJECT_NAME);
6196
+ }
6197
+ cachedProjectContext = context;
6198
+ cachedProjectContextCwd = cwd;
6199
+ return context;
6200
+ }
6201
+ function getPathKind(pathValue) {
6202
+ try {
6203
+ const stat = import_fs2.default.statSync(pathValue);
6204
+ if (stat.isDirectory()) {
6205
+ return "directory";
6206
+ }
6207
+ if (stat.isFile()) {
6208
+ return "file";
6209
+ }
6210
+ } catch (_) {
6211
+ return "unknown";
6212
+ }
6213
+ return "unknown";
6214
+ }
6215
+ var Tracker = class _Tracker {
6216
+ static instance;
6217
+ gateway;
6218
+ product;
6219
+ source;
6220
+ disabled;
6221
+ constructor(gateway, product) {
6222
+ this.gateway = trimTrailingSlash2(
6223
+ gateway || process.env.PINME_TRACKER_GATEWAY || DEFAULT_GATEWAY
6224
+ );
6225
+ this.product = product || DEFAULT_PRODUCT;
6226
+ this.source = sanitizeTrackValue(process.env.PINME_TRACK_SOURCE);
6227
+ this.disabled = shouldDisableTracking();
6228
+ }
6229
+ static getInstance(gateway, product) {
6230
+ if (!_Tracker.instance) {
6231
+ _Tracker.instance = new _Tracker(gateway, product);
6232
+ }
6233
+ return _Tracker.instance;
6234
+ }
6235
+ trackEvent(event, page, data = {}) {
6236
+ if (this.disabled || !this.gateway) {
6237
+ return Promise.resolve();
6238
+ }
6239
+ try {
6240
+ const payload = this.buildPayload(event, page, data);
6241
+ const params = new URLSearchParams(payload).toString();
6242
+ const url2 = `${this.gateway}/track.gif?${params}`;
6243
+ this.dispatch(url2);
6244
+ } catch (_) {
6245
+ }
6246
+ return Promise.resolve();
6247
+ }
6248
+ buildPayload(event, page, data) {
6249
+ const projectContext = resolveProjectContext();
6250
+ const action = resolveTrackAction(event, data);
6251
+ const payload = {
6252
+ ...data,
6253
+ u: getUid(),
6254
+ s: this.source,
6255
+ pd: this.product,
6256
+ p: page,
6257
+ a: action,
6258
+ ev: event,
6259
+ event,
6260
+ project_name: projectContext.projectName,
6261
+ project_dir: projectContext.projectDir,
6262
+ cli_version: version,
6263
+ node_version: process.version,
6264
+ os: import_os3.default.platform(),
6265
+ arch: import_os3.default.arch()
6266
+ };
6267
+ const filtered = {};
6268
+ for (const [key, value] of Object.entries(payload)) {
6269
+ const normalized = sanitizeTrackValue(value);
6270
+ if (normalized) {
6271
+ filtered[key] = normalized;
6272
+ }
6273
+ }
6274
+ return filtered;
6275
+ }
6276
+ dispatch(url2) {
6277
+ const child = (0, import_child_process2.spawn)(process.execPath, ["-e", TRACK_CHILD_SCRIPT, url2], {
6278
+ detached: true,
6279
+ stdio: "ignore",
6280
+ windowsHide: true
6281
+ });
6282
+ child.unref();
6283
+ }
6284
+ };
6285
+ var tracker = Tracker.getInstance();
6286
+ var tracker_default = tracker;
6287
+
6288
+ // bin/utils/trackerEvents.ts
6289
+ var TRACK_PAGES = {
6290
+ auth: "cli_auth",
6291
+ login: "cli_login",
6292
+ upload: "cli_upload",
6293
+ import: "cli_import",
6294
+ export: "cli_export",
6295
+ remove: "cli_remove",
6296
+ domain: "cli_domain",
6297
+ wallet: "cli_wallet",
6298
+ project: "cli_project",
6299
+ deploy: "cli_deploy"
6300
+ };
6301
+ var TRACK_EVENTS = {
6302
+ cliLoginSuccess: "cli_login_success",
6303
+ cliLoginFailed: "cli_login_failed",
6304
+ appKeySetSuccess: "appkey_set_success",
6305
+ appKeySetFailed: "appkey_set_failed",
6306
+ logoutSuccess: "logout_success",
6307
+ logoutFailed: "logout_failed",
6308
+ uploadSuccess: "upload_success",
6309
+ uploadFailed: "upload_failed",
6310
+ importSuccess: "import_success",
6311
+ importFailed: "import_failed",
6312
+ exportSuccess: "export_success",
6313
+ exportFailed: "export_failed",
6314
+ removeSuccess: "remove_success",
6315
+ removeFailed: "remove_failed",
6316
+ domainBindSuccess: "domain_bind_success",
6317
+ domainBindFailed: "domain_bind_failed",
6318
+ myDomainsSuccess: "my_domains_success",
6319
+ myDomainsFailed: "my_domains_failed",
6320
+ walletBalanceSuccess: "wallet_balance_success",
6321
+ walletBalanceFailed: "wallet_balance_failed",
6322
+ projectCreateSuccess: "project_create_success",
6323
+ projectCreateFailed: "project_create_failed",
6324
+ projectSaveSuccess: "project_save_success",
6325
+ projectSaveFailed: "project_save_failed",
6326
+ projectUpdateDbSuccess: "project_update_db_success",
6327
+ projectUpdateDbFailed: "project_update_db_failed",
6328
+ projectUpdateWorkerSuccess: "project_update_worker_success",
6329
+ projectUpdateWorkerFailed: "project_update_worker_failed",
6330
+ projectDeleteSuccess: "project_delete_success",
6331
+ projectDeleteFailed: "project_delete_failed",
6332
+ projectUpdateWebSuccess: "project_update_web_success",
6333
+ projectUpdateWebFailed: "project_update_web_failed",
6334
+ appKeyShownSuccess: "appkey_shown_success",
6335
+ appKeyShownFailed: "appkey_shown_failed",
6336
+ uploadHistoryViewed: "upload_history_viewed",
6337
+ uploadHistoryCleared: "upload_history_cleared",
6338
+ uploadHistoryFailed: "upload_history_failed"
6339
+ };
6340
+ var TRACK_ACTIONS = {
6341
+ init: "init",
6342
+ click: "click",
6343
+ view: "view",
6344
+ exposure: "exposure",
6345
+ submit: "submit",
6346
+ success: "success",
6347
+ fail: "fail"
6348
+ };
6349
+ function resolveTrackAction2(event) {
6350
+ switch (event) {
6351
+ case TRACK_EVENTS.uploadHistoryViewed:
6352
+ case TRACK_EVENTS.myDomainsSuccess:
6353
+ case TRACK_EVENTS.walletBalanceSuccess:
6354
+ case TRACK_EVENTS.appKeyShownSuccess:
6355
+ return TRACK_ACTIONS.view;
6356
+ case TRACK_EVENTS.uploadHistoryCleared:
6357
+ return TRACK_ACTIONS.click;
6358
+ case TRACK_EVENTS.uploadSuccess:
6359
+ case TRACK_EVENTS.importSuccess:
6360
+ case TRACK_EVENTS.exportSuccess:
6361
+ case TRACK_EVENTS.removeSuccess:
6362
+ case TRACK_EVENTS.domainBindSuccess:
6363
+ case TRACK_EVENTS.cliLoginSuccess:
6364
+ case TRACK_EVENTS.appKeySetSuccess:
6365
+ case TRACK_EVENTS.logoutSuccess:
6366
+ case TRACK_EVENTS.projectCreateSuccess:
6367
+ case TRACK_EVENTS.projectSaveSuccess:
6368
+ case TRACK_EVENTS.projectUpdateDbSuccess:
6369
+ case TRACK_EVENTS.projectUpdateWorkerSuccess:
6370
+ case TRACK_EVENTS.projectUpdateWebSuccess:
6371
+ case TRACK_EVENTS.projectDeleteSuccess:
6372
+ return TRACK_ACTIONS.success;
6373
+ case TRACK_EVENTS.uploadFailed:
6374
+ case TRACK_EVENTS.importFailed:
6375
+ case TRACK_EVENTS.exportFailed:
6376
+ case TRACK_EVENTS.removeFailed:
6377
+ case TRACK_EVENTS.domainBindFailed:
6378
+ case TRACK_EVENTS.cliLoginFailed:
6379
+ case TRACK_EVENTS.appKeySetFailed:
6380
+ case TRACK_EVENTS.logoutFailed:
6381
+ case TRACK_EVENTS.myDomainsFailed:
6382
+ case TRACK_EVENTS.walletBalanceFailed:
6383
+ case TRACK_EVENTS.projectCreateFailed:
6384
+ case TRACK_EVENTS.projectSaveFailed:
6385
+ case TRACK_EVENTS.projectUpdateDbFailed:
6386
+ case TRACK_EVENTS.projectUpdateWorkerFailed:
6387
+ case TRACK_EVENTS.projectUpdateWebFailed:
6388
+ case TRACK_EVENTS.projectDeleteFailed:
6389
+ case TRACK_EVENTS.appKeyShownFailed:
6390
+ case TRACK_EVENTS.uploadHistoryFailed:
6391
+ return TRACK_ACTIONS.fail;
6392
+ default:
6393
+ return TRACK_ACTIONS.view;
6394
+ }
6395
+ }
6396
+
6397
+ // bin/utils/history.ts
6398
+ var HISTORY_DIR = import_path5.default.join(import_os4.default.homedir(), ".pinme");
6399
+ var HISTORY_FILE = import_path5.default.join(HISTORY_DIR, "upload-history.json");
6086
6400
  var ensureHistoryDir = () => {
6087
6401
  if (!import_fs_extra3.default.existsSync(HISTORY_DIR)) {
6088
6402
  import_fs_extra3.default.mkdirSync(HISTORY_DIR, { recursive: true });
@@ -6099,7 +6413,7 @@ var saveUploadHistory = (uploadData) => {
6099
6413
  timestamp: Date.now(),
6100
6414
  date: (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss"),
6101
6415
  path: uploadData.path,
6102
- filename: uploadData.filename || import_path4.default.basename(uploadData.path),
6416
+ filename: uploadData.filename || import_path5.default.basename(uploadData.path),
6103
6417
  contentHash: uploadData.contentHash,
6104
6418
  previewHash: uploadData.previewHash,
6105
6419
  size: uploadData.size,
@@ -6158,55 +6472,78 @@ async function formatHistoryUrl(value, options) {
6158
6472
  return `https://${normalized}`;
6159
6473
  }
6160
6474
  var displayUploadHistory = async (limit = 10) => {
6161
- const history = getUploadHistory(limit);
6162
- if (history.length === 0) {
6163
- console.log(import_chalk5.default.yellow("No upload history found."));
6164
- return;
6165
- }
6166
- console.log(import_chalk5.default.cyan("Upload History:"));
6167
- console.log(import_chalk5.default.cyan("-".repeat(80)));
6168
- let rootDomain = null;
6169
6475
  try {
6170
- rootDomain = await getRootDomain();
6171
- } catch {
6172
- rootDomain = null;
6173
- }
6174
- const recentHistory = history.slice(-limit);
6175
- for (const [index, item] of recentHistory.entries()) {
6176
- console.log(import_chalk5.default.green(`${index + 1}. ${item.filename}`));
6177
- console.log(import_chalk5.default.white(` Path: ${item.path}`));
6178
- console.log(import_chalk5.default.white(` IPFS CID: ${item.contentHash}`));
6179
- const preferredUrl = await formatHistoryUrl(item.dnsUrl) || await formatHistoryUrl(item.pinmeUrl, {
6180
- appendRootDomain: true,
6181
- rootDomain
6182
- }) || await formatHistoryUrl(item.shortUrl, {
6183
- appendRootDomain: true,
6184
- rootDomain
6476
+ const history = getUploadHistory(limit);
6477
+ void tracker_default.trackEvent(TRACK_EVENTS.uploadHistoryViewed, TRACK_PAGES.upload, {
6478
+ a: resolveTrackAction2(TRACK_EVENTS.uploadHistoryViewed),
6479
+ record_count: history.length,
6480
+ limit
6185
6481
  });
6186
- if (preferredUrl) {
6187
- console.log(import_chalk5.default.white(` URL: ${preferredUrl}`));
6188
- }
6189
- console.log(import_chalk5.default.white(` Size: ${formatSize(item.size)}`));
6190
- console.log(import_chalk5.default.white(` Files: ${item.fileCount}`));
6191
- console.log(import_chalk5.default.white(` Type: ${item.type === "directory" ? "Directory" : "File"}`));
6192
- if (item.timestamp) {
6193
- console.log(import_chalk5.default.white(` Date: ${new Date(item.timestamp).toLocaleString()}`));
6482
+ if (history.length === 0) {
6483
+ console.log(import_chalk5.default.yellow("No upload history found."));
6484
+ return;
6194
6485
  }
6486
+ console.log(import_chalk5.default.cyan("Upload History:"));
6195
6487
  console.log(import_chalk5.default.cyan("-".repeat(80)));
6488
+ let rootDomain = null;
6489
+ try {
6490
+ rootDomain = await getRootDomain();
6491
+ } catch {
6492
+ rootDomain = null;
6493
+ }
6494
+ const recentHistory = history.slice(-limit);
6495
+ for (const [index, item] of recentHistory.entries()) {
6496
+ console.log(import_chalk5.default.green(`${index + 1}. ${item.filename}`));
6497
+ console.log(import_chalk5.default.white(` Path: ${item.path}`));
6498
+ console.log(import_chalk5.default.white(` IPFS CID: ${item.contentHash}`));
6499
+ const preferredUrl = await formatHistoryUrl(item.dnsUrl) || await formatHistoryUrl(item.pinmeUrl, {
6500
+ appendRootDomain: true,
6501
+ rootDomain
6502
+ }) || await formatHistoryUrl(item.shortUrl, {
6503
+ appendRootDomain: true,
6504
+ rootDomain
6505
+ });
6506
+ if (preferredUrl) {
6507
+ console.log(import_chalk5.default.white(` URL: ${preferredUrl}`));
6508
+ }
6509
+ console.log(import_chalk5.default.white(` Size: ${formatSize(item.size)}`));
6510
+ console.log(import_chalk5.default.white(` Files: ${item.fileCount}`));
6511
+ console.log(import_chalk5.default.white(` Type: ${item.type === "directory" ? "Directory" : "File"}`));
6512
+ if (item.timestamp) {
6513
+ console.log(import_chalk5.default.white(` Date: ${new Date(item.timestamp).toLocaleString()}`));
6514
+ }
6515
+ console.log(import_chalk5.default.cyan("-".repeat(80)));
6516
+ }
6517
+ const totalSize = history.reduce((sum, record) => sum + record.size, 0);
6518
+ const totalFiles = history.reduce((sum, record) => sum + record.fileCount, 0);
6519
+ console.log(import_chalk5.default.bold(`Total Uploads: ${history.length}`));
6520
+ console.log(import_chalk5.default.bold(`Total Files: ${totalFiles}`));
6521
+ console.log(import_chalk5.default.bold(`Total Size: ${formatSize(totalSize)}`));
6522
+ } catch (error) {
6523
+ void tracker_default.trackEvent(TRACK_EVENTS.uploadHistoryFailed, TRACK_PAGES.upload, {
6524
+ a: resolveTrackAction2(TRACK_EVENTS.uploadHistoryFailed),
6525
+ action: "view",
6526
+ reason: getTrackErrorReason(error)
6527
+ });
6528
+ throw error;
6196
6529
  }
6197
- const totalSize = history.reduce((sum, record) => sum + record.size, 0);
6198
- const totalFiles = history.reduce((sum, record) => sum + record.fileCount, 0);
6199
- console.log(import_chalk5.default.bold(`Total Uploads: ${history.length}`));
6200
- console.log(import_chalk5.default.bold(`Total Files: ${totalFiles}`));
6201
- console.log(import_chalk5.default.bold(`Total Size: ${formatSize(totalSize)}`));
6202
6530
  };
6203
6531
  var clearUploadHistory = () => {
6204
6532
  try {
6205
6533
  ensureHistoryDir();
6206
6534
  import_fs_extra3.default.writeJsonSync(HISTORY_FILE, { uploads: [] });
6535
+ void tracker_default.trackEvent(TRACK_EVENTS.uploadHistoryCleared, TRACK_PAGES.upload, {
6536
+ a: resolveTrackAction2(TRACK_EVENTS.uploadHistoryCleared),
6537
+ cleared: true
6538
+ });
6207
6539
  console.log(import_chalk5.default.green("Upload history cleared successfully."));
6208
6540
  return true;
6209
6541
  } catch (error) {
6542
+ void tracker_default.trackEvent(TRACK_EVENTS.uploadHistoryFailed, TRACK_PAGES.upload, {
6543
+ a: resolveTrackAction2(TRACK_EVENTS.uploadHistoryFailed),
6544
+ action: "clear",
6545
+ reason: getTrackErrorReason(error)
6546
+ });
6210
6547
  console.error(import_chalk5.default.red(`Error clearing upload history: ${error.message}`));
6211
6548
  return false;
6212
6549
  }
@@ -6221,6 +6558,7 @@ var RETRY_DELAY = APP_CONFIG.upload.retryDelayMs;
6221
6558
  var TIMEOUT = APP_CONFIG.upload.timeoutMs;
6222
6559
  var MAX_POLL_TIME = APP_CONFIG.upload.maxPollTimeMs;
6223
6560
  var POLL_INTERVAL = APP_CONFIG.upload.pollIntervalMs;
6561
+ var COMPLETE_TO_STATUS_DELAY = 5e3;
6224
6562
  var PROGRESS_UPDATE_INTERVAL = 200;
6225
6563
  var EXPECTED_UPLOAD_TIME = 6e4;
6226
6564
  var MAX_PROGRESS = 0.9;
@@ -6262,11 +6600,14 @@ function createUploadBusinessError(stage, endpoint, method, status, data) {
6262
6600
  [`Endpoint: ${endpoint}`]
6263
6601
  );
6264
6602
  }
6265
- function logAxiosErrorDetails(prefix, error) {
6603
+ function logAxiosErrorDetails(prefix, error, traceId) {
6266
6604
  var _a2, _b;
6267
6605
  const status = (_a2 = error == null ? void 0 : error.response) == null ? void 0 : _a2.status;
6268
6606
  const responseData = (_b = error == null ? void 0 : error.response) == null ? void 0 : _b.data;
6269
6607
  console.error(`[pinme upload] ${prefix}`);
6608
+ if (traceId) {
6609
+ console.error(`[pinme upload] trace_id: ${traceId}`);
6610
+ }
6270
6611
  console.error(`[pinme upload] status: ${status ?? "unknown"}`);
6271
6612
  if (responseData === void 0) {
6272
6613
  console.error("[pinme upload] response: <empty>");
@@ -6278,6 +6619,16 @@ function logAxiosErrorDetails(prefix, error) {
6278
6619
  console.error(`[pinme upload] response: ${String(responseData)}`);
6279
6620
  }
6280
6621
  }
6622
+ function delay(ms) {
6623
+ return new Promise((resolve) => setTimeout(resolve, ms));
6624
+ }
6625
+ function appendTraceIdToError(error, traceId) {
6626
+ const message = error instanceof Error ? error.message : String(error);
6627
+ if (message.includes(`trace_id: ${traceId}`)) {
6628
+ return error instanceof Error ? error : new Error(message);
6629
+ }
6630
+ return new Error(`${message} (trace_id: ${traceId})`);
6631
+ }
6281
6632
  function isStorageLimitError(error) {
6282
6633
  const message = extractAxiosErrorMessage(error).toLowerCase();
6283
6634
  return message.includes("storage space limit") || message.includes("space limit reached") || message.includes("storage limit reached") || message.includes("quota exceeded") || message.includes("insufficient storage");
@@ -6396,9 +6747,9 @@ async function compressDirectory(sourcePath) {
6396
6747
  if (!import_fs_extra4.default.existsSync(tempDir)) {
6397
6748
  import_fs_extra4.default.mkdirSync(tempDir, { recursive: true });
6398
6749
  }
6399
- const outputPath = import_path5.default.join(
6750
+ const outputPath = import_path6.default.join(
6400
6751
  tempDir,
6401
- `pinme_${import_path5.default.basename(sourcePath)}_${Date.now()}.zip`
6752
+ `pinme_${import_path6.default.basename(sourcePath)}_${Date.now()}.zip`
6402
6753
  );
6403
6754
  const output = import_fs_extra4.default.createWriteStream(outputPath);
6404
6755
  const zlib2 = require("zlib");
@@ -6423,7 +6774,7 @@ async function compressDirectory(sourcePath) {
6423
6774
  async function initChunkSession(filePath, deviceId, options = {}, isDirectory = false) {
6424
6775
  var _a2;
6425
6776
  const stats = import_fs_extra4.default.statSync(filePath);
6426
- const fileName = import_path5.default.basename(filePath);
6777
+ const fileName = import_path6.default.basename(filePath);
6427
6778
  const fileSize = stats.size;
6428
6779
  const md5 = await calculateMD5(filePath);
6429
6780
  try {
@@ -6533,7 +6884,7 @@ async function uploadChunkWithAbort(sessionId, chunkIndex, chunkData, deviceId,
6533
6884
  );
6534
6885
  }
6535
6886
  }
6536
- async function delayWithAbortCheck(delay, signal) {
6887
+ async function delayWithAbortCheck(delay2, signal) {
6537
6888
  return new Promise((resolve, reject) => {
6538
6889
  const timeoutId = setTimeout(() => {
6539
6890
  if (signal.aborted) {
@@ -6541,7 +6892,7 @@ async function delayWithAbortCheck(delay, signal) {
6541
6892
  } else {
6542
6893
  resolve();
6543
6894
  }
6544
- }, delay);
6895
+ }, delay2);
6545
6896
  if (signal.aborted) {
6546
6897
  clearTimeout(timeoutId);
6547
6898
  reject(new Error("Request cancelled"));
@@ -6685,19 +7036,29 @@ async function getChunkStatus(sessionId, deviceId, options = {}) {
6685
7036
  );
6686
7037
  } catch (error) {
6687
7038
  if (axios_default.isAxiosError(error)) {
6688
- logAxiosErrorDetails("up_status failed", error);
6689
- throw formatAxiosError("Upload status check failed", error);
7039
+ logAxiosErrorDetails("up_status failed", error, sessionId);
7040
+ throw formatAxiosError(
7041
+ `Upload status check failed (trace_id: ${sessionId})`,
7042
+ error
7043
+ );
6690
7044
  }
6691
- throw error;
7045
+ console.error("[pinme upload] up_status failed");
7046
+ console.error(`[pinme upload] trace_id: ${sessionId}`);
7047
+ console.error(
7048
+ `[pinme upload] reason: ${error instanceof Error ? error.message : String(error)}`
7049
+ );
7050
+ throw appendTraceIdToError(error, sessionId);
6692
7051
  }
6693
7052
  }
6694
7053
  async function monitorChunkProgress(traceId, deviceId, options = {}, progressBar) {
6695
7054
  let consecutiveErrors = 0;
6696
- const startTime = Date.now();
7055
+ let startTime = Date.now();
6697
7056
  if (progressBar) {
6698
7057
  progressBar.startSimulatingProgress();
6699
7058
  }
6700
7059
  try {
7060
+ await delay(COMPLETE_TO_STATUS_DELAY);
7061
+ startTime = Date.now();
6701
7062
  while (Date.now() - startTime < MAX_POLL_TIME) {
6702
7063
  try {
6703
7064
  const status = await getChunkStatus(traceId, deviceId, options);
@@ -6725,7 +7086,9 @@ async function monitorChunkProgress(traceId, deviceId, options = {}, progressBar
6725
7086
  await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL));
6726
7087
  }
6727
7088
  const maxPollTimeMinutes = Math.floor(MAX_POLL_TIME / (60 * 1e3));
6728
- throw new Error(`Polling timeout after ${maxPollTimeMinutes} minutes`);
7089
+ throw new Error(
7090
+ `Polling timeout after ${maxPollTimeMinutes} minutes (trace_id: ${traceId})`
7091
+ );
6729
7092
  } finally {
6730
7093
  if (progressBar) {
6731
7094
  progressBar.stopSimulatingProgress();
@@ -6741,7 +7104,7 @@ async function uploadDirectoryInChunks(directoryPath, deviceId, options = {}) {
6741
7104
  )} (size: ${formatSize(sizeCheck.size)})`
6742
7105
  );
6743
7106
  }
6744
- const progressBar = new StepProgressBar(import_path5.default.basename(directoryPath), true);
7107
+ const progressBar = new StepProgressBar(import_path6.default.basename(directoryPath), true);
6745
7108
  try {
6746
7109
  progressBar.startStep(0, "Preparing compression");
6747
7110
  const compressedPath = await compressDirectory(directoryPath);
@@ -6785,7 +7148,7 @@ async function uploadDirectoryInChunks(directoryPath, deviceId, options = {}) {
6785
7148
  }
6786
7149
  const uploadData = {
6787
7150
  path: directoryPath,
6788
- filename: import_path5.default.basename(directoryPath),
7151
+ filename: import_path6.default.basename(directoryPath),
6789
7152
  contentHash: (result == null ? void 0 : result.hash) || "unknown",
6790
7153
  size: sizeCheck.size,
6791
7154
  fileCount: 0,
@@ -6814,7 +7177,7 @@ async function uploadFileInChunks(filePath, deviceId, options = {}) {
6814
7177
  )} (size: ${formatSize(sizeCheck.size)})`
6815
7178
  );
6816
7179
  }
6817
- const fileName = import_path5.default.basename(filePath);
7180
+ const fileName = import_path6.default.basename(filePath);
6818
7181
  const progressBar = new StepProgressBar(fileName, false);
6819
7182
  try {
6820
7183
  progressBar.startStep(0, "Initializing session");
@@ -7008,8 +7371,8 @@ function printHighlightedUrl(label, url2, tone = "primary") {
7008
7371
  checkNodeVersion();
7009
7372
  function checkPathSync(inputPath) {
7010
7373
  try {
7011
- const absolutePath = import_path6.default.resolve(inputPath);
7012
- if (import_fs2.default.existsSync(absolutePath)) {
7374
+ const absolutePath = import_path7.default.resolve(inputPath);
7375
+ if (import_fs3.default.existsSync(absolutePath)) {
7013
7376
  return absolutePath;
7014
7377
  }
7015
7378
  return null;
@@ -7070,6 +7433,7 @@ async function checkWalletBalanceStatus(authConfig) {
7070
7433
  }
7071
7434
  async function bindDomain(domain, contentHash, isDns, authConfig) {
7072
7435
  const displayDomain = normalizeDomain(domain);
7436
+ const domainType = isDns ? "dns" : "pinme_subdomain";
7073
7437
  if (isDns) {
7074
7438
  console.log(import_chalk7.default.blue("Binding DNS domain..."));
7075
7439
  const dnsResult = await bindDnsDomainV4(
@@ -7079,9 +7443,22 @@ async function bindDomain(domain, contentHash, isDns, authConfig) {
7079
7443
  authConfig.token
7080
7444
  );
7081
7445
  if (dnsResult.code !== 200) {
7446
+ void tracker_default.trackEvent(TRACK_EVENTS.domainBindFailed, TRACK_PAGES.domain, {
7447
+ a: resolveTrackAction2(TRACK_EVENTS.domainBindFailed),
7448
+ domain_type: domainType,
7449
+ domain_name: displayDomain,
7450
+ bind_source: "upload",
7451
+ reason: dnsResult.msg || "dns_bind_failed"
7452
+ });
7082
7453
  console.log(import_chalk7.default.red(`DNS binding failed: ${dnsResult.msg}`));
7083
7454
  return false;
7084
7455
  }
7456
+ void tracker_default.trackEvent(TRACK_EVENTS.domainBindSuccess, TRACK_PAGES.domain, {
7457
+ a: resolveTrackAction2(TRACK_EVENTS.domainBindSuccess),
7458
+ domain_type: domainType,
7459
+ domain_name: displayDomain,
7460
+ bind_source: "upload"
7461
+ });
7085
7462
  console.log(import_chalk7.default.green(`DNS bind success: ${displayDomain}`));
7086
7463
  console.log(import_chalk7.default.white(`Visit: https://${displayDomain}`));
7087
7464
  console.log(
@@ -7093,9 +7470,22 @@ async function bindDomain(domain, contentHash, isDns, authConfig) {
7093
7470
  console.log(import_chalk7.default.blue("Binding Pinme subdomain..."));
7094
7471
  const ok = await bindPinmeDomain(displayDomain, contentHash);
7095
7472
  if (!ok) {
7473
+ void tracker_default.trackEvent(TRACK_EVENTS.domainBindFailed, TRACK_PAGES.domain, {
7474
+ a: resolveTrackAction2(TRACK_EVENTS.domainBindFailed),
7475
+ domain_type: domainType,
7476
+ domain_name: displayDomain,
7477
+ bind_source: "upload",
7478
+ reason: "pinme_bind_failed"
7479
+ });
7096
7480
  console.log(import_chalk7.default.red("Binding failed. Please try again later."));
7097
7481
  return false;
7098
7482
  }
7483
+ void tracker_default.trackEvent(TRACK_EVENTS.domainBindSuccess, TRACK_PAGES.domain, {
7484
+ a: resolveTrackAction2(TRACK_EVENTS.domainBindSuccess),
7485
+ domain_type: domainType,
7486
+ domain_name: displayDomain,
7487
+ bind_source: "upload"
7488
+ });
7099
7489
  console.log(import_chalk7.default.green(`Bind success: ${displayDomain}`));
7100
7490
  const rootDomain = await (await Promise.resolve().then(() => (init_pinmeApi(), pinmeApi_exports))).getRootDomain();
7101
7491
  console.log(import_chalk7.default.white(`Visit: https://${displayDomain}.${rootDomain}`));
@@ -7127,6 +7517,7 @@ var upload_default = async (options) => {
7127
7517
  console.log(import_chalk7.default.red(`path ${argPath} does not exist`));
7128
7518
  return;
7129
7519
  }
7520
+ const pathKind = getPathKind(absolutePath);
7130
7521
  const isDns = dnsArg || (domainArg ? isDnsDomain(domainArg) : false);
7131
7522
  const displayDomain = domainArg == null ? void 0 : domainArg.replace(/^https?:\/\//, "").replace(/\/$/, "");
7132
7523
  if (isDns && domainArg) {
@@ -7182,13 +7573,31 @@ var upload_default = async (options) => {
7182
7573
  uid: authConfig == null ? void 0 : authConfig.address
7183
7574
  });
7184
7575
  } catch (error) {
7576
+ void tracker_default.trackEvent(TRACK_EVENTS.uploadFailed, TRACK_PAGES.upload, {
7577
+ a: resolveTrackAction2(TRACK_EVENTS.uploadFailed),
7578
+ path_kind: pathKind,
7579
+ has_domain: Boolean(domainArg),
7580
+ reason: getTrackErrorReason(error)
7581
+ });
7185
7582
  printCliError(error, "Upload failed.");
7186
7583
  process.exit(1);
7187
7584
  }
7188
7585
  if (!result) {
7586
+ void tracker_default.trackEvent(TRACK_EVENTS.uploadFailed, TRACK_PAGES.upload, {
7587
+ a: resolveTrackAction2(TRACK_EVENTS.uploadFailed),
7588
+ path_kind: pathKind,
7589
+ has_domain: Boolean(domainArg),
7590
+ reason: "no_result_returned"
7591
+ });
7189
7592
  console.error(import_chalk7.default.red("Upload failed: no result returned"));
7190
7593
  process.exit(1);
7191
7594
  }
7595
+ void tracker_default.trackEvent(TRACK_EVENTS.uploadSuccess, TRACK_PAGES.upload, {
7596
+ a: resolveTrackAction2(TRACK_EVENTS.uploadSuccess),
7597
+ path_kind: pathKind,
7598
+ has_domain: Boolean(domainArg),
7599
+ project_name: APP_CONFIG.pinmeProjectName
7600
+ });
7192
7601
  console.log(
7193
7602
  import_chalk7.default.cyan(import_figlet.default.textSync("Successful", { horizontalLayout: "full" }))
7194
7603
  );
@@ -7224,6 +7633,7 @@ var upload_default = async (options) => {
7224
7633
  console.log(import_chalk7.default.red(`path ${answer.path} does not exist`));
7225
7634
  return;
7226
7635
  }
7636
+ const pathKind = getPathKind(absolutePath);
7227
7637
  const isDns = dnsArg || (domainArg ? isDnsDomain(domainArg) : false);
7228
7638
  const displayDomain = domainArg == null ? void 0 : domainArg.replace(/^https?:\/\//, "").replace(/\/$/, "");
7229
7639
  if (isDns && domainArg) {
@@ -7279,13 +7689,31 @@ var upload_default = async (options) => {
7279
7689
  uid: authConfig == null ? void 0 : authConfig.address
7280
7690
  });
7281
7691
  } catch (error) {
7692
+ void tracker_default.trackEvent(TRACK_EVENTS.uploadFailed, TRACK_PAGES.upload, {
7693
+ a: resolveTrackAction2(TRACK_EVENTS.uploadFailed),
7694
+ path_kind: pathKind,
7695
+ has_domain: Boolean(domainArg),
7696
+ reason: getTrackErrorReason(error)
7697
+ });
7282
7698
  printCliError(error, "Upload failed.");
7283
7699
  process.exit(1);
7284
7700
  }
7285
7701
  if (!result) {
7702
+ void tracker_default.trackEvent(TRACK_EVENTS.uploadFailed, TRACK_PAGES.upload, {
7703
+ a: resolveTrackAction2(TRACK_EVENTS.uploadFailed),
7704
+ path_kind: pathKind,
7705
+ has_domain: Boolean(domainArg),
7706
+ reason: "no_result_returned"
7707
+ });
7286
7708
  console.error(import_chalk7.default.red("Upload failed: no result returned"));
7287
7709
  process.exit(1);
7288
7710
  }
7711
+ void tracker_default.trackEvent(TRACK_EVENTS.uploadSuccess, TRACK_PAGES.upload, {
7712
+ a: resolveTrackAction2(TRACK_EVENTS.uploadSuccess),
7713
+ path_kind: pathKind,
7714
+ has_domain: Boolean(domainArg),
7715
+ project_name: APP_CONFIG.pinmeProjectName
7716
+ });
7289
7717
  console.log(
7290
7718
  import_chalk7.default.cyan(import_figlet.default.textSync("Successful", { horizontalLayout: "full" }))
7291
7719
  );
@@ -7314,11 +7742,11 @@ var upload_default = async (options) => {
7314
7742
  };
7315
7743
 
7316
7744
  // bin/importCar.ts
7317
- var import_path7 = __toESM(require("path"));
7745
+ var import_path8 = __toESM(require("path"));
7318
7746
  var import_chalk8 = __toESM(require("chalk"));
7319
7747
  var import_inquirer2 = __toESM(require("inquirer"));
7320
7748
  var import_figlet2 = __toESM(require("figlet"));
7321
- var import_fs3 = __toESM(require("fs"));
7749
+ var import_fs4 = __toESM(require("fs"));
7322
7750
  var import_crypto_js2 = __toESM(require("crypto-js"));
7323
7751
  init_pinmeApi();
7324
7752
  init_cliError();
@@ -7341,8 +7769,8 @@ function encryptHash2(contentHash, key, uid) {
7341
7769
  }
7342
7770
  function checkPathSync2(inputPath) {
7343
7771
  try {
7344
- const absolutePath = import_path7.default.resolve(inputPath);
7345
- if (import_fs3.default.existsSync(absolutePath)) {
7772
+ const absolutePath = import_path8.default.resolve(inputPath);
7773
+ if (import_fs4.default.existsSync(absolutePath)) {
7346
7774
  return absolutePath;
7347
7775
  }
7348
7776
  return null;
@@ -7390,6 +7818,7 @@ var importCar_default = async (options) => {
7390
7818
  console.log(import_chalk8.default.red(`path ${argPath} does not exist`));
7391
7819
  return;
7392
7820
  }
7821
+ const pathKind = getPathKind(absolutePath);
7393
7822
  if (domainArg) {
7394
7823
  const check = await checkDomainAvailable(domainArg);
7395
7824
  if (!check.is_valid) {
@@ -7409,6 +7838,11 @@ var importCar_default = async (options) => {
7409
7838
  uid: getUid2()
7410
7839
  });
7411
7840
  if (result) {
7841
+ void tracker_default.trackEvent(TRACK_EVENTS.importSuccess, TRACK_PAGES.import, {
7842
+ a: resolveTrackAction2(TRACK_EVENTS.importSuccess),
7843
+ path_kind: pathKind,
7844
+ has_domain: Boolean(domainArg)
7845
+ });
7412
7846
  const uid = getUid2();
7413
7847
  const encryptedCID = encryptHash2(
7414
7848
  result.contentHash,
@@ -7433,6 +7867,12 @@ var importCar_default = async (options) => {
7433
7867
  );
7434
7868
  const ok = await bindPinmeDomain(domainArg, result.contentHash);
7435
7869
  if (ok) {
7870
+ void tracker_default.trackEvent(TRACK_EVENTS.domainBindSuccess, TRACK_PAGES.domain, {
7871
+ a: resolveTrackAction2(TRACK_EVENTS.domainBindSuccess),
7872
+ domain_type: "pinme_subdomain",
7873
+ domain_name: domainArg,
7874
+ bind_source: "import"
7875
+ });
7436
7876
  console.log(import_chalk8.default.green(`Bind success: ${domainArg}`));
7437
7877
  const rootDomain = await getRootDomain();
7438
7878
  console.log(
@@ -7441,12 +7881,25 @@ var importCar_default = async (options) => {
7441
7881
  )
7442
7882
  );
7443
7883
  } else {
7884
+ void tracker_default.trackEvent(TRACK_EVENTS.domainBindFailed, TRACK_PAGES.domain, {
7885
+ a: resolveTrackAction2(TRACK_EVENTS.domainBindFailed),
7886
+ domain_type: "pinme_subdomain",
7887
+ domain_name: domainArg,
7888
+ bind_source: "import",
7889
+ reason: "pinme_bind_failed"
7890
+ });
7444
7891
  console.log(import_chalk8.default.red("Binding failed. Please try again later."));
7445
7892
  }
7446
7893
  }
7447
7894
  console.log(import_chalk8.default.green("\n\u{1F389} import successful, program exit"));
7448
7895
  }
7449
7896
  } catch (error) {
7897
+ void tracker_default.trackEvent(TRACK_EVENTS.importFailed, TRACK_PAGES.import, {
7898
+ a: resolveTrackAction2(TRACK_EVENTS.importFailed),
7899
+ path_kind: pathKind,
7900
+ has_domain: Boolean(domainArg),
7901
+ reason: getTrackErrorReason(error)
7902
+ });
7450
7903
  printCliError(error, "Import failed.");
7451
7904
  }
7452
7905
  process.exit(0);
@@ -7464,6 +7917,7 @@ var importCar_default = async (options) => {
7464
7917
  console.log(import_chalk8.default.red(`path ${answer.path} does not exist`));
7465
7918
  return;
7466
7919
  }
7920
+ const pathKind = getPathKind(absolutePath);
7467
7921
  if (domainArg) {
7468
7922
  const check = await checkDomainAvailable(domainArg);
7469
7923
  if (!check.is_valid) {
@@ -7483,6 +7937,11 @@ var importCar_default = async (options) => {
7483
7937
  uid: getUid2()
7484
7938
  });
7485
7939
  if (result) {
7940
+ void tracker_default.trackEvent(TRACK_EVENTS.importSuccess, TRACK_PAGES.import, {
7941
+ a: resolveTrackAction2(TRACK_EVENTS.importSuccess),
7942
+ path_kind: pathKind,
7943
+ has_domain: Boolean(domainArg)
7944
+ });
7486
7945
  const uid = getUid2();
7487
7946
  const encryptedCID = encryptHash2(
7488
7947
  result.contentHash,
@@ -7507,6 +7966,12 @@ var importCar_default = async (options) => {
7507
7966
  );
7508
7967
  const ok = await bindPinmeDomain(domainArg, result.contentHash);
7509
7968
  if (ok) {
7969
+ void tracker_default.trackEvent(TRACK_EVENTS.domainBindSuccess, TRACK_PAGES.domain, {
7970
+ a: resolveTrackAction2(TRACK_EVENTS.domainBindSuccess),
7971
+ domain_type: "pinme_subdomain",
7972
+ domain_name: domainArg,
7973
+ bind_source: "import"
7974
+ });
7510
7975
  console.log(import_chalk8.default.green(`Bind success: ${domainArg}`));
7511
7976
  const rootDomain = await getRootDomain();
7512
7977
  console.log(
@@ -7515,27 +7980,44 @@ var importCar_default = async (options) => {
7515
7980
  )
7516
7981
  );
7517
7982
  } else {
7983
+ void tracker_default.trackEvent(TRACK_EVENTS.domainBindFailed, TRACK_PAGES.domain, {
7984
+ a: resolveTrackAction2(TRACK_EVENTS.domainBindFailed),
7985
+ domain_type: "pinme_subdomain",
7986
+ domain_name: domainArg,
7987
+ bind_source: "import",
7988
+ reason: "pinme_bind_failed"
7989
+ });
7518
7990
  console.log(import_chalk8.default.red("Binding failed. Please try again later."));
7519
7991
  }
7520
7992
  }
7521
7993
  console.log(import_chalk8.default.green("\n\u{1F389} import successful, program exit"));
7522
7994
  }
7523
7995
  } catch (error) {
7996
+ void tracker_default.trackEvent(TRACK_EVENTS.importFailed, TRACK_PAGES.import, {
7997
+ a: resolveTrackAction2(TRACK_EVENTS.importFailed),
7998
+ path_kind: pathKind,
7999
+ has_domain: Boolean(domainArg),
8000
+ reason: getTrackErrorReason(error)
8001
+ });
7524
8002
  printCliError(error, "Import failed.");
7525
8003
  }
7526
8004
  process.exit(0);
7527
8005
  }
7528
8006
  } catch (error) {
8007
+ void tracker_default.trackEvent(TRACK_EVENTS.importFailed, TRACK_PAGES.import, {
8008
+ a: resolveTrackAction2(TRACK_EVENTS.importFailed),
8009
+ reason: getTrackErrorReason(error)
8010
+ });
7529
8011
  printCliError(error, "Import failed.");
7530
8012
  }
7531
8013
  };
7532
8014
 
7533
8015
  // bin/exportCar.ts
7534
- var import_path8 = __toESM(require("path"));
8016
+ var import_path9 = __toESM(require("path"));
7535
8017
  var import_chalk9 = __toESM(require("chalk"));
7536
8018
  var import_inquirer3 = __toESM(require("inquirer"));
7537
8019
  var import_figlet3 = __toESM(require("figlet"));
7538
- var import_fs4 = __toESM(require("fs"));
8020
+ var import_fs5 = __toESM(require("fs"));
7539
8021
  init_axios2();
7540
8022
  var import_ora2 = __toESM(require("ora"));
7541
8023
  init_cliError();
@@ -7578,7 +8060,7 @@ async function downloadCarFile(downloadUrl, outputPath) {
7578
8060
  timeout: 18e5
7579
8061
  // 30 minutes timeout
7580
8062
  });
7581
- const writer = import_fs4.default.createWriteStream(outputPath);
8063
+ const writer = import_fs5.default.createWriteStream(outputPath);
7582
8064
  let downloadedBytes = 0;
7583
8065
  const totalBytes = parseInt(response.headers["content-length"] || "0", 10);
7584
8066
  response.data.on("data", (chunk) => {
@@ -7674,15 +8156,15 @@ var exportCar_default = async () => {
7674
8156
  ]);
7675
8157
  outputDir = answer.output.trim() || currentDir;
7676
8158
  }
7677
- outputDir = import_path8.default.resolve(outputDir);
7678
- if (!import_fs4.default.existsSync(outputDir)) {
7679
- import_fs4.default.mkdirSync(outputDir, { recursive: true });
7680
- } else if (!import_fs4.default.statSync(outputDir).isDirectory()) {
8159
+ outputDir = import_path9.default.resolve(outputDir);
8160
+ if (!import_fs5.default.existsSync(outputDir)) {
8161
+ import_fs5.default.mkdirSync(outputDir, { recursive: true });
8162
+ } else if (!import_fs5.default.statSync(outputDir).isDirectory()) {
7681
8163
  console.log(import_chalk9.default.red(`Error: ${outputDir} exists but is not a directory.`));
7682
8164
  return;
7683
8165
  }
7684
- const finalOutputPath = import_path8.default.join(outputDir, `${cid}.car`);
7685
- if (import_fs4.default.existsSync(finalOutputPath)) {
8166
+ const finalOutputPath = import_path9.default.join(outputDir, `${cid}.car`);
8167
+ if (import_fs5.default.existsSync(finalOutputPath)) {
7686
8168
  const answer = await import_inquirer3.default.prompt([
7687
8169
  {
7688
8170
  type: "confirm",
@@ -7710,12 +8192,22 @@ var exportCar_default = async () => {
7710
8192
  startTime
7711
8193
  );
7712
8194
  if (!downloadUrl) {
8195
+ void tracker_default.trackEvent(TRACK_EVENTS.exportFailed, TRACK_PAGES.export, {
8196
+ a: resolveTrackAction2(TRACK_EVENTS.exportFailed),
8197
+ cid,
8198
+ reason: "export_failed_or_timed_out"
8199
+ });
7713
8200
  console.log(import_chalk9.default.red("Export failed or timed out."));
7714
8201
  return;
7715
8202
  }
7716
8203
  const success = await downloadCarFile(downloadUrl, finalOutputPath);
7717
8204
  if (success) {
7718
- const fileSize = import_fs4.default.statSync(finalOutputPath).size;
8205
+ void tracker_default.trackEvent(TRACK_EVENTS.exportSuccess, TRACK_PAGES.export, {
8206
+ a: resolveTrackAction2(TRACK_EVENTS.exportSuccess),
8207
+ cid,
8208
+ output_dir: outputDir
8209
+ });
8210
+ const fileSize = import_fs5.default.statSync(finalOutputPath).size;
7719
8211
  const fileSizeMB = (fileSize / (1024 * 1024)).toFixed(2);
7720
8212
  console.log(
7721
8213
  import_chalk9.default.cyan(
@@ -7728,13 +8220,27 @@ var exportCar_default = async () => {
7728
8220
  console.log(import_chalk9.default.cyan(`Size: ${fileSizeMB} MB`));
7729
8221
  console.log(import_chalk9.default.cyan(`CID: ${cid}`));
7730
8222
  } else {
8223
+ void tracker_default.trackEvent(TRACK_EVENTS.exportFailed, TRACK_PAGES.export, {
8224
+ a: resolveTrackAction2(TRACK_EVENTS.exportFailed),
8225
+ cid,
8226
+ reason: "download_failed"
8227
+ });
7731
8228
  console.log(import_chalk9.default.red("Download failed."));
7732
8229
  }
7733
8230
  } catch (error) {
8231
+ void tracker_default.trackEvent(TRACK_EVENTS.exportFailed, TRACK_PAGES.export, {
8232
+ a: resolveTrackAction2(TRACK_EVENTS.exportFailed),
8233
+ cid,
8234
+ reason: getTrackErrorReason(error)
8235
+ });
7734
8236
  spinner.fail(`Error: ${error.message}`);
7735
8237
  printCliError(error, "Export failed.");
7736
8238
  }
7737
8239
  } catch (error) {
8240
+ void tracker_default.trackEvent(TRACK_EVENTS.exportFailed, TRACK_PAGES.export, {
8241
+ a: resolveTrackAction2(TRACK_EVENTS.exportFailed),
8242
+ reason: getTrackErrorReason(error)
8243
+ });
7738
8244
  printCliError(error, "Export failed.");
7739
8245
  }
7740
8246
  };
@@ -7882,6 +8388,10 @@ var remove_default = async (options) => {
7882
8388
  try {
7883
8389
  const success = await removeFromIpfs(parsedInput.value, parsedInput.type);
7884
8390
  if (success) {
8391
+ void tracker_default.trackEvent(TRACK_EVENTS.removeSuccess, TRACK_PAGES.remove, {
8392
+ a: resolveTrackAction2(TRACK_EVENTS.removeSuccess),
8393
+ input_type: parsedInput.type
8394
+ });
7885
8395
  console.log(
7886
8396
  import_chalk11.default.cyan(
7887
8397
  import_figlet4.default.textSync("Successful", { horizontalLayout: "full" })
@@ -7889,6 +8399,11 @@ var remove_default = async (options) => {
7889
8399
  );
7890
8400
  }
7891
8401
  } catch (error) {
8402
+ void tracker_default.trackEvent(TRACK_EVENTS.removeFailed, TRACK_PAGES.remove, {
8403
+ a: resolveTrackAction2(TRACK_EVENTS.removeFailed),
8404
+ input_type: parsedInput.type,
8405
+ reason: getTrackErrorReason(error)
8406
+ });
7892
8407
  console.error(import_chalk11.default.red(`Error: ${error.message}`));
7893
8408
  }
7894
8409
  return;
@@ -7946,6 +8461,10 @@ var remove_default = async (options) => {
7946
8461
  try {
7947
8462
  const success = await removeFromIpfs(parsedInput.value, parsedInput.type);
7948
8463
  if (success) {
8464
+ void tracker_default.trackEvent(TRACK_EVENTS.removeSuccess, TRACK_PAGES.remove, {
8465
+ a: resolveTrackAction2(TRACK_EVENTS.removeSuccess),
8466
+ input_type: parsedInput.type
8467
+ });
7949
8468
  console.log(
7950
8469
  import_chalk11.default.cyan(
7951
8470
  import_figlet4.default.textSync("Successful", { horizontalLayout: "full" })
@@ -7953,10 +8472,19 @@ var remove_default = async (options) => {
7953
8472
  );
7954
8473
  }
7955
8474
  } catch (error) {
8475
+ void tracker_default.trackEvent(TRACK_EVENTS.removeFailed, TRACK_PAGES.remove, {
8476
+ a: resolveTrackAction2(TRACK_EVENTS.removeFailed),
8477
+ input_type: parsedInput.type,
8478
+ reason: getTrackErrorReason(error)
8479
+ });
7956
8480
  console.error(import_chalk11.default.red(`Error: ${error.message}`));
7957
8481
  }
7958
8482
  }
7959
8483
  } catch (error) {
8484
+ void tracker_default.trackEvent(TRACK_EVENTS.removeFailed, TRACK_PAGES.remove, {
8485
+ a: resolveTrackAction2(TRACK_EVENTS.removeFailed),
8486
+ reason: getTrackErrorReason(error)
8487
+ });
7960
8488
  console.error(import_chalk11.default.red(`Error executing remove command: ${error.message}`));
7961
8489
  console.error(error.stack);
7962
8490
  }
@@ -7994,7 +8522,16 @@ async function setAppKeyCmd() {
7994
8522
  } else {
7995
8523
  console.log(import_chalk12.default.yellow("Anonymous history merge not confirmed. You may retry later."));
7996
8524
  }
8525
+ void tracker_default.trackEvent(TRACK_EVENTS.appKeySetSuccess, TRACK_PAGES.auth, {
8526
+ a: resolveTrackAction2(TRACK_EVENTS.appKeySetSuccess),
8527
+ merged_anonymous_history: ok,
8528
+ has_token_address: Boolean(saved.address)
8529
+ });
7997
8530
  } catch (e) {
8531
+ void tracker_default.trackEvent(TRACK_EVENTS.appKeySetFailed, TRACK_PAGES.auth, {
8532
+ a: resolveTrackAction2(TRACK_EVENTS.appKeySetFailed),
8533
+ reason: getTrackErrorReason(e)
8534
+ });
7998
8535
  console.log(import_chalk12.default.red(`Failed to set AppKey: ${(e == null ? void 0 : e.message) || e}`));
7999
8536
  }
8000
8537
  }
@@ -8023,9 +8560,17 @@ async function logoutCmd() {
8023
8560
  return;
8024
8561
  }
8025
8562
  clearAuthToken();
8563
+ void tracker_default.trackEvent(TRACK_EVENTS.logoutSuccess, TRACK_PAGES.auth, {
8564
+ a: resolveTrackAction2(TRACK_EVENTS.logoutSuccess),
8565
+ had_session: true
8566
+ });
8026
8567
  console.log(import_chalk13.default.green("Successfully logged out."));
8027
8568
  console.log(import_chalk13.default.gray(`Address ${auth.address} has been removed from local storage.`));
8028
8569
  } catch (e) {
8570
+ void tracker_default.trackEvent(TRACK_EVENTS.logoutFailed, TRACK_PAGES.auth, {
8571
+ a: resolveTrackAction2(TRACK_EVENTS.logoutFailed),
8572
+ reason: getTrackErrorReason(e)
8573
+ });
8029
8574
  console.log(import_chalk13.default.red(`Failed to logout: ${(e == null ? void 0 : e.message) || e}`));
8030
8575
  }
8031
8576
  }
@@ -8037,6 +8582,10 @@ function showAppKeyCmd() {
8037
8582
  try {
8038
8583
  const auth = getAuthConfig();
8039
8584
  if (!auth) {
8585
+ void tracker_default.trackEvent(TRACK_EVENTS.appKeyShownFailed, TRACK_PAGES.auth, {
8586
+ a: resolveTrackAction2(TRACK_EVENTS.appKeyShownFailed),
8587
+ reason: "no_appkey_found"
8588
+ });
8040
8589
  console.log(import_chalk14.default.yellow("No AppKey found. Please set your AppKey first."));
8041
8590
  console.log(import_chalk14.default.gray("Run: pinme set-appkey <AppKey>"));
8042
8591
  return;
@@ -8057,7 +8606,15 @@ function showAppKeyCmd() {
8057
8606
  } else {
8058
8607
  console.log(import_chalk14.default.cyan(` AppKey: ${"*".repeat(combined.length)}`));
8059
8608
  }
8609
+ void tracker_default.trackEvent(TRACK_EVENTS.appKeyShownSuccess, TRACK_PAGES.auth, {
8610
+ a: resolveTrackAction2(TRACK_EVENTS.appKeyShownSuccess),
8611
+ has_token_address: Boolean(auth.address)
8612
+ });
8060
8613
  } catch (e) {
8614
+ void tracker_default.trackEvent(TRACK_EVENTS.appKeyShownFailed, TRACK_PAGES.auth, {
8615
+ a: resolveTrackAction2(TRACK_EVENTS.appKeyShownFailed),
8616
+ reason: getTrackErrorReason(e)
8617
+ });
8061
8618
  console.log(import_chalk14.default.red(`Failed to show AppKey: ${(e == null ? void 0 : e.message) || e}`));
8062
8619
  }
8063
8620
  }
@@ -8070,6 +8627,10 @@ init_pinmeApi();
8070
8627
  async function myDomainsCmd() {
8071
8628
  try {
8072
8629
  const list = await getMyDomains();
8630
+ void tracker_default.trackEvent(TRACK_EVENTS.myDomainsSuccess, TRACK_PAGES.domain, {
8631
+ a: resolveTrackAction2(TRACK_EVENTS.myDomainsSuccess),
8632
+ domain_count: list.length
8633
+ });
8073
8634
  if (!list.length) {
8074
8635
  console.log(import_chalk15.default.yellow("No bound domains found."));
8075
8636
  return;
@@ -8089,6 +8650,10 @@ async function myDomainsCmd() {
8089
8650
  console.log(import_chalk15.default.cyan("-".repeat(80)));
8090
8651
  });
8091
8652
  } catch (e) {
8653
+ void tracker_default.trackEvent(TRACK_EVENTS.myDomainsFailed, TRACK_PAGES.domain, {
8654
+ a: resolveTrackAction2(TRACK_EVENTS.myDomainsFailed),
8655
+ reason: getTrackErrorReason(e)
8656
+ });
8092
8657
  printCliError(e, "Failed to fetch domains.");
8093
8658
  }
8094
8659
  }
@@ -8110,9 +8675,18 @@ async function walletBalanceCmd() {
8110
8675
  const result = await getWalletBalance(auth.address, auth.token);
8111
8676
  const balance = Number(((_a2 = result.data) == null ? void 0 : _a2.wallet_balance_usd) ?? 0);
8112
8677
  if (!Number.isFinite(balance)) {
8678
+ void tracker_default.trackEvent(TRACK_EVENTS.walletBalanceFailed, TRACK_PAGES.wallet, {
8679
+ a: resolveTrackAction2(TRACK_EVENTS.walletBalanceFailed),
8680
+ reason: "invalid_balance_value"
8681
+ });
8113
8682
  console.log(import_chalk16.default.red("Failed to parse wallet balance."));
8114
8683
  return;
8115
8684
  }
8685
+ void tracker_default.trackEvent(TRACK_EVENTS.walletBalanceSuccess, TRACK_PAGES.wallet, {
8686
+ a: resolveTrackAction2(TRACK_EVENTS.walletBalanceSuccess),
8687
+ has_balance: balance > 0,
8688
+ balance_usd: balance.toFixed(2)
8689
+ });
8116
8690
  console.log(import_chalk16.default.cyan("Wallet balance:"));
8117
8691
  console.log(import_chalk16.default.green(` USD: $${balance.toFixed(2)}`));
8118
8692
  if (balance <= 0) {
@@ -8120,12 +8694,16 @@ async function walletBalanceCmd() {
8120
8694
  printRechargeUrl(getWalletRechargeUrl());
8121
8695
  }
8122
8696
  } catch (e) {
8697
+ void tracker_default.trackEvent(TRACK_EVENTS.walletBalanceFailed, TRACK_PAGES.wallet, {
8698
+ a: resolveTrackAction2(TRACK_EVENTS.walletBalanceFailed),
8699
+ reason: getTrackErrorReason(e)
8700
+ });
8123
8701
  printCliError(e, "Failed to fetch wallet balance.");
8124
8702
  }
8125
8703
  }
8126
8704
 
8127
8705
  // bin/bind.ts
8128
- var import_path9 = __toESM(require("path"));
8706
+ var import_path10 = __toESM(require("path"));
8129
8707
  var import_chalk17 = __toESM(require("chalk"));
8130
8708
  var import_inquirer7 = __toESM(require("inquirer"));
8131
8709
  init_pinmeApi();
@@ -8214,6 +8792,8 @@ async function bindCmd() {
8214
8792
  }
8215
8793
  const isDns = dns || isDnsDomain(domain);
8216
8794
  const displayDomain = normalizeDomain(domain);
8795
+ const pathKind = getPathKind(import_path10.default.resolve(targetPath));
8796
+ const domainType = isDns ? "dns" : "pinme_subdomain";
8217
8797
  if (isDns) {
8218
8798
  const validation = validateDnsDomain(domain);
8219
8799
  if (!validation.valid) {
@@ -8253,13 +8833,24 @@ async function bindCmd() {
8253
8833
  }
8254
8834
  throw e;
8255
8835
  }
8256
- const absolutePath = import_path9.default.resolve(targetPath);
8836
+ const absolutePath = import_path10.default.resolve(targetPath);
8257
8837
  console.log(import_chalk17.default.blue(`Uploading: ${absolutePath}`));
8258
8838
  const up = await uploadPath(absolutePath, { uid: authConfig.address });
8259
8839
  if (!(up == null ? void 0 : up.contentHash)) {
8840
+ void tracker_default.trackEvent(TRACK_EVENTS.uploadFailed, TRACK_PAGES.upload, {
8841
+ a: resolveTrackAction2(TRACK_EVENTS.uploadFailed),
8842
+ path_kind: pathKind,
8843
+ has_domain: true,
8844
+ reason: "no_content_hash"
8845
+ });
8260
8846
  console.log(import_chalk17.default.red("Upload failed, binding aborted."));
8261
8847
  return;
8262
8848
  }
8849
+ void tracker_default.trackEvent(TRACK_EVENTS.uploadSuccess, TRACK_PAGES.upload, {
8850
+ a: resolveTrackAction2(TRACK_EVENTS.uploadSuccess),
8851
+ path_kind: pathKind,
8852
+ has_domain: true
8853
+ });
8263
8854
  console.log(import_chalk17.default.green(`Upload success, CID: ${up.contentHash}`));
8264
8855
  try {
8265
8856
  if (isDns) {
@@ -8271,9 +8862,22 @@ async function bindCmd() {
8271
8862
  authConfig.token
8272
8863
  );
8273
8864
  if (dnsResult.code !== 200) {
8865
+ void tracker_default.trackEvent(TRACK_EVENTS.domainBindFailed, TRACK_PAGES.domain, {
8866
+ a: resolveTrackAction2(TRACK_EVENTS.domainBindFailed),
8867
+ domain_type: domainType,
8868
+ domain_name: displayDomain,
8869
+ bind_source: "bind",
8870
+ reason: dnsResult.msg || "dns_bind_failed"
8871
+ });
8274
8872
  console.log(import_chalk17.default.red(`DNS binding failed: ${dnsResult.msg}`));
8275
8873
  return;
8276
8874
  }
8875
+ void tracker_default.trackEvent(TRACK_EVENTS.domainBindSuccess, TRACK_PAGES.domain, {
8876
+ a: resolveTrackAction2(TRACK_EVENTS.domainBindSuccess),
8877
+ domain_type: domainType,
8878
+ domain_name: displayDomain,
8879
+ bind_source: "bind"
8880
+ });
8277
8881
  console.log(import_chalk17.default.green(`DNS bind success: ${displayDomain}`));
8278
8882
  console.log(import_chalk17.default.white(`Visit: https://${displayDomain}`));
8279
8883
  console.log(
@@ -8285,9 +8889,22 @@ async function bindCmd() {
8285
8889
  console.log(import_chalk17.default.blue("Binding Pinme subdomain..."));
8286
8890
  const ok = await bindPinmeDomain(displayDomain, up.contentHash);
8287
8891
  if (!ok) {
8892
+ void tracker_default.trackEvent(TRACK_EVENTS.domainBindFailed, TRACK_PAGES.domain, {
8893
+ a: resolveTrackAction2(TRACK_EVENTS.domainBindFailed),
8894
+ domain_type: domainType,
8895
+ domain_name: displayDomain,
8896
+ bind_source: "bind",
8897
+ reason: "pinme_bind_failed"
8898
+ });
8288
8899
  console.log(import_chalk17.default.red("Binding failed. Please try again later."));
8289
8900
  return;
8290
8901
  }
8902
+ void tracker_default.trackEvent(TRACK_EVENTS.domainBindSuccess, TRACK_PAGES.domain, {
8903
+ a: resolveTrackAction2(TRACK_EVENTS.domainBindSuccess),
8904
+ domain_type: domainType,
8905
+ domain_name: displayDomain,
8906
+ bind_source: "bind"
8907
+ });
8291
8908
  console.log(import_chalk17.default.green(`Bind success: ${displayDomain}`));
8292
8909
  const rootDomain = await getRootDomain();
8293
8910
  console.log(
@@ -8301,6 +8918,11 @@ async function bindCmd() {
8301
8918
  throw e;
8302
8919
  }
8303
8920
  } catch (e) {
8921
+ void tracker_default.trackEvent(TRACK_EVENTS.domainBindFailed, TRACK_PAGES.domain, {
8922
+ a: resolveTrackAction2(TRACK_EVENTS.domainBindFailed),
8923
+ bind_source: "bind",
8924
+ reason: getTrackErrorReason(e)
8925
+ });
8304
8926
  printCliError(e, "Bind failed.");
8305
8927
  }
8306
8928
  }
@@ -8315,9 +8937,9 @@ var ENV_URLS = {
8315
8937
  prod: "https://pinme.eth.limo"
8316
8938
  };
8317
8939
  async function loginCmd(options = {}) {
8940
+ const env = (options.env || "prod").toLowerCase();
8318
8941
  try {
8319
8942
  let webBaseUrl;
8320
- const env = (options.env || "prod").toLowerCase();
8321
8943
  if (ENV_URLS[env]) {
8322
8944
  webBaseUrl = ENV_URLS[env];
8323
8945
  console.log(import_chalk18.default.blue(`Using ${env} environment: ${webBaseUrl}`));
@@ -8338,8 +8960,19 @@ async function loginCmd(options = {}) {
8338
8960
  if (ok) {
8339
8961
  console.log(import_chalk18.default.green("History merged to your account"));
8340
8962
  }
8963
+ void tracker_default.trackEvent(TRACK_EVENTS.cliLoginSuccess, TRACK_PAGES.login, {
8964
+ a: resolveTrackAction2(TRACK_EVENTS.cliLoginSuccess),
8965
+ env,
8966
+ has_token_address: true,
8967
+ merged_anonymous_history: ok
8968
+ });
8341
8969
  process.exit(0);
8342
8970
  } catch (e) {
8971
+ void tracker_default.trackEvent(TRACK_EVENTS.cliLoginFailed, TRACK_PAGES.login, {
8972
+ a: resolveTrackAction2(TRACK_EVENTS.cliLoginFailed),
8973
+ env,
8974
+ reason: getTrackErrorReason(e)
8975
+ });
8343
8976
  console.log(import_chalk18.default.red(`
8344
8977
  Login failed: ${(e == null ? void 0 : e.message) || e}`));
8345
8978
  process.exit(1);
@@ -8349,23 +8982,23 @@ Login failed: ${(e == null ? void 0 : e.message) || e}`));
8349
8982
  // bin/create.ts
8350
8983
  var import_chalk20 = __toESM(require("chalk"));
8351
8984
  var import_fs_extra6 = __toESM(require("fs-extra"));
8352
- var import_path11 = __toESM(require("path"));
8985
+ var import_path12 = __toESM(require("path"));
8353
8986
  var import_inquirer8 = __toESM(require("inquirer"));
8354
8987
  init_axios2();
8355
- var import_child_process3 = require("child_process");
8988
+ var import_child_process4 = require("child_process");
8356
8989
  init_webLogin();
8357
8990
 
8358
8991
  // bin/utils/installProjectDependencies.ts
8359
8992
  var import_fs_extra5 = __toESM(require("fs-extra"));
8360
- var import_os4 = __toESM(require("os"));
8361
- var import_path10 = __toESM(require("path"));
8993
+ var import_os5 = __toESM(require("os"));
8994
+ var import_path11 = __toESM(require("path"));
8362
8995
  var import_chalk19 = __toESM(require("chalk"));
8363
- var import_child_process2 = require("child_process");
8996
+ var import_child_process3 = require("child_process");
8364
8997
  function makeTempCacheDir() {
8365
- return import_fs_extra5.default.mkdtempSync(import_path10.default.join(import_os4.default.tmpdir(), "pinme-npm-cache-"));
8998
+ return import_fs_extra5.default.mkdtempSync(import_path11.default.join(import_os5.default.tmpdir(), "pinme-npm-cache-"));
8366
8999
  }
8367
9000
  function runInstall(cwd, cacheDir) {
8368
- (0, import_child_process2.execFileSync)("npm", ["install", "--cache", cacheDir, "--no-audit", "--no-fund"], {
9001
+ (0, import_child_process3.execFileSync)("npm", ["install", "--cache", cacheDir, "--no-audit", "--no-fund"], {
8369
9002
  cwd,
8370
9003
  stdio: "inherit",
8371
9004
  env: {
@@ -8434,7 +9067,7 @@ function resolveExtractedTemplateDir(extractDir) {
8434
9067
  `Template branch: ${TEMPLATE_BRANCH}`
8435
9068
  ]);
8436
9069
  }
8437
- return import_path11.default.join(extractDir, templateDir.name);
9070
+ return import_path12.default.join(extractDir, templateDir.name);
8438
9071
  }
8439
9072
  function updateFrontendUrlInConfig(configPath, frontendUrl) {
8440
9073
  let config = import_fs_extra6.default.readFileSync(configPath, "utf-8");
@@ -8483,7 +9116,7 @@ async function createCmd(options) {
8483
9116
  ]);
8484
9117
  projectName = answers.projectName;
8485
9118
  }
8486
- const targetDir = import_path11.default.join(PROJECT_DIR, projectName);
9119
+ const targetDir = import_path12.default.join(PROJECT_DIR, projectName);
8487
9120
  if (import_fs_extra6.default.existsSync(targetDir) && !options.force) {
8488
9121
  console.log(import_chalk20.default.yellow(`
8489
9122
  Directory "${projectName}" already exists.`));
@@ -8534,15 +9167,15 @@ Directory "${projectName}" already exists.`));
8534
9167
  ]);
8535
9168
  }
8536
9169
  console.log(import_chalk20.default.blue("\n2. Downloading template from repository..."));
8537
- const zipPath = import_path11.default.join(PROJECT_DIR, "template.zip");
8538
- const extractDir = import_path11.default.join(PROJECT_DIR, `.pinme-template-${Date.now()}`);
9170
+ const zipPath = import_path12.default.join(PROJECT_DIR, "template.zip");
9171
+ const extractDir = import_path12.default.join(PROJECT_DIR, `.pinme-template-${Date.now()}`);
8539
9172
  const templateZipUrl = getTemplateZipUrl(TEMPLATE_BRANCH);
8540
9173
  let downloadSuccess = false;
8541
9174
  console.log(import_chalk20.default.gray(` Template branch: ${TEMPLATE_BRANCH}`));
8542
9175
  for (let attempt = 1; attempt <= 3 && !downloadSuccess; attempt++) {
8543
9176
  try {
8544
9177
  console.log(import_chalk20.default.gray(` Download attempt ${attempt}/3...`));
8545
- (0, import_child_process3.execSync)(`curl -L --retry 3 --retry-delay 2 -o "${zipPath}" "${templateZipUrl}"`, {
9178
+ (0, import_child_process4.execSync)(`curl -L --retry 3 --retry-delay 2 -o "${zipPath}" "${templateZipUrl}"`, {
8546
9179
  stdio: "inherit"
8547
9180
  });
8548
9181
  if (!import_fs_extra6.default.existsSync(zipPath) || import_fs_extra6.default.statSync(zipPath).size < 100) {
@@ -8561,15 +9194,15 @@ Directory "${projectName}" already exists.`));
8561
9194
  }
8562
9195
  try {
8563
9196
  import_fs_extra6.default.ensureDirSync(extractDir);
8564
- (0, import_child_process3.execSync)(`unzip -o "${zipPath}" -d "${extractDir}"`, {
9197
+ (0, import_child_process4.execSync)(`unzip -o "${zipPath}" -d "${extractDir}"`, {
8565
9198
  stdio: "inherit"
8566
9199
  });
8567
9200
  const subDir = resolveExtractedTemplateDir(extractDir);
8568
9201
  import_fs_extra6.default.copySync(subDir, targetDir);
8569
9202
  import_fs_extra6.default.removeSync(zipPath);
8570
9203
  import_fs_extra6.default.removeSync(extractDir);
8571
- const nodeModulesPath = import_path11.default.join(targetDir, "node_modules");
8572
- const packageLockPath = import_path11.default.join(targetDir, "package-lock.json");
9204
+ const nodeModulesPath = import_path12.default.join(targetDir, "node_modules");
9205
+ const packageLockPath = import_path12.default.join(targetDir, "package-lock.json");
8573
9206
  if (import_fs_extra6.default.existsSync(nodeModulesPath)) {
8574
9207
  console.log(import_chalk20.default.gray(" Removing existing node_modules..."));
8575
9208
  import_fs_extra6.default.removeSync(nodeModulesPath);
@@ -8578,10 +9211,10 @@ Directory "${projectName}" already exists.`));
8578
9211
  console.log(import_chalk20.default.gray(" Removing existing package-lock.json..."));
8579
9212
  import_fs_extra6.default.removeSync(packageLockPath);
8580
9213
  }
8581
- const frontendNodeModules = import_path11.default.join(targetDir, "frontend", "node_modules");
8582
- const backendNodeModules = import_path11.default.join(targetDir, "backend", "node_modules");
8583
- const frontendPackageLock = import_path11.default.join(targetDir, "frontend", "package-lock.json");
8584
- const backendPackageLock = import_path11.default.join(targetDir, "backend", "package-lock.json");
9214
+ const frontendNodeModules = import_path12.default.join(targetDir, "frontend", "node_modules");
9215
+ const backendNodeModules = import_path12.default.join(targetDir, "backend", "node_modules");
9216
+ const frontendPackageLock = import_path12.default.join(targetDir, "frontend", "package-lock.json");
9217
+ const backendPackageLock = import_path12.default.join(targetDir, "backend", "package-lock.json");
8585
9218
  if (import_fs_extra6.default.existsSync(frontendNodeModules)) import_fs_extra6.default.removeSync(frontendNodeModules);
8586
9219
  if (import_fs_extra6.default.existsSync(backendNodeModules)) import_fs_extra6.default.removeSync(backendNodeModules);
8587
9220
  if (import_fs_extra6.default.existsSync(frontendPackageLock)) import_fs_extra6.default.removeSync(frontendPackageLock);
@@ -8593,7 +9226,7 @@ Directory "${projectName}" already exists.`));
8593
9226
  ]);
8594
9227
  }
8595
9228
  console.log(import_chalk20.default.blue("\n3. Updating configuration..."));
8596
- const configPath = import_path11.default.join(targetDir, "pinme.toml");
9229
+ const configPath = import_path12.default.join(targetDir, "pinme.toml");
8597
9230
  const config = import_fs_extra6.default.readFileSync(configPath, "utf-8");
8598
9231
  let updatedConfig = config.replace(
8599
9232
  /project_name = ".*"/,
@@ -8602,16 +9235,16 @@ Directory "${projectName}" already exists.`));
8602
9235
  import_fs_extra6.default.writeFileSync(configPath, updatedConfig);
8603
9236
  console.log(import_chalk20.default.green(` Updated pinme.toml`));
8604
9237
  console.log(import_chalk20.default.gray(` metadata: ${workerData.metadata}`));
8605
- const backendDir = import_path11.default.join(targetDir, "backend");
9238
+ const backendDir = import_path12.default.join(targetDir, "backend");
8606
9239
  if (import_fs_extra6.default.existsSync(backendDir) && workerData.metadata) {
8607
9240
  const metadataContent = typeof workerData.metadata === "string" ? workerData.metadata : JSON.stringify(workerData.metadata, null, 2);
8608
9241
  import_fs_extra6.default.writeFileSync(
8609
- import_path11.default.join(backendDir, "metadata.json"),
9242
+ import_path12.default.join(backendDir, "metadata.json"),
8610
9243
  metadataContent
8611
9244
  );
8612
9245
  console.log(import_chalk20.default.green(` Saved metadata.json`));
8613
9246
  }
8614
- const wranglerPath = import_path11.default.join(backendDir, "wrangler.toml");
9247
+ const wranglerPath = import_path12.default.join(backendDir, "wrangler.toml");
8615
9248
  if (import_fs_extra6.default.existsSync(wranglerPath) && workerData.api_key) {
8616
9249
  let wranglerContent = import_fs_extra6.default.readFileSync(wranglerPath, "utf-8");
8617
9250
  wranglerContent = wranglerContent.replace(
@@ -8621,18 +9254,18 @@ Directory "${projectName}" already exists.`));
8621
9254
  import_fs_extra6.default.writeFileSync(wranglerPath, wranglerContent);
8622
9255
  console.log(import_chalk20.default.green(` Updated backend/wrangler.toml API_KEY`));
8623
9256
  }
8624
- const frontendConfigPath = import_path11.default.join(targetDir, "frontend", "src", "utils", "config.ts");
9257
+ const frontendConfigPath = import_path12.default.join(targetDir, "frontend", "src", "utils", "config.ts");
8625
9258
  if (workerData.public_client_config) {
8626
9259
  const frontendConfigContent = import_fs_extra6.default.existsSync(frontendConfigPath) ? import_fs_extra6.default.readFileSync(frontendConfigPath, "utf-8") : "";
8627
- import_fs_extra6.default.ensureDirSync(import_path11.default.dirname(frontendConfigPath));
9260
+ import_fs_extra6.default.ensureDirSync(import_path12.default.dirname(frontendConfigPath));
8628
9261
  import_fs_extra6.default.writeFileSync(
8629
9262
  frontendConfigPath,
8630
9263
  injectPublicClientConfigIntoFile(frontendConfigContent, workerData.public_client_config)
8631
9264
  );
8632
9265
  console.log(import_chalk20.default.green(` Updated frontend/src/utils/config.ts public_client_config`));
8633
9266
  }
8634
- const envExamplePath = import_path11.default.join(targetDir, "frontend", ".env.example");
8635
- const envPath = import_path11.default.join(targetDir, "frontend", ".env");
9267
+ const envExamplePath = import_path12.default.join(targetDir, "frontend", ".env.example");
9268
+ const envPath = import_path12.default.join(targetDir, "frontend", ".env");
8636
9269
  if (import_fs_extra6.default.existsSync(envExamplePath)) {
8637
9270
  let envContent = import_fs_extra6.default.readFileSync(envExamplePath, "utf-8");
8638
9271
  envContent = envContent.replace(/your-project/g, workerData.project_name);
@@ -8707,7 +9340,7 @@ Directory "${projectName}" already exists.`));
8707
9340
  }
8708
9341
  console.log(import_chalk20.default.blue("\n5. Building backend worker..."));
8709
9342
  try {
8710
- (0, import_child_process3.execSync)("npm run build:worker", {
9343
+ (0, import_child_process4.execSync)("npm run build:worker", {
8711
9344
  cwd: targetDir,
8712
9345
  stdio: "inherit"
8713
9346
  });
@@ -8717,8 +9350,8 @@ Directory "${projectName}" already exists.`));
8717
9350
  "Fix the build error shown above, then rerun `pinme create`."
8718
9351
  ]);
8719
9352
  }
8720
- const distWorkerDir = import_path11.default.join(targetDir, "dist-worker");
8721
- const workerJsPath = import_path11.default.join(distWorkerDir, "worker.js");
9353
+ const distWorkerDir = import_path12.default.join(targetDir, "dist-worker");
9354
+ const workerJsPath = import_path12.default.join(distWorkerDir, "worker.js");
8722
9355
  if (!import_fs_extra6.default.existsSync(distWorkerDir) || !import_fs_extra6.default.existsSync(workerJsPath)) {
8723
9356
  throw createConfigError("Built worker output not found: `dist-worker/worker.js`.", [
8724
9357
  "Make sure `npm run build:worker` completed successfully."
@@ -8728,15 +9361,15 @@ Directory "${projectName}" already exists.`));
8728
9361
  const files = import_fs_extra6.default.readdirSync(distWorkerDir);
8729
9362
  for (const file of files) {
8730
9363
  if (file.endsWith(".js") && file !== "worker.js") {
8731
- modulePaths.push(import_path11.default.join(distWorkerDir, file));
9364
+ modulePaths.push(import_path12.default.join(distWorkerDir, file));
8732
9365
  }
8733
9366
  }
8734
- const sqlDir = import_path11.default.join(targetDir, "db");
9367
+ const sqlDir = import_path12.default.join(targetDir, "db");
8735
9368
  const sqlFiles = [];
8736
9369
  if (import_fs_extra6.default.existsSync(sqlDir)) {
8737
9370
  const sqlFileNames = import_fs_extra6.default.readdirSync(sqlDir).filter((f) => f.endsWith(".sql")).sort();
8738
9371
  for (const filename of sqlFileNames) {
8739
- sqlFiles.push(import_path11.default.join(sqlDir, filename));
9372
+ sqlFiles.push(import_path12.default.join(sqlDir, filename));
8740
9373
  console.log(import_chalk20.default.gray(` Including SQL: ${filename}`));
8741
9374
  }
8742
9375
  }
@@ -8756,14 +9389,14 @@ Directory "${projectName}" already exists.`));
8756
9389
  type: "application/javascript+module"
8757
9390
  }), "worker.js");
8758
9391
  for (const modulePath of modulePaths) {
8759
- const filename = import_path11.default.basename(modulePath);
9392
+ const filename = import_path12.default.basename(modulePath);
8760
9393
  const content = import_fs_extra6.default.readFileSync(modulePath, "utf-8");
8761
9394
  formData.append(filename, new Blob2([content], {
8762
9395
  type: "application/javascript+module"
8763
9396
  }), filename);
8764
9397
  }
8765
9398
  for (const sqlFile of sqlFiles) {
8766
- const filename = import_path11.default.basename(sqlFile);
9399
+ const filename = import_path12.default.basename(sqlFile);
8767
9400
  const content = import_fs_extra6.default.readFileSync(sqlFile, "utf-8");
8768
9401
  formData.append("sql_file", new Blob2([content], {
8769
9402
  type: "application/sql"
@@ -8797,10 +9430,10 @@ Directory "${projectName}" already exists.`));
8797
9430
  ]);
8798
9431
  }
8799
9432
  console.log(import_chalk20.default.blue("\n7. Building frontend..."));
8800
- const frontendDir = import_path11.default.join(targetDir, "frontend");
9433
+ const frontendDir = import_path12.default.join(targetDir, "frontend");
8801
9434
  if (import_fs_extra6.default.existsSync(frontendDir)) {
8802
9435
  try {
8803
- (0, import_child_process3.execSync)("npm run build:frontend", {
9436
+ (0, import_child_process4.execSync)("npm run build:frontend", {
8804
9437
  cwd: targetDir,
8805
9438
  stdio: "inherit"
8806
9439
  });
@@ -8812,13 +9445,13 @@ Directory "${projectName}" already exists.`));
8812
9445
  }
8813
9446
  console.log(import_chalk20.default.blue(" Uploading to IPFS..."));
8814
9447
  try {
8815
- const uploadResult = await uploadPath(import_path11.default.join(frontendDir, "dist"), {
9448
+ const uploadResult = await uploadPath(import_path12.default.join(frontendDir, "dist"), {
8816
9449
  projectName: workerData.project_name,
8817
9450
  uid: headers["token-address"]
8818
9451
  });
8819
9452
  printHighlightedUrl("Frontend URL", uploadResult.publicUrl, "primary");
8820
9453
  updateFrontendUrlInConfig(
8821
- import_path11.default.join(targetDir, "pinme.toml"),
9454
+ import_path12.default.join(targetDir, "pinme.toml"),
8822
9455
  uploadResult.publicUrl
8823
9456
  );
8824
9457
  console.log(import_chalk20.default.green(" Updated pinme.toml with frontend URL"));
@@ -8840,8 +9473,29 @@ Project Details:`));
8840
9473
  Next steps:`));
8841
9474
  console.log(import_chalk20.default.gray(` cd ${projectName}`));
8842
9475
  console.log(import_chalk20.default.gray(` pinme save`));
9476
+ void tracker_default.trackEvent(
9477
+ TRACK_EVENTS.projectCreateSuccess,
9478
+ TRACK_PAGES.project,
9479
+ {
9480
+ a: resolveTrackAction2(TRACK_EVENTS.projectCreateSuccess),
9481
+ project_name: workerData.project_name,
9482
+ template_branch: TEMPLATE_BRANCH,
9483
+ force: Boolean(options.force)
9484
+ }
9485
+ );
8843
9486
  process.exit(0);
8844
9487
  } catch (error) {
9488
+ void tracker_default.trackEvent(
9489
+ TRACK_EVENTS.projectCreateFailed,
9490
+ TRACK_PAGES.project,
9491
+ {
9492
+ a: resolveTrackAction2(TRACK_EVENTS.projectCreateFailed),
9493
+ project_name: options.name,
9494
+ template_branch: TEMPLATE_BRANCH,
9495
+ force: Boolean(options.force),
9496
+ reason: getTrackErrorReason(error)
9497
+ }
9498
+ );
8845
9499
  printCliError(error, "Project creation failed.");
8846
9500
  process.exit(1);
8847
9501
  }
@@ -8850,9 +9504,9 @@ Next steps:`));
8850
9504
  // bin/save.ts
8851
9505
  var import_chalk21 = __toESM(require("chalk"));
8852
9506
  var import_fs_extra7 = __toESM(require("fs-extra"));
8853
- var import_path12 = __toESM(require("path"));
9507
+ var import_path13 = __toESM(require("path"));
8854
9508
  init_axios2();
8855
- var import_child_process4 = require("child_process");
9509
+ var import_child_process5 = require("child_process");
8856
9510
  init_webLogin();
8857
9511
  init_pinmeApi();
8858
9512
  init_domainValidator();
@@ -8860,7 +9514,7 @@ init_cliError();
8860
9514
  init_config();
8861
9515
  var PROJECT_DIR2 = process.cwd();
8862
9516
  function loadConfig() {
8863
- const configPath = import_path12.default.join(PROJECT_DIR2, "pinme.toml");
9517
+ const configPath = import_path13.default.join(PROJECT_DIR2, "pinme.toml");
8864
9518
  if (!import_fs_extra7.default.existsSync(configPath)) {
8865
9519
  throw createConfigError("`pinme.toml` not found in the current directory.", [
8866
9520
  "Run this command from the Pinme project root.",
@@ -8877,7 +9531,7 @@ function getProjectManagementUrl2(projectName) {
8877
9531
  return `${APP_CONFIG.projectPeviewUrl}${projectName}`;
8878
9532
  }
8879
9533
  function getMetadata() {
8880
- const metadataPath = import_path12.default.join(PROJECT_DIR2, "backend", "metadata.json");
9534
+ const metadataPath = import_path13.default.join(PROJECT_DIR2, "backend", "metadata.json");
8881
9535
  if (!import_fs_extra7.default.existsSync(metadataPath)) {
8882
9536
  console.log(import_chalk21.default.yellow(" Warning: metadata.json not found, using empty metadata"));
8883
9537
  return {};
@@ -8887,7 +9541,7 @@ function getMetadata() {
8887
9541
  function buildWorker() {
8888
9542
  console.log(import_chalk21.default.blue("Building worker..."));
8889
9543
  try {
8890
- (0, import_child_process4.execSync)("npm run build:worker", {
9544
+ (0, import_child_process5.execSync)("npm run build:worker", {
8891
9545
  cwd: PROJECT_DIR2,
8892
9546
  stdio: "inherit"
8893
9547
  });
@@ -8943,13 +9597,13 @@ function installDependencies() {
8943
9597
  }
8944
9598
  }
8945
9599
  function getBuiltWorker() {
8946
- const distWorkerDir = import_path12.default.join(PROJECT_DIR2, "dist-worker");
9600
+ const distWorkerDir = import_path13.default.join(PROJECT_DIR2, "dist-worker");
8947
9601
  if (!import_fs_extra7.default.existsSync(distWorkerDir)) {
8948
9602
  throw createConfigError("Built worker output not found: `dist-worker/`.", [
8949
9603
  "Make sure `npm run build:worker` completed successfully."
8950
9604
  ]);
8951
9605
  }
8952
- const workerJsPath = import_path12.default.join(distWorkerDir, "worker.js");
9606
+ const workerJsPath = import_path13.default.join(distWorkerDir, "worker.js");
8953
9607
  if (!import_fs_extra7.default.existsSync(workerJsPath)) {
8954
9608
  throw createConfigError("Built worker entry file not found: `dist-worker/worker.js`.", [
8955
9609
  "Check the worker build output and bundler config."
@@ -8959,18 +9613,18 @@ function getBuiltWorker() {
8959
9613
  const files = import_fs_extra7.default.readdirSync(distWorkerDir);
8960
9614
  for (const file of files) {
8961
9615
  if (file.endsWith(".js") && file !== "worker.js") {
8962
- modulePaths.push(import_path12.default.join(distWorkerDir, file));
9616
+ modulePaths.push(import_path13.default.join(distWorkerDir, file));
8963
9617
  }
8964
9618
  }
8965
9619
  return { workerJsPath, modulePaths };
8966
9620
  }
8967
9621
  function getSqlFiles() {
8968
- const sqlDir = import_path12.default.join(PROJECT_DIR2, "db");
9622
+ const sqlDir = import_path13.default.join(PROJECT_DIR2, "db");
8969
9623
  if (!import_fs_extra7.default.existsSync(sqlDir)) {
8970
9624
  return [];
8971
9625
  }
8972
9626
  const files = import_fs_extra7.default.readdirSync(sqlDir).filter((f) => f.endsWith(".sql")).sort();
8973
- return files.map((f) => import_path12.default.join(sqlDir, f));
9627
+ return files.map((f) => import_path13.default.join(sqlDir, f));
8974
9628
  }
8975
9629
  async function saveWorker(workerJsPath, modulePaths, sqlFiles, metadata, projectName) {
8976
9630
  var _a2, _b;
@@ -8995,14 +9649,14 @@ async function saveWorker(workerJsPath, modulePaths, sqlFiles, metadata, project
8995
9649
  type: "application/javascript+module"
8996
9650
  }), "worker.js");
8997
9651
  for (const modulePath of modulePaths) {
8998
- const filename = import_path12.default.basename(modulePath);
9652
+ const filename = import_path13.default.basename(modulePath);
8999
9653
  const content = import_fs_extra7.default.readFileSync(modulePath, "utf-8");
9000
9654
  formData.append(filename, new Blob2([content], {
9001
9655
  type: "application/javascript+module"
9002
9656
  }), filename);
9003
9657
  }
9004
9658
  for (const sqlFile of sqlFiles) {
9005
- const filename = import_path12.default.basename(sqlFile);
9659
+ const filename = import_path13.default.basename(sqlFile);
9006
9660
  const content = import_fs_extra7.default.readFileSync(sqlFile, "utf-8");
9007
9661
  formData.append("sql_file", new Blob2([content], {
9008
9662
  type: "application/sql"
@@ -9041,7 +9695,7 @@ async function saveWorker(workerJsPath, modulePaths, sqlFiles, metadata, project
9041
9695
  function buildFrontend() {
9042
9696
  console.log(import_chalk21.default.blue("Building frontend..."));
9043
9697
  try {
9044
- (0, import_child_process4.execSync)("npm run build:frontend", {
9698
+ (0, import_child_process5.execSync)("npm run build:frontend", {
9045
9699
  cwd: PROJECT_DIR2,
9046
9700
  stdio: "inherit"
9047
9701
  });
@@ -9072,11 +9726,11 @@ async function deployFrontend(projectName) {
9072
9726
  console.log(import_chalk21.default.blue("Deploying frontend to IPFS..."));
9073
9727
  try {
9074
9728
  const headers = getAuthHeaders();
9075
- const uploadResult = await uploadPath(import_path12.default.join(PROJECT_DIR2, "frontend", "dist"), {
9729
+ const uploadResult = await uploadPath(import_path13.default.join(PROJECT_DIR2, "frontend", "dist"), {
9076
9730
  projectName,
9077
9731
  uid: headers["token-address"]
9078
9732
  });
9079
- updateFrontendUrlInConfig2(import_path12.default.join(PROJECT_DIR2, "pinme.toml"), uploadResult.publicUrl);
9733
+ updateFrontendUrlInConfig2(import_path13.default.join(PROJECT_DIR2, "pinme.toml"), uploadResult.publicUrl);
9080
9734
  return {
9081
9735
  contentHash: uploadResult.contentHash,
9082
9736
  publicUrl: uploadResult.publicUrl
@@ -9126,9 +9780,9 @@ async function saveCmd(options) {
9126
9780
  "Run `pinme login` and retry."
9127
9781
  ]);
9128
9782
  }
9129
- const projectDir = options.projectName || options.name ? import_path12.default.join(PROJECT_DIR2, options.projectName || options.name) : PROJECT_DIR2;
9130
- const tokenFileSrc = import_path12.default.join(PROJECT_DIR2, ".token.json");
9131
- const tokenFileDst = import_path12.default.join(projectDir, ".token.json");
9783
+ const projectDir = options.projectName || options.name ? import_path13.default.join(PROJECT_DIR2, options.projectName || options.name) : PROJECT_DIR2;
9784
+ const tokenFileSrc = import_path13.default.join(PROJECT_DIR2, ".token.json");
9785
+ const tokenFileDst = import_path13.default.join(projectDir, ".token.json");
9132
9786
  if (import_fs_extra7.default.existsSync(tokenFileSrc) && !import_fs_extra7.default.existsSync(tokenFileDst)) {
9133
9787
  import_fs_extra7.default.copySync(tokenFileSrc, tokenFileDst);
9134
9788
  }
@@ -9174,8 +9828,20 @@ async function saveCmd(options) {
9174
9828
  "management"
9175
9829
  );
9176
9830
  console.log(import_chalk21.default.green("\nDeployment complete."));
9831
+ void tracker_default.trackEvent(TRACK_EVENTS.projectSaveSuccess, TRACK_PAGES.deploy, {
9832
+ a: resolveTrackAction2(TRACK_EVENTS.projectSaveSuccess),
9833
+ project_name: projectName,
9834
+ has_domain: Boolean(options.domain),
9835
+ domain_type: options.domain ? isDnsDomain(options.domain) ? "dns" : "pinme_subdomain" : void 0
9836
+ });
9177
9837
  process.exit(0);
9178
9838
  } catch (error) {
9839
+ void tracker_default.trackEvent(TRACK_EVENTS.projectSaveFailed, TRACK_PAGES.deploy, {
9840
+ a: resolveTrackAction2(TRACK_EVENTS.projectSaveFailed),
9841
+ project_name: options.projectName || options.name,
9842
+ has_domain: Boolean(options.domain),
9843
+ reason: getTrackErrorReason(error)
9844
+ });
9179
9845
  printCliError(error, "Save failed.");
9180
9846
  process.exit(1);
9181
9847
  }
@@ -9184,14 +9850,14 @@ async function saveCmd(options) {
9184
9850
  // bin/updateDb.ts
9185
9851
  var import_chalk22 = __toESM(require("chalk"));
9186
9852
  var import_fs_extra8 = __toESM(require("fs-extra"));
9187
- var import_path13 = __toESM(require("path"));
9853
+ var import_path14 = __toESM(require("path"));
9188
9854
  init_axios2();
9189
9855
  init_webLogin();
9190
9856
  init_cliError();
9191
9857
  init_config();
9192
9858
  var PROJECT_DIR3 = process.cwd();
9193
9859
  function loadConfig2() {
9194
- const configPath = import_path13.default.join(PROJECT_DIR3, "pinme.toml");
9860
+ const configPath = import_path14.default.join(PROJECT_DIR3, "pinme.toml");
9195
9861
  if (!import_fs_extra8.default.existsSync(configPath)) {
9196
9862
  throw createConfigError("`pinme.toml` not found in the current directory.", [
9197
9863
  "Run this command from the Pinme project root."
@@ -9204,7 +9870,7 @@ function loadConfig2() {
9204
9870
  };
9205
9871
  }
9206
9872
  function getSqlFiles2() {
9207
- const sqlDir = import_path13.default.join(PROJECT_DIR3, "db");
9873
+ const sqlDir = import_path14.default.join(PROJECT_DIR3, "db");
9208
9874
  if (!import_fs_extra8.default.existsSync(sqlDir)) {
9209
9875
  throw createConfigError("SQL directory not found: `db/`.", [
9210
9876
  "Create a `db/` directory and add at least one `.sql` migration file."
@@ -9216,7 +9882,7 @@ function getSqlFiles2() {
9216
9882
  "Add one or more migration files before running `pinme update-db`."
9217
9883
  ]);
9218
9884
  }
9219
- return files.map((f) => import_path13.default.join(sqlDir, f));
9885
+ return files.map((f) => import_path14.default.join(sqlDir, f));
9220
9886
  }
9221
9887
  async function updateDb(sqlFiles, projectName) {
9222
9888
  console.log(import_chalk22.default.blue("Importing SQL files to database..."));
@@ -9231,7 +9897,7 @@ async function updateDb(sqlFiles, projectName) {
9231
9897
  const formData = new FormData4();
9232
9898
  let totalSize = 0;
9233
9899
  for (const sqlFile of sqlFiles) {
9234
- const filename = import_path13.default.basename(sqlFile);
9900
+ const filename = import_path14.default.basename(sqlFile);
9235
9901
  const content = import_fs_extra8.default.readFileSync(sqlFile);
9236
9902
  totalSize += content.length;
9237
9903
  if (totalSize > 10 * 1024 * 1024) {
@@ -9287,9 +9953,9 @@ async function updateDbCmd(options) {
9287
9953
  "Run `pinme login` and retry."
9288
9954
  ]);
9289
9955
  }
9290
- const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path13.default.join(PROJECT_DIR3, options.projectName || options.name) : PROJECT_DIR3;
9291
- const tokenFileSrc = import_path13.default.join(PROJECT_DIR3, ".token.json");
9292
- const tokenFileDst = import_path13.default.join(projectDir, ".token.json");
9956
+ const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path14.default.join(PROJECT_DIR3, options.projectName || options.name) : PROJECT_DIR3;
9957
+ const tokenFileSrc = import_path14.default.join(PROJECT_DIR3, ".token.json");
9958
+ const tokenFileDst = import_path14.default.join(projectDir, ".token.json");
9293
9959
  if (import_fs_extra8.default.existsSync(tokenFileSrc) && !import_fs_extra8.default.existsSync(tokenFileDst)) {
9294
9960
  import_fs_extra8.default.copySync(tokenFileSrc, tokenFileDst);
9295
9961
  }
@@ -9307,8 +9973,26 @@ async function updateDbCmd(options) {
9307
9973
  console.log(import_chalk22.default.gray(`Found ${sqlFiles.length} SQL file(s) in db`));
9308
9974
  await updateDb(sqlFiles, projectName);
9309
9975
  console.log(import_chalk22.default.green("\nDatabase update complete."));
9976
+ void tracker_default.trackEvent(
9977
+ TRACK_EVENTS.projectUpdateDbSuccess,
9978
+ TRACK_PAGES.deploy,
9979
+ {
9980
+ a: resolveTrackAction2(TRACK_EVENTS.projectUpdateDbSuccess),
9981
+ project_name: projectName,
9982
+ sql_file_count: sqlFiles.length
9983
+ }
9984
+ );
9310
9985
  process.exit(0);
9311
9986
  } catch (error) {
9987
+ void tracker_default.trackEvent(
9988
+ TRACK_EVENTS.projectUpdateDbFailed,
9989
+ TRACK_PAGES.deploy,
9990
+ {
9991
+ a: resolveTrackAction2(TRACK_EVENTS.projectUpdateDbFailed),
9992
+ project_name: (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name),
9993
+ reason: getTrackErrorReason(error)
9994
+ }
9995
+ );
9312
9996
  printCliError(error, "Database update failed.");
9313
9997
  process.exit(1);
9314
9998
  }
@@ -9317,15 +10001,15 @@ async function updateDbCmd(options) {
9317
10001
  // bin/updateWorker.ts
9318
10002
  var import_chalk23 = __toESM(require("chalk"));
9319
10003
  var import_fs_extra9 = __toESM(require("fs-extra"));
9320
- var import_path14 = __toESM(require("path"));
10004
+ var import_path15 = __toESM(require("path"));
9321
10005
  init_axios2();
9322
- var import_child_process5 = require("child_process");
10006
+ var import_child_process6 = require("child_process");
9323
10007
  init_webLogin();
9324
10008
  init_cliError();
9325
10009
  init_config();
9326
10010
  var PROJECT_DIR4 = process.cwd();
9327
10011
  function loadConfig3() {
9328
- const configPath = import_path14.default.join(PROJECT_DIR4, "pinme.toml");
10012
+ const configPath = import_path15.default.join(PROJECT_DIR4, "pinme.toml");
9329
10013
  if (!import_fs_extra9.default.existsSync(configPath)) {
9330
10014
  throw createConfigError("`pinme.toml` not found in the current directory.", [
9331
10015
  "Run this command from the Pinme project root."
@@ -9338,7 +10022,7 @@ function loadConfig3() {
9338
10022
  };
9339
10023
  }
9340
10024
  function getMetadata2() {
9341
- const metadataPath = import_path14.default.join(PROJECT_DIR4, "backend", "metadata.json");
10025
+ const metadataPath = import_path15.default.join(PROJECT_DIR4, "backend", "metadata.json");
9342
10026
  if (!import_fs_extra9.default.existsSync(metadataPath)) {
9343
10027
  throw createConfigError("`backend/metadata.json` not found.", [
9344
10028
  "Create `backend/metadata.json` or restore it from the project template."
@@ -9349,7 +10033,7 @@ function getMetadata2() {
9349
10033
  function buildWorker2() {
9350
10034
  console.log(import_chalk23.default.blue("Building worker..."));
9351
10035
  try {
9352
- (0, import_child_process5.execSync)("npm run build:worker", {
10036
+ (0, import_child_process6.execSync)("npm run build:worker", {
9353
10037
  cwd: PROJECT_DIR4,
9354
10038
  stdio: "inherit"
9355
10039
  });
@@ -9361,13 +10045,13 @@ function buildWorker2() {
9361
10045
  }
9362
10046
  }
9363
10047
  function getBuiltWorker2() {
9364
- const distWorkerDir = import_path14.default.join(PROJECT_DIR4, "dist-worker");
10048
+ const distWorkerDir = import_path15.default.join(PROJECT_DIR4, "dist-worker");
9365
10049
  if (!import_fs_extra9.default.existsSync(distWorkerDir)) {
9366
10050
  throw createConfigError("Built worker output not found: `dist-worker/`.", [
9367
10051
  "Make sure `npm run build:worker` completed successfully."
9368
10052
  ]);
9369
10053
  }
9370
- const workerJsPath = import_path14.default.join(distWorkerDir, "worker.js");
10054
+ const workerJsPath = import_path15.default.join(distWorkerDir, "worker.js");
9371
10055
  if (!import_fs_extra9.default.existsSync(workerJsPath)) {
9372
10056
  throw createConfigError("Built worker entry file not found: `dist-worker/worker.js`.", [
9373
10057
  "Check the worker build output and bundler config."
@@ -9377,7 +10061,7 @@ function getBuiltWorker2() {
9377
10061
  const files = import_fs_extra9.default.readdirSync(distWorkerDir);
9378
10062
  for (const file of files) {
9379
10063
  if (file.endsWith(".js") && file !== "worker.js") {
9380
- modulePaths.push(import_path14.default.join(distWorkerDir, file));
10064
+ modulePaths.push(import_path15.default.join(distWorkerDir, file));
9381
10065
  }
9382
10066
  }
9383
10067
  return { workerJsPath, modulePaths };
@@ -9403,7 +10087,7 @@ async function updateWorker(workerJsPath, modulePaths, metadata, projectName) {
9403
10087
  type: "application/javascript+module"
9404
10088
  }), "worker.js");
9405
10089
  for (const modulePath of modulePaths) {
9406
- const filename = import_path14.default.basename(modulePath);
10090
+ const filename = import_path15.default.basename(modulePath);
9407
10091
  const content = import_fs_extra9.default.readFileSync(modulePath, "utf-8");
9408
10092
  formData.append(filename, new Blob2([content], {
9409
10093
  type: "application/javascript+module"
@@ -9466,9 +10150,9 @@ async function updateWorkerCmd(options) {
9466
10150
  "Run `pinme login` and retry."
9467
10151
  ]);
9468
10152
  }
9469
- const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path14.default.join(PROJECT_DIR4, options.projectName || options.name) : PROJECT_DIR4;
9470
- const tokenFileSrc = import_path14.default.join(PROJECT_DIR4, ".token.json");
9471
- const tokenFileDst = import_path14.default.join(projectDir, ".token.json");
10153
+ const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path15.default.join(PROJECT_DIR4, options.projectName || options.name) : PROJECT_DIR4;
10154
+ const tokenFileSrc = import_path15.default.join(PROJECT_DIR4, ".token.json");
10155
+ const tokenFileDst = import_path15.default.join(projectDir, ".token.json");
9472
10156
  if (import_fs_extra9.default.existsSync(tokenFileSrc) && !import_fs_extra9.default.existsSync(tokenFileDst)) {
9473
10157
  import_fs_extra9.default.copySync(tokenFileSrc, tokenFileDst);
9474
10158
  }
@@ -9491,8 +10175,26 @@ async function updateWorkerCmd(options) {
9491
10175
  console.log(import_chalk23.default.gray(`SQL files: ignored (not processed for update_worker)`));
9492
10176
  await updateWorker(workerJsPath, modulePaths, metadata, projectName);
9493
10177
  console.log(import_chalk23.default.green("\nWorker update complete."));
10178
+ void tracker_default.trackEvent(
10179
+ TRACK_EVENTS.projectUpdateWorkerSuccess,
10180
+ TRACK_PAGES.deploy,
10181
+ {
10182
+ a: resolveTrackAction2(TRACK_EVENTS.projectUpdateWorkerSuccess),
10183
+ project_name: projectName,
10184
+ module_count: modulePaths.length
10185
+ }
10186
+ );
9494
10187
  process.exit(0);
9495
10188
  } catch (error) {
10189
+ void tracker_default.trackEvent(
10190
+ TRACK_EVENTS.projectUpdateWorkerFailed,
10191
+ TRACK_PAGES.deploy,
10192
+ {
10193
+ a: resolveTrackAction2(TRACK_EVENTS.projectUpdateWorkerFailed),
10194
+ project_name: (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name),
10195
+ reason: getTrackErrorReason(error)
10196
+ }
10197
+ );
9496
10198
  printCliError(error, "Worker update failed.");
9497
10199
  process.exit(1);
9498
10200
  }
@@ -9501,14 +10203,14 @@ async function updateWorkerCmd(options) {
9501
10203
  // bin/updateWeb.ts
9502
10204
  var import_chalk24 = __toESM(require("chalk"));
9503
10205
  var import_fs_extra10 = __toESM(require("fs-extra"));
9504
- var import_path15 = __toESM(require("path"));
9505
- var import_child_process6 = require("child_process");
10206
+ var import_path16 = __toESM(require("path"));
10207
+ var import_child_process7 = require("child_process");
9506
10208
  init_webLogin();
9507
10209
  init_cliError();
9508
10210
  init_config();
9509
10211
  var PROJECT_DIR5 = process.cwd();
9510
10212
  function loadConfig4() {
9511
- const configPath = import_path15.default.join(PROJECT_DIR5, "pinme.toml");
10213
+ const configPath = import_path16.default.join(PROJECT_DIR5, "pinme.toml");
9512
10214
  if (!import_fs_extra10.default.existsSync(configPath)) {
9513
10215
  throw createConfigError("`pinme.toml` not found in the current directory.", [
9514
10216
  "Run this command from the Pinme project root."
@@ -9526,7 +10228,7 @@ function getProjectManagementUrl3(projectName) {
9526
10228
  function buildFrontend2() {
9527
10229
  console.log(import_chalk24.default.blue("Building frontend..."));
9528
10230
  try {
9529
- (0, import_child_process6.execSync)("npm run build:frontend", {
10231
+ (0, import_child_process7.execSync)("npm run build:frontend", {
9530
10232
  cwd: PROJECT_DIR5,
9531
10233
  stdio: "inherit"
9532
10234
  });
@@ -9541,7 +10243,7 @@ async function deployFrontend2(projectName) {
9541
10243
  console.log(import_chalk24.default.blue("Deploying frontend to IPFS..."));
9542
10244
  try {
9543
10245
  const headers = getAuthHeaders();
9544
- const uploadResult = await uploadPath(import_path15.default.join(PROJECT_DIR5, "frontend", "dist"), {
10246
+ const uploadResult = await uploadPath(import_path16.default.join(PROJECT_DIR5, "frontend", "dist"), {
9545
10247
  projectName,
9546
10248
  uid: headers["token-address"]
9547
10249
  });
@@ -9565,9 +10267,9 @@ async function updateWebCmd(options) {
9565
10267
  "Run `pinme login` and retry."
9566
10268
  ]);
9567
10269
  }
9568
- const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path15.default.join(PROJECT_DIR5, options.projectName || options.name) : PROJECT_DIR5;
9569
- const tokenFileSrc = import_path15.default.join(PROJECT_DIR5, ".token.json");
9570
- const tokenFileDst = import_path15.default.join(projectDir, ".token.json");
10270
+ const projectDir = (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name) ? import_path16.default.join(PROJECT_DIR5, options.projectName || options.name) : PROJECT_DIR5;
10271
+ const tokenFileSrc = import_path16.default.join(PROJECT_DIR5, ".token.json");
10272
+ const tokenFileDst = import_path16.default.join(projectDir, ".token.json");
9571
10273
  if (import_fs_extra10.default.existsSync(tokenFileSrc) && !import_fs_extra10.default.existsSync(tokenFileDst)) {
9572
10274
  import_fs_extra10.default.copySync(tokenFileSrc, tokenFileDst);
9573
10275
  }
@@ -9585,8 +10287,25 @@ async function updateWebCmd(options) {
9585
10287
  buildFrontend2();
9586
10288
  await deployFrontend2(projectName);
9587
10289
  console.log(import_chalk24.default.green("\nWeb update complete."));
10290
+ void tracker_default.trackEvent(
10291
+ TRACK_EVENTS.projectUpdateWebSuccess,
10292
+ TRACK_PAGES.deploy,
10293
+ {
10294
+ a: resolveTrackAction2(TRACK_EVENTS.projectUpdateWebSuccess),
10295
+ project_name: projectName
10296
+ }
10297
+ );
9588
10298
  process.exit(0);
9589
10299
  } catch (error) {
10300
+ void tracker_default.trackEvent(
10301
+ TRACK_EVENTS.projectUpdateWebFailed,
10302
+ TRACK_PAGES.deploy,
10303
+ {
10304
+ a: resolveTrackAction2(TRACK_EVENTS.projectUpdateWebFailed),
10305
+ project_name: (options == null ? void 0 : options.projectName) || (options == null ? void 0 : options.name),
10306
+ reason: getTrackErrorReason(error)
10307
+ }
10308
+ );
9590
10309
  printCliError(error, "Web update failed.");
9591
10310
  process.exit(1);
9592
10311
  }
@@ -9597,11 +10316,11 @@ var import_chalk25 = __toESM(require("chalk"));
9597
10316
  var import_inquirer9 = __toESM(require("inquirer"));
9598
10317
  init_axios2();
9599
10318
  var import_fs_extra11 = __toESM(require("fs-extra"));
9600
- var import_path16 = __toESM(require("path"));
10319
+ var import_path17 = __toESM(require("path"));
9601
10320
  init_webLogin();
9602
10321
  init_config();
9603
10322
  function getProjectName() {
9604
- const configPath = import_path16.default.join(process.cwd(), "pinme.toml");
10323
+ const configPath = import_path17.default.join(process.cwd(), "pinme.toml");
9605
10324
  if (!import_fs_extra11.default.existsSync(configPath)) {
9606
10325
  return null;
9607
10326
  }
@@ -9668,6 +10387,17 @@ async function deleteCmd(options) {
9668
10387
  });
9669
10388
  const data = response.data;
9670
10389
  if (data.code === 200) {
10390
+ void tracker_default.trackEvent(
10391
+ TRACK_EVENTS.projectDeleteSuccess,
10392
+ TRACK_PAGES.project,
10393
+ {
10394
+ a: resolveTrackAction2(TRACK_EVENTS.projectDeleteSuccess),
10395
+ project_name: data.data.project_name,
10396
+ domain_deleted: Boolean(data.data.domain_deleted),
10397
+ worker_deleted: Boolean(data.data.worker_deleted),
10398
+ database_deleted: Boolean(data.data.database_deleted)
10399
+ }
10400
+ );
9671
10401
  console.log(import_chalk25.default.green("\n\u2705 Project deleted successfully!"));
9672
10402
  console.log(import_chalk25.default.gray(`
9673
10403
  Project: ${data.data.project_name}`));
@@ -9681,6 +10411,16 @@ Project: ${data.data.project_name}`));
9681
10411
  }
9682
10412
  process.exit(0);
9683
10413
  } catch (error) {
10414
+ void tracker_default.trackEvent(
10415
+ TRACK_EVENTS.projectDeleteFailed,
10416
+ TRACK_PAGES.project,
10417
+ {
10418
+ a: resolveTrackAction2(TRACK_EVENTS.projectDeleteFailed),
10419
+ project_name: options.name || getProjectName() || void 0,
10420
+ force: Boolean(options.force),
10421
+ reason: getTrackErrorReason(error)
10422
+ }
10423
+ );
9684
10424
  console.log(import_chalk25.default.red(error));
9685
10425
  const errorMsg = ((_b = (_a2 = error.response) == null ? void 0 : _a2.data) == null ? void 0 : _b.msg) || error.message || "Failed to delete project";
9686
10426
  console.error(import_chalk25.default.red(`