Skip to content

Commit b6e65c1

Browse files
committed
feat: Document new synthetic default dataset item event
1 parent fb821d3 commit b6e65c1

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

sources/platform/actors/publishing/monetize/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ The following table compares the two main pricing models available for monetizin
3838
| Marketing boost | Standard visibility | Standard visibility | Priority store placement |
3939
| Commission opportunities| Standard 20% | Standard 20% | Promotional 0% periods (until 01/11/2025) |
4040
| Custom event billing | Not available | Not available | ✅ Charge for any event |
41-
| Per-result billing | Not available | ✅ Charge per dataset item | Optional (via event) |
41+
| Per-result billing | Not available | ✅ Charge per dataset item | Optional (via event; automatic via `apify-actor-default-dataset-item`) |
4242

4343
## Setting up monetization
4444

sources/platform/actors/publishing/monetize/pay_per_event.mdx

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ async def charge_for_api_product_detail():
108108

109109
async def main():
110110
await Actor.init()
111-
111+
112112
# API call, or any other logic that you want to charge for
113113

114114
charge_result = await charge_for_api_product_detail()
@@ -136,7 +136,7 @@ Use our [SDKs](/sdk) (JS and, Python or use [`apify actor charge`](/cli/docs/nex
136136

137137
### Use synthetic start event `apify-actor-start`
138138

139-
:::info Synthetic Actor recommended
139+
:::info Synthetic Actor start event recommended
140140

141141
We recommend using the synthetic Actor start event in PPE Actors. It benefits both you and your users.
142142

@@ -179,13 +179,28 @@ Your Actor might already have a start event defined, such as `actor-start` or an
179179

180180
If you want to use the synthetic start event, remove the existing start event from your Actor and add the synthetic start event in Apify Console in the **Publication** tab.
181181

182+
### Use synthetic default dataset item event `apify-actor-default-dataset-item`
183+
184+
::::info Automatic per-item charging
185+
186+
The `apify-actor-default-dataset-item` synthetic event charges users for each item written to the run's default dataset. It lets you align PPE pricing with per-result use cases without adding charging code to your Actor.
187+
188+
::::
189+
190+
#### How the synthetic default dataset item event works
191+
192+
- Apify automatically charges this event whenever your Actor writes an item to the default dataset (for example, when using `Actor.pushData` without opening a named dataset).
193+
- No code changes are required to charge this event.
194+
- You can remove the event in Apify Console if you don't want automatic charging for default dataset items. If you remove it, default dataset writes will no longer be charged automatically.
195+
- The event applies only to the default dataset of the run. Writes to other (non-default) datasets are not charged by this synthetic event.
196+
182197
### Set memory limits
183198

184199
Set memory limits using `minMemoryMbytes` and `maxMemoryMbytes` in your [`actor.json`](https://docs.apify.com/platform/actors/development/actor-definition/actor-json) file to control platform usage costs.
185200

186201
```json
187202
{
188-
"actorSpecification": 1,
203+
"actorSpecification": 1,
189204
"name": "name-of-my-scraper",
190205
"version": "0.0",
191206
"minMemoryMbytes": 512,
@@ -213,15 +228,15 @@ import { Actor } from 'apify';
213228

214229
const processUrl = async (url) => {
215230
const response = await fetch(url);
216-
231+
217232
if (response.status === 404) {
218233
// Charge for the work done and return error item in one call
219234
await Actor.pushData({
220235
url: url,
221236
error: "404",
222237
errorMessage: "Page not found"
223238
}, 'scraped-result');
224-
239+
225240
return;
226241
}
227242

@@ -232,7 +247,7 @@ await Actor.init();
232247

233248
const input = await Actor.getInput();
234249
const { urls } = input;
235-
250+
236251
for (const url of urls) {
237252
await processUrl(url);
238253
}
@@ -251,30 +266,30 @@ import requests
251266

252267
async def process_url(url):
253268
response = requests.get(url)
254-
269+
255270
if response.status_code == 404:
256271
# Charge for the work done and return error item in one call
257272
await Actor.push_data({
258273
'url': url,
259274
'error': '404',
260275
'errorMessage': 'Page not found'
261276
}, 'scraped-result')
262-
277+
263278
return
264279

265280
# Rest of the process_url function
266281

267282
async def main():
268283
await Actor.init()
269-
284+
270285
input_data = await Actor.get_input()
271286
urls = input_data.get('urls', [])
272-
287+
273288
for url in urls:
274289
await process_url(url)
275-
290+
276291
# Rest of the Actor logic
277-
292+
278293
await Actor.exit()
279294
```
280295

@@ -294,7 +309,7 @@ However, we acknowledge that some events don't produce tangible results (such as
294309
Examples:
295310

296311
- _`post` event_: Each charge adds one social media post to the dataset
297-
- _`profile` event_: Each charge adds one user profile to the dataset
312+
- _`profile` event_: Each charge adds one user profile to the dataset
298313
- _`processed-image` event_: Each charge adds one processed image to the dataset
299314
- _`ai-analysis` event_: Each charge processes one document through an AI workflow (no tangible output, but valuable processing)
300315

0 commit comments

Comments
 (0)