extension 3.18.1 → 3.18.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -6561,6 +6561,9 @@ Cross-Browser Compatibility
6561
6561
  else obj[key] = value;
6562
6562
  return obj;
6563
6563
  }
6564
+ function sanitizeTag(value) {
6565
+ return String(value).trim().replace(/[^a-zA-Z0-9._-]/g, '').slice(0, 64);
6566
+ }
6564
6567
  const DEFAULT_SAMPLE_RATE = Number(process.env.EXTENSION_TELEMETRY_SAMPLE_RATE || 0.2);
6565
6568
  const DEFAULT_MAX_EVENTS = Number(process.env.EXTENSION_TELEMETRY_MAX_EVENTS || 3);
6566
6569
  const DEFAULT_DEBOUNCE_MS = Number(process.env.EXTENSION_TELEMETRY_DEBOUNCE_MS || 60000);
@@ -6710,6 +6713,8 @@ Cross-Browser Compatibility
6710
6713
  success: Boolean(props.success),
6711
6714
  version: String(props.version ?? this.version).slice(0, 32)
6712
6715
  };
6716
+ if (props.template) enforcedProps.template = sanitizeTag(props.template);
6717
+ if (props.source) enforcedProps.source = sanitizeTag(props.source);
6713
6718
  const payload = {
6714
6719
  event,
6715
6720
  properties: {
@@ -6721,7 +6726,7 @@ Cross-Browser Compatibility
6721
6726
  distinct_id: this.anonId
6722
6727
  };
6723
6728
  this.writeAudit(payload);
6724
- if ('command_executed' === event && Math.random() > this.sampleRate) return;
6729
+ if ('command_executed' === event && 'create' !== props.command && Math.random() > this.sampleRate) return;
6725
6730
  if (!this.apiKey || !this.host) return;
6726
6731
  this.buffer.push(payload);
6727
6732
  this.sent += 1;
@@ -6826,6 +6831,30 @@ Cross-Browser Compatibility
6826
6831
  }
6827
6832
  return 'unknown';
6828
6833
  }
6834
+ function readArgValue(argv, names) {
6835
+ for(let i = 2; i < argv.length; i += 1){
6836
+ const arg = argv[i];
6837
+ if (arg) for (const name of names){
6838
+ if (arg === name) {
6839
+ const next = argv[i + 1];
6840
+ return next && !next.startsWith('-') ? next : void 0;
6841
+ }
6842
+ if (arg.startsWith(`${name}=`)) return arg.slice(name.length + 1);
6843
+ }
6844
+ }
6845
+ }
6846
+ function commandContext(command) {
6847
+ if ('create' !== command) return {};
6848
+ return {
6849
+ template: readArgValue(process.argv, [
6850
+ '--template',
6851
+ '-t'
6852
+ ]),
6853
+ source: readArgValue(process.argv, [
6854
+ '--source'
6855
+ ]) || 'cli'
6856
+ };
6857
+ }
6829
6858
  const consent = resolveTelemetryConsent(process.argv);
6830
6859
  const invoked = detectInvokedCommand(process.argv);
6831
6860
  const telemetry_cli_version = getCliPackageJson().version;
@@ -6856,7 +6885,8 @@ Cross-Browser Compatibility
6856
6885
  telemetry.track('command_executed', {
6857
6886
  command,
6858
6887
  success: true,
6859
- version: telemetry_cli_version
6888
+ version: telemetry_cli_version,
6889
+ ...commandContext(command)
6860
6890
  });
6861
6891
  }
6862
6892
  function markCommandFailure(command = invoked) {
@@ -6864,7 +6894,8 @@ Cross-Browser Compatibility
6864
6894
  telemetry.track('command_failed', {
6865
6895
  command,
6866
6896
  success: false,
6867
- version: telemetry_cli_version
6897
+ version: telemetry_cli_version,
6898
+ ...commandContext(command)
6868
6899
  });
6869
6900
  }
6870
6901
  function printOptOutNoticeIfFirstRun() {
@@ -6929,7 +6960,7 @@ Cross-Browser Compatibility
6929
6960
  }
6930
6961
  const create_require = (0, external_module_.createRequire)(__rslib_import_meta_url__);
6931
6962
  function registerCreateCommand(program) {
6932
- program.command('create').arguments('<project-name|project-path>').usage('create <project-name|project-path> [options]').description(commandDescriptions.create).option('-t, --template <template-name>', 'specify a template for the created project').option('--install [boolean]', 'whether or not to install the dependencies after creating the project (disabled by default — pass --install to opt in)', parseOptionalBoolean, false).action(async function(pathOrRemoteUrl, { template, install }) {
6963
+ program.command('create').arguments('<project-name|project-path>').usage('create <project-name|project-path> [options]').description(commandDescriptions.create).option('-t, --template <template-name>', 'specify a template for the created project').option('--install [boolean]', 'whether or not to install the dependencies after creating the project (disabled by default — pass --install to opt in)', parseOptionalBoolean, false).option('--source <source>', 'attribution tag for where this create was initiated (e.g. cli, templates); recorded in anonymous telemetry only').action(async function(pathOrRemoteUrl, { template, install }) {
6933
6964
  if (!process.env.EXTENSION_CREATE_DEVELOP_ROOT) try {
6934
6965
  process.env.EXTENSION_CREATE_DEVELOP_ROOT = resolveExtensionDevelopRoot();
6935
6966
  } catch {
@@ -3,6 +3,8 @@ export type TelemetryProps = {
3
3
  command: string;
4
4
  success: boolean;
5
5
  version: string;
6
+ template?: string;
7
+ source?: string;
6
8
  };
7
9
  export type TelemetrySource = 'env' | 'flag' | 'config' | 'default';
8
10
  type TelemetryInit = {
package/package.json CHANGED
@@ -38,7 +38,7 @@
38
38
  "extension": "./bin/extension.cjs"
39
39
  },
40
40
  "name": "extension",
41
- "version": "3.18.1",
41
+ "version": "3.18.3",
42
42
  "description": "Create cross-browser extensions with no build configuration.",
43
43
  "homepage": "https://extension.js.org/",
44
44
  "bugs": {
@@ -100,9 +100,9 @@
100
100
  "cross-spawn": "^7.0.6",
101
101
  "edge-location": "2.2.0",
102
102
  "firefox-location2": "3.0.0",
103
- "extension-create": "3.18.1",
104
- "extension-develop": "3.18.1",
105
- "extension-install": "3.18.1",
103
+ "extension-create": "3.18.3",
104
+ "extension-develop": "3.18.3",
105
+ "extension-install": "3.18.3",
106
106
  "commander": "^14.0.3",
107
107
  "pintor": "0.3.0",
108
108
  "semver": "^7.7.3",