project-id.js 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.getRawProjectId = getRawProjectId;
  6. var _childProcess = require("child_process");
  7. // Q: Why does Next.js need a project ID? Why is it looking at my git remote?
  8. // A:
  9. // Next.js' telemetry is and always will be completely anonymous. Because of
  10. // this, we need a way to differentiate different projects to track feature
  11. // usage accurately. For example, to prevent a feature from appearing to be
  12. // constantly `used` and then `unused` when switching between local projects.
  13. // To reiterate,
  14. // we **never** can read your actual git remote. The value is hashed one-way
  15. // with random salt data, making it impossible for us to reverse or try to
  16. // guess the remote by re-computing hashes.
  17. function _getProjectIdByGit() {
  18. try {
  19. const originBuffer = (0, _childProcess).execSync(`git config --local --get remote.origin.url`, {
  20. timeout: 1000,
  21. stdio: `pipe`
  22. });
  23. return String(originBuffer).trim();
  24. } catch (_) {
  25. return null;
  26. }
  27. }
  28. function getRawProjectId() {
  29. return _getProjectIdByGit() || process.env.REPOSITORY_URL || process.cwd();
  30. }
  31. //# sourceMappingURL=project-id.js.map