Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use Actor/Apify env vars instead of ENV_VARS #373

Merged
merged 3 commits into from Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -57,7 +57,7 @@
"build:browser": "webpack"
},
"dependencies": {
"@apify/consts": "^2.9.0",
"@apify/consts": "^2.19.0",
"@apify/log": "^2.2.6",
"@crawlee/types": "^3.3.0",
"agentkeepalive": "^4.2.1",
Expand Down
6 changes: 3 additions & 3 deletions src/apify_client.ts
@@ -1,5 +1,5 @@
import ow from 'ow';
import { ME_USER_NAME_PLACEHOLDER, ENV_VARS } from '@apify/consts';
import { ME_USER_NAME_PLACEHOLDER, ACTOR_ENV_VARS } from '@apify/consts';
import logger, { Log } from '@apify/log';

import { SetStatusMessageOptions } from '@crawlee/types';
Expand Down Expand Up @@ -312,8 +312,8 @@ export class ApifyClient {
}

async setStatusMessage(message: string, options?: SetStatusMessageOptions): Promise<void> {
const runId = process.env[ENV_VARS.ACTOR_RUN_ID];
if (!runId) { throw new Error(`Environment variable ${ENV_VARS.ACTOR_RUN_ID} is not set!`); }
const runId = process.env[ACTOR_ENV_VARS.RUN_ID];
if (!runId) { throw new Error(`Environment variable ${ACTOR_ENV_VARS.RUN_ID} is not set!`); }
await this.run(runId).update({
statusMessage: message,
...options,
Expand Down
6 changes: 3 additions & 3 deletions src/http_client.ts
Expand Up @@ -2,7 +2,7 @@ import axios, { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse } f
import retry, { RetryFunction } from 'async-retry';
import KeepAliveAgent from 'agentkeepalive';
import os from 'os';
import { ENV_VARS } from '@apify/consts';
import { APIFY_ENV_VARS } from '@apify/consts';
import { Log } from '@apify/log';
import { ApifyApiError } from './apify_api_error';
import {
Expand Down Expand Up @@ -52,7 +52,7 @@ export class HttpClient {
this.userProvidedRequestInterceptors = options.requestInterceptors;
this.timeoutMillis = options.timeoutSecs * 1000;
this.logger = options.logger;
this.workflowKey = options.workflowKey || process.env[ENV_VARS.WORKFLOW_KEY];
this.workflowKey = options.workflowKey || process.env[APIFY_ENV_VARS.WORKFLOW_KEY];
this._onRequestRetry = this._onRequestRetry.bind(this);

if (isNode()) {
Expand Down Expand Up @@ -106,7 +106,7 @@ export class HttpClient {

if (isNode()) {
// Works only in Node. Cannot be set in browser
const isAtHome = !!process.env[ENV_VARS.IS_AT_HOME];
const isAtHome = !!process.env[APIFY_ENV_VARS.IS_AT_HOME];
const userAgent = `ApifyClient/${version} (${os.type()}; Node/${process.version}); isAtHome/${isAtHome}`;
this.axios.defaults.headers['User-Agent'] = userAgent;
}
Expand Down