Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,56 @@ DESCRIPTION
USAGE
$ apify telemetry disable
```

##### `apify feedback`

```sh
DESCRIPTION
Sends feedback about the Apify CLI to the Apify team: report a problem, or
tell us something worked well.
It's one-way, so you won't get a reply. For support, use
https://apify.com/contact.
It's sent even when telemetry is disabled, because you asked to send it. Don't
include personal data, credentials, or secrets.
Feedback that contains an API token or another secret isn't sent.

USAGE
$ apify feedback <message> [--actor-id <value>]
[--actor-run-id <value>] [--actual <value>]
[--category
bug|spec_mismatch|readme_unclear|missing_capability|improvement|worked_well]
[--expected <value>] [--json] [--sent-by human|agent]
[--sentiment positive|negative|neutral] [--source user|model]

ARGUMENTS
message What happened, or what worked. At most 2000 characters.

FLAGS
--actor-id=<value> ID of the Actor the feedback
is about.
--actor-run-id=<value> ID of the Actor run the
feedback is about.
--actual=<value> What actually happened. At
most 2000 characters.
--category=<option> What kind of feedback it is.
Use improvement for suggestions that aren't bugs.
<options:
bug|spec_mismatch|readme_unclear|missing_capability|improvement|worked_well>
--expected=<value> What you expected to happen.
At most 2000 characters.
--json Format the command output as
JSON.
--sent-by=<option> Whether a human or an agent
ran this command. Defaults to agent when the CLI
detects an AI agent, otherwise human.
<options: human|agent>
--sentiment=<option> How it went overall.
<options: positive|negative|neutral>
--source=<option> Who decided to send it: user
means the user asked to send it, model means the agent
sent it on its own.
<options: user|model>
```
<!-- general-commands-end -->
<!-- prettier-ignore-end -->

Expand Down
14 changes: 14 additions & 0 deletions docs/telemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,17 @@ apify telemetry disable
```

Alternatively, set the `APIFY_CLI_DISABLE_TELEMETRY` environment variable to `1`.

## Feedback

`apify feedback` sends a report to the Apify team. Unlike other commands, it sends the text you pass to it. The report includes:

- The message and any optional fields you pass, such as `--actor-id` or `--expected`.
- The CLI version, OS, and install method.
- The name of the command you ran before `apify feedback` and its exit code, without its arguments or flag values.
- Whether a human or an AI agent sent it, and which agent, if the CLI detects one.
- The same random ID and Apify user ID as other events.

The CLI sends feedback even when telemetry is turned off, because you explicitly asked it to. Don't include personal data, credentials, or secrets.

The CLI doesn't send feedback that contains an API token, a password, or another secret it recognizes. It checks for Apify tokens, for values passed to something named like a credential (such as `--token` or `password:`), and for the tokens stored on your machine. Replace the secret with a placeholder such as `<token>`, then send the feedback again.
2 changes: 1 addition & 1 deletion docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ apify help COMMAND

## Need help?

For general support, reach out to us at [apify.com/contact](https://apify.com/contact). You can also join [Apify Discord](https://apify.com/discord), if you have a question. If you believe you are encountering a bug, file it on [GitHub](https://github.com/apify/apify-cli/issues/new).
For general support, reach out to us at [apify.com/contact](https://apify.com/contact). You can also join [Apify Discord](https://apify.com/discord), if you have a question. If you believe you're encountering a bug, run `apify feedback "<what happened>"`, or file it on [GitHub](https://github.com/apify/apify-cli/issues/new) if you want a reply.
1 change: 1 addition & 0 deletions scripts/generate-cli-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const categories: Record<string, CommandsInCategory[]> = {
{ command: Commands.telemetry },
{ command: Commands.telemetryEnable },
{ command: Commands.telemetryDisable },
{ command: Commands.feedback },
],
'dataset': [
//
Expand Down
4 changes: 4 additions & 0 deletions skills/apify/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,7 @@ apify api POST acts -d '<json>' -p '{"limit":1}' # -d body (use - for stdin),
```

The `v2/` prefix and leading slash are optional.

## Reporting CLI problems

`apify feedback "<what happened>"` can report a CLI problem you couldn't resolve to the Apify CLI team. Run `apify feedback -h` for its flags. Replace any token or password in the text with a placeholder such as `<token>`: feedback that contains a secret isn't sent.
2 changes: 2 additions & 0 deletions src/commands/_register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { UpgradeCommand } from './cli-management/upgrade.js';
import { CreateCommand } from './create.js';
import { DatasetsIndexCommand } from './datasets/_index.js';
import { EditInputSchemaCommand } from './edit-input-schema.js';
import { FeedbackCommand } from './feedback.js';
import { HelpCommand } from './help.js';
import { InfoCommand } from './info.js';
import { WrapScrapyCommand } from './init-wrap-scrapy.js';
Expand Down Expand Up @@ -64,6 +65,7 @@ export const apifyCommands = [
InstallCommand,
CreateCommand,
EditInputSchemaCommand,
FeedbackCommand,
InfoCommand,
WrapScrapyCommand,
InitCommand,
Expand Down
9 changes: 5 additions & 4 deletions src/commands/cli-management/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { USER_AGENT } from '../../entrypoints/_shared.js';
import { writeEntrypointShims } from '../../lib/bundleMigration.js';
import { ApifyCommand } from '../../lib/command-framework/apify-command.js';
import { Flags } from '../../lib/command-framework/flags.js';
import { REPORT_PROBLEM_INSTRUCTION } from '../../lib/consts.js';
import { execWithLog } from '../../lib/exec.js';
import { DEVELOPMENT_VERSION_MARKER, type InstallMethod, useCLIMetadata } from '../../lib/hooks/useCLIMetadata.js';
import type { Asset } from '../../lib/hooks/useCLIVersionAssets.js';
Expand Down Expand Up @@ -165,7 +166,7 @@ export class UpgradeCommand extends ApifyCommand<typeof UpgradeCommand> {
if (!assets.length) {
error({
message: [
'Failed to find the assets for your system and the provided version. Please open an issue on https://github.com/apify/apify-cli/issues/new and provide the following information:',
`Failed to find the assets for your system and the provided version. Please report this issue: ${REPORT_PROBLEM_INSTRUCTION}, and provide the following information:`,
`- The version you are trying to upgrade to: ${versionWithoutV}`,
`- The system you are running on: ${metadata.platform} ${metadata.arch}`,
].join('\n'),
Expand All @@ -184,7 +185,7 @@ export class UpgradeCommand extends ApifyCommand<typeof UpgradeCommand> {

error({
message: [
`Failed to find the currently installed ${this.cliName} bundle. Please open an issue on https://github.com/apify/apify-cli/issues/new and provide the following information:`,
`Failed to find the currently installed ${this.cliName} bundle. Please report this issue: ${REPORT_PROBLEM_INSTRUCTION}, and provide the following information:`,
`- The version you are trying to upgrade to: ${versionWithoutV}`,
`- The system you are running on: ${metadata.platform} ${metadata.arch}`,
`- The directory where the ${this.cliName} bundle is installed: ${bundleDirectory}`,
Expand Down Expand Up @@ -311,7 +312,7 @@ export class UpgradeCommand extends ApifyCommand<typeof UpgradeCommand> {

error({
message: [
`Failed to fetch the ${cliName} bundle. Please open an issue on https://github.com/apify/apify-cli/issues/new and provide the following information:`,
`Failed to fetch the ${cliName} bundle. Please report this issue: ${REPORT_PROBLEM_INSTRUCTION}, and provide the following information:`,
`- The version you are trying to upgrade to: ${version}`,
`- The system you are running on: ${metadata.platform} ${metadata.arch}`,
`- The URL of the asset that failed to fetch: ${asset.browser_download_url}`,
Expand Down Expand Up @@ -355,7 +356,7 @@ export class UpgradeCommand extends ApifyCommand<typeof UpgradeCommand> {

error({
message: [
`Failed to write the ${cliName} bundle. Please open an issue on https://github.com/apify/apify-cli/issues/new and provide the following information:`,
`Failed to write the ${cliName} bundle. Please report this issue: ${REPORT_PROBLEM_INSTRUCTION}, and provide the following information:`,
`- The version you are trying to upgrade to: ${version}`,
`- The system you are running on: ${metadata.platform} ${metadata.arch}`,
`- The URL of the asset that failed to fetch: ${asset.browser_download_url}`,
Expand Down
161 changes: 161 additions & 0 deletions src/commands/feedback.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
import { ApifyCommand } from '../lib/command-framework/apify-command.js';
import { Args } from '../lib/command-framework/args.js';
import { Flags } from '../lib/command-framework/flags.js';
import { containsCredential } from '../lib/hooks/telemetry/credentialsInText.js';
import { detectAiAgent } from '../lib/hooks/telemetry/detectEnvironment.js';
import { sendEvent } from '../lib/hooks/telemetry/trackEvent.js';
import { useTelemetryState } from '../lib/hooks/telemetry/useTelemetryState.js';
import { useCLIMetadata } from '../lib/hooks/useCLIMetadata.js';
import { success } from '../lib/outputs.js';
import { printJsonToStdout } from '../lib/utils.js';

const MAX_TEXT_LENGTH = 2000;
const MAX_ID_LENGTH = 200;

function assertMaxLength(name: string, value: string | undefined, max: number) {
if (value !== undefined && value.length > max) {
throw new Error(`${name} can be at most ${max} characters long, but it's ${value.length}. Nothing was sent.`);
}
}

async function assertNoCredential(name: string, value: string | undefined) {
if (value !== undefined && (await containsCredential(value))) {
throw new Error(
`${name} contains what looks like an API token, a password, or another secret. Nothing was sent. ` +
'Replace it with a placeholder such as <token>, then try again.',
);
}
}

export class FeedbackCommand extends ApifyCommand<typeof FeedbackCommand> {
static override name = 'feedback' as const;

static override description =
'Sends feedback about the Apify CLI to the Apify team: report a problem, or tell us something worked well.\n' +
"It's one-way, so you won't get a reply. For support, use https://apify.com/contact.\n" +
"It's sent even when telemetry is disabled, because you asked to send it. Don't include personal data, credentials, or secrets.\n" +
"Feedback that contains an API token or another secret isn't sent.";

static override group = 'Utilities';

static override enableJsonFlag = true;

static override examples = [
{
description: "Report a problem in plain words. Quote the message, so a flag it mentions isn't read as an option.",
command: 'apify feedback "apify push hangs on Windows after the build finishes"',
},
{
description: 'Report a problem with a specific Actor.',
command:
'apify feedback "The README lists a startUrls field, but the input schema calls it urls" --actor-id <actorId> --category spec_mismatch',
},
{
description: 'Report a problem as an agent, on its own initiative, with machine-readable output.',
command:
'apify feedback "apify runs ls --json returns an empty list right after a run starts" --category bug --source model --json',
},
];

static override args = {
message: Args.string({
required: true,
catchAll: true,
description: `What happened, or what worked. At most ${MAX_TEXT_LENGTH} characters.`,
}),
};

static override flags = {
'actor-id': Flags.string({
description: 'ID of the Actor the feedback is about.',
}),
'actor-run-id': Flags.string({
description: 'ID of the Actor run the feedback is about.',
}),
'sentiment': Flags.string({
description: 'How it went overall.',
choices: ['positive', 'negative', 'neutral'] as const,
}),
'category': Flags.string({
description: "What kind of feedback it is. Use improvement for suggestions that aren't bugs.",
choices: ['bug', 'spec_mismatch', 'readme_unclear', 'missing_capability', 'improvement', 'worked_well'] as const,
}),
'source': Flags.string({
description:
'Who decided to send it: user means the user asked to send it, model means the agent sent it on its own.',
choices: ['user', 'model'] as const,
}),
'expected': Flags.string({
description: `What you expected to happen. At most ${MAX_TEXT_LENGTH} characters.`,
}),
'actual': Flags.string({
description: `What actually happened. At most ${MAX_TEXT_LENGTH} characters.`,
}),
'sent-by': Flags.string({
description:
'Whether a human or an agent ran this command. Defaults to agent when the CLI detects an AI agent, otherwise human.',
choices: ['human', 'agent'] as const,
}),
};

static override docsUrl = 'https://docs.apify.com/cli/docs/reference#apify-feedback';

// A retried or second report should still name the command it's about, not `feedback`.
protected override recordAsLastCommand = false;

async run() {
const message = this.args.message.trim();

if (!message) {
throw new Error('The feedback message is empty. Describe what happened, then try again.');
}

assertMaxLength('The feedback message', message, MAX_TEXT_LENGTH);
assertMaxLength('--actor-id', this.flags.actorId, MAX_ID_LENGTH);
assertMaxLength('--actor-run-id', this.flags.actorRunId, MAX_ID_LENGTH);
assertMaxLength('--expected', this.flags.expected, MAX_TEXT_LENGTH);
assertMaxLength('--actual', this.flags.actual, MAX_TEXT_LENGTH);

await assertNoCredential('The feedback message', message);
await assertNoCredential('--actor-id', this.flags.actorId);
await assertNoCredential('--actor-run-id', this.flags.actorRunId);
await assertNoCredential('--expected', this.flags.expected);
await assertNoCredential('--actual', this.flags.actual);

const metadata = useCLIMetadata();
const telemetryState = await useTelemetryState();
const aiAgent = detectAiAgent();

const sent = await sendEvent('CLI Reported Problem', {
message,
actor_id: this.flags.actorId,
actor_run_id: this.flags.actorRunId,
sentiment: this.flags.sentiment,
category: this.flags.category,
source: this.flags.source,
expected: this.flags.expected,
actual: this.flags.actual,
app_version: metadata.version,
os: metadata.platform,
os_arch: metadata.arch,
install_method: metadata.installMethod,
last_command: telemetryState.lastCommand,
last_command_exit_code: telemetryState.lastCommandExitCode,
sent_by: this.flags.sentBy ?? (aiAgent ? 'agent' : 'human'),
ai_agent: aiAgent,
});

if (!sent) {
throw new Error(
"Your feedback couldn't be sent. Try again, or open an issue at https://github.com/apify/apify-cli/issues/new.",
);
}

if (this.flags.json) {
printJsonToStdout({ sent: true });
return;
}

success({ message: 'Thanks for your feedback! It was sent to the Apify CLI team.' });
}
}
3 changes: 3 additions & 0 deletions src/commands/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export class HelpCommand extends ApifyCommand<typeof HelpCommand> {
}),
};

// Reading help after a failure shouldn't replace the failed command in a later `apify feedback`.
protected override recordAsLastCommand = false;

async run() {
const { commandString } = this.args;

Expand Down
3 changes: 2 additions & 1 deletion src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
INTERRUPT_SIGNALS,
LEGACY_LOCAL_STORAGE_DIR,
MINIMUM_SUPPORTED_PYTHON_VERSION,
REPORT_PROBLEM_INSTRUCTION,
SUPPORTED_NODEJS_VERSION,
} from '../lib/consts.js';
import { execWithLog } from '../lib/exec.js';
Expand Down Expand Up @@ -544,7 +545,7 @@ export class RunCommand extends ApifyCommand<typeof RunCommand> {
}
default:
error({
message: `Failed to detect the language of your project. Please report this issue to the Apify team with your project structure over at https://github.com/apify/apify-cli/issues`,
message: `Failed to detect the language of your project. Please report this issue to the Apify team with your project structure: ${REPORT_PROBLEM_INSTRUCTION}.`,
});
}
} catch (err) {
Expand Down
2 changes: 2 additions & 0 deletions src/entrypoints/_shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ export async function runCLI(entrypoint: string) {

cliDebugPrint('CommandArgsResult', commandResult);
} catch (err) {
await instance['_recordUsageError']();

const commandError = CommandError.into(err, FinalCommand);

error({ message: commandError.getPrettyMessage() });
Expand Down
2 changes: 1 addition & 1 deletion src/lib/auth-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function writeAuthFile(data: AuthFile) {
}

/** Temp file then rename: two CLI processes can run at once, and a torn file reads as logged out. */
function atomicWriteJson(path: string, data: unknown) {
export function atomicWriteJson(path: string, data: unknown) {
ensureApifyDirectory(path);

const tempPath = `${path}.tmp-${cryptoRandomObjectId(8)}`;
Expand Down
7 changes: 4 additions & 3 deletions src/lib/command-framework/CommandError.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import chalk from 'chalk';

import { describeStdinRead } from '../commands/read-stdin.js';
import { REPORT_PROBLEM_INSTRUCTION } from '../consts.js';
import { useCLIMetadata } from '../hooks/useCLIMetadata.js';
import type { BuiltApifyCommand } from './apify-command.js';
import { selectiveRenderHelpForCommand } from './help.js';
Expand Down Expand Up @@ -74,7 +75,7 @@ export class CommandError extends Error {

if (!match) {
throw new Error(
`Encountered unparsable error message from argument parser: ${this.message}.\n\nPlease report this issue at https://github.com/apify/apify-cli/issues`,
`Encountered unparsable error message from argument parser: ${this.message}.\n\nPlease report this issue: ${REPORT_PROBLEM_INSTRUCTION}.`,
);
}

Expand All @@ -93,7 +94,7 @@ export class CommandError extends Error {

if (!match) {
throw new Error(
`Encountered unparsable error message from argument parser: ${this.message}.\n\nPlease report this issue at https://github.com/apify/apify-cli/issues`,
`Encountered unparsable error message from argument parser: ${this.message}.\n\nPlease report this issue: ${REPORT_PROBLEM_INSTRUCTION}.`,
);
}

Expand Down Expand Up @@ -213,7 +214,7 @@ export class CommandError extends Error {

return [
'The CLI encountered an unhandled argument parsing error!',
`Please report this issue at https://github.com/apify/apify-cli/issues, and provide the following information:`,
`Please report this issue: ${REPORT_PROBLEM_INSTRUCTION}, and provide the following information:`,
'',
`- Error code: ${this.code} (${CommandErrorCode[this.code]})`,
`- Error metadata: ${JSON.stringify(this.metadata)}`,
Expand Down
Loading
Loading