@@ -35097,6 +35097,64 @@ function wrappy (fn, cb) {
35097
35097
}
35098
35098
35099
35099
35100
+ /***/ }),
35101
+
35102
+ /***/ 1267:
35103
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
35104
+
35105
+ "use strict";
35106
+
35107
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35108
+ return (mod && mod.__esModule) ? mod : { "default": mod };
35109
+ };
35110
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
35111
+ exports.sendAnalytics = sendAnalytics;
35112
+ const crypto_1 = __importDefault(__nccwpck_require__(6982));
35113
+ const os_1 = __importDefault(__nccwpck_require__(857));
35114
+ const apiUtils_1 = __nccwpck_require__(890);
35115
+ const k6helper_1 = __nccwpck_require__(5354);
35116
+ const ANALYTICS_SOURCE = 'github-action';
35117
+ /**
35118
+ * Gets the usage stats id which is an identifier for the invocation of the action
35119
+ * Here we use a hash of GITHUB_ACTION and GITHUB_REPOSITORY to identify the unique users and
35120
+ * club multiple invocations from the same user/repo
35121
+ *
35122
+ * @returns The usage stats id
35123
+ */
35124
+ function getUsageStatsId() {
35125
+ const githubAction = process.env.GITHUB_ACTION || '';
35126
+ const githubWorkflow = process.env.GITHUB_WORKFLOW || '';
35127
+ return crypto_1.default
35128
+ .createHash('sha256')
35129
+ .update(`${githubAction}-${githubWorkflow}`)
35130
+ .digest('hex');
35131
+ }
35132
+ async function sendAnalytics(userSpecifiedAnalyticsData) {
35133
+ const analyticsData = {
35134
+ ...userSpecifiedAnalyticsData,
35135
+ source: ANALYTICS_SOURCE,
35136
+ usageStatsId: getUsageStatsId(),
35137
+ osPlatform: os_1.default.platform(),
35138
+ osArch: os_1.default.arch(),
35139
+ osType: os_1.default.type(),
35140
+ k6Version: (0, k6helper_1.getInstalledK6Version)(),
35141
+ };
35142
+ const url = process.env.GRAFANA_ANALYTICS_URL || 'https://stats.grafana.org';
35143
+ try {
35144
+ await (0, apiUtils_1.apiRequest)(url, {
35145
+ method: 'POST',
35146
+ body: JSON.stringify(analyticsData),
35147
+ }, {
35148
+ ...apiUtils_1.DEFAULT_RETRY_OPTIONS,
35149
+ maxRetries: 1,
35150
+ });
35151
+ }
35152
+ catch (error) {
35153
+ console.error('Error sending analytics:', error);
35154
+ }
35155
+ }
35156
+
35157
+
35100
35158
/***/ }),
35101
35159
35102
35160
/***/ 890:
@@ -35494,6 +35552,7 @@ var __importStar = (this && this.__importStar) || (function () {
35494
35552
Object.defineProperty(exports, "__esModule", ({ value: true }));
35495
35553
exports.run = run;
35496
35554
const core = __importStar(__nccwpck_require__(7484));
35555
+ const analytics_1 = __nccwpck_require__(1267);
35497
35556
const githubHelper_1 = __nccwpck_require__(2384);
35498
35557
const k6helper_1 = __nccwpck_require__(5354);
35499
35558
const utils_1 = __nccwpck_require__(1798);
@@ -35514,6 +35573,7 @@ async function run() {
35514
35573
const onlyVerifyScripts = core.getBooleanInput('only-verify-scripts');
35515
35574
const shouldCommentCloudTestRunUrlOnPR = core.getBooleanInput('cloud-comment-on-pr');
35516
35575
const debug = core.getBooleanInput('debug');
35576
+ const disableAnalytics = core.getBooleanInput('disable-analytics');
35517
35577
const allPromises = [];
35518
35578
core.debug(`Flag to show k6 progress output set to: ${debug}`);
35519
35579
core.debug(`🔍 Found following ${testPaths.length} test run files:`);
@@ -35536,6 +35596,20 @@ async function run() {
35536
35596
return;
35537
35597
}
35538
35598
const isCloud = (0, k6helper_1.isCloudIntegrationEnabled)();
35599
+ if (!disableAnalytics) {
35600
+ const userSpecifiedAnalyticsData = {
35601
+ totalTestScriptsExecuted: verifiedTestPaths.length,
35602
+ isCloudRun: isCloud,
35603
+ isUsingFlags: flags.length > 0,
35604
+ isUsingInspectFlags: inspectFlags.length > 0,
35605
+ failFast,
35606
+ commentOnPr: shouldCommentCloudTestRunUrlOnPR,
35607
+ parallelFlag: parallel,
35608
+ cloudRunLocally,
35609
+ onlyVerifyScripts,
35610
+ };
35611
+ (0, analytics_1.sendAnalytics)(userSpecifiedAnalyticsData);
35612
+ }
35539
35613
const commands = testPaths.map((testPath) => (0, k6helper_1.generateK6RunCommand)(testPath, flags, isCloud, cloudRunLocally)), TOTAL_TEST_RUNS = commands.length, TEST_RESULT_URLS_MAP = new Proxy({}, {
35540
35614
set: (target, key, value) => {
35541
35615
target[key] = value;
@@ -35867,6 +35941,8 @@ exports.executeRunK6Command = executeRunK6Command;
35867
35941
exports.extractTestRunId = extractTestRunId;
35868
35942
exports.fetchTestRunSummary = fetchTestRunSummary;
35869
35943
exports.fetchChecks = fetchChecks;
35944
+ exports.extractK6SemVer = extractK6SemVer;
35945
+ exports.getInstalledK6Version = getInstalledK6Version;
35870
35946
// Common helper functions used in the action
35871
35947
const core = __importStar(__nccwpck_require__(7484));
35872
35948
const child_process_1 = __nccwpck_require__(5317);
@@ -36049,6 +36125,35 @@ async function fetchChecks(testRunId) {
36049
36125
// Return the checks array from the response
36050
36126
return response.value;
36051
36127
}
36128
+ /**
36129
+ * Extracts the semantic version (e.g., "0.56.0") from the full k6 version string which looks like
36130
+ * `k6 v0.56.0 (go1.23.4, darwin/arm64)`.
36131
+ *
36132
+ * @param {string} versionString - The full version string from k6 version command
36133
+ * @returns {string} The semantic version or empty string if not found
36134
+ */
36135
+ function extractK6SemVer(versionString) {
36136
+ // Match pattern like "v0.56.0" and extract just the digits and dots
36137
+ const match = versionString.match(/v(\d+\.\d+\.\d+)/);
36138
+ return match ? match[1] : '';
36139
+ }
36140
+ /**
36141
+ * Gets the installed k6 version using the `k6 version` command.
36142
+ *
36143
+ * @returns The installed k6 version as a semantic version string
36144
+ */
36145
+ function getInstalledK6Version() {
36146
+ try {
36147
+ // Use execSync for synchronous output capture
36148
+ const output = (0, child_process_1.execSync)('k6 version').toString().trim();
36149
+ // Return only the semantic version if requested
36150
+ return extractK6SemVer(output);
36151
+ }
36152
+ catch (error) {
36153
+ console.error('Error executing k6 version:', error);
36154
+ return '';
36155
+ }
36156
+ }
36052
36157
36053
36158
36054
36159
/***/ }),
0 commit comments