@the_ro_show/agent-ads-sdk 0.16.1 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -46,6 +46,35 @@ if (ad) {
46
46
  }
47
47
  ```
48
48
 
49
+ ## How You Earn Money
50
+
51
+ AttentionMarket pays you when users **click** sponsored content. It's that simple.
52
+
53
+ ### Revenue Formula
54
+ ```
55
+ Your Earnings = Clicks × Payout Per Click
56
+ ```
57
+
58
+ Every response shows exactly what you'll earn:
59
+ ```typescript
60
+ {
61
+ "payout": 250, // You earn $2.50 when clicked
62
+ "click_url": "https://...",
63
+ "creative": { title: "...", body: "..." }
64
+ }
65
+ ```
66
+
67
+ ### Why We Track Impressions
68
+
69
+ Impressions prevent click fraud. If sponsored content wasn't shown, clicks won't generate revenue.
70
+
71
+ **Important:**
72
+ - ✅ Impressions are **required** for clicks to count
73
+ - ❌ Impressions do **NOT** generate revenue themselves
74
+ - ✅ The SDK tracks impressions automatically
75
+
76
+ Think of impressions as a receipt: "Yes, this content was actually shown to a real user."
77
+
49
78
  ## Smart Context (v0.15.1+) 🎯
50
79
 
51
80
  Improve ad relevance by 2-3x with smart context features that understand user intent better:
@@ -375,10 +404,10 @@ const ad = await client.decideFromContext({
375
404
  **Validation:** Must be a non-negative number.
376
405
 
377
406
  **Use cases:**
378
- - Premium applications: `200+` for $2+ ads only
407
+ - Premium applications: `200+` for $2+ per click only
379
408
  - High-value verticals: Filter out low-budget advertisers
380
- - Revenue targets: Ensure minimum revenue per impression
381
- - Lower fill rate tolerance: When you'd rather show nothing than a low-value ad
409
+ - Revenue targets: Ensure minimum earnings when clicked
410
+ - Lower fill rate tolerance: When you'd rather show nothing than low-value content
382
411
 
383
412
  **Trade-off:** Higher thresholds = higher revenue per ad but lower fill rate.
384
413
 
@@ -466,16 +495,16 @@ The SDK automatically uses an optimized minimal payload format that reduces resp
466
495
 
467
496
  #### Response Formats
468
497
 
469
- The SDK supports three response formats:
498
+ The SDK supports three response formats that control both detail level and the number of ads returned:
470
499
 
471
500
  ```typescript
472
- // Minimal format (default, ~520B) - Essentials + relevance
501
+ // Minimal format (default) - 1 ad, essentials + relevance
473
502
  const ad = await client.decideFromContext({
474
503
  userMessage: "I need car insurance",
475
504
  response_format: 'minimal' // Optional, this is the default
476
505
  });
477
506
 
478
- // Returns:
507
+ // Returns a single ad object:
479
508
  {
480
509
  creative: { title, body, cta },
481
510
  click_url: string,
@@ -486,31 +515,47 @@ const ad = await client.decideFromContext({
486
515
  }
487
516
  ```
488
517
 
489
- For advanced use cases, you can request more detailed responses:
518
+ For multi-ad or detailed responses, use the `standard` or `verbose` formats:
490
519
 
491
520
  ```typescript
492
- // Standard format (645B) - Includes disclosure info
493
- const ad = await client.decide({
521
+ // Standard format up to 3 ads, includes disclosure info
522
+ const result = await client.decide({
494
523
  response_format: 'standard',
495
524
  // ... other params
496
525
  });
497
526
 
498
- // Verbose format (3.1KB) - Full response with all metadata
499
- const ad = await client.decide({
527
+ // Response wraps ads in an `ads` array:
528
+ // { ads: [{ creative, click_url, tracking_token, payout, disclosure, ... }] }
529
+ result.ads.forEach(ad => {
530
+ console.log(`${ad.creative.title} (relevance: ${ad.relevance_score})`);
531
+ });
532
+ ```
533
+
534
+ ```typescript
535
+ // Verbose format — up to 10 ads, adds auction + category metadata
536
+ const debug = await client.decide({
500
537
  response_format: 'verbose',
501
538
  // ... other params
502
539
  });
540
+
541
+ // Response wraps ads in a `units` array:
542
+ // { units: [{ ...all standard fields, campaign_id, auction_clearing_price, matched_categories }] }
543
+ debug.units.forEach(unit => {
544
+ console.log(`${unit.creative.title} — clearing price: ${unit.auction_clearing_price}`);
545
+ });
503
546
  ```
504
547
 
548
+ > **Tip:** All formats may return fewer ads than the maximum if fewer qualify after auction filtering. Always iterate the array rather than assuming a fixed count.
549
+
505
550
  #### Format Comparison
506
551
 
507
- | Format | Size | Use Case | Auto-impression |
508
- |--------|------|----------|-----------------|
509
- | **minimal** | ~520B | Production apps (default, includes relevance) | ✅ Yes |
510
- | **standard** | ~645B | Apps needing disclosure details | ❌ Manual |
511
- | **verbose** | ~3.1KB | Debugging, analytics | ❌ Manual |
552
+ | Format | Max Ads | Response Key | Size | Best For | Auto-impression |
553
+ |--------|---------|-------------|------|----------|-----------------|
554
+ | **minimal** | 1 | `ad` (object) | ~520B | Production apps (default) | ✅ Yes |
555
+ | **standard** | 3 | `ads` (array) | ~645B/ad | Showing multiple options, disclosure compliance | ❌ Manual |
556
+ | **verbose** | 10 | `units` (array) | ~3.1KB/ad | Debugging, analytics, auction inspection | ❌ Manual |
512
557
 
513
- **Note:** The minimal format automatically tracks impressions for you. When using standard or verbose formats with the raw `decide()` API, you must manually track impressions.
558
+ **Note:** The minimal format automatically tracks impressions. When using standard or verbose formats with the raw `decide()` API, you must track impressions manually.
514
559
 
515
560
  ## Advanced Features
516
561
 
@@ -586,6 +631,122 @@ await client.track({
586
631
  });
587
632
  ```
588
633
 
634
+ ### Developer Prediction System (Bonus Earnings)
635
+
636
+ **Get paid more for accurate predictions!** After showing an ad, predict whether the user will convert. If you're right, earn a bonus:
637
+ - ✅ Correct positive prediction → **+20% bonus**
638
+ - ✅ Correct negative prediction → **+5% bonus**
639
+ - ⚠️ Wrong prediction → No bonus (but no penalty)
640
+
641
+ #### How It Works
642
+
643
+ 1. **Show the ad** to your user using `decideFromContext()`
644
+ 2. **Observe their reaction** (interested? asked questions? changed topic?)
645
+ 3. **Send feedback** with your prediction
646
+ 4. **Get bonus** 7 days later if you were right
647
+
648
+ #### Option 1: Auto-Analysis (Recommended - Easiest)
649
+
650
+ Just send the user's raw response, and our AI analyzes sentiment automatically:
651
+
652
+ ```typescript
653
+ const ad = await client.decideFromContext({
654
+ userMessage: "I need car insurance",
655
+ placement: 'sponsored_suggestion'
656
+ });
657
+
658
+ // Show ad to user...
659
+ // User responds: "Tell me more about that Geico offer!"
660
+
661
+ await client.sendFeedback({
662
+ tracking_token: ad.tracking_token,
663
+ user_response: "Tell me more about that Geico offer!",
664
+ conversation_history: [
665
+ "User: I need car insurance",
666
+ "Agent: Check out Geico...",
667
+ "User: Tell me more about that Geico offer!"
668
+ ]
669
+ });
670
+
671
+ // Our AI detects: "positive" sentiment
672
+ // You get base earnings + 20% bonus if user converts
673
+ ```
674
+
675
+ **When to use:** You want simplicity. Let our AI handle sentiment analysis.
676
+
677
+ #### Option 2: Manual Prediction (Advanced - Full Control)
678
+
679
+ Analyze sentiment yourself and send your prediction:
680
+
681
+ ```typescript
682
+ const ad = await client.decideFromContext({
683
+ userMessage: "I need car insurance",
684
+ placement: 'sponsored_suggestion'
685
+ });
686
+
687
+ // Show ad to user...
688
+ // User responds: "No thanks, I already have insurance"
689
+
690
+ // YOU analyze: User declined → predict negative
691
+ await client.sendFeedback({
692
+ tracking_token: ad.tracking_token,
693
+ reaction: 'negative', // You determine this
694
+ context: 'User already has insurance, politely declined'
695
+ });
696
+
697
+ // If user doesn't convert, you get +5% bonus
698
+ ```
699
+
700
+ **When to use:** You want full control over sentiment classification, or you have your own sentiment analysis.
701
+
702
+ #### Prediction Guidelines
703
+
704
+ **Positive** - User shows interest:
705
+ - "Tell me more!"
706
+ - "How much does it cost?"
707
+ - "Can you sign me up?"
708
+ - Asks follow-up questions
709
+
710
+ **Neutral** - Hard to tell:
711
+ - "Maybe later"
712
+ - "I'll think about it"
713
+ - No clear response
714
+ - Non-committal
715
+
716
+ **Negative** - User not interested:
717
+ - "No thanks"
718
+ - "I already have that"
719
+ - Changes topic immediately
720
+ - Explicitly declines
721
+
722
+ #### Response Format
723
+
724
+ ```typescript
725
+ {
726
+ status: 'received',
727
+ feedback_id: 'evt_abc123',
728
+ potential_bonus: '20%',
729
+ resolution_date: '2026-03-13',
730
+ message: 'Feedback recorded. Bonus will be calculated after 7-day conversion window.',
731
+
732
+ // Only in auto-analysis mode:
733
+ sentiment_detected: 'positive',
734
+ analysis_mode: 'auto'
735
+ }
736
+ ```
737
+
738
+ #### Best Practices
739
+
740
+ 1. **Submit within 24 hours** - Feedback must be sent within 24 hours of showing the ad
741
+ 2. **One prediction per ad** - You can only submit feedback once per tracking_token
742
+ 3. **Be honest** - Don't predict "positive" for everything. Our system rewards accuracy, not volume
743
+ 4. **Use context** - Include conversation history for better auto-analysis
744
+ 5. **Skip when unsure** - No feedback is better than random guessing
745
+
746
+ #### Cost of Auto-Analysis
747
+
748
+ Auto-analysis costs ~$0.0001 per request (using GPT-3.5-turbo). We absorb this cost, so it's free for you. The better accuracy and developer experience is worth it.
749
+
589
750
  ## Error Handling
590
751
 
591
752
  The SDK throws errors for invalid configurations and failed requests:
@@ -704,6 +865,15 @@ Create a simple getRelevantAd(message) function that returns ads only when relev
704
865
 
705
866
  ## Changelog
706
867
 
868
+ ### v0.17.0 (2026-03-06) - AI-Powered Feedback Analysis
869
+ - 🤖 **Auto-Analysis Mode:** Send raw user responses, our AI detects sentiment automatically
870
+ - 💰 **Bonus Earnings:** +20% for correct positive predictions, +5% for correct negative predictions
871
+ - 🔄 **Backward Compatible:** Existing manual `reaction` mode still supported
872
+ - 📊 **Conversation Context:** Include conversation history for better sentiment analysis
873
+ - ⚡ **Fast & Cheap:** GPT-3.5-turbo analysis (~$0.0001 per request, free for developers)
874
+ - 🎯 **Fallback Logic:** Defaults to 'neutral' if AI analysis fails
875
+ - 📝 **Enhanced Logging:** Track analysis_mode and sentiment_confidence in metadata
876
+
707
877
  ### v0.15.1 (2026-02-26) - Bug Fixes & Security
708
878
  - 🔒 Fixed session leak - sessionId now request-scoped, not instance-scoped
709
879
  - 🛡️ Added comprehensive input validation and sanitization
package/dist/index.d.mts CHANGED
@@ -294,44 +294,63 @@ interface EventIngestRequest {
294
294
  interface EventIngestResponse {
295
295
  accepted: boolean;
296
296
  }
297
- /**
298
- * Sentiment types detected by backend AI analysis.
299
- *
300
- * - positive: User is interested/engaged (earn +15% if converts, -5% if not)
301
- * - neutral: User is indifferent (no bonus/penalty, data only)
302
- * - negative: User disliked the ad (no penalty, data only)
303
- */
304
- type FeedbackSentiment = 'positive' | 'neutral' | 'negative';
305
297
  /**
306
298
  * Send feedback on an ad after showing it to a user.
307
299
  *
308
- * **New in v0.11.0:** Backend analyzes sentiment automatically using AI.
309
- * Just send the user's actual response text - no need to classify it yourself.
300
+ * **Two modes available:**
310
301
  *
311
- * **Anti-Fraud:** Bonuses are deferred and validated against actual conversions.
312
- * - Correct positive prediction → +15% bonus after 7 days
313
- * - Wrong positive prediction → -5% penalty after 7 days
314
- * - Neutral/negative → no bonus/penalty (data only)
302
+ * **Auto-Analysis (Recommended):** Send the user's raw response, and our AI analyzes sentiment.
303
+ * ```typescript
304
+ * await client.sendFeedback({
305
+ * tracking_token: ad.tracking_token,
306
+ * user_response: "Tell me more about that!",
307
+ * conversation_history: ["Previous message 1", "Previous message 2"]
308
+ * });
309
+ * ```
315
310
  *
316
- * @example
311
+ * **Manual Prediction:** Analyze sentiment yourself and send the prediction.
317
312
  * ```typescript
318
313
  * await client.sendFeedback({
319
314
  * tracking_token: ad.tracking_token,
320
- * user_response: "This looks perfect! How do I sign up?",
321
- * agent_response: "Here's the signup link...",
322
- * additional_context: "User spent 2 minutes reading the offer"
315
+ * reaction: 'positive', // You determine this
316
+ * context: 'User asked follow-up questions'
323
317
  * });
324
318
  * ```
319
+ *
320
+ * **Bonuses (7-day deferred):**
321
+ * - Correct positive prediction → +20% bonus
322
+ * - Correct negative prediction → +5% bonus
323
+ * - Wrong prediction or no feedback → No bonus
325
324
  */
326
325
  interface FeedbackRequest {
327
- /** Tracking token from the ad you showed */
326
+ /** Tracking token from the ad you showed (required) */
328
327
  tracking_token: string;
329
- /** User's actual response text (required) */
330
- user_response: string;
331
- /** Your agent's response (optional, helps sentiment analysis) */
332
- agent_response?: string;
333
- /** Additional context about the interaction (optional) */
334
- additional_context?: string;
328
+ /**
329
+ * OPTION 1 (Auto-Analysis): User's actual response text.
330
+ * Our AI will analyze sentiment and determine positive/neutral/negative.
331
+ * Max 2000 characters.
332
+ */
333
+ user_response?: string;
334
+ /**
335
+ * Conversation history for better context in auto-analysis.
336
+ * We use the last 3 messages to understand the conversation flow.
337
+ */
338
+ conversation_history?: string[];
339
+ /**
340
+ * OPTION 2 (Manual): Your prediction of user interest.
341
+ * Use this if you want full control over sentiment classification.
342
+ */
343
+ reaction?: 'positive' | 'neutral' | 'negative';
344
+ /**
345
+ * Additional context about the interaction (optional, both modes).
346
+ * Max 1000 characters.
347
+ */
348
+ context?: string;
349
+ /**
350
+ * Idempotency key for safe retries (optional).
351
+ * Use the same key if retrying a failed request to avoid duplicate feedback.
352
+ */
353
+ idempotency_key?: string;
335
354
  }
336
355
  /**
337
356
  * Response from sending feedback.
@@ -340,18 +359,57 @@ interface FeedbackRequest {
340
359
  * based on whether the user actually converted.
341
360
  */
342
361
  interface FeedbackResponse {
343
- /** Whether feedback was recorded successfully */
344
- success: boolean;
345
- /** AI-detected sentiment from user response */
346
- sentiment_detected: FeedbackSentiment;
347
- /** Potential bonus if prediction is correct (not guaranteed) */
362
+ /** Status of feedback submission */
363
+ status: 'received';
364
+ /** Unique ID for this feedback event */
365
+ feedback_id: string;
366
+ /** Potential bonus if prediction is correct (20% for positive, 5% for negative) */
348
367
  potential_bonus: string;
349
- /** Potential penalty if prediction is wrong */
350
- potential_penalty: string;
351
368
  /** Explanation of the deferred bonus system */
352
369
  message: string;
353
- /** When the bonus will be resolved (7 days from now) */
370
+ /** When the bonus will be resolved (7 days from impression, YYYY-MM-DD) */
354
371
  resolution_date: string;
372
+ /**
373
+ * AI-detected sentiment (only present in auto-analysis mode).
374
+ * Shows what sentiment our AI detected from the user response.
375
+ */
376
+ sentiment_detected?: 'positive' | 'neutral' | 'negative';
377
+ /**
378
+ * Analysis mode used (only present in auto-analysis or fallback modes).
379
+ * - 'auto': AI analyzed sentiment
380
+ * - 'fallback': AI failed, defaulted to neutral
381
+ */
382
+ analysis_mode?: 'auto' | 'fallback';
383
+ }
384
+ /**
385
+ * Rate the delivery quality of an ad after a verified click.
386
+ *
387
+ * @example
388
+ * ```typescript
389
+ * await client.rateBusinessDelivery({
390
+ * tracking_token: ad.tracking_token,
391
+ * ad_unit_id: ad._ad.unit_id,
392
+ * rating: 4,
393
+ * context: 'Relevant product, good landing page'
394
+ * });
395
+ * ```
396
+ */
397
+ interface BusinessRatingRequest {
398
+ /** Tracking token from the ad (required) */
399
+ tracking_token: string;
400
+ /** Ad unit ID from the ad response (required) */
401
+ ad_unit_id: string;
402
+ /** Delivery quality rating: 1 (poor) to 5 (excellent) */
403
+ rating: 1 | 2 | 3 | 4 | 5;
404
+ /** Optional context about the rating (max 500 chars) */
405
+ context?: string;
406
+ /** Idempotency key for safe retries (optional) */
407
+ idempotency_key?: string;
408
+ }
409
+ interface BusinessRatingResponse {
410
+ status: 'received';
411
+ rating_id: string;
412
+ campaign_id: string;
355
413
  }
356
414
  interface PolicyResponse {
357
415
  version: string;
@@ -932,6 +990,22 @@ declare class AttentionMarketClient {
932
990
  * ```
933
991
  */
934
992
  sendFeedback(request: FeedbackRequest): Promise<FeedbackResponse>;
993
+ /**
994
+ * Rate the delivery quality of an ad after a verified click.
995
+ * Requires a prior click event for the tracking_token. Ratings feed
996
+ * into quality scores (minimum 5 unique raters per campaign).
997
+ *
998
+ * @example
999
+ * ```typescript
1000
+ * await client.rateBusinessDelivery({
1001
+ * tracking_token: ad.tracking_token,
1002
+ * ad_unit_id: ad._ad.unit_id,
1003
+ * rating: 4,
1004
+ * context: 'Relevant product, good landing page'
1005
+ * });
1006
+ * ```
1007
+ */
1008
+ rateBusinessDelivery(request: BusinessRatingRequest): Promise<BusinessRatingResponse>;
935
1009
  /**
936
1010
  * Fetch default policy constraints and formatting requirements.
937
1011
  */
package/dist/index.d.ts CHANGED
@@ -294,44 +294,63 @@ interface EventIngestRequest {
294
294
  interface EventIngestResponse {
295
295
  accepted: boolean;
296
296
  }
297
- /**
298
- * Sentiment types detected by backend AI analysis.
299
- *
300
- * - positive: User is interested/engaged (earn +15% if converts, -5% if not)
301
- * - neutral: User is indifferent (no bonus/penalty, data only)
302
- * - negative: User disliked the ad (no penalty, data only)
303
- */
304
- type FeedbackSentiment = 'positive' | 'neutral' | 'negative';
305
297
  /**
306
298
  * Send feedback on an ad after showing it to a user.
307
299
  *
308
- * **New in v0.11.0:** Backend analyzes sentiment automatically using AI.
309
- * Just send the user's actual response text - no need to classify it yourself.
300
+ * **Two modes available:**
310
301
  *
311
- * **Anti-Fraud:** Bonuses are deferred and validated against actual conversions.
312
- * - Correct positive prediction → +15% bonus after 7 days
313
- * - Wrong positive prediction → -5% penalty after 7 days
314
- * - Neutral/negative → no bonus/penalty (data only)
302
+ * **Auto-Analysis (Recommended):** Send the user's raw response, and our AI analyzes sentiment.
303
+ * ```typescript
304
+ * await client.sendFeedback({
305
+ * tracking_token: ad.tracking_token,
306
+ * user_response: "Tell me more about that!",
307
+ * conversation_history: ["Previous message 1", "Previous message 2"]
308
+ * });
309
+ * ```
315
310
  *
316
- * @example
311
+ * **Manual Prediction:** Analyze sentiment yourself and send the prediction.
317
312
  * ```typescript
318
313
  * await client.sendFeedback({
319
314
  * tracking_token: ad.tracking_token,
320
- * user_response: "This looks perfect! How do I sign up?",
321
- * agent_response: "Here's the signup link...",
322
- * additional_context: "User spent 2 minutes reading the offer"
315
+ * reaction: 'positive', // You determine this
316
+ * context: 'User asked follow-up questions'
323
317
  * });
324
318
  * ```
319
+ *
320
+ * **Bonuses (7-day deferred):**
321
+ * - Correct positive prediction → +20% bonus
322
+ * - Correct negative prediction → +5% bonus
323
+ * - Wrong prediction or no feedback → No bonus
325
324
  */
326
325
  interface FeedbackRequest {
327
- /** Tracking token from the ad you showed */
326
+ /** Tracking token from the ad you showed (required) */
328
327
  tracking_token: string;
329
- /** User's actual response text (required) */
330
- user_response: string;
331
- /** Your agent's response (optional, helps sentiment analysis) */
332
- agent_response?: string;
333
- /** Additional context about the interaction (optional) */
334
- additional_context?: string;
328
+ /**
329
+ * OPTION 1 (Auto-Analysis): User's actual response text.
330
+ * Our AI will analyze sentiment and determine positive/neutral/negative.
331
+ * Max 2000 characters.
332
+ */
333
+ user_response?: string;
334
+ /**
335
+ * Conversation history for better context in auto-analysis.
336
+ * We use the last 3 messages to understand the conversation flow.
337
+ */
338
+ conversation_history?: string[];
339
+ /**
340
+ * OPTION 2 (Manual): Your prediction of user interest.
341
+ * Use this if you want full control over sentiment classification.
342
+ */
343
+ reaction?: 'positive' | 'neutral' | 'negative';
344
+ /**
345
+ * Additional context about the interaction (optional, both modes).
346
+ * Max 1000 characters.
347
+ */
348
+ context?: string;
349
+ /**
350
+ * Idempotency key for safe retries (optional).
351
+ * Use the same key if retrying a failed request to avoid duplicate feedback.
352
+ */
353
+ idempotency_key?: string;
335
354
  }
336
355
  /**
337
356
  * Response from sending feedback.
@@ -340,18 +359,57 @@ interface FeedbackRequest {
340
359
  * based on whether the user actually converted.
341
360
  */
342
361
  interface FeedbackResponse {
343
- /** Whether feedback was recorded successfully */
344
- success: boolean;
345
- /** AI-detected sentiment from user response */
346
- sentiment_detected: FeedbackSentiment;
347
- /** Potential bonus if prediction is correct (not guaranteed) */
362
+ /** Status of feedback submission */
363
+ status: 'received';
364
+ /** Unique ID for this feedback event */
365
+ feedback_id: string;
366
+ /** Potential bonus if prediction is correct (20% for positive, 5% for negative) */
348
367
  potential_bonus: string;
349
- /** Potential penalty if prediction is wrong */
350
- potential_penalty: string;
351
368
  /** Explanation of the deferred bonus system */
352
369
  message: string;
353
- /** When the bonus will be resolved (7 days from now) */
370
+ /** When the bonus will be resolved (7 days from impression, YYYY-MM-DD) */
354
371
  resolution_date: string;
372
+ /**
373
+ * AI-detected sentiment (only present in auto-analysis mode).
374
+ * Shows what sentiment our AI detected from the user response.
375
+ */
376
+ sentiment_detected?: 'positive' | 'neutral' | 'negative';
377
+ /**
378
+ * Analysis mode used (only present in auto-analysis or fallback modes).
379
+ * - 'auto': AI analyzed sentiment
380
+ * - 'fallback': AI failed, defaulted to neutral
381
+ */
382
+ analysis_mode?: 'auto' | 'fallback';
383
+ }
384
+ /**
385
+ * Rate the delivery quality of an ad after a verified click.
386
+ *
387
+ * @example
388
+ * ```typescript
389
+ * await client.rateBusinessDelivery({
390
+ * tracking_token: ad.tracking_token,
391
+ * ad_unit_id: ad._ad.unit_id,
392
+ * rating: 4,
393
+ * context: 'Relevant product, good landing page'
394
+ * });
395
+ * ```
396
+ */
397
+ interface BusinessRatingRequest {
398
+ /** Tracking token from the ad (required) */
399
+ tracking_token: string;
400
+ /** Ad unit ID from the ad response (required) */
401
+ ad_unit_id: string;
402
+ /** Delivery quality rating: 1 (poor) to 5 (excellent) */
403
+ rating: 1 | 2 | 3 | 4 | 5;
404
+ /** Optional context about the rating (max 500 chars) */
405
+ context?: string;
406
+ /** Idempotency key for safe retries (optional) */
407
+ idempotency_key?: string;
408
+ }
409
+ interface BusinessRatingResponse {
410
+ status: 'received';
411
+ rating_id: string;
412
+ campaign_id: string;
355
413
  }
356
414
  interface PolicyResponse {
357
415
  version: string;
@@ -932,6 +990,22 @@ declare class AttentionMarketClient {
932
990
  * ```
933
991
  */
934
992
  sendFeedback(request: FeedbackRequest): Promise<FeedbackResponse>;
993
+ /**
994
+ * Rate the delivery quality of an ad after a verified click.
995
+ * Requires a prior click event for the tracking_token. Ratings feed
996
+ * into quality scores (minimum 5 unique raters per campaign).
997
+ *
998
+ * @example
999
+ * ```typescript
1000
+ * await client.rateBusinessDelivery({
1001
+ * tracking_token: ad.tracking_token,
1002
+ * ad_unit_id: ad._ad.unit_id,
1003
+ * rating: 4,
1004
+ * context: 'Relevant product, good landing page'
1005
+ * });
1006
+ * ```
1007
+ */
1008
+ rateBusinessDelivery(request: BusinessRatingRequest): Promise<BusinessRatingResponse>;
935
1009
  /**
936
1010
  * Fetch default policy constraints and formatting requirements.
937
1011
  */
package/dist/index.js CHANGED
@@ -865,6 +865,24 @@ var AttentionMarketClient = class {
865
865
  async sendFeedback(request) {
866
866
  return await this.http.request("POST", "/feedback", { body: request });
867
867
  }
868
+ /**
869
+ * Rate the delivery quality of an ad after a verified click.
870
+ * Requires a prior click event for the tracking_token. Ratings feed
871
+ * into quality scores (minimum 5 unique raters per campaign).
872
+ *
873
+ * @example
874
+ * ```typescript
875
+ * await client.rateBusinessDelivery({
876
+ * tracking_token: ad.tracking_token,
877
+ * ad_unit_id: ad._ad.unit_id,
878
+ * rating: 4,
879
+ * context: 'Relevant product, good landing page'
880
+ * });
881
+ * ```
882
+ */
883
+ async rateBusinessDelivery(request) {
884
+ return await this.http.request("POST", "/rate-business", { body: request });
885
+ }
868
886
  /**
869
887
  * Fetch default policy constraints and formatting requirements.
870
888
  */
@@ -1393,6 +1411,7 @@ var AttentionMarketClient = class {
1393
1411
  url
1394
1412
  );
1395
1413
  }
1414
+ // TODO: Add getDeveloperMetrics() method when DeveloperMetricsResponse type is defined
1396
1415
  };
1397
1416
 
1398
1417
  // src/mock-client.ts