eas-cli 27.1.0 → 27.2.0
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/README.md +221 -146
- package/build/analytics/AnalyticsManager.d.ts +2 -0
- package/build/analytics/AnalyticsManager.js +2 -0
- package/build/build/build.d.ts +1 -2
- package/build/build/build.js +3 -4
- package/build/build/freeTierNearLimitAgentUpdatesTip.d.ts +98 -0
- package/build/build/freeTierNearLimitAgentUpdatesTip.js +205 -0
- package/build/build/runBuildAndSubmit.d.ts +2 -0
- package/build/build/runBuildAndSubmit.js +3 -0
- package/build/build/simulatorsLaunchHint.d.ts +7 -0
- package/build/build/simulatorsLaunchHint.js +40 -0
- package/build/commands/build/index.js +8 -1
- package/build/commands/observe/session.js +4 -3
- package/build/commands/observe/trace.d.ts +17 -0
- package/build/commands/observe/trace.js +58 -0
- package/build/commands/observe/traces.d.ts +33 -0
- package/build/commands/observe/traces.js +159 -0
- package/build/graphql/generated.d.ts +404 -0
- package/build/graphql/mutations/UserPreferenceMutation.d.ts +5 -0
- package/build/graphql/mutations/UserPreferenceMutation.js +24 -0
- package/build/graphql/queries/AccountQuery.d.ts +3 -1
- package/build/graphql/queries/AccountQuery.js +54 -0
- package/build/graphql/queries/ObserveQuery.d.ts +24 -1
- package/build/graphql/queries/ObserveQuery.js +114 -1
- package/build/graphql/queries/UserPreferenceQuery.d.ts +8 -0
- package/build/graphql/queries/UserPreferenceQuery.js +28 -0
- package/build/graphql/types/Observe.d.ts +1 -0
- package/build/graphql/types/Observe.js +53 -1
- package/build/observe/fetchSessions.d.ts +12 -1
- package/build/observe/fetchSessions.js +39 -2
- package/build/observe/fetchSpans.d.ts +27 -0
- package/build/observe/fetchSpans.js +36 -0
- package/build/observe/formatSessions.d.ts +3 -1
- package/build/observe/formatSessions.js +40 -3
- package/build/observe/formatSpans.d.ts +110 -0
- package/build/observe/formatSpans.js +250 -0
- package/build/observe/spanFilters.d.ts +5 -0
- package/build/observe/spanFilters.js +32 -0
- package/oclif.manifest.json +352 -2
- package/package.json +6 -6
- package/build/build/freeTierLimitGuidance.d.ts +0 -19
- package/build/build/freeTierLimitGuidance.js +0 -39
|
@@ -42,6 +42,8 @@ export declare enum BuildEvent {
|
|
|
42
42
|
BUILD_REQUEST_SUCCESS = "build cli build request success",
|
|
43
43
|
BUILD_REQUEST_FAIL = "build cli build request fail",
|
|
44
44
|
FREE_TIER_LIMIT_CHECKOUT_PROMPT = "build cli free tier limit checkout prompt",
|
|
45
|
+
FREE_TIER_NEAR_LIMIT_AGENT_UPDATES_TIP = "build cli free tier near limit agent updates tip",
|
|
46
|
+
SIMULATORS_LAUNCH_HINT_SHOWN = "build cli simulators launch hint shown",
|
|
45
47
|
BUILD_STATUS_COMMAND = "build cli build status",
|
|
46
48
|
CREDENTIALS_SYNC_COMMAND = "build cli credentials sync command",
|
|
47
49
|
CREDENTIALS_SYNC_UPDATE_LOCAL_ATTEMPT = "build cli credentials sync update local attempt",
|
|
@@ -67,6 +67,8 @@ var BuildEvent;
|
|
|
67
67
|
BuildEvent["BUILD_REQUEST_SUCCESS"] = "build cli build request success";
|
|
68
68
|
BuildEvent["BUILD_REQUEST_FAIL"] = "build cli build request fail";
|
|
69
69
|
BuildEvent["FREE_TIER_LIMIT_CHECKOUT_PROMPT"] = "build cli free tier limit checkout prompt";
|
|
70
|
+
BuildEvent["FREE_TIER_NEAR_LIMIT_AGENT_UPDATES_TIP"] = "build cli free tier near limit agent updates tip";
|
|
71
|
+
BuildEvent["SIMULATORS_LAUNCH_HINT_SHOWN"] = "build cli simulators launch hint shown";
|
|
70
72
|
BuildEvent["BUILD_STATUS_COMMAND"] = "build cli build status";
|
|
71
73
|
BuildEvent["CREDENTIALS_SYNC_COMMAND"] = "build cli credentials sync command";
|
|
72
74
|
BuildEvent["CREDENTIALS_SYNC_UPDATE_LOCAL_ATTEMPT"] = "build cli credentials sync update local attempt";
|
package/build/build/build.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { ArchiveSource, BuildJob, Platform } from '@expo/eas-build-job';
|
|
|
2
2
|
import { CredentialsSource } from '@expo/eas-json';
|
|
3
3
|
import { BuildContext } from './context';
|
|
4
4
|
import { FreeTierLimitCheckoutExperiment } from './freeTierLimitCheckout';
|
|
5
|
-
import { FreeTierLimitAgentGuidanceExperiment } from './freeTierLimitGuidance';
|
|
6
5
|
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
|
7
6
|
import { BuildFragment, BuildMetadataInput, BuildParamsInput } from '../graphql/generated';
|
|
8
7
|
import { BuildResult } from '../graphql/mutations/BuildMutation';
|
|
@@ -23,7 +22,7 @@ interface Builder<TPlatform extends Platform, Credentials, TJob extends BuildJob
|
|
|
23
22
|
}
|
|
24
23
|
export type BuildRequestSender = () => Promise<BuildFragment | undefined>;
|
|
25
24
|
export declare function prepareBuildRequestForPlatformAsync<TPlatform extends Platform, Credentials, TJob extends BuildJob>(builder: Builder<TPlatform, Credentials, TJob>): Promise<BuildRequestSender>;
|
|
26
|
-
export declare function handleBuildRequestErrorAsync(error: any, platform: Platform, accountName?: string,
|
|
25
|
+
export declare function handleBuildRequestErrorAsync(error: any, platform: Platform, accountName?: string, freeTierLimitCheckoutExperiment?: FreeTierLimitCheckoutExperiment): Promise<never>;
|
|
27
26
|
export type MaybeBuildFragment = BuildFragment | null;
|
|
28
27
|
export declare function waitForBuildEndAsync(graphqlClient: ExpoGraphqlClient, { buildIds, accountName }: {
|
|
29
28
|
buildIds: string[];
|
package/build/build/build.js
CHANGED
|
@@ -12,7 +12,6 @@ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
|
12
12
|
const nullthrows_1 = tslib_1.__importDefault(require("nullthrows"));
|
|
13
13
|
const errors_1 = require("./errors");
|
|
14
14
|
const freeTierLimitCheckout_1 = require("./freeTierLimitCheckout");
|
|
15
|
-
const freeTierLimitGuidance_1 = require("./freeTierLimitGuidance");
|
|
16
15
|
const graphql_1 = require("./graphql");
|
|
17
16
|
const local_1 = require("./local");
|
|
18
17
|
const logs_1 = require("./logs");
|
|
@@ -125,7 +124,7 @@ async function prepareBuildRequestForPlatformAsync(builder) {
|
|
|
125
124
|
return await sendBuildRequestAsync(builder, job, graphqlMetadata, buildParams);
|
|
126
125
|
}
|
|
127
126
|
catch (error) {
|
|
128
|
-
return await handleBuildRequestErrorAsync(error, job.platform, ctx.accountName, (0,
|
|
127
|
+
return await handleBuildRequestErrorAsync(error, job.platform, ctx.accountName, (0, freeTierLimitCheckout_1.getFreeTierLimitCheckoutExperiment)(ctx));
|
|
129
128
|
}
|
|
130
129
|
}
|
|
131
130
|
else {
|
|
@@ -144,7 +143,7 @@ const SERVER_SIDE_DEFINED_ERRORS = {
|
|
|
144
143
|
EAS_BUILD_LEGACY_RESOURCE_CLASS_NOT_AVAILABLE: errors_1.EasBuildLegacyResourceClassNotAvailableError,
|
|
145
144
|
VALIDATION_ERROR: errors_1.RequestValidationError,
|
|
146
145
|
};
|
|
147
|
-
async function handleBuildRequestErrorAsync(error, platform, accountName,
|
|
146
|
+
async function handleBuildRequestErrorAsync(error, platform, accountName, freeTierLimitCheckoutExperiment) {
|
|
148
147
|
logBuildRequestErrorDebugInfo(error);
|
|
149
148
|
const graphQLErrors = Array.isArray(error?.graphQLErrors)
|
|
150
149
|
? error.graphQLErrors
|
|
@@ -158,7 +157,7 @@ async function handleBuildRequestErrorAsync(error, platform, accountName, freeTi
|
|
|
158
157
|
if (!isFreeTierLimitError) {
|
|
159
158
|
throw new ErrorClass(message);
|
|
160
159
|
}
|
|
161
|
-
const limitMessage =
|
|
160
|
+
const limitMessage = `${message}\nRun ${(0, plans_1.formatStarterSubscribeCommand)(accountName)} to upgrade to the Starter plan.`;
|
|
162
161
|
const messageAlreadyPrinted = await (0, freeTierLimitCheckout_1.maybeOfferFreeTierLimitCheckoutAsync)(limitMessage, freeTierLimitCheckoutExperiment);
|
|
163
162
|
throw new ErrorClass(limitMessage, { messageAlreadyPrinted });
|
|
164
163
|
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ExpoConfig } from '@expo/config';
|
|
2
|
+
import { Analytics, AnalyticsEventProperties } from '../analytics/AnalyticsManager';
|
|
3
|
+
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
|
4
|
+
import { LazyExperimentationClient } from '../experimentation/LazyExperimentationClient';
|
|
5
|
+
import { AppPlatform, BuildFragment } from '../graphql/generated';
|
|
6
|
+
import { LoggedInAuthenticationInfo } from '../user/SessionManager';
|
|
7
|
+
import { Actor } from '../user/User';
|
|
8
|
+
export declare const FREE_TIER_NEAR_LIMIT_AGENT_UPDATES_TIP_EXPERIMENT_NAMESPACE = "cli-build-free-tier-near-limit-agent-updates-tip";
|
|
9
|
+
/** The tip shows when this many builds or fewer are left on the platform. */
|
|
10
|
+
export declare const FREE_TIER_NEAR_LIMIT_AGENT_UPDATES_TIP_BUILDS_LEFT = 5;
|
|
11
|
+
export declare const EAS_UPDATE_GETTING_STARTED_URL = "https://docs.expo.dev/eas-update/getting-started/";
|
|
12
|
+
export type FreeTierNearLimitAgentUpdatesTipVariant = 'control' | 'treatment';
|
|
13
|
+
/** The project state of one platform's build. Each build profile evaluates its own config. */
|
|
14
|
+
export type FreeTierNearLimitAgentUpdatesTipPlatformProject = {
|
|
15
|
+
developmentClient: boolean;
|
|
16
|
+
projectDir: string;
|
|
17
|
+
projectId: string;
|
|
18
|
+
exp: ExpoConfig;
|
|
19
|
+
manifestHostOverride: string | null;
|
|
20
|
+
};
|
|
21
|
+
export type FreeTierNearLimitAgentUpdatesTipExperiment = {
|
|
22
|
+
experimentation: LazyExperimentationClient;
|
|
23
|
+
graphqlClient: ExpoGraphqlClient;
|
|
24
|
+
analytics: Analytics;
|
|
25
|
+
analyticsEventProperties: AnalyticsEventProperties;
|
|
26
|
+
accountId: string;
|
|
27
|
+
/** Only regular and SSO users can store user preferences. */
|
|
28
|
+
isUser: boolean;
|
|
29
|
+
runFromCI: boolean;
|
|
30
|
+
json: boolean;
|
|
31
|
+
projectByPlatform: Partial<Record<AppPlatform, FreeTierNearLimitAgentUpdatesTipPlatformProject>>;
|
|
32
|
+
};
|
|
33
|
+
export type FreeTierNearLimitAgentUpdatesTipBuildContext = {
|
|
34
|
+
experimentation?: LazyExperimentationClient;
|
|
35
|
+
authenticationInfo?: LoggedInAuthenticationInfo;
|
|
36
|
+
analytics: Analytics;
|
|
37
|
+
analyticsEventProperties: AnalyticsEventProperties;
|
|
38
|
+
accountId: string;
|
|
39
|
+
user: Actor;
|
|
40
|
+
developmentClient: boolean;
|
|
41
|
+
projectDir: string;
|
|
42
|
+
projectId: string;
|
|
43
|
+
exp: ExpoConfig;
|
|
44
|
+
easJsonCliConfig: {
|
|
45
|
+
updateManifestHostOverride?: string;
|
|
46
|
+
} | undefined;
|
|
47
|
+
runFromCI: boolean;
|
|
48
|
+
};
|
|
49
|
+
export type FreeTierPlatformBuildUsage = {
|
|
50
|
+
used: number;
|
|
51
|
+
limit: number;
|
|
52
|
+
};
|
|
53
|
+
export type FreeTierBuildUsage = {
|
|
54
|
+
billingPeriodId: string;
|
|
55
|
+
byPlatform: Record<AppPlatform, FreeTierPlatformBuildUsage>;
|
|
56
|
+
};
|
|
57
|
+
/** All build contexts belong to one command run, so the account and the actor are shared. */
|
|
58
|
+
export declare function getFreeTierNearLimitAgentUpdatesTipExperiment(buildCtxByPlatform: Partial<Record<AppPlatform, FreeTierNearLimitAgentUpdatesTipBuildContext>>, { json }: {
|
|
59
|
+
json: boolean;
|
|
60
|
+
}): FreeTierNearLimitAgentUpdatesTipExperiment | undefined;
|
|
61
|
+
export declare function isProjectConfiguredForEASUpdate({ projectDir, exp, projectId, manifestHostOverride, }: Pick<FreeTierNearLimitAgentUpdatesTipPlatformProject, 'projectDir' | 'exp' | 'projectId' | 'manifestHostOverride'>): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Only runs driven by a coding agent logged in as a user, outside CI and without --json are
|
|
64
|
+
* eligible. Everything else gets no tip and no usage request.
|
|
65
|
+
*/
|
|
66
|
+
export declare function isEligibleForFreeTierNearLimitAgentUpdatesTip(experiment: FreeTierNearLimitAgentUpdatesTipExperiment): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* A platform is eligible when its project is not set up for Expo Update. Development builds load
|
|
69
|
+
* JavaScript from the dev server, so the tip does not apply to them.
|
|
70
|
+
*/
|
|
71
|
+
export declare function isPlatformEligibleForFreeTierNearLimitAgentUpdatesTip(project: FreeTierNearLimitAgentUpdatesTipPlatformProject): boolean;
|
|
72
|
+
/** True when the platform still has builds left, but no more than the tip's threshold. */
|
|
73
|
+
export declare function isWithinFreeTierNearLimitBand({ used, limit }: FreeTierPlatformBuildUsage): boolean;
|
|
74
|
+
/** Returns the Free plan build usage per platform, or null when the account is not on the Free plan. */
|
|
75
|
+
export declare function getFreeTierBuildUsageAsync({ graphqlClient, accountId, }: Pick<FreeTierNearLimitAgentUpdatesTipExperiment, 'graphqlClient' | 'accountId'>): Promise<FreeTierBuildUsage | null>;
|
|
76
|
+
/**
|
|
77
|
+
* The first call logs the exposure, so call it only when the tip would show. Accounts outside the
|
|
78
|
+
* rollout get the control default and no exposure.
|
|
79
|
+
*/
|
|
80
|
+
export declare function resolveFreeTierNearLimitAgentUpdatesTipVariantAsync({ experimentation, accountId, }: Pick<FreeTierNearLimitAgentUpdatesTipExperiment, 'experimentation' | 'accountId'>): Promise<FreeTierNearLimitAgentUpdatesTipVariant>;
|
|
81
|
+
export declare function formatFreeTierNearLimitAgentUpdatesTip({ platform, used, limit, }: FreeTierPlatformBuildUsage & {
|
|
82
|
+
platform: AppPlatform;
|
|
83
|
+
}): string;
|
|
84
|
+
export declare function getFreeTierNearLimitAgentUpdatesTipPreferenceKey(accountId: string, platform: AppPlatform): string;
|
|
85
|
+
/**
|
|
86
|
+
* The tip shows at most once per user, account, platform and billing period. The marker is a
|
|
87
|
+
* user preference on the server, so it follows the user across machines and fresh agent
|
|
88
|
+
* sandboxes.
|
|
89
|
+
*/
|
|
90
|
+
export declare function wasFreeTierNearLimitAgentUpdatesTipShownAsync(graphqlClient: ExpoGraphqlClient, accountId: string, platform: AppPlatform, billingPeriodId: string): Promise<boolean>;
|
|
91
|
+
export declare function markFreeTierNearLimitAgentUpdatesTipShownAsync(graphqlClient: ExpoGraphqlClient, accountId: string, platform: AppPlatform, billingPeriodId: string): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* After finished builds, suggests Expo Update to coding agents whose Free plan account is close to
|
|
94
|
+
* the platform build limit. The exposure logs only when every eligibility check passed, so both
|
|
95
|
+
* arms see the same population. The treatment arm prints the tip, logs the tip event, then
|
|
96
|
+
* writes the marker, so a failed write means at most a repeated tip. Fails open on any error.
|
|
97
|
+
*/
|
|
98
|
+
export declare function maybeSuggestEASUpdateToAgentNearFreeTierLimitAsync(builds: (BuildFragment | null)[], experiment: FreeTierNearLimitAgentUpdatesTipExperiment | undefined): Promise<void>;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EAS_UPDATE_GETTING_STARTED_URL = exports.FREE_TIER_NEAR_LIMIT_AGENT_UPDATES_TIP_BUILDS_LEFT = exports.FREE_TIER_NEAR_LIMIT_AGENT_UPDATES_TIP_EXPERIMENT_NAMESPACE = void 0;
|
|
4
|
+
exports.getFreeTierNearLimitAgentUpdatesTipExperiment = getFreeTierNearLimitAgentUpdatesTipExperiment;
|
|
5
|
+
exports.isProjectConfiguredForEASUpdate = isProjectConfiguredForEASUpdate;
|
|
6
|
+
exports.isEligibleForFreeTierNearLimitAgentUpdatesTip = isEligibleForFreeTierNearLimitAgentUpdatesTip;
|
|
7
|
+
exports.isPlatformEligibleForFreeTierNearLimitAgentUpdatesTip = isPlatformEligibleForFreeTierNearLimitAgentUpdatesTip;
|
|
8
|
+
exports.isWithinFreeTierNearLimitBand = isWithinFreeTierNearLimitBand;
|
|
9
|
+
exports.getFreeTierBuildUsageAsync = getFreeTierBuildUsageAsync;
|
|
10
|
+
exports.resolveFreeTierNearLimitAgentUpdatesTipVariantAsync = resolveFreeTierNearLimitAgentUpdatesTipVariantAsync;
|
|
11
|
+
exports.formatFreeTierNearLimitAgentUpdatesTip = formatFreeTierNearLimitAgentUpdatesTip;
|
|
12
|
+
exports.getFreeTierNearLimitAgentUpdatesTipPreferenceKey = getFreeTierNearLimitAgentUpdatesTipPreferenceKey;
|
|
13
|
+
exports.wasFreeTierNearLimitAgentUpdatesTipShownAsync = wasFreeTierNearLimitAgentUpdatesTipShownAsync;
|
|
14
|
+
exports.markFreeTierNearLimitAgentUpdatesTipShownAsync = markFreeTierNearLimitAgentUpdatesTipShownAsync;
|
|
15
|
+
exports.maybeSuggestEASUpdateToAgentNearFreeTierLimitAsync = maybeSuggestEASUpdateToAgentNearFreeTierLimitAsync;
|
|
16
|
+
const tslib_1 = require("tslib");
|
|
17
|
+
const agent_1 = require("../analytics/agent");
|
|
18
|
+
const AnalyticsManager_1 = require("../analytics/AnalyticsManager");
|
|
19
|
+
const createGraphqlClient_1 = require("../commandUtils/context/contextUtils/createGraphqlClient");
|
|
20
|
+
const generated_1 = require("../graphql/generated");
|
|
21
|
+
const UserPreferenceMutation_1 = require("../graphql/mutations/UserPreferenceMutation");
|
|
22
|
+
const AccountQuery_1 = require("../graphql/queries/AccountQuery");
|
|
23
|
+
const UserPreferenceQuery_1 = require("../graphql/queries/UserPreferenceQuery");
|
|
24
|
+
const log_1 = tslib_1.__importDefault(require("../log"));
|
|
25
|
+
const platform_1 = require("../platform");
|
|
26
|
+
const projectUtils_1 = require("../project/projectUtils");
|
|
27
|
+
exports.FREE_TIER_NEAR_LIMIT_AGENT_UPDATES_TIP_EXPERIMENT_NAMESPACE = 'cli-build-free-tier-near-limit-agent-updates-tip';
|
|
28
|
+
/** The tip shows when this many builds or fewer are left on the platform. */
|
|
29
|
+
exports.FREE_TIER_NEAR_LIMIT_AGENT_UPDATES_TIP_BUILDS_LEFT = 5;
|
|
30
|
+
exports.EAS_UPDATE_GETTING_STARTED_URL = 'https://docs.expo.dev/eas-update/getting-started/';
|
|
31
|
+
/** Server-side user preference key prefix. The full key is `<prefix>/<accountId>/<platform>`. */
|
|
32
|
+
const USER_PREFERENCE_KEY_PREFIX = 'free-tier-near-limit-agent-updates-tip-shown';
|
|
33
|
+
/** The tip's requests run after the build, so a stalled request must not delay the exit. */
|
|
34
|
+
const REQUEST_TIMEOUT_MS = 3000;
|
|
35
|
+
/** All build contexts belong to one command run, so the account and the actor are shared. */
|
|
36
|
+
function getFreeTierNearLimitAgentUpdatesTipExperiment(buildCtxByPlatform, { json }) {
|
|
37
|
+
const ctx = Object.values(buildCtxByPlatform)[0];
|
|
38
|
+
if (!ctx?.experimentation || !ctx.authenticationInfo) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
const projectByPlatform = {};
|
|
42
|
+
for (const [platform, platformCtx] of Object.entries(buildCtxByPlatform)) {
|
|
43
|
+
projectByPlatform[platform] = {
|
|
44
|
+
developmentClient: platformCtx.developmentClient,
|
|
45
|
+
projectDir: platformCtx.projectDir,
|
|
46
|
+
projectId: platformCtx.projectId,
|
|
47
|
+
exp: platformCtx.exp,
|
|
48
|
+
manifestHostOverride: platformCtx.easJsonCliConfig?.updateManifestHostOverride ?? null,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
experimentation: ctx.experimentation,
|
|
53
|
+
graphqlClient: (0, createGraphqlClient_1.createGraphqlClient)(ctx.authenticationInfo, {
|
|
54
|
+
requestTimeoutMs: REQUEST_TIMEOUT_MS,
|
|
55
|
+
}),
|
|
56
|
+
analytics: ctx.analytics,
|
|
57
|
+
analyticsEventProperties: ctx.analyticsEventProperties,
|
|
58
|
+
accountId: ctx.accountId,
|
|
59
|
+
isUser: ctx.user.__typename === 'User' || ctx.user.__typename === 'SSOUser',
|
|
60
|
+
runFromCI: ctx.runFromCI,
|
|
61
|
+
json,
|
|
62
|
+
projectByPlatform,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function isProjectConfiguredForEASUpdate({ projectDir, exp, projectId, manifestHostOverride, }) {
|
|
66
|
+
return ((0, projectUtils_1.isExpoUpdatesInstalled)(projectDir) && (0, projectUtils_1.isUsingEASUpdate)(exp, projectId, manifestHostOverride));
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Only runs driven by a coding agent logged in as a user, outside CI and without --json are
|
|
70
|
+
* eligible. Everything else gets no tip and no usage request.
|
|
71
|
+
*/
|
|
72
|
+
function isEligibleForFreeTierNearLimitAgentUpdatesTip(experiment) {
|
|
73
|
+
return !(experiment.runFromCI ||
|
|
74
|
+
experiment.json ||
|
|
75
|
+
!experiment.isUser ||
|
|
76
|
+
!(0, agent_1.getAgentTelemetryContext)());
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A platform is eligible when its project is not set up for Expo Update. Development builds load
|
|
80
|
+
* JavaScript from the dev server, so the tip does not apply to them.
|
|
81
|
+
*/
|
|
82
|
+
function isPlatformEligibleForFreeTierNearLimitAgentUpdatesTip(project) {
|
|
83
|
+
return !project.developmentClient && !isProjectConfiguredForEASUpdate(project);
|
|
84
|
+
}
|
|
85
|
+
/** True when the platform still has builds left, but no more than the tip's threshold. */
|
|
86
|
+
function isWithinFreeTierNearLimitBand({ used, limit }) {
|
|
87
|
+
return limit > 0 && used < limit && limit - used <= exports.FREE_TIER_NEAR_LIMIT_AGENT_UPDATES_TIP_BUILDS_LEFT;
|
|
88
|
+
}
|
|
89
|
+
/** Returns the Free plan build usage per platform, or null when the account is not on the Free plan. */
|
|
90
|
+
async function getFreeTierBuildUsageAsync({ graphqlClient, accountId, }) {
|
|
91
|
+
const account = await AccountQuery_1.AccountQuery.getFreeTierBuildUsageAsync(graphqlClient, accountId, new Date());
|
|
92
|
+
if ((account.subscription?.name ?? 'Free') !== 'Free') {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const buildMetric = account.usageMetrics.EAS_BUILD.planMetrics.find(metric => metric.serviceMetric === generated_1.EasServiceMetric.Builds &&
|
|
96
|
+
metric.metricType === generated_1.UsageMetricType.Build);
|
|
97
|
+
const breakdown = buildMetric?.platformBreakdown;
|
|
98
|
+
if (!breakdown) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
billingPeriodId: account.billingPeriod.id,
|
|
103
|
+
byPlatform: {
|
|
104
|
+
[generated_1.AppPlatform.Android]: { used: breakdown.android.value, limit: breakdown.android.limit },
|
|
105
|
+
[generated_1.AppPlatform.Ios]: { used: breakdown.ios.value, limit: breakdown.ios.limit },
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The first call logs the exposure, so call it only when the tip would show. Accounts outside the
|
|
111
|
+
* rollout get the control default and no exposure.
|
|
112
|
+
*/
|
|
113
|
+
async function resolveFreeTierNearLimitAgentUpdatesTipVariantAsync({ experimentation, accountId, }) {
|
|
114
|
+
const client = await experimentation.getClientAsync();
|
|
115
|
+
return client
|
|
116
|
+
.getAccountNamespace(exports.FREE_TIER_NEAR_LIMIT_AGENT_UPDATES_TIP_EXPERIMENT_NAMESPACE, { accountId })
|
|
117
|
+
.getParam('variant', 'control');
|
|
118
|
+
}
|
|
119
|
+
function formatFreeTierNearLimitAgentUpdatesTip({ platform, used, limit, }) {
|
|
120
|
+
const platformName = platform_1.appPlatformDisplayNames[platform];
|
|
121
|
+
return [
|
|
122
|
+
`Tip: this account has used ${used} of ${limit} ${platformName} builds on the Free plan this period. This project isn't set up for Expo Update, so every change needs a new build.`,
|
|
123
|
+
'With Expo Update, JavaScript, styling and image changes reach installed builds without a new build. Setup takes effect from the next build, so it saves the most builds if done now.',
|
|
124
|
+
'Next: eas update:configure --non-interactive, then build once more.',
|
|
125
|
+
'Tell the user: this adds expo-updates and changes app.json and eas.json.',
|
|
126
|
+
`Docs: ${exports.EAS_UPDATE_GETTING_STARTED_URL}`,
|
|
127
|
+
].join('\n');
|
|
128
|
+
}
|
|
129
|
+
function getFreeTierNearLimitAgentUpdatesTipPreferenceKey(accountId, platform) {
|
|
130
|
+
return `${USER_PREFERENCE_KEY_PREFIX}/${accountId}/${platform.toLowerCase()}`;
|
|
131
|
+
}
|
|
132
|
+
function isShownTipPreference(value) {
|
|
133
|
+
return (typeof value === 'object' &&
|
|
134
|
+
value !== null &&
|
|
135
|
+
typeof value.billingPeriodId === 'string');
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* The tip shows at most once per user, account, platform and billing period. The marker is a
|
|
139
|
+
* user preference on the server, so it follows the user across machines and fresh agent
|
|
140
|
+
* sandboxes.
|
|
141
|
+
*/
|
|
142
|
+
async function wasFreeTierNearLimitAgentUpdatesTipShownAsync(graphqlClient, accountId, platform, billingPeriodId) {
|
|
143
|
+
const value = await UserPreferenceQuery_1.UserPreferenceQuery.getValueAsync(graphqlClient, getFreeTierNearLimitAgentUpdatesTipPreferenceKey(accountId, platform));
|
|
144
|
+
return isShownTipPreference(value) && value.billingPeriodId === billingPeriodId;
|
|
145
|
+
}
|
|
146
|
+
async function markFreeTierNearLimitAgentUpdatesTipShownAsync(graphqlClient, accountId, platform, billingPeriodId) {
|
|
147
|
+
const value = { billingPeriodId };
|
|
148
|
+
await UserPreferenceMutation_1.UserPreferenceMutation.setAsync(graphqlClient, getFreeTierNearLimitAgentUpdatesTipPreferenceKey(accountId, platform), value);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* After finished builds, suggests Expo Update to coding agents whose Free plan account is close to
|
|
152
|
+
* the platform build limit. The exposure logs only when every eligibility check passed, so both
|
|
153
|
+
* arms see the same population. The treatment arm prints the tip, logs the tip event, then
|
|
154
|
+
* writes the marker, so a failed write means at most a repeated tip. Fails open on any error.
|
|
155
|
+
*/
|
|
156
|
+
async function maybeSuggestEASUpdateToAgentNearFreeTierLimitAsync(builds, experiment) {
|
|
157
|
+
if (!experiment || !isEligibleForFreeTierNearLimitAgentUpdatesTip(experiment)) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const eligiblePlatforms = new Set(builds
|
|
161
|
+
.filter((build) => build?.status === generated_1.BuildStatus.Finished)
|
|
162
|
+
.map(build => build.platform)
|
|
163
|
+
.filter(platform => {
|
|
164
|
+
const project = experiment.projectByPlatform[platform];
|
|
165
|
+
return project && isPlatformEligibleForFreeTierNearLimitAgentUpdatesTip(project);
|
|
166
|
+
}));
|
|
167
|
+
if (eligiblePlatforms.size === 0) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
try {
|
|
171
|
+
const usage = await getFreeTierBuildUsageAsync(experiment);
|
|
172
|
+
if (!usage) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
for (const platform of eligiblePlatforms) {
|
|
176
|
+
const platformUsage = usage.byPlatform[platform];
|
|
177
|
+
if (!isWithinFreeTierNearLimitBand(platformUsage) ||
|
|
178
|
+
(await wasFreeTierNearLimitAgentUpdatesTipShownAsync(experiment.graphqlClient, experiment.accountId, platform, usage.billingPeriodId))) {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
const variant = await resolveFreeTierNearLimitAgentUpdatesTipVariantAsync(experiment);
|
|
182
|
+
if (variant !== 'treatment') {
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
log_1.default.newLine();
|
|
186
|
+
log_1.default.log(formatFreeTierNearLimitAgentUpdatesTip({ platform, ...platformUsage }));
|
|
187
|
+
experiment.analytics.logEvent(AnalyticsManager_1.BuildEvent.FREE_TIER_NEAR_LIMIT_AGENT_UPDATES_TIP, {
|
|
188
|
+
...experiment.analyticsEventProperties,
|
|
189
|
+
platform,
|
|
190
|
+
builds_used: platformUsage.used,
|
|
191
|
+
builds_limit: platformUsage.limit,
|
|
192
|
+
});
|
|
193
|
+
try {
|
|
194
|
+
await markFreeTierNearLimitAgentUpdatesTipShownAsync(experiment.graphqlClient, experiment.accountId, platform, usage.billingPeriodId);
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
// The tip was shown. A missing marker means at most a repeated tip, so keep going.
|
|
198
|
+
log_1.default.debug('Failed to mark the Expo Update tip as shown:', error?.message ?? error);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
log_1.default.debug('Failed to run the Expo Update tip check:', error?.message ?? error);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
@@ -2,6 +2,7 @@ import { ExpoConfig } from '@expo/config';
|
|
|
2
2
|
import { Env } from '@expo/eas-build-job';
|
|
3
3
|
import { ResourceClass } from '@expo/eas-json';
|
|
4
4
|
import { LoggerLevel } from '@expo/logger';
|
|
5
|
+
import { MaybeBuildFragment } from './build';
|
|
5
6
|
import { LocalBuildOptions } from './local';
|
|
6
7
|
import { Analytics } from '../analytics/AnalyticsManager';
|
|
7
8
|
import { DynamicConfigContextFn } from '../commandUtils/context/DynamicProjectConfigContextField';
|
|
@@ -54,5 +55,6 @@ export declare function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsCl
|
|
|
54
55
|
}): Promise<{
|
|
55
56
|
buildIds: string[];
|
|
56
57
|
buildProfiles?: ProfileData<'build'>[];
|
|
58
|
+
builds?: MaybeBuildFragment[];
|
|
57
59
|
}>;
|
|
58
60
|
export declare function downloadAndRunAsync(build: BuildFragment, simulator?: SimulatorRunTarget): Promise<void>;
|
|
@@ -19,6 +19,7 @@ const build_3 = require("./ios/build");
|
|
|
19
19
|
const local_1 = require("./local");
|
|
20
20
|
const validateLockfile_1 = require("./validateLockfile");
|
|
21
21
|
const devClient_1 = require("./utils/devClient");
|
|
22
|
+
const freeTierNearLimitAgentUpdatesTip_1 = require("./freeTierNearLimitAgentUpdatesTip");
|
|
22
23
|
const printBuildInfo_1 = require("./utils/printBuildInfo");
|
|
23
24
|
const repository_1 = require("./utils/repository");
|
|
24
25
|
const queries_1 = require("../channel/queries");
|
|
@@ -201,6 +202,7 @@ async function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsClient, pro
|
|
|
201
202
|
if (!flags.json) {
|
|
202
203
|
(0, printBuildInfo_1.printBuildResults)(builds);
|
|
203
204
|
}
|
|
205
|
+
await (0, freeTierNearLimitAgentUpdatesTip_1.maybeSuggestEASUpdateToAgentNearFreeTierLimitAsync)(builds, (0, freeTierNearLimitAgentUpdatesTip_1.getFreeTierNearLimitAgentUpdatesTipExperiment)(buildCtxByPlatform, { json: flags.json }));
|
|
204
206
|
const haveAllBuildsFailedOrCanceled = builds.every(build => build?.status &&
|
|
205
207
|
[generated_1.BuildStatus.Errored, generated_1.BuildStatus.Canceled, generated_1.BuildStatus.PendingCancel].includes(build?.status));
|
|
206
208
|
await maybeDownloadAndRunSimulatorBuildsAsync(builds, flags, downloadSimBuildAutoConfirm);
|
|
@@ -222,6 +224,7 @@ async function runBuildAndSubmitAsync({ graphqlClient, analytics, vcsClient, pro
|
|
|
222
224
|
return {
|
|
223
225
|
buildIds: startedBuilds.map(({ build }) => build.id),
|
|
224
226
|
buildProfiles,
|
|
227
|
+
builds,
|
|
225
228
|
};
|
|
226
229
|
}
|
|
227
230
|
async function prepareAndStartBuildAsync({ projectDir, flags, moreBuilds, buildProfile, easJsonCliConfig, actor, graphqlClient, analytics, vcsClient, exp, projectId, customBuildConfigMetadata, env, easJsonAccessor, experimentation, authenticationInfo, }) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Analytics } from '../analytics/AnalyticsManager';
|
|
2
|
+
import { LoggedInAuthenticationInfo } from '../user/SessionManager';
|
|
3
|
+
import { Actor } from '../user/User';
|
|
4
|
+
export declare function maybeShowSimulatorsLaunchHintAsync(authenticationInfo: LoggedInAuthenticationInfo, analytics: Analytics, { actor, nonInteractive }: {
|
|
5
|
+
actor: Actor;
|
|
6
|
+
nonInteractive: boolean;
|
|
7
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.maybeShowSimulatorsLaunchHintAsync = maybeShowSimulatorsLaunchHintAsync;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const getenv_1 = require("getenv");
|
|
6
|
+
const AnalyticsManager_1 = require("../analytics/AnalyticsManager");
|
|
7
|
+
const createGraphqlClient_1 = require("../commandUtils/context/contextUtils/createGraphqlClient");
|
|
8
|
+
const UserPreferenceMutation_1 = require("../graphql/mutations/UserPreferenceMutation");
|
|
9
|
+
const UserPreferenceQuery_1 = require("../graphql/queries/UserPreferenceQuery");
|
|
10
|
+
const log_1 = tslib_1.__importStar(require("../log"));
|
|
11
|
+
const SIMULATORS_LAUNCH_AT = new Date('2026-11-05T18:00:00Z');
|
|
12
|
+
const SIMULATORS_LAUNCH_HINT_PREFERENCE_KEY = 'simulators-launch-cli-hint-seen';
|
|
13
|
+
const REQUEST_TIMEOUT_MS = 3000;
|
|
14
|
+
const SIMULATORS_QUICKSTART_URL = 'https://docs.expo.dev/preview/simulators/get-started/?utm_source=eas-cli&utm_medium=cli&utm_campaign=simulators-launch';
|
|
15
|
+
async function maybeShowSimulatorsLaunchHintAsync(authenticationInfo, analytics, { actor, nonInteractive }) {
|
|
16
|
+
if (nonInteractive ||
|
|
17
|
+
(0, getenv_1.boolish)('CI', false) ||
|
|
18
|
+
Date.now() < SIMULATORS_LAUNCH_AT.getTime() ||
|
|
19
|
+
(actor.__typename !== 'User' && actor.__typename !== 'SSOUser')) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const graphqlClient = (0, createGraphqlClient_1.createGraphqlClient)(authenticationInfo, {
|
|
24
|
+
requestTimeoutMs: REQUEST_TIMEOUT_MS,
|
|
25
|
+
});
|
|
26
|
+
const value = await UserPreferenceQuery_1.UserPreferenceQuery.getValueAsync(graphqlClient, SIMULATORS_LAUNCH_HINT_PREFERENCE_KEY);
|
|
27
|
+
if (value && typeof value === 'object' && 'isDismissed' in value && value.isDismissed) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
log_1.default.newLine();
|
|
31
|
+
log_1.default.log(`✨ New: run your build in Expo Simulators, cloud Android and iOS simulators for you and your agents. ${(0, log_1.link)(SIMULATORS_QUICKSTART_URL)}`);
|
|
32
|
+
analytics.logEvent(AnalyticsManager_1.BuildEvent.SIMULATORS_LAUNCH_HINT_SHOWN, {});
|
|
33
|
+
await UserPreferenceMutation_1.UserPreferenceMutation.setAsync(graphqlClient, SIMULATORS_LAUNCH_HINT_PREFERENCE_KEY, {
|
|
34
|
+
isDismissed: true,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
log_1.default.debug('Failed to show the Expo Simulators hint', error);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -12,6 +12,7 @@ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
|
12
12
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
13
13
|
const local_1 = require("../../build/local");
|
|
14
14
|
const runBuildAndSubmit_1 = require("../../build/runBuildAndSubmit");
|
|
15
|
+
const simulatorsLaunchHint_1 = require("../../build/simulatorsLaunchHint");
|
|
15
16
|
const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
|
|
16
17
|
const flags_1 = require("../../commandUtils/flags");
|
|
17
18
|
const generated_1 = require("../../graphql/generated");
|
|
@@ -127,7 +128,7 @@ class Build extends EasCommand_1.default {
|
|
|
127
128
|
: [generated_1.StatuspageServiceName.EasBuild]);
|
|
128
129
|
}
|
|
129
130
|
const flagsWithPlatform = await this.ensurePlatformSelectedAsync(flags);
|
|
130
|
-
const { buildProfiles } = await (0, runBuildAndSubmit_1.runBuildAndSubmitAsync)({
|
|
131
|
+
const { buildProfiles, builds } = await (0, runBuildAndSubmit_1.runBuildAndSubmitAsync)({
|
|
131
132
|
graphqlClient,
|
|
132
133
|
analytics,
|
|
133
134
|
vcsClient,
|
|
@@ -142,6 +143,12 @@ class Build extends EasCommand_1.default {
|
|
|
142
143
|
buildProfiles,
|
|
143
144
|
nonInteractive: flags.nonInteractive,
|
|
144
145
|
});
|
|
146
|
+
if (builds?.some(build => build?.status === generated_1.BuildStatus.Finished)) {
|
|
147
|
+
await (0, simulatorsLaunchHint_1.maybeShowSimulatorsLaunchHintAsync)(authenticationInfo, analytics, {
|
|
148
|
+
actor,
|
|
149
|
+
nonInteractive: flags.nonInteractive,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
145
152
|
}
|
|
146
153
|
sanitizeFlags(flags) {
|
|
147
154
|
const { json, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
|
|
@@ -24,7 +24,7 @@ const SESSION_PAGE_SIZE = 100;
|
|
|
24
24
|
// users narrow further with --days / --sort.
|
|
25
25
|
const PICKER_CANDIDATE_LIMIT = 25;
|
|
26
26
|
class ObserveSession extends EasCommand_1.default {
|
|
27
|
-
static description = 'display the timeline of metric and
|
|
27
|
+
static description = 'display the timeline of metric, log, and request trace span events for a specific session';
|
|
28
28
|
static args = {
|
|
29
29
|
sessionId: core_1.Args.string({
|
|
30
30
|
description: 'Session ID to inspect (omit in interactive mode to pick one from a list)',
|
|
@@ -90,12 +90,12 @@ class ObserveSession extends EasCommand_1.default {
|
|
|
90
90
|
environment: flags.environment,
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
|
-
const { entries, metadata, hasMoreMetricEvents, hasMoreLogEvents } = await (0, planGating_1.withObservePlanGateHandlingAsync)(() => (0, fetchSessions_1.fetchObserveSessionEventsAsync)(graphqlClient, projectId, {
|
|
93
|
+
const { entries, metadata, hasMoreMetricEvents, hasMoreLogEvents, hasMoreSpans } = await (0, planGating_1.withObservePlanGateHandlingAsync)(() => (0, fetchSessions_1.fetchObserveSessionEventsAsync)(graphqlClient, projectId, {
|
|
94
94
|
sessionId,
|
|
95
95
|
limit: SESSION_PAGE_SIZE,
|
|
96
96
|
}));
|
|
97
97
|
if (json) {
|
|
98
|
-
(0, json_1.printJsonOnlyOutput)((0, formatSessions_1.buildObserveSessionEventsJson)(entries, sessionId, metadata, hasMoreMetricEvents, hasMoreLogEvents));
|
|
98
|
+
(0, json_1.printJsonOnlyOutput)((0, formatSessions_1.buildObserveSessionEventsJson)(entries, sessionId, metadata, hasMoreMetricEvents, hasMoreLogEvents, hasMoreSpans));
|
|
99
99
|
}
|
|
100
100
|
else {
|
|
101
101
|
log_1.default.addNewLineIfNone();
|
|
@@ -103,6 +103,7 @@ class ObserveSession extends EasCommand_1.default {
|
|
|
103
103
|
metadata,
|
|
104
104
|
hasMoreMetricEvents,
|
|
105
105
|
hasMoreLogEvents,
|
|
106
|
+
hasMoreSpans,
|
|
106
107
|
}));
|
|
107
108
|
}
|
|
108
109
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import EasCommand from '../../commandUtils/EasCommand';
|
|
2
|
+
export default class ObserveTrace extends EasCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
traceId: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
6
|
+
};
|
|
7
|
+
static flags: {
|
|
8
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
'project-id': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
11
|
+
};
|
|
12
|
+
static contextDefinition: {
|
|
13
|
+
loggedIn: import("../../commandUtils/context/LoggedInContextField").default;
|
|
14
|
+
projectId: import("../../commandUtils/context/ProjectIdContextField").ProjectIdContextField;
|
|
15
|
+
};
|
|
16
|
+
runAsync(): Promise<void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
|
|
6
|
+
const errors_1 = require("../../commandUtils/errors");
|
|
7
|
+
const flags_1 = require("../../commandUtils/flags");
|
|
8
|
+
const ObserveQuery_1 = require("../../graphql/queries/ObserveQuery");
|
|
9
|
+
const log_1 = tslib_1.__importDefault(require("../../log"));
|
|
10
|
+
const formatSpans_1 = require("../../observe/formatSpans");
|
|
11
|
+
const planGating_1 = require("../../observe/planGating");
|
|
12
|
+
const json_1 = require("../../utils/json");
|
|
13
|
+
// A trace ID is the 32-character hex string of the OTLP JSON encoding.
|
|
14
|
+
const TRACE_ID_REGEX = /^[0-9a-f]{32}$/i;
|
|
15
|
+
class ObserveTrace extends EasCommand_1.default {
|
|
16
|
+
static description = 'display every span of a single request trace by its trace ID, oldest first, with child spans indented under their parent. Trace IDs are shown by `eas observe:traces`. In `--json` output a span with no `parentSpanId` is a root span, and a span with no `http` object is not an HTTP request';
|
|
17
|
+
static args = {
|
|
18
|
+
traceId: core_1.Args.string({
|
|
19
|
+
description: 'ID of the trace to display',
|
|
20
|
+
required: true,
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
static flags = {
|
|
24
|
+
...flags_1.EasProjectIdFlag,
|
|
25
|
+
...flags_1.EasNonInteractiveAndJsonFlags,
|
|
26
|
+
};
|
|
27
|
+
static contextDefinition = {
|
|
28
|
+
...this.ContextOptions.ProjectId,
|
|
29
|
+
...this.ContextOptions.LoggedIn,
|
|
30
|
+
};
|
|
31
|
+
async runAsync() {
|
|
32
|
+
const { flags, args } = await this.parse(ObserveTrace);
|
|
33
|
+
const { json, nonInteractive } = (0, flags_1.resolveNonInteractiveAndJsonFlags)(flags);
|
|
34
|
+
const traceId = args.traceId;
|
|
35
|
+
if (!TRACE_ID_REGEX.test(traceId)) {
|
|
36
|
+
throw new errors_1.EasCommandError(`"${traceId}" is not a valid trace ID. A trace ID is 32 hexadecimal characters; copy it from the Trace ID column of \`eas observe:traces\`.`);
|
|
37
|
+
}
|
|
38
|
+
const { projectId, loggedIn: { graphqlClient }, } = await this.getContextAsync(ObserveTrace, {
|
|
39
|
+
nonInteractive,
|
|
40
|
+
projectIdOverride: flags['project-id'],
|
|
41
|
+
});
|
|
42
|
+
if (json) {
|
|
43
|
+
(0, json_1.enableJsonOutput)();
|
|
44
|
+
}
|
|
45
|
+
const trace = await (0, planGating_1.withObservePlanGateHandlingAsync)(() => ObserveQuery_1.ObserveQuery.traceByIdAsync(graphqlClient, { appId: projectId, id: traceId }));
|
|
46
|
+
if (!trace) {
|
|
47
|
+
throw new errors_1.EasCommandError(`No trace found with ID "${traceId}". Trace IDs come from \`eas observe:traces\`, and traces age out of retention.`);
|
|
48
|
+
}
|
|
49
|
+
if (json) {
|
|
50
|
+
(0, json_1.printJsonOnlyOutput)((0, formatSpans_1.buildObserveTraceJson)(trace));
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
log_1.default.addNewLineIfNone();
|
|
54
|
+
log_1.default.log((0, formatSpans_1.buildObserveTraceTable)(trace));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.default = ObserveTrace;
|