@@ -93735,7 +93735,7 @@ const external_node_path_namespaceObject = __WEBPACK_EXTERNAL_createRequire(impo
9373593735const external_node_stream_promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:stream/promises");
9373693736;// CONCATENATED MODULE: external "node:zlib"
9373793737const external_node_zlib_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:zlib");
93738- ;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@9d66d2c89c150f796165fdcc20b3be538807c0f4_46ybmzqhaua4eiwu3nj2qm63te /node_modules/detsys-ts/dist/index.js
93738+ ;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@fe64ba33b4bdeec0991bb65ae00420bf68b9954c_ler7zqcm5mrt635umsvjcuxcmy /node_modules/detsys-ts/dist/index.js
9373993739var __defProp = Object.defineProperty;
9374093740var __export = (target, all) => {
9374193741 for (var name in all)
@@ -94072,7 +94072,7 @@ var IdsHost = class {
9407294072 setPrioritizedUrls(urls) {
9407394073 this.prioritizedURLs = urls;
9407494074 }
94075- async getRootUrl () {
94075+ async getDynamicRootUrl () {
9407694076 const idsHost = process.env["IDS_HOST"];
9407794077 if (idsHost !== void 0) {
9407894078 try {
@@ -94093,9 +94093,17 @@ var IdsHost = class {
9409394093 );
9409494094 }
9409594095 if (url === void 0) {
94096- url = new URL(DEFAULT_IDS_HOST);
94096+ return void 0;
94097+ } else {
94098+ return new URL(url);
9409794099 }
94098- return new URL(url);
94100+ }
94101+ async getRootUrl() {
94102+ const url = await this.getDynamicRootUrl();
94103+ if (url === void 0) {
94104+ return new URL(DEFAULT_IDS_HOST);
94105+ }
94106+ return url;
9409994107 }
9410094108 async getDiagnosticsUrl() {
9410194109 if (this.runtimeDiagnosticsUrl === "") {
@@ -94406,6 +94414,7 @@ var STATE_KEY_EXECUTION_PHASE = "detsys_action_execution_phase";
9440694414var STATE_KEY_NIX_NOT_FOUND = "detsys_action_nix_not_found";
9440794415var STATE_NOT_FOUND = "not-found";
9440894416var DIAGNOSTIC_ENDPOINT_TIMEOUT_MS = 3e4;
94417+ var CHECK_IN_ENDPOINT_TIMEOUT_MS = 5e3;
9440994418var DetSysAction = class {
9441094419 determineExecutionPhase() {
9441194420 const currentPhase = core.getState(STATE_KEY_EXECUTION_PHASE);
@@ -94428,6 +94437,8 @@ var DetSysAction = class {
9442894437 this.exceptionAttachments = /* @__PURE__ */ new Map();
9442994438 this.nixStoreTrust = "unknown";
9443094439 this.strictMode = getBool("_internal-strict-mode");
94440+ this.features = {};
94441+ this.featureEventMetadata = /* @__PURE__ */ new Map();
9443194442 this.events = [];
9443294443 this.client = got_dist_source.extend({
9443394444 retry: {
@@ -94537,11 +94548,13 @@ var DetSysAction = class {
9453794548 return this.identity;
9453894549 }
9453994550 recordEvent(eventName, context = {}) {
94551+ const prefixedName = eventName === "$feature_flag_called" ? eventName : `${this.actionOptions.eventPrefix}${eventName}`;
9454094552 this.events.push({
94541- event_name: `${this.actionOptions.eventPrefix}${eventName}` ,
94553+ event_name: prefixedName ,
9454294554 context,
9454394555 correlation: this.identity,
9454494556 facts: this.facts,
94557+ features: this.featureEventMetadata,
9454594558 timestamp: /* @__PURE__ */ new Date(),
9454694559 uuid: (0,external_node_crypto_namespaceObject.randomUUID)()
9454794560 });
@@ -94577,6 +94590,7 @@ var DetSysAction = class {
9457794590 }
9457894591 async executeAsync() {
9457994592 try {
94593+ await this.checkIn();
9458094594 process.env.DETSYS_CORRELATION = JSON.stringify(
9458194595 this.getCorrelationHashes()
9458294596 );
@@ -94624,6 +94638,94 @@ var DetSysAction = class {
9462494638 await this.complete();
9462594639 }
9462694640 }
94641+ async checkIn() {
94642+ const checkin = await this.requestCheckIn();
94643+ if (checkin === void 0) {
94644+ return;
94645+ }
94646+ this.features = checkin.options;
94647+ for (const [key, feature] of Object.entries(this.features)) {
94648+ this.featureEventMetadata.set(key, feature.variant);
94649+ }
94650+ const impactSymbol = /* @__PURE__ */ new Map([
94651+ ["none", "\u26AA"],
94652+ ["maintenance", "\u{1F6E0}\uFE0F"],
94653+ ["minor", "\u{1F7E1}"],
94654+ ["major", "\u{1F7E0}"],
94655+ ["critical", "\u{1F534}"]
94656+ ]);
94657+ const defaultImpactSymbol = "\u{1F535}";
94658+ if (checkin.status !== null) {
94659+ const summaries = [];
94660+ for (const incident of checkin.status.incidents) {
94661+ summaries.push(
94662+ `${impactSymbol.get(incident.impact) || defaultImpactSymbol} ${incident.status.replace("_", " ")}: ${incident.name} (${incident.shortlink})`
94663+ );
94664+ }
94665+ for (const maintenance of checkin.status.scheduled_maintenances) {
94666+ summaries.push(
94667+ `${impactSymbol.get(maintenance.impact) || defaultImpactSymbol} ${maintenance.status.replace("_", " ")}: ${maintenance.name} (${maintenance.shortlink})`
94668+ );
94669+ }
94670+ if (summaries.length > 0) {
94671+ core.info(
94672+ // Bright red, Bold, Underline
94673+ `${"\x1B[0;31m"}${"\x1B[1m"}${"\x1B[4m"}${checkin.status.page.name} Status`
94674+ );
94675+ for (const notice of summaries) {
94676+ core.info(notice);
94677+ }
94678+ core.info(`See: ${checkin.status.page.url}`);
94679+ core.info(``);
94680+ }
94681+ }
94682+ }
94683+ getFeature(name) {
94684+ if (!this.features.hasOwnProperty(name)) {
94685+ return void 0;
94686+ }
94687+ const result = this.features[name];
94688+ if (result === void 0) {
94689+ return void 0;
94690+ }
94691+ this.recordEvent("$feature_flag_called", {
94692+ $feature_flag: name,
94693+ $feature_flag_response: result.variant
94694+ });
94695+ return result;
94696+ }
94697+ /**
94698+ * Check in to install.determinate.systems, to accomplish three things:
94699+ *
94700+ * 1. Preflight the server selected from IdsHost, to increase the chances of success.
94701+ * 2. Fetch any incidents and maintenance events to let users know in case things are weird.
94702+ * 3. Get feature flag data so we can gently roll out new features.
94703+ */
94704+ async requestCheckIn() {
94705+ for (let attemptsRemaining = 5; attemptsRemaining > 0; attemptsRemaining--) {
94706+ const checkInUrl = await this.getCheckInUrl();
94707+ if (checkInUrl === void 0) {
94708+ return void 0;
94709+ }
94710+ try {
94711+ core.debug(`Preflighting via ${checkInUrl}`);
94712+ checkInUrl.searchParams.set("ci", "github");
94713+ checkInUrl.searchParams.set(
94714+ "correlation",
94715+ JSON.stringify(this.identity)
94716+ );
94717+ return await this.client.get(checkInUrl, {
94718+ timeout: {
94719+ request: CHECK_IN_ENDPOINT_TIMEOUT_MS
94720+ }
94721+ }).json();
94722+ } catch (e) {
94723+ core.debug(`Error checking in: ${stringifyError2(e)}`);
94724+ this.idsHost.markCurrentHostBroken();
94725+ }
94726+ }
94727+ return void 0;
94728+ }
9462794729 /**
9462894730 * Fetch an artifact, such as a tarball, from the location determined by the
9462994731 * `source-*` inputs. If `source-binary` is specified, this will return a path
@@ -94701,6 +94803,14 @@ var DetSysAction = class {
9470194803 this.recordEvent(`complete_${this.executionPhase}`);
9470294804 await this.submitEvents();
9470394805 }
94806+ async getCheckInUrl() {
94807+ const checkInUrl = await this.idsHost.getDynamicRootUrl();
94808+ if (checkInUrl === void 0) {
94809+ return void 0;
94810+ }
94811+ checkInUrl.pathname += "check-in";
94812+ return checkInUrl;
94813+ }
9470494814 async getSourceUrl() {
9470594815 const p = this.sourceParameters;
9470694816 if (p.url) {
0 commit comments