@zapier/zapier-sdk-cli 0.13.2 → 0.13.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @zapier/zapier-sdk-cli
2
2
 
3
+ ## 0.13.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 80732ea: Add basic event-driven telemetry for key lifecycle events and CLI logins
8
+ - Updated dependencies [80732ea]
9
+ - @zapier/zapier-sdk@0.13.4
10
+ - @zapier/zapier-sdk-mcp@0.3.17
11
+
12
+ ## 0.13.3
13
+
14
+ ### Patch Changes
15
+
16
+ - 53fa85e: Show id and key properties when listing actions. Allow getAction to use an id or key. Make runAction pass action_id to API to ensure it always works.
17
+ - Updated dependencies [53fa85e]
18
+ - @zapier/zapier-sdk@0.13.3
19
+ - @zapier/zapier-sdk-mcp@0.3.16
20
+
3
21
  ## 0.13.2
4
22
 
5
23
  ### Patch Changes
package/dist/cli.cjs CHANGED
@@ -626,12 +626,18 @@ function formatItemsFromSchema(functionInfo, items, startingNumber = 0) {
626
626
  }
627
627
  function formatSingleItem(formatted, itemNumber) {
628
628
  let titleLine = `${chalk3__default.default.gray(`${itemNumber + 1}.`)} ${chalk3__default.default.cyan(formatted.title)}`;
629
- if (formatted.id) {
630
- titleLine += ` ${chalk3__default.default.gray(`(ID: ${formatted.id})`)}`;
631
- } else if (formatted.keys) {
632
- titleLine += ` ${chalk3__default.default.gray(`(${formatted.keys.join(", ")})`)}`;
629
+ const subtitleParts = [];
630
+ if (formatted.keys) {
631
+ subtitleParts.push(...formatted.keys);
633
632
  } else if (formatted.key) {
634
- titleLine += ` ${chalk3__default.default.gray(`(${formatted.key})`)}`;
633
+ subtitleParts.push(formatted.key);
634
+ }
635
+ if (formatted.id) {
636
+ subtitleParts.push(formatted.id);
637
+ }
638
+ const uniqueParts = [...new Set(subtitleParts)];
639
+ if (uniqueParts.length > 0) {
640
+ titleLine += ` ${chalk3__default.default.gray(`(${uniqueParts.join(", ")})`)}`;
635
641
  }
636
642
  console.log(titleLine);
637
643
  if (formatted.description) {
@@ -1399,7 +1405,66 @@ var LoginSchema = zod.z.object({
1399
1405
  timeout: zod.z.string().optional().describe("Login timeout in seconds (default: 300)")
1400
1406
  }).describe("Log in to Zapier to access your account");
1401
1407
 
1408
+ // package.json
1409
+ var package_default = {
1410
+ version: "0.13.4"};
1411
+
1412
+ // src/telemetry/builders.ts
1413
+ function createCliBaseEvent(context = {}) {
1414
+ return {
1415
+ event_id: zapierSdk.generateEventId(),
1416
+ timestamp_ms: zapierSdk.getCurrentTimestamp(),
1417
+ release_id: zapierSdk.getReleaseId(),
1418
+ customuser_id: context.customuser_id ?? null,
1419
+ account_id: context.account_id ?? null,
1420
+ identity_id: context.identity_id ?? null,
1421
+ visitor_id: context.visitor_id ?? null,
1422
+ correlation_id: context.correlation_id ?? null
1423
+ };
1424
+ }
1425
+ function buildCliCommandExecutedEvent({
1426
+ data,
1427
+ context = {},
1428
+ cliVersion = package_default.version
1429
+ }) {
1430
+ const osInfo = zapierSdk.getOsInfo();
1431
+ const platformVersions = zapierSdk.getPlatformVersions();
1432
+ return {
1433
+ ...createCliBaseEvent(context),
1434
+ system_name: "zapier-sdk-cli",
1435
+ session_id: context.session_id ?? null,
1436
+ cli_version: data.cli_version ?? cliVersion,
1437
+ cli_arguments: data.cli_arguments ?? null,
1438
+ cli_primary_command: data.cli_primary_command,
1439
+ os_platform: osInfo.platform,
1440
+ os_release: osInfo.release,
1441
+ os_architecture: osInfo.architecture,
1442
+ platform_versions: platformVersions,
1443
+ selected_api: context.selected_api ?? null,
1444
+ app_id: context.app_id ?? null,
1445
+ app_version_id: context.app_version_id ?? null,
1446
+ execution_duration_ms: data.execution_duration_ms ?? null,
1447
+ success_flag: data.success_flag,
1448
+ exit_code: data.exit_code ?? (data.success_flag ? 0 : 1),
1449
+ error_message: data.error_message ?? null,
1450
+ command_category: data.command_category ?? null,
1451
+ requires_auth: data.requires_auth ?? null,
1452
+ is_ci_environment: zapierSdk.isCi(),
1453
+ ci_platform: zapierSdk.getCiPlatform(),
1454
+ package_manager: data.package_manager ?? "pnpm",
1455
+ // Default based on project setup
1456
+ made_network_requests: data.made_network_requests ?? null,
1457
+ files_modified_count: data.files_modified_count ?? null,
1458
+ files_created_count: data.files_created_count ?? null,
1459
+ files_processed_size_bytes: data.files_processed_size_bytes ?? null,
1460
+ peak_memory_usage_bytes: data.peak_memory_usage_bytes ?? null,
1461
+ cpu_time_ms: data.cpu_time_ms ?? null,
1462
+ subprocess_count: data.subprocess_count ?? null
1463
+ };
1464
+ }
1465
+
1402
1466
  // src/plugins/login/index.ts
1467
+ var CLI_COMMAND_EXECUTED_EVENT_SUBJECT = "platform.sdk.CliCommandExecutedEvent";
1403
1468
  var loginWithSdk = zapierSdk.createFunction(async function loginWithSdk2(options) {
1404
1469
  const timeoutSeconds = options.timeout ? parseInt(options.timeout, 10) : 300;
1405
1470
  if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
@@ -1410,17 +1475,56 @@ var loginWithSdk = zapierSdk.createFunction(async function loginWithSdk2(options
1410
1475
  console.log(`\u2705 Successfully logged in as ${user.email}`);
1411
1476
  setTimeout(() => process.exit(0), 100);
1412
1477
  }, LoginSchema);
1413
- var loginPlugin = () => ({
1414
- login: loginWithSdk,
1415
- context: {
1416
- meta: {
1417
- login: {
1418
- categories: ["account"],
1419
- inputSchema: LoginSchema
1478
+ var loginPlugin = ({ context }) => {
1479
+ const loginWithTelemetry = async (options) => {
1480
+ const startTime = Date.now();
1481
+ let success = false;
1482
+ let errorMessage = null;
1483
+ try {
1484
+ await loginWithSdk(options);
1485
+ success = true;
1486
+ } catch (error) {
1487
+ success = false;
1488
+ errorMessage = error instanceof Error ? error.message : "Login failed";
1489
+ throw error;
1490
+ } finally {
1491
+ const event = buildCliCommandExecutedEvent({
1492
+ data: {
1493
+ cli_primary_command: "login",
1494
+ success_flag: success,
1495
+ execution_duration_ms: Date.now() - startTime,
1496
+ exit_code: success ? 0 : 1,
1497
+ error_message: errorMessage,
1498
+ command_category: "authentication",
1499
+ requires_auth: false,
1500
+ cli_arguments: [
1501
+ "login",
1502
+ options.timeout ? `--timeout=${options.timeout}` : null
1503
+ ].filter(Boolean)
1504
+ },
1505
+ context: {
1506
+ session_id: context.session_id,
1507
+ selected_api: context.selected_api,
1508
+ app_id: context.app_id,
1509
+ app_version_id: context.app_version_id
1510
+ },
1511
+ cliVersion: package_default.version
1512
+ });
1513
+ context.eventEmission.emit(CLI_COMMAND_EXECUTED_EVENT_SUBJECT, event);
1514
+ }
1515
+ };
1516
+ return {
1517
+ login: loginWithTelemetry,
1518
+ context: {
1519
+ meta: {
1520
+ login: {
1521
+ categories: ["account"],
1522
+ inputSchema: LoginSchema
1523
+ }
1420
1524
  }
1421
1525
  }
1422
- }
1423
- });
1526
+ };
1527
+ };
1424
1528
  var LogoutSchema = zod.z.object({}).describe("Log out of your Zapier account");
1425
1529
 
1426
1530
  // src/plugins/logout/index.ts
@@ -2275,7 +2379,8 @@ var addPlugin = ({ sdk: sdk2, context }) => {
2275
2379
  // src/sdk.ts
2276
2380
  function createZapierCliSdk(options = {}) {
2277
2381
  let sdk2 = zapierSdk.createZapierSdkWithoutRegistry({
2278
- debug: options.debug
2382
+ debug: options.debug,
2383
+ eventEmission: options.eventEmission
2279
2384
  });
2280
2385
  sdk2 = sdk2.addPlugin(bundleCodePlugin);
2281
2386
  sdk2 = sdk2.addPlugin(getLoginConfigPathPlugin);
@@ -2287,13 +2392,13 @@ function createZapierCliSdk(options = {}) {
2287
2392
  return finalSdk;
2288
2393
  }
2289
2394
 
2290
- // package.json
2291
- var package_default = {
2292
- version: "0.13.2"};
2395
+ // package.json with { type: 'json' }
2396
+ var package_default2 = {
2397
+ version: "0.13.4"};
2293
2398
 
2294
2399
  // src/cli.ts
2295
2400
  var program = new commander.Command();
2296
- program.name("zapier-sdk").description("CLI for Zapier SDK").version(package_default.version, "-v, --version", "display version number").option("--debug", "Enable debug logging");
2401
+ program.name("zapier-sdk").description("CLI for Zapier SDK").version(package_default2.version, "-v, --version", "display version number").option("--debug", "Enable debug logging");
2297
2402
  var isDebugMode = process.env.DEBUG === "true" || process.argv.includes("--debug");
2298
2403
  var sdk = createZapierCliSdk({
2299
2404
  debug: isDebugMode
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from 'commander';
3
3
  import { z } from 'zod';
4
- import { createFunction, OutputPropertySchema, DEFAULT_CONFIG_PATH, createZapierSdkWithoutRegistry, registryPlugin, toSnakeCase, ZapierError, formatErrorMessage, isPositional } from '@zapier/zapier-sdk';
4
+ import { createFunction, OutputPropertySchema, DEFAULT_CONFIG_PATH, createZapierSdkWithoutRegistry, registryPlugin, toSnakeCase, ZapierError, formatErrorMessage, getOsInfo, getPlatformVersions, getCiPlatform, isCi, isPositional, getReleaseId, getCurrentTimestamp, generateEventId } from '@zapier/zapier-sdk';
5
5
  import inquirer from 'inquirer';
6
6
  import chalk3 from 'chalk';
7
7
  import util from 'util';
@@ -593,12 +593,18 @@ function formatItemsFromSchema(functionInfo, items, startingNumber = 0) {
593
593
  }
594
594
  function formatSingleItem(formatted, itemNumber) {
595
595
  let titleLine = `${chalk3.gray(`${itemNumber + 1}.`)} ${chalk3.cyan(formatted.title)}`;
596
- if (formatted.id) {
597
- titleLine += ` ${chalk3.gray(`(ID: ${formatted.id})`)}`;
598
- } else if (formatted.keys) {
599
- titleLine += ` ${chalk3.gray(`(${formatted.keys.join(", ")})`)}`;
596
+ const subtitleParts = [];
597
+ if (formatted.keys) {
598
+ subtitleParts.push(...formatted.keys);
600
599
  } else if (formatted.key) {
601
- titleLine += ` ${chalk3.gray(`(${formatted.key})`)}`;
600
+ subtitleParts.push(formatted.key);
601
+ }
602
+ if (formatted.id) {
603
+ subtitleParts.push(formatted.id);
604
+ }
605
+ const uniqueParts = [...new Set(subtitleParts)];
606
+ if (uniqueParts.length > 0) {
607
+ titleLine += ` ${chalk3.gray(`(${uniqueParts.join(", ")})`)}`;
602
608
  }
603
609
  console.log(titleLine);
604
610
  if (formatted.description) {
@@ -1366,7 +1372,66 @@ var LoginSchema = z.object({
1366
1372
  timeout: z.string().optional().describe("Login timeout in seconds (default: 300)")
1367
1373
  }).describe("Log in to Zapier to access your account");
1368
1374
 
1375
+ // package.json
1376
+ var package_default = {
1377
+ version: "0.13.4"};
1378
+
1379
+ // src/telemetry/builders.ts
1380
+ function createCliBaseEvent(context = {}) {
1381
+ return {
1382
+ event_id: generateEventId(),
1383
+ timestamp_ms: getCurrentTimestamp(),
1384
+ release_id: getReleaseId(),
1385
+ customuser_id: context.customuser_id ?? null,
1386
+ account_id: context.account_id ?? null,
1387
+ identity_id: context.identity_id ?? null,
1388
+ visitor_id: context.visitor_id ?? null,
1389
+ correlation_id: context.correlation_id ?? null
1390
+ };
1391
+ }
1392
+ function buildCliCommandExecutedEvent({
1393
+ data,
1394
+ context = {},
1395
+ cliVersion = package_default.version
1396
+ }) {
1397
+ const osInfo = getOsInfo();
1398
+ const platformVersions = getPlatformVersions();
1399
+ return {
1400
+ ...createCliBaseEvent(context),
1401
+ system_name: "zapier-sdk-cli",
1402
+ session_id: context.session_id ?? null,
1403
+ cli_version: data.cli_version ?? cliVersion,
1404
+ cli_arguments: data.cli_arguments ?? null,
1405
+ cli_primary_command: data.cli_primary_command,
1406
+ os_platform: osInfo.platform,
1407
+ os_release: osInfo.release,
1408
+ os_architecture: osInfo.architecture,
1409
+ platform_versions: platformVersions,
1410
+ selected_api: context.selected_api ?? null,
1411
+ app_id: context.app_id ?? null,
1412
+ app_version_id: context.app_version_id ?? null,
1413
+ execution_duration_ms: data.execution_duration_ms ?? null,
1414
+ success_flag: data.success_flag,
1415
+ exit_code: data.exit_code ?? (data.success_flag ? 0 : 1),
1416
+ error_message: data.error_message ?? null,
1417
+ command_category: data.command_category ?? null,
1418
+ requires_auth: data.requires_auth ?? null,
1419
+ is_ci_environment: isCi(),
1420
+ ci_platform: getCiPlatform(),
1421
+ package_manager: data.package_manager ?? "pnpm",
1422
+ // Default based on project setup
1423
+ made_network_requests: data.made_network_requests ?? null,
1424
+ files_modified_count: data.files_modified_count ?? null,
1425
+ files_created_count: data.files_created_count ?? null,
1426
+ files_processed_size_bytes: data.files_processed_size_bytes ?? null,
1427
+ peak_memory_usage_bytes: data.peak_memory_usage_bytes ?? null,
1428
+ cpu_time_ms: data.cpu_time_ms ?? null,
1429
+ subprocess_count: data.subprocess_count ?? null
1430
+ };
1431
+ }
1432
+
1369
1433
  // src/plugins/login/index.ts
1434
+ var CLI_COMMAND_EXECUTED_EVENT_SUBJECT = "platform.sdk.CliCommandExecutedEvent";
1370
1435
  var loginWithSdk = createFunction(async function loginWithSdk2(options) {
1371
1436
  const timeoutSeconds = options.timeout ? parseInt(options.timeout, 10) : 300;
1372
1437
  if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
@@ -1377,17 +1442,56 @@ var loginWithSdk = createFunction(async function loginWithSdk2(options) {
1377
1442
  console.log(`\u2705 Successfully logged in as ${user.email}`);
1378
1443
  setTimeout(() => process.exit(0), 100);
1379
1444
  }, LoginSchema);
1380
- var loginPlugin = () => ({
1381
- login: loginWithSdk,
1382
- context: {
1383
- meta: {
1384
- login: {
1385
- categories: ["account"],
1386
- inputSchema: LoginSchema
1445
+ var loginPlugin = ({ context }) => {
1446
+ const loginWithTelemetry = async (options) => {
1447
+ const startTime = Date.now();
1448
+ let success = false;
1449
+ let errorMessage = null;
1450
+ try {
1451
+ await loginWithSdk(options);
1452
+ success = true;
1453
+ } catch (error) {
1454
+ success = false;
1455
+ errorMessage = error instanceof Error ? error.message : "Login failed";
1456
+ throw error;
1457
+ } finally {
1458
+ const event = buildCliCommandExecutedEvent({
1459
+ data: {
1460
+ cli_primary_command: "login",
1461
+ success_flag: success,
1462
+ execution_duration_ms: Date.now() - startTime,
1463
+ exit_code: success ? 0 : 1,
1464
+ error_message: errorMessage,
1465
+ command_category: "authentication",
1466
+ requires_auth: false,
1467
+ cli_arguments: [
1468
+ "login",
1469
+ options.timeout ? `--timeout=${options.timeout}` : null
1470
+ ].filter(Boolean)
1471
+ },
1472
+ context: {
1473
+ session_id: context.session_id,
1474
+ selected_api: context.selected_api,
1475
+ app_id: context.app_id,
1476
+ app_version_id: context.app_version_id
1477
+ },
1478
+ cliVersion: package_default.version
1479
+ });
1480
+ context.eventEmission.emit(CLI_COMMAND_EXECUTED_EVENT_SUBJECT, event);
1481
+ }
1482
+ };
1483
+ return {
1484
+ login: loginWithTelemetry,
1485
+ context: {
1486
+ meta: {
1487
+ login: {
1488
+ categories: ["account"],
1489
+ inputSchema: LoginSchema
1490
+ }
1387
1491
  }
1388
1492
  }
1389
- }
1390
- });
1493
+ };
1494
+ };
1391
1495
  var LogoutSchema = z.object({}).describe("Log out of your Zapier account");
1392
1496
 
1393
1497
  // src/plugins/logout/index.ts
@@ -2242,7 +2346,8 @@ var addPlugin = ({ sdk: sdk2, context }) => {
2242
2346
  // src/sdk.ts
2243
2347
  function createZapierCliSdk(options = {}) {
2244
2348
  let sdk2 = createZapierSdkWithoutRegistry({
2245
- debug: options.debug
2349
+ debug: options.debug,
2350
+ eventEmission: options.eventEmission
2246
2351
  });
2247
2352
  sdk2 = sdk2.addPlugin(bundleCodePlugin);
2248
2353
  sdk2 = sdk2.addPlugin(getLoginConfigPathPlugin);
@@ -2254,13 +2359,13 @@ function createZapierCliSdk(options = {}) {
2254
2359
  return finalSdk;
2255
2360
  }
2256
2361
 
2257
- // package.json
2258
- var package_default = {
2259
- version: "0.13.2"};
2362
+ // package.json with { type: 'json' }
2363
+ var package_default2 = {
2364
+ version: "0.13.4"};
2260
2365
 
2261
2366
  // src/cli.ts
2262
2367
  var program = new Command();
2263
- program.name("zapier-sdk").description("CLI for Zapier SDK").version(package_default.version, "-v, --version", "display version number").option("--debug", "Enable debug logging");
2368
+ program.name("zapier-sdk").description("CLI for Zapier SDK").version(package_default2.version, "-v, --version", "display version number").option("--debug", "Enable debug logging");
2264
2369
  var isDebugMode = process.env.DEBUG === "true" || process.argv.includes("--debug");
2265
2370
  var sdk = createZapierCliSdk({
2266
2371
  debug: isDebugMode
package/dist/index.cjs CHANGED
@@ -261,7 +261,66 @@ var LoginSchema = zod.z.object({
261
261
  timeout: zod.z.string().optional().describe("Login timeout in seconds (default: 300)")
262
262
  }).describe("Log in to Zapier to access your account");
263
263
 
264
+ // package.json
265
+ var package_default = {
266
+ version: "0.13.4"};
267
+
268
+ // src/telemetry/builders.ts
269
+ function createCliBaseEvent(context = {}) {
270
+ return {
271
+ event_id: zapierSdk.generateEventId(),
272
+ timestamp_ms: zapierSdk.getCurrentTimestamp(),
273
+ release_id: zapierSdk.getReleaseId(),
274
+ customuser_id: context.customuser_id ?? null,
275
+ account_id: context.account_id ?? null,
276
+ identity_id: context.identity_id ?? null,
277
+ visitor_id: context.visitor_id ?? null,
278
+ correlation_id: context.correlation_id ?? null
279
+ };
280
+ }
281
+ function buildCliCommandExecutedEvent({
282
+ data,
283
+ context = {},
284
+ cliVersion = package_default.version
285
+ }) {
286
+ const osInfo = zapierSdk.getOsInfo();
287
+ const platformVersions = zapierSdk.getPlatformVersions();
288
+ return {
289
+ ...createCliBaseEvent(context),
290
+ system_name: "zapier-sdk-cli",
291
+ session_id: context.session_id ?? null,
292
+ cli_version: data.cli_version ?? cliVersion,
293
+ cli_arguments: data.cli_arguments ?? null,
294
+ cli_primary_command: data.cli_primary_command,
295
+ os_platform: osInfo.platform,
296
+ os_release: osInfo.release,
297
+ os_architecture: osInfo.architecture,
298
+ platform_versions: platformVersions,
299
+ selected_api: context.selected_api ?? null,
300
+ app_id: context.app_id ?? null,
301
+ app_version_id: context.app_version_id ?? null,
302
+ execution_duration_ms: data.execution_duration_ms ?? null,
303
+ success_flag: data.success_flag,
304
+ exit_code: data.exit_code ?? (data.success_flag ? 0 : 1),
305
+ error_message: data.error_message ?? null,
306
+ command_category: data.command_category ?? null,
307
+ requires_auth: data.requires_auth ?? null,
308
+ is_ci_environment: zapierSdk.isCi(),
309
+ ci_platform: zapierSdk.getCiPlatform(),
310
+ package_manager: data.package_manager ?? "pnpm",
311
+ // Default based on project setup
312
+ made_network_requests: data.made_network_requests ?? null,
313
+ files_modified_count: data.files_modified_count ?? null,
314
+ files_created_count: data.files_created_count ?? null,
315
+ files_processed_size_bytes: data.files_processed_size_bytes ?? null,
316
+ peak_memory_usage_bytes: data.peak_memory_usage_bytes ?? null,
317
+ cpu_time_ms: data.cpu_time_ms ?? null,
318
+ subprocess_count: data.subprocess_count ?? null
319
+ };
320
+ }
321
+
264
322
  // src/plugins/login/index.ts
323
+ var CLI_COMMAND_EXECUTED_EVENT_SUBJECT = "platform.sdk.CliCommandExecutedEvent";
265
324
  var loginWithSdk = zapierSdk.createFunction(async function loginWithSdk2(options) {
266
325
  const timeoutSeconds = options.timeout ? parseInt(options.timeout, 10) : 300;
267
326
  if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
@@ -272,17 +331,56 @@ var loginWithSdk = zapierSdk.createFunction(async function loginWithSdk2(options
272
331
  console.log(`\u2705 Successfully logged in as ${user.email}`);
273
332
  setTimeout(() => process.exit(0), 100);
274
333
  }, LoginSchema);
275
- var loginPlugin = () => ({
276
- login: loginWithSdk,
277
- context: {
278
- meta: {
279
- login: {
280
- categories: ["account"],
281
- inputSchema: LoginSchema
334
+ var loginPlugin = ({ context }) => {
335
+ const loginWithTelemetry = async (options) => {
336
+ const startTime = Date.now();
337
+ let success = false;
338
+ let errorMessage = null;
339
+ try {
340
+ await loginWithSdk(options);
341
+ success = true;
342
+ } catch (error) {
343
+ success = false;
344
+ errorMessage = error instanceof Error ? error.message : "Login failed";
345
+ throw error;
346
+ } finally {
347
+ const event = buildCliCommandExecutedEvent({
348
+ data: {
349
+ cli_primary_command: "login",
350
+ success_flag: success,
351
+ execution_duration_ms: Date.now() - startTime,
352
+ exit_code: success ? 0 : 1,
353
+ error_message: errorMessage,
354
+ command_category: "authentication",
355
+ requires_auth: false,
356
+ cli_arguments: [
357
+ "login",
358
+ options.timeout ? `--timeout=${options.timeout}` : null
359
+ ].filter(Boolean)
360
+ },
361
+ context: {
362
+ session_id: context.session_id,
363
+ selected_api: context.selected_api,
364
+ app_id: context.app_id,
365
+ app_version_id: context.app_version_id
366
+ },
367
+ cliVersion: package_default.version
368
+ });
369
+ context.eventEmission.emit(CLI_COMMAND_EXECUTED_EVENT_SUBJECT, event);
370
+ }
371
+ };
372
+ return {
373
+ login: loginWithTelemetry,
374
+ context: {
375
+ meta: {
376
+ login: {
377
+ categories: ["account"],
378
+ inputSchema: LoginSchema
379
+ }
282
380
  }
283
381
  }
284
- }
285
- });
382
+ };
383
+ };
286
384
  var LogoutSchema = zod.z.object({}).describe("Log out of your Zapier account");
287
385
 
288
386
  // src/plugins/logout/index.ts
@@ -1137,7 +1235,8 @@ var addPlugin = ({ sdk, context }) => {
1137
1235
  // src/sdk.ts
1138
1236
  function createZapierCliSdk(options = {}) {
1139
1237
  let sdk = zapierSdk.createZapierSdkWithoutRegistry({
1140
- debug: options.debug
1238
+ debug: options.debug,
1239
+ eventEmission: options.eventEmission
1141
1240
  });
1142
1241
  sdk = sdk.addPlugin(bundleCodePlugin);
1143
1242
  sdk = sdk.addPlugin(getLoginConfigPathPlugin);
@@ -1149,4 +1248,5 @@ function createZapierCliSdk(options = {}) {
1149
1248
  return finalSdk;
1150
1249
  }
1151
1250
 
1251
+ exports.buildCliCommandExecutedEvent = buildCliCommandExecutedEvent;
1152
1252
  exports.createZapierCliSdk = createZapierCliSdk;
package/dist/index.d.mts CHANGED
@@ -1,7 +1,15 @@
1
- import { ZapierSdk } from '@zapier/zapier-sdk';
1
+ import { ZapierSdk, BaseEvent } from '@zapier/zapier-sdk';
2
2
 
3
3
  interface ZapierCliSdkOptions {
4
4
  debug?: boolean;
5
+ eventEmission?: {
6
+ enabled?: boolean;
7
+ transport?: {
8
+ type: "http" | "console" | "noop";
9
+ endpoint?: string;
10
+ headers?: Record<string, string>;
11
+ };
12
+ };
5
13
  }
6
14
  /**
7
15
  * Create a Zapier SDK instance configured specifically for the CLI
@@ -9,4 +17,85 @@ interface ZapierCliSdkOptions {
9
17
  */
10
18
  declare function createZapierCliSdk(options?: ZapierCliSdkOptions): ZapierSdk;
11
19
 
12
- export { type ZapierCliSdkOptions, createZapierCliSdk };
20
+ /**
21
+ * CLI-specific telemetry event definitions
22
+ */
23
+
24
+ /**
25
+ * Event emitted when a CLI command is executed
26
+ */
27
+ interface CliCommandExecutedEvent extends BaseEvent {
28
+ system_name: string;
29
+ session_id?: string | null;
30
+ cli_version?: string | null;
31
+ cli_arguments?: (string | null)[] | null;
32
+ cli_primary_command?: string | null;
33
+ os_platform?: string | null;
34
+ os_release?: string | null;
35
+ os_architecture?: string | null;
36
+ platform_versions?: Record<string, string | null> | null;
37
+ selected_api?: string | null;
38
+ app_id?: number | null;
39
+ app_version_id?: number | null;
40
+ execution_duration_ms?: number | null;
41
+ success_flag: boolean;
42
+ exit_code?: number | null;
43
+ error_message?: string | null;
44
+ command_category?: string | null;
45
+ requires_auth?: boolean | null;
46
+ is_ci_environment?: boolean | null;
47
+ ci_platform?: string | null;
48
+ package_manager?: string | null;
49
+ made_network_requests?: boolean | null;
50
+ files_modified_count?: number | null;
51
+ files_created_count?: number | null;
52
+ files_processed_size_bytes?: number | null;
53
+ peak_memory_usage_bytes?: number | null;
54
+ cpu_time_ms?: number | null;
55
+ subprocess_count?: number | null;
56
+ }
57
+
58
+ /**
59
+ * CLI-specific event builders
60
+ *
61
+ * Provides builder functions for CLI command telemetry that auto-populate
62
+ * common CLI fields and system information.
63
+ */
64
+
65
+ interface CliEventContext {
66
+ customuser_id?: number | null;
67
+ account_id?: number | null;
68
+ identity_id?: number | null;
69
+ visitor_id?: string | null;
70
+ correlation_id?: string | null;
71
+ session_id?: string | null;
72
+ selected_api?: string | null;
73
+ app_id?: number | null;
74
+ app_version_id?: number | null;
75
+ }
76
+ interface CliCommandExecutedEventData {
77
+ cli_primary_command: string;
78
+ success_flag: boolean;
79
+ execution_duration_ms?: number | null;
80
+ exit_code?: number | null;
81
+ error_message?: string | null;
82
+ command_category?: string | null;
83
+ requires_auth?: boolean | null;
84
+ cli_arguments?: (string | null)[] | null;
85
+ cli_version?: string | null;
86
+ made_network_requests?: boolean | null;
87
+ files_modified_count?: number | null;
88
+ files_created_count?: number | null;
89
+ files_processed_size_bytes?: number | null;
90
+ peak_memory_usage_bytes?: number | null;
91
+ cpu_time_ms?: number | null;
92
+ subprocess_count?: number | null;
93
+ package_manager?: string | null;
94
+ }
95
+ declare function buildCliCommandExecutedEvent({ data, context, cliVersion, }: {
96
+ data: CliCommandExecutedEventData;
97
+ context?: CliEventContext;
98
+ cliVersion?: string;
99
+ }): CliCommandExecutedEvent;
100
+
101
+ export { type CliCommandExecutedEvent, type CliCommandExecutedEventData, type CliEventContext, type ZapierCliSdkOptions, buildCliCommandExecutedEvent, createZapierCliSdk };