Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

Changed Apify.webhook() to Apify.addWebhook()

drobnikj9eae0ac8ee53
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3580caeec..15c00a962 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,6 @@
0.13.1 / 2019-03-19
===================
-- Added `Apify.webhook()`
+- Added `Apify.addWebhook()`
0.13.0 / 2019-03-14
===================
diff --git a/src/actor.js b/src/actor.js
index ac58d79fa..f94b92fe9 100644
--- a/src/actor.js
+++ b/src/actor.js
@@ -781,14 +781,14 @@ export const getApifyProxyUrl = (options = {}) => {
*
* @memberof module:Apify
* @function
- * @name webhook
+ * @name addWebhook
*/
-export const webhook = async ({ eventTypes, requestUrl }) => {
+export const addWebhook = async ({ eventTypes, requestUrl }) => {
checkParamOrThrow(eventTypes, 'eventTypes', '[String]');
checkParamOrThrow(requestUrl, 'requestUrl', 'String');
if (!isAtHome()) {
- log.warning('Apify.webhook() is only supported when running on the Apify platform. The webhook will not be invoked.');
+ log.warning('Apify.addWebhook() is only supported when running on the Apify platform. The webhook will not be invoked.');
return;
}
diff --git a/src/index.js b/src/index.js
index 683cecbf5..ec2d6feee 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,7 +1,7 @@
import EventEmitter from 'events';
import log from 'apify-shared/log';
import { ENV_VARS } from 'apify-shared/consts';
-import { main, getEnv, call, callTask, getApifyProxyUrl, metamorph, webhook } from './actor';
+import { main, getEnv, call, callTask, getApifyProxyUrl, metamorph, addWebhook } from './actor';
import AutoscaledPool from './autoscaling/autoscaled_pool';
import BasicCrawler from './basic_crawler';
import CheerioCrawler from './cheerio_crawler';
@@ -58,7 +58,7 @@ module.exports = {
getApifyProxyUrl,
isAtHome,
client: apifyClient,
- webhook,
+ addWebhook,
// Autoscaled pool
AutoscaledPool,
diff --git a/test/actor.js b/test/actor.js
index a5ec5e36d..e2f510a12 100644
--- a/test/actor.js
+++ b/test/actor.js
@@ -1142,7 +1142,7 @@ describe('Apify.getApifyProxyUrl()', () => {
});
-describe('Apify.webhook()', () => {
+describe('Apify.addWebhook()', () => {
it('works', async () => {
const runId = 'my-run-id';
const expectedEventTypes = ['ACTOR.RUN.SUCCEEDED'];
@@ -1166,7 +1166,7 @@ describe('Apify.webhook()', () => {
.returns(Promise.resolve());
- await Apify.webhook({ eventTypes: expectedEventTypes, requestUrl: expectedRequestUrl });
+ await Apify.addWebhook({ eventTypes: expectedEventTypes, requestUrl: expectedRequestUrl });
delete process.env[ENV_VARS.ACTOR_RUN_ID];
delete process.env[ENV_VARS.IS_AT_HOME];
@@ -1185,7 +1185,7 @@ describe('Apify.webhook()', () => {
const logMock = sinon.mock(log);
logMock.expects('warning').once();
- await Apify.webhook({ eventTypes: expectedEventTypes, requestUrl: expectedRequestUrl });
+ await Apify.addWebhook({ eventTypes: expectedEventTypes, requestUrl: expectedRequestUrl });
webhooksMock.verify();
webhooksMock.restore();
@@ -1201,7 +1201,7 @@ describe('Apify.webhook()', () => {
let isThrow;
try {
- await Apify.webhook({ eventTypes: expectedEventTypes, requestUrl: expectedRequestUrl });
+ await Apify.addWebhook({ eventTypes: expectedEventTypes, requestUrl: expectedRequestUrl });
} catch (err) {
isThrow = true;
}