@fern-api/fern-api-dev 5.23.3-94-g1434a7f90c8 → 5.23.3-99-g2ce21a4a41d
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/cli.cjs +436 -35
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -44559,6 +44559,7 @@ function createMockTaskContext({ logger: logger4 = CONSOLE_LOGGER } = {}) {
|
|
|
44559
44559
|
context3.failAndThrow(message, error50);
|
|
44560
44560
|
},
|
|
44561
44561
|
captureException: () => {
|
|
44562
|
+
return void 0;
|
|
44562
44563
|
},
|
|
44563
44564
|
getResult: () => TaskResult.Success,
|
|
44564
44565
|
getLastFailureMessage: () => void 0,
|
|
@@ -667930,13 +667931,20 @@ var AccessTokenPosthogManager = class {
|
|
|
667930
667931
|
properties: {
|
|
667931
667932
|
...event,
|
|
667932
667933
|
...event.properties,
|
|
667933
|
-
version: "5.23.3-
|
|
667934
|
+
version: "5.23.3-99-g2ce21a4a41d",
|
|
667934
667935
|
usingAccessToken: true,
|
|
667935
667936
|
...getRunIdProperties()
|
|
667936
667937
|
}
|
|
667937
667938
|
});
|
|
667938
667939
|
}
|
|
667939
667940
|
}
|
|
667941
|
+
sendAutomationEvent(event) {
|
|
667942
|
+
this.posthog.capture({
|
|
667943
|
+
distinctId: event.distinctId,
|
|
667944
|
+
event: event.event,
|
|
667945
|
+
properties: event.properties
|
|
667946
|
+
});
|
|
667947
|
+
}
|
|
667940
667948
|
async flush() {
|
|
667941
667949
|
try {
|
|
667942
667950
|
await Promise.race([this.posthog.flush(), new Promise((resolve15) => setTimeout(resolve15, 3e3))]);
|
|
@@ -667949,6 +667957,8 @@ var AccessTokenPosthogManager = class {
|
|
|
667949
667957
|
var NoopPosthogManager = class {
|
|
667950
667958
|
async sendEvent() {
|
|
667951
667959
|
}
|
|
667960
|
+
async sendAutomationEvent() {
|
|
667961
|
+
}
|
|
667952
667962
|
async identify() {
|
|
667953
667963
|
}
|
|
667954
667964
|
async flush() {
|
|
@@ -667985,7 +667995,7 @@ var UserPosthogManager = class {
|
|
|
667985
667995
|
distinctId: this.userId ?? await this.getPersistedDistinctId(),
|
|
667986
667996
|
event: "CLI",
|
|
667987
667997
|
properties: {
|
|
667988
|
-
version: "5.23.3-
|
|
667998
|
+
version: "5.23.3-99-g2ce21a4a41d",
|
|
667989
667999
|
...event,
|
|
667990
668000
|
...event.properties,
|
|
667991
668001
|
usingAccessToken: false,
|
|
@@ -667994,6 +668004,13 @@ var UserPosthogManager = class {
|
|
|
667994
668004
|
}
|
|
667995
668005
|
});
|
|
667996
668006
|
}
|
|
668007
|
+
sendAutomationEvent(event) {
|
|
668008
|
+
this.posthog.capture({
|
|
668009
|
+
distinctId: event.distinctId,
|
|
668010
|
+
event: event.event,
|
|
668011
|
+
properties: event.properties
|
|
668012
|
+
});
|
|
668013
|
+
}
|
|
667997
668014
|
async flush() {
|
|
667998
668015
|
try {
|
|
667999
668016
|
await Promise.race([this.posthog.flush(), new Promise((resolve15) => setTimeout(resolve15, 3e3))]);
|
|
@@ -671960,18 +671977,26 @@ var TelemetryClient = class _TelemetryClient {
|
|
|
671960
671977
|
* The caller is responsible for deciding which errors are worth reporting
|
|
671961
671978
|
* (see `shouldReportToSentry` in withContext.ts).
|
|
671962
671979
|
*/
|
|
671963
|
-
captureException(error50,
|
|
671980
|
+
captureException(error50, options2) {
|
|
671964
671981
|
if (this.sentry === void 0) {
|
|
671965
|
-
return;
|
|
671982
|
+
return void 0;
|
|
671966
671983
|
}
|
|
671967
671984
|
try {
|
|
671968
|
-
this.
|
|
671969
|
-
|
|
671970
|
-
|
|
671971
|
-
|
|
671985
|
+
const tags = { ...this.baseTags, ...this.accumulatedTags, ...options2?.tags };
|
|
671986
|
+
const context3 = options2?.context;
|
|
671987
|
+
return withScope2((scope) => {
|
|
671988
|
+
scope.setTags(tags);
|
|
671989
|
+
if (context3 != null) {
|
|
671990
|
+
for (const [key2, value2] of Object.entries(context3)) {
|
|
671991
|
+
if (value2 != null) {
|
|
671992
|
+
scope.setContext(key2, value2);
|
|
671993
|
+
}
|
|
671994
|
+
}
|
|
671972
671995
|
}
|
|
671996
|
+
return this.sentry?.captureException(error50, void 0, scope);
|
|
671973
671997
|
});
|
|
671974
671998
|
} catch {
|
|
671999
|
+
return void 0;
|
|
671975
672000
|
}
|
|
671976
672001
|
}
|
|
671977
672002
|
async flush() {
|
|
@@ -673459,7 +673484,9 @@ function reportError(context3, error50, options2) {
|
|
|
673459
673484
|
const capturable = error50 ?? new CliError({ message: options2?.message ?? "", code: code5 });
|
|
673460
673485
|
if (shouldReportToSentry(code5)) {
|
|
673461
673486
|
context3.telemetry.captureException(capturable, {
|
|
673462
|
-
|
|
673487
|
+
tags: {
|
|
673488
|
+
"error.code": code5
|
|
673489
|
+
}
|
|
673463
673490
|
});
|
|
673464
673491
|
}
|
|
673465
673492
|
context3.telemetry.sendLifecycleEvent({
|
|
@@ -673658,9 +673685,8 @@ var TaskContextAdapter = class {
|
|
|
673658
673685
|
getLastFailureMessage() {
|
|
673659
673686
|
return this.lastFailureMessage;
|
|
673660
673687
|
}
|
|
673661
|
-
captureException(error50,
|
|
673662
|
-
|
|
673663
|
-
this.context.telemetry.captureException(error50, { errorCode });
|
|
673688
|
+
captureException(error50, options2) {
|
|
673689
|
+
return this.context.telemetry.captureException(error50, options2);
|
|
673664
673690
|
}
|
|
673665
673691
|
getFullErrorMessage(message, error50) {
|
|
673666
673692
|
const errorDetails = this.formatError(error50);
|
|
@@ -859541,7 +859567,7 @@ var LOCAL_STORAGE_FOLDER4 = ".fern-dev";
|
|
|
859541
859567
|
var LOGS_FOLDER_NAME = "logs";
|
|
859542
859568
|
var MAX_LOGS_DIR_SIZE_BYTES = 100 * 1024 * 1024;
|
|
859543
859569
|
function getCliSource() {
|
|
859544
|
-
const version7 = "5.23.3-
|
|
859570
|
+
const version7 = "5.23.3-99-g2ce21a4a41d";
|
|
859545
859571
|
return `cli@${version7}`;
|
|
859546
859572
|
}
|
|
859547
859573
|
var DebugLogger = class {
|
|
@@ -873514,7 +873540,7 @@ var LegacyDocsPublisher = class {
|
|
|
873514
873540
|
previewId,
|
|
873515
873541
|
disableTemplates: void 0,
|
|
873516
873542
|
skipUpload,
|
|
873517
|
-
cliVersion: "5.23.3-
|
|
873543
|
+
cliVersion: "5.23.3-99-g2ce21a4a41d",
|
|
873518
873544
|
loginCommand: "fern auth login"
|
|
873519
873545
|
});
|
|
873520
873546
|
if (taskContext.getResult() === TaskResult.Failure) {
|
|
@@ -947728,6 +947754,260 @@ var esm_default16 = createPrompt((config5, done) => {
|
|
|
947728
947754
|
// src/cli-context/CliContext.ts
|
|
947729
947755
|
init_lodash();
|
|
947730
947756
|
|
|
947757
|
+
// src/telemetry/automationTelemetryEvent.ts
|
|
947758
|
+
var AUTOMATION_EVENT_NAMES = {
|
|
947759
|
+
GENERATION_STARTED: "generation_started",
|
|
947760
|
+
GENERATION_COMPLETED: "generation_completed",
|
|
947761
|
+
GENERATION_FAILED: "generation_failed",
|
|
947762
|
+
VERIFICATION_FAILED: "verification_failed",
|
|
947763
|
+
SDK_PR_CREATED: "sdk_pr_created",
|
|
947764
|
+
UPGRADE_APPLIED: "upgrade_applied",
|
|
947765
|
+
MAJOR_VERSION_BUMP: "major_version_bump"
|
|
947766
|
+
};
|
|
947767
|
+
var AUTOMATION_EVENT_FAILURE = {
|
|
947768
|
+
[AUTOMATION_EVENT_NAMES.GENERATION_STARTED]: false,
|
|
947769
|
+
[AUTOMATION_EVENT_NAMES.GENERATION_COMPLETED]: false,
|
|
947770
|
+
[AUTOMATION_EVENT_NAMES.GENERATION_FAILED]: true,
|
|
947771
|
+
[AUTOMATION_EVENT_NAMES.VERIFICATION_FAILED]: true,
|
|
947772
|
+
[AUTOMATION_EVENT_NAMES.SDK_PR_CREATED]: false,
|
|
947773
|
+
[AUTOMATION_EVENT_NAMES.UPGRADE_APPLIED]: false,
|
|
947774
|
+
[AUTOMATION_EVENT_NAMES.MAJOR_VERSION_BUMP]: false
|
|
947775
|
+
};
|
|
947776
|
+
function isFailureAutomationEventName(event) {
|
|
947777
|
+
return AUTOMATION_EVENT_FAILURE[event];
|
|
947778
|
+
}
|
|
947779
|
+
function toPosthogProperties(event, context3) {
|
|
947780
|
+
return {
|
|
947781
|
+
automation_mode: true,
|
|
947782
|
+
surface: "cli",
|
|
947783
|
+
action: context3.action,
|
|
947784
|
+
run_id: context3.run_id,
|
|
947785
|
+
github_run_id: context3.github_run_id,
|
|
947786
|
+
github_run_url: context3.github_run_url,
|
|
947787
|
+
org: context3.org,
|
|
947788
|
+
config_repo: context3.config_repo,
|
|
947789
|
+
config_commit_sha: context3.config_commit_sha,
|
|
947790
|
+
config_branch: context3.config_branch,
|
|
947791
|
+
config_pr_number: context3.config_pr_number,
|
|
947792
|
+
trigger: context3.trigger,
|
|
947793
|
+
cli_version: context3.cli_version,
|
|
947794
|
+
...event.errorCode !== void 0 ? { error_code: event.errorCode } : {},
|
|
947795
|
+
...event.attributes ?? {}
|
|
947796
|
+
};
|
|
947797
|
+
}
|
|
947798
|
+
function toSentryTags(event, context3) {
|
|
947799
|
+
function appendStringIfPresent(target, key2, value2) {
|
|
947800
|
+
if (value2 != null) {
|
|
947801
|
+
target[key2] = value2;
|
|
947802
|
+
}
|
|
947803
|
+
}
|
|
947804
|
+
const tags = {
|
|
947805
|
+
surface: "cli",
|
|
947806
|
+
automation_mode: "true"
|
|
947807
|
+
};
|
|
947808
|
+
appendStringIfPresent(tags, "event", event.event);
|
|
947809
|
+
appendStringIfPresent(tags, "action", context3.action);
|
|
947810
|
+
appendStringIfPresent(tags, "run_id", context3.run_id);
|
|
947811
|
+
appendStringIfPresent(tags, "org", context3.org);
|
|
947812
|
+
appendStringIfPresent(tags, "config_repo", context3.config_repo);
|
|
947813
|
+
appendStringIfPresent(tags, "trigger", context3.trigger);
|
|
947814
|
+
appendStringIfPresent(tags, "error_code", event.errorCode ?? "none");
|
|
947815
|
+
return tags;
|
|
947816
|
+
}
|
|
947817
|
+
function toSentryContext(event, context3) {
|
|
947818
|
+
return {
|
|
947819
|
+
github_run_id: context3.github_run_id,
|
|
947820
|
+
github_run_url: context3.github_run_url,
|
|
947821
|
+
config_commit_sha: context3.config_commit_sha,
|
|
947822
|
+
config_branch: context3.config_branch,
|
|
947823
|
+
config_pr_number: context3.config_pr_number,
|
|
947824
|
+
cli_version: context3.cli_version,
|
|
947825
|
+
...event.attributes ?? {}
|
|
947826
|
+
};
|
|
947827
|
+
}
|
|
947828
|
+
function toAutomationEventApiBody(event, context3) {
|
|
947829
|
+
return {
|
|
947830
|
+
event: event.event,
|
|
947831
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
947832
|
+
surface: "cli",
|
|
947833
|
+
action: context3.action,
|
|
947834
|
+
run_id: context3.run_id,
|
|
947835
|
+
github_run_id: context3.github_run_id,
|
|
947836
|
+
github_run_url: context3.github_run_url,
|
|
947837
|
+
org: context3.org,
|
|
947838
|
+
config_repo: context3.config_repo,
|
|
947839
|
+
config_commit_sha: context3.config_commit_sha,
|
|
947840
|
+
config_branch: context3.config_branch,
|
|
947841
|
+
config_pr_number: context3.config_pr_number,
|
|
947842
|
+
trigger: context3.trigger,
|
|
947843
|
+
cli_version: context3.cli_version,
|
|
947844
|
+
...event.errorCode !== void 0 ? { error_code: event.errorCode } : {},
|
|
947845
|
+
...event.attributes ?? {}
|
|
947846
|
+
};
|
|
947847
|
+
}
|
|
947848
|
+
function failureEventNameForCommand(argv) {
|
|
947849
|
+
const joined = argv.join(" ");
|
|
947850
|
+
if (/\bautomations\s+generate\b/.test(joined)) {
|
|
947851
|
+
return AUTOMATION_EVENT_NAMES.GENERATION_FAILED;
|
|
947852
|
+
}
|
|
947853
|
+
if (/\bautomations\s+preview\b/.test(joined)) {
|
|
947854
|
+
return AUTOMATION_EVENT_NAMES.VERIFICATION_FAILED;
|
|
947855
|
+
}
|
|
947856
|
+
return AUTOMATION_EVENT_NAMES.GENERATION_FAILED;
|
|
947857
|
+
}
|
|
947858
|
+
|
|
947859
|
+
// src/telemetry/AutomationEventApiClient.ts
|
|
947860
|
+
var DEFAULT_AUTOMATION_EVENTS_ORIGIN = "";
|
|
947861
|
+
var AUTOMATION_EVENTS_ORIGIN_ENV_VAR = "FERN_AUTOMATION_EVENTS_ORIGIN";
|
|
947862
|
+
var POST_TIMEOUT_MS = 3e3;
|
|
947863
|
+
var AutomationEventApiClient = class _AutomationEventApiClient {
|
|
947864
|
+
static instance;
|
|
947865
|
+
origin;
|
|
947866
|
+
inflight = [];
|
|
947867
|
+
static getInstance() {
|
|
947868
|
+
if (_AutomationEventApiClient.instance == null) {
|
|
947869
|
+
_AutomationEventApiClient.instance = new _AutomationEventApiClient(
|
|
947870
|
+
process.env[AUTOMATION_EVENTS_ORIGIN_ENV_VAR] ?? DEFAULT_AUTOMATION_EVENTS_ORIGIN
|
|
947871
|
+
);
|
|
947872
|
+
}
|
|
947873
|
+
return _AutomationEventApiClient.instance;
|
|
947874
|
+
}
|
|
947875
|
+
constructor(origin2) {
|
|
947876
|
+
this.origin = origin2;
|
|
947877
|
+
}
|
|
947878
|
+
/**
|
|
947879
|
+
* Resolves the automation event API endpoint from the baked origin.
|
|
947880
|
+
* Returns undefined when no origin is configured - callers silently skip
|
|
947881
|
+
* the POST in that case.
|
|
947882
|
+
*/
|
|
947883
|
+
resolveEndpoint() {
|
|
947884
|
+
if (this.origin.length === 0) {
|
|
947885
|
+
return void 0;
|
|
947886
|
+
}
|
|
947887
|
+
return `${this.origin.replace(/\/$/, "")}/v1/automation/events`;
|
|
947888
|
+
}
|
|
947889
|
+
/**
|
|
947890
|
+
* Enqueues an automation event POST to the automation event API.
|
|
947891
|
+
*
|
|
947892
|
+
* Best-effort: on any failure (timeout, DNS, non-2xx, missing endpoint),
|
|
947893
|
+
* the request settles without throwing. Sentry + PostHog already captured
|
|
947894
|
+
* the incident.
|
|
947895
|
+
*/
|
|
947896
|
+
post(event, context3) {
|
|
947897
|
+
this.inflight.push(this.send(event, context3));
|
|
947898
|
+
}
|
|
947899
|
+
async shutdown() {
|
|
947900
|
+
const pending = this.inflight;
|
|
947901
|
+
this.inflight = [];
|
|
947902
|
+
if (pending.length > 0) {
|
|
947903
|
+
await Promise.allSettled(pending);
|
|
947904
|
+
}
|
|
947905
|
+
}
|
|
947906
|
+
async send(event, context3) {
|
|
947907
|
+
const endpoint3 = this.resolveEndpoint();
|
|
947908
|
+
if (endpoint3 == null) {
|
|
947909
|
+
return;
|
|
947910
|
+
}
|
|
947911
|
+
const controller = new AbortController();
|
|
947912
|
+
const timer2 = setTimeout(() => controller.abort(), POST_TIMEOUT_MS);
|
|
947913
|
+
try {
|
|
947914
|
+
const headers2 = { "content-type": "application/json" };
|
|
947915
|
+
const token = await getAccessToken();
|
|
947916
|
+
if (token != null && token.value.length > 0) {
|
|
947917
|
+
headers2.Authorization = `Bearer ${token.value}`;
|
|
947918
|
+
}
|
|
947919
|
+
const response = await fetch(endpoint3, {
|
|
947920
|
+
method: "POST",
|
|
947921
|
+
headers: headers2,
|
|
947922
|
+
body: JSON.stringify(toAutomationEventApiBody(event, context3)),
|
|
947923
|
+
signal: controller.signal
|
|
947924
|
+
});
|
|
947925
|
+
void response;
|
|
947926
|
+
} catch {
|
|
947927
|
+
return;
|
|
947928
|
+
} finally {
|
|
947929
|
+
clearTimeout(timer2);
|
|
947930
|
+
}
|
|
947931
|
+
}
|
|
947932
|
+
};
|
|
947933
|
+
|
|
947934
|
+
// src/telemetry/automationTelemetryContext.ts
|
|
947935
|
+
function getAutomationContextFromEnv() {
|
|
947936
|
+
const { fern_run_id, github_run_id } = getRunIdProperties();
|
|
947937
|
+
return {
|
|
947938
|
+
action: process.env.FERN_ACTION,
|
|
947939
|
+
run_id: fern_run_id,
|
|
947940
|
+
github_run_id,
|
|
947941
|
+
github_run_url: process.env.FERN_GITHUB_RUN_URL,
|
|
947942
|
+
org: void 0,
|
|
947943
|
+
config_repo: process.env.FERN_CONFIG_REPO,
|
|
947944
|
+
config_commit_sha: process.env.FERN_CONFIG_COMMIT_SHA,
|
|
947945
|
+
config_branch: process.env.FERN_CONFIG_BRANCH,
|
|
947946
|
+
config_pr_number: process.env.FERN_CONFIG_PR_NUMBER,
|
|
947947
|
+
trigger: process.env.GITHUB_EVENT_NAME,
|
|
947948
|
+
cli_version: "5.23.3-99-g2ce21a4a41d"
|
|
947949
|
+
};
|
|
947950
|
+
}
|
|
947951
|
+
function isAutomationMode() {
|
|
947952
|
+
return process.env.FERN_AUTOMATION === "true";
|
|
947953
|
+
}
|
|
947954
|
+
|
|
947955
|
+
// src/telemetry/AutomationTelemetryManager.ts
|
|
947956
|
+
var AutomationTelemetryManager = class {
|
|
947957
|
+
constructor(reporter, automationEventApiClient = AutomationEventApiClient.getInstance()) {
|
|
947958
|
+
this.reporter = reporter;
|
|
947959
|
+
this.automationEventApiClient = automationEventApiClient;
|
|
947960
|
+
this.context = getAutomationContextFromEnv();
|
|
947961
|
+
}
|
|
947962
|
+
reporter;
|
|
947963
|
+
automationEventApiClient;
|
|
947964
|
+
context;
|
|
947965
|
+
setOrganization(organization) {
|
|
947966
|
+
this.context = { ...this.context, org: organization };
|
|
947967
|
+
}
|
|
947968
|
+
emit(event, options2) {
|
|
947969
|
+
const sentryEventId = this.captureSentryForFailure({
|
|
947970
|
+
event,
|
|
947971
|
+
context: this.context,
|
|
947972
|
+
error: options2?.error
|
|
947973
|
+
});
|
|
947974
|
+
const eventWithSentry = sentryEventId == null ? event : { ...event, attributes: { ...event.attributes ?? {}, sentry_event_id: sentryEventId } };
|
|
947975
|
+
this.capturePostHogEvent({ event: eventWithSentry, context: this.context });
|
|
947976
|
+
this.captureAutomationEventApiEvent(eventWithSentry, this.context);
|
|
947977
|
+
}
|
|
947978
|
+
async flush() {
|
|
947979
|
+
await this.automationEventApiClient.shutdown();
|
|
947980
|
+
}
|
|
947981
|
+
capturePostHogEvent({
|
|
947982
|
+
event,
|
|
947983
|
+
context: context3
|
|
947984
|
+
}) {
|
|
947985
|
+
this.reporter.instrumentPostHogAutomationEvent({
|
|
947986
|
+
distinctId: context3.run_id ?? void 0,
|
|
947987
|
+
event: event.event,
|
|
947988
|
+
properties: toPosthogProperties(event, context3)
|
|
947989
|
+
});
|
|
947990
|
+
}
|
|
947991
|
+
captureSentryForFailure({
|
|
947992
|
+
event,
|
|
947993
|
+
context: context3,
|
|
947994
|
+
error: error50
|
|
947995
|
+
}) {
|
|
947996
|
+
if (!isFailureAutomationEventName(event.event) || event.errorCode == null) {
|
|
947997
|
+
return void 0;
|
|
947998
|
+
}
|
|
947999
|
+
return this.reporter.captureException(error50, {
|
|
948000
|
+
tags: toSentryTags(event, context3),
|
|
948001
|
+
context: {
|
|
948002
|
+
automation: toSentryContext(event, context3)
|
|
948003
|
+
}
|
|
948004
|
+
});
|
|
948005
|
+
}
|
|
948006
|
+
captureAutomationEventApiEvent(event, context3) {
|
|
948007
|
+
this.automationEventApiClient.post(event, context3);
|
|
948008
|
+
}
|
|
948009
|
+
};
|
|
948010
|
+
|
|
947731
948011
|
// src/telemetry/reportError.ts
|
|
947732
948012
|
init_lib6();
|
|
947733
948013
|
function reportError2(reporter, error50, options2) {
|
|
@@ -947735,17 +948015,47 @@ function reportError2(reporter, error50, options2) {
|
|
|
947735
948015
|
return;
|
|
947736
948016
|
}
|
|
947737
948017
|
const code5 = resolveErrorCode(error50, options2?.code);
|
|
948018
|
+
const argv = options2?.argv ?? process.argv;
|
|
948019
|
+
const command3 = argv.join(" ");
|
|
948020
|
+
const errorMessage = options2?.message ?? (error50 instanceof Error ? error50.message : void 0) ?? "";
|
|
948021
|
+
const reportedError = error50 ?? new CliError({ message: errorMessage, code: code5 });
|
|
948022
|
+
if (isAutomationMode()) {
|
|
948023
|
+
reportErrorForAutomationMode(argv, reporter, code5, errorMessage, reportedError);
|
|
948024
|
+
} else {
|
|
948025
|
+
reportErrorForNormalMode(reporter, command3, code5, reportedError);
|
|
948026
|
+
}
|
|
948027
|
+
}
|
|
948028
|
+
function reportErrorForNormalMode(reporter, command3, code5, reportedError) {
|
|
947738
948029
|
reporter.instrumentPostHogEvent({
|
|
947739
|
-
command:
|
|
948030
|
+
command: command3,
|
|
947740
948031
|
properties: {
|
|
947741
948032
|
failed: true,
|
|
947742
948033
|
errorCode: code5
|
|
947743
948034
|
}
|
|
947744
948035
|
});
|
|
947745
948036
|
if (shouldReportToSentry(code5)) {
|
|
947746
|
-
reporter.captureException(
|
|
948037
|
+
reporter.captureException(reportedError, {
|
|
948038
|
+
tags: {
|
|
948039
|
+
"error.code": code5
|
|
948040
|
+
}
|
|
948041
|
+
});
|
|
947747
948042
|
}
|
|
947748
948043
|
}
|
|
948044
|
+
function reportErrorForAutomationMode(argv, reporter, code5, errorMessage, reportedError) {
|
|
948045
|
+
const failureEventName = failureEventNameForCommand(argv);
|
|
948046
|
+
reporter.emitAutomationTelemetryEvent(
|
|
948047
|
+
{
|
|
948048
|
+
event: failureEventName,
|
|
948049
|
+
errorCode: code5,
|
|
948050
|
+
attributes: {
|
|
948051
|
+
error_message: errorMessage
|
|
948052
|
+
}
|
|
948053
|
+
},
|
|
948054
|
+
{
|
|
948055
|
+
error: reportedError
|
|
948056
|
+
}
|
|
948057
|
+
);
|
|
948058
|
+
}
|
|
947749
948059
|
|
|
947750
948060
|
// src/telemetry/SentryClient.ts
|
|
947751
948061
|
init_lib6();
|
|
@@ -947755,12 +948065,26 @@ function isTelemetryDisabled() {
|
|
|
947755
948065
|
return process.env.FERN_DISABLE_TELEMETRY === "true";
|
|
947756
948066
|
}
|
|
947757
948067
|
|
|
948068
|
+
// src/telemetry/shouldInitializeTelemetry.ts
|
|
948069
|
+
function shouldInitializeTelemetry({
|
|
948070
|
+
cliName,
|
|
948071
|
+
packageVersion: packageVersion3,
|
|
948072
|
+
isLocal
|
|
948073
|
+
}) {
|
|
948074
|
+
if (isTelemetryDisabled() || isLocal) {
|
|
948075
|
+
return false;
|
|
948076
|
+
}
|
|
948077
|
+
const isLocalDev = packageVersion3 === "0.0.0";
|
|
948078
|
+
const isProductionCli = cliName === "fern" && false;
|
|
948079
|
+
return !isLocalDev && isProductionCli;
|
|
948080
|
+
}
|
|
948081
|
+
|
|
947758
948082
|
// src/telemetry/SentryClient.ts
|
|
947759
948083
|
var SentryClient = class {
|
|
947760
948084
|
sentry;
|
|
947761
|
-
constructor({ release: release2 }) {
|
|
948085
|
+
constructor({ release: release2, telemetry }) {
|
|
947762
948086
|
const sentryDsn = "https://84f58b5e457f06999d92f11ce4b79158@o4509504076185600.ingest.us.sentry.io/4511021546602496";
|
|
947763
|
-
if (
|
|
948087
|
+
if (shouldInitializeTelemetry(telemetry) && sentryDsn != null && sentryDsn.length > 0) {
|
|
947764
948088
|
const sentryEnvironment = "development";
|
|
947765
948089
|
if (sentryEnvironment == null || sentryEnvironment.length === 0) {
|
|
947766
948090
|
throw new CliError({
|
|
@@ -947803,16 +948127,33 @@ var SentryClient = class {
|
|
|
947803
948127
|
setSentryRunIdTags();
|
|
947804
948128
|
}
|
|
947805
948129
|
}
|
|
947806
|
-
captureException(error50,
|
|
948130
|
+
captureException(error50, options2) {
|
|
947807
948131
|
if (this.sentry == null) {
|
|
947808
|
-
return;
|
|
948132
|
+
return void 0;
|
|
947809
948133
|
}
|
|
947810
948134
|
try {
|
|
947811
|
-
|
|
947812
|
-
|
|
947813
|
-
|
|
947814
|
-
);
|
|
948135
|
+
const tags = options2?.tags;
|
|
948136
|
+
const context3 = options2?.context;
|
|
948137
|
+
const hasTags = tags != null && Object.keys(tags).length > 0;
|
|
948138
|
+
const hasContext = context3 != null && Object.values(context3).some((value2) => value2 != null);
|
|
948139
|
+
if (!hasTags && !hasContext) {
|
|
948140
|
+
return this.sentry.captureException(error50);
|
|
948141
|
+
}
|
|
948142
|
+
return withScope2((scope) => {
|
|
948143
|
+
if (hasTags) {
|
|
948144
|
+
scope.setTags(tags);
|
|
948145
|
+
}
|
|
948146
|
+
if (context3 != null) {
|
|
948147
|
+
for (const [key2, value2] of Object.entries(context3)) {
|
|
948148
|
+
if (value2 != null) {
|
|
948149
|
+
scope.setContext(key2, value2);
|
|
948150
|
+
}
|
|
948151
|
+
}
|
|
948152
|
+
}
|
|
948153
|
+
return this.sentry?.captureException(error50, void 0, scope);
|
|
948154
|
+
});
|
|
947815
948155
|
} catch {
|
|
948156
|
+
return void 0;
|
|
947816
948157
|
}
|
|
947817
948158
|
}
|
|
947818
948159
|
async flush() {
|
|
@@ -947878,6 +948219,7 @@ var TaskContextImpl = class {
|
|
|
947878
948219
|
onResult;
|
|
947879
948220
|
instrumentPostHogEventImpl;
|
|
947880
948221
|
captureExceptionImpl;
|
|
948222
|
+
emitAutomationTelemetryEventImpl;
|
|
947881
948223
|
constructor({
|
|
947882
948224
|
logImmediately,
|
|
947883
948225
|
logPrefix,
|
|
@@ -947886,7 +948228,8 @@ var TaskContextImpl = class {
|
|
|
947886
948228
|
onResult,
|
|
947887
948229
|
shouldBufferLogs,
|
|
947888
948230
|
instrumentPostHogEvent,
|
|
947889
|
-
captureException: captureException2
|
|
948231
|
+
captureException: captureException2,
|
|
948232
|
+
emitAutomationTelemetryEvent
|
|
947890
948233
|
}) {
|
|
947891
948234
|
this.logImmediately = logImmediately;
|
|
947892
948235
|
this.logPrefix = logPrefix ?? "";
|
|
@@ -947896,6 +948239,7 @@ var TaskContextImpl = class {
|
|
|
947896
948239
|
this.shouldBufferLogs = shouldBufferLogs;
|
|
947897
948240
|
this.instrumentPostHogEventImpl = instrumentPostHogEvent;
|
|
947898
948241
|
this.captureExceptionImpl = captureException2;
|
|
948242
|
+
this.emitAutomationTelemetryEventImpl = emitAutomationTelemetryEvent;
|
|
947899
948243
|
}
|
|
947900
948244
|
start() {
|
|
947901
948245
|
this.status = "running";
|
|
@@ -947935,8 +948279,11 @@ var TaskContextImpl = class {
|
|
|
947935
948279
|
getLastFailureMessage() {
|
|
947936
948280
|
return this.lastFailureMessage;
|
|
947937
948281
|
}
|
|
947938
|
-
captureException(error50,
|
|
947939
|
-
this.captureExceptionImpl?.(error50,
|
|
948282
|
+
captureException(error50, options2) {
|
|
948283
|
+
return this.captureExceptionImpl?.(error50, options2);
|
|
948284
|
+
}
|
|
948285
|
+
emitAutomationTelemetryEvent(event, options2) {
|
|
948286
|
+
this.emitAutomationTelemetryEventImpl(event, options2);
|
|
947940
948287
|
}
|
|
947941
948288
|
getResult() {
|
|
947942
948289
|
return this.result;
|
|
@@ -947979,7 +948326,8 @@ var TaskContextImpl = class {
|
|
|
947979
948326
|
onResult: this.onResult,
|
|
947980
948327
|
shouldBufferLogs: this.shouldBufferLogs,
|
|
947981
948328
|
instrumentPostHogEvent: (event) => this.instrumentPostHogEventImpl(event),
|
|
947982
|
-
captureException: this.captureExceptionImpl
|
|
948329
|
+
captureException: this.captureExceptionImpl,
|
|
948330
|
+
emitAutomationTelemetryEvent: this.emitAutomationTelemetryEventImpl
|
|
947983
948331
|
});
|
|
947984
948332
|
this.subtasks.push(subtask);
|
|
947985
948333
|
return subtask;
|
|
@@ -948376,6 +948724,7 @@ var CliContext = class _CliContext {
|
|
|
948376
948724
|
environment;
|
|
948377
948725
|
sentryClient;
|
|
948378
948726
|
posthogManager;
|
|
948727
|
+
automationTelemetryManager;
|
|
948379
948728
|
didSucceed = true;
|
|
948380
948729
|
numTasks = 0;
|
|
948381
948730
|
ttyAwareLogger;
|
|
@@ -948402,7 +948751,15 @@ var CliContext = class _CliContext {
|
|
|
948402
948751
|
packageVersion: packageVersion3,
|
|
948403
948752
|
cliName
|
|
948404
948753
|
};
|
|
948405
|
-
this.sentryClient = new SentryClient({
|
|
948754
|
+
this.sentryClient = new SentryClient({
|
|
948755
|
+
release: `cli@${this.environment.packageVersion}`,
|
|
948756
|
+
telemetry: {
|
|
948757
|
+
cliName: this.environment.cliName,
|
|
948758
|
+
packageVersion: this.environment.packageVersion,
|
|
948759
|
+
isLocal: this.isLocal
|
|
948760
|
+
}
|
|
948761
|
+
});
|
|
948762
|
+
this.automationTelemetryManager = new AutomationTelemetryManager(this);
|
|
948406
948763
|
}
|
|
948407
948764
|
getPackageName() {
|
|
948408
948765
|
if (false) {
|
|
@@ -948414,7 +948771,7 @@ var CliContext = class _CliContext {
|
|
|
948414
948771
|
if (false) {
|
|
948415
948772
|
this.logger.error("CLI_VERSION is not defined");
|
|
948416
948773
|
}
|
|
948417
|
-
return "5.23.3-
|
|
948774
|
+
return "5.23.3-99-g2ce21a4a41d";
|
|
948418
948775
|
}
|
|
948419
948776
|
getCliName() {
|
|
948420
948777
|
if (false) {
|
|
@@ -948479,6 +948836,7 @@ var CliContext = class _CliContext {
|
|
|
948479
948836
|
} catch {
|
|
948480
948837
|
}
|
|
948481
948838
|
await this.sentryClient.flush();
|
|
948839
|
+
await this.automationTelemetryManager.flush();
|
|
948482
948840
|
this.exitProgram({ code: code5 });
|
|
948483
948841
|
}
|
|
948484
948842
|
async nudgeUpgradeIfAvailable() {
|
|
@@ -948521,6 +948879,7 @@ var CliContext = class _CliContext {
|
|
|
948521
948879
|
project;
|
|
948522
948880
|
registerProject(project) {
|
|
948523
948881
|
this.project = project;
|
|
948882
|
+
this.automationTelemetryManager.setOrganization(project.config.organization);
|
|
948524
948883
|
}
|
|
948525
948884
|
runTask(run) {
|
|
948526
948885
|
return this.runTaskWithInit(this.constructTaskInit(), run);
|
|
@@ -948555,8 +948914,16 @@ var CliContext = class _CliContext {
|
|
|
948555
948914
|
this.posthogManager.sendEvent(event);
|
|
948556
948915
|
}
|
|
948557
948916
|
}
|
|
948558
|
-
|
|
948559
|
-
this.
|
|
948917
|
+
instrumentPostHogAutomationEvent(event) {
|
|
948918
|
+
if (!this.isLocal) {
|
|
948919
|
+
this.posthogManager.sendAutomationEvent(event);
|
|
948920
|
+
}
|
|
948921
|
+
}
|
|
948922
|
+
captureException(error50, options2) {
|
|
948923
|
+
return this.sentryClient.captureException(error50, options2);
|
|
948924
|
+
}
|
|
948925
|
+
emitAutomationTelemetryEvent(event, options2) {
|
|
948926
|
+
this.automationTelemetryManager.emit(event, options2);
|
|
948560
948927
|
}
|
|
948561
948928
|
logger = createLogger((level, ...args) => this.log(level, ...args));
|
|
948562
948929
|
stderr = createLogger((level, ...args) => this.logStderr(level, ...args));
|
|
@@ -948586,9 +948953,8 @@ var CliContext = class _CliContext {
|
|
|
948586
948953
|
this.instrumentPostHogEvent(event);
|
|
948587
948954
|
},
|
|
948588
948955
|
shouldBufferLogs: false,
|
|
948589
|
-
captureException: (error50,
|
|
948590
|
-
|
|
948591
|
-
}
|
|
948956
|
+
captureException: (error50, options2) => this.sentryClient.captureException(error50, options2),
|
|
948957
|
+
emitAutomationTelemetryEvent: (event, options2) => this.emitAutomationTelemetryEvent(event, options2)
|
|
948592
948958
|
};
|
|
948593
948959
|
}
|
|
948594
948960
|
log(level, ...parts) {
|
|
@@ -967784,6 +968150,40 @@ function evaluateRuntime4() {
|
|
|
967784
968150
|
};
|
|
967785
968151
|
}
|
|
967786
968152
|
|
|
968153
|
+
// src/telemetry/processHandlers.ts
|
|
968154
|
+
init_lib6();
|
|
968155
|
+
function installProcessHandlers(cliContext, { isLocal }) {
|
|
968156
|
+
if (!shouldInitializeTelemetry({
|
|
968157
|
+
cliName: cliContext.environment.cliName,
|
|
968158
|
+
packageVersion: cliContext.environment.packageVersion,
|
|
968159
|
+
isLocal
|
|
968160
|
+
})) {
|
|
968161
|
+
return;
|
|
968162
|
+
}
|
|
968163
|
+
let isHandlingFatal = false;
|
|
968164
|
+
const handleFatal = async (label, error50) => {
|
|
968165
|
+
if (isHandlingFatal) {
|
|
968166
|
+
process.exit(1);
|
|
968167
|
+
}
|
|
968168
|
+
isHandlingFatal = true;
|
|
968169
|
+
try {
|
|
968170
|
+
cliContext.failWithoutThrowing(label, error50, { code: CliError.Code.InternalError });
|
|
968171
|
+
} catch {
|
|
968172
|
+
}
|
|
968173
|
+
try {
|
|
968174
|
+
await cliContext.exit({ code: 1 });
|
|
968175
|
+
} catch {
|
|
968176
|
+
process.exit(1);
|
|
968177
|
+
}
|
|
968178
|
+
};
|
|
968179
|
+
process.on("uncaughtException", (error50) => {
|
|
968180
|
+
void handleFatal("uncaught exception", error50);
|
|
968181
|
+
});
|
|
968182
|
+
process.on("unhandledRejection", (reason) => {
|
|
968183
|
+
void handleFatal("unhandled promise rejection", reason);
|
|
968184
|
+
});
|
|
968185
|
+
}
|
|
968186
|
+
|
|
967787
968187
|
// src/cli.ts
|
|
967788
968188
|
if (process.platform === "linux" && parseInt(process.versions.node.split(".")[0] ?? "0", 10) >= 26 && process.env.UV_USE_IO_URING !== "0") {
|
|
967789
968189
|
const result = (0, import_node_child_process7.spawnSync)(process.execPath, process.argv.slice(1), {
|
|
@@ -967806,6 +968206,7 @@ async function runCli() {
|
|
|
967806
968206
|
if (isCompletion) {
|
|
967807
968207
|
cliContext.suppressUpgradeMessage();
|
|
967808
968208
|
}
|
|
968209
|
+
installProcessHandlers(cliContext, { isLocal });
|
|
967809
968210
|
const exit3 = async () => {
|
|
967810
968211
|
await cliContext.exit();
|
|
967811
968212
|
};
|
package/package.json
CHANGED