Skip to content

Commit 4b9e054

Browse files
feat: Document new synthetic default dataset item event (#2007)
resolves: apify/apify-core#23408
1 parent 5ff565c commit 4b9e054

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-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-default-dataset-item`) |
4242

4343
## Setting up monetization
4444

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

Lines changed: 26 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,26 @@ 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-default-dataset-item`
183+
184+
The `apify-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.
185+
186+
This event simplifies migration from pay-per-result (PPR) Actors to the pay-per-event (PPE) model. No code changes are required.
187+
188+
#### How the synthetic default dataset item event works
189+
190+
- Apify automatically charges this event whenever your Actor writes an item to the default dataset (for example, when using `Actor.pushData`).
191+
- No code changes are required to charge this event.
192+
- 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.
193+
- The event applies only to the default dataset of the run. Writes to other (non-default) datasets are not charged by this synthetic event.
194+
182195
### Set memory limits
183196

184197
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.
185198

186199
```json
187200
{
188-
"actorSpecification": 1,
201+
"actorSpecification": 1,
189202
"name": "name-of-my-scraper",
190203
"version": "0.0",
191204
"minMemoryMbytes": 512,
@@ -213,15 +226,15 @@ import { Actor } from 'apify';
213226

214227
const processUrl = async (url) => {
215228
const response = await fetch(url);
216-
229+
217230
if (response.status === 404) {
218231
// Charge for the work done and return error item in one call
219232
await Actor.pushData({
220233
url: url,
221234
error: "404",
222235
errorMessage: "Page not found"
223236
}, 'scraped-result');
224-
237+
225238
return;
226239
}
227240

@@ -232,7 +245,7 @@ await Actor.init();
232245

233246
const input = await Actor.getInput();
234247
const { urls } = input;
235-
248+
236249
for (const url of urls) {
237250
await processUrl(url);
238251
}
@@ -251,30 +264,30 @@ import requests
251264

252265
async def process_url(url):
253266
response = requests.get(url)
254-
267+
255268
if response.status_code == 404:
256269
# Charge for the work done and return error item in one call
257270
await Actor.push_data({
258271
'url': url,
259272
'error': '404',
260273
'errorMessage': 'Page not found'
261274
}, 'scraped-result')
262-
275+
263276
return
264277

265278
# Rest of the process_url function
266279

267280
async def main():
268281
await Actor.init()
269-
282+
270283
input_data = await Actor.get_input()
271284
urls = input_data.get('urls', [])
272-
285+
273286
for url in urls:
274287
await process_url(url)
275-
288+
276289
# Rest of the Actor logic
277-
290+
278291
await Actor.exit()
279292
```
280293

@@ -294,7 +307,7 @@ However, we acknowledge that some events don't produce tangible results (such as
294307
Examples:
295308

296309
- _`post` event_: Each charge adds one social media post to the dataset
297-
- _`profile` event_: Each charge adds one user profile to the dataset
310+
- _`profile` event_: Each charge adds one user profile to the dataset
298311
- _`processed-image` event_: Each charge adds one processed image to the dataset
299312
- _`ai-analysis` event_: Each charge processes one document through an AI workflow (no tangible output, but valuable processing)
300313

0 commit comments

Comments
 (0)