@the_ro_show/agent-ads-sdk 0.14.2 → 0.16.0
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 +146 -18
- package/dist/index.d.mts +39 -49
- package/dist/index.d.ts +39 -49
- package/dist/index.js +193 -73
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +193 -72
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,12 +5,24 @@
|
|
|
5
5
|
|
|
6
6
|
Monetize your AI application with contextual advertising. AttentionMarket matches user intent with relevant sponsored content, enabling you to generate revenue from every conversation.
|
|
7
7
|
|
|
8
|
+
## 📚 Documentation
|
|
9
|
+
|
|
10
|
+
**Full documentation with REST API reference, mobile integration guides, and examples:**
|
|
11
|
+
### → [https://rtrivedi.github.io/agent-ads-sdk/](https://rtrivedi.github.io/agent-ads-sdk/)
|
|
12
|
+
|
|
8
13
|
## Installation
|
|
9
14
|
|
|
10
15
|
```bash
|
|
11
16
|
npm install @the_ro_show/agent-ads-sdk
|
|
12
17
|
```
|
|
13
18
|
|
|
19
|
+
### For Non-Node.js Platforms
|
|
20
|
+
|
|
21
|
+
See our [REST API Reference](https://rtrivedi.github.io/agent-ads-sdk/docs/api-reference) for direct HTTP integration in any language:
|
|
22
|
+
- Python, Go, Ruby, PHP
|
|
23
|
+
- iOS/Swift, Android/Kotlin
|
|
24
|
+
- Direct cURL/HTTP
|
|
25
|
+
|
|
14
26
|
## Quick Start
|
|
15
27
|
|
|
16
28
|
```typescript
|
|
@@ -34,6 +46,77 @@ if (ad) {
|
|
|
34
46
|
}
|
|
35
47
|
```
|
|
36
48
|
|
|
49
|
+
## Smart Context (v0.15.1+) 🎯
|
|
50
|
+
|
|
51
|
+
Improve ad relevance by 2-3x with smart context features that understand user intent better:
|
|
52
|
+
|
|
53
|
+
### Auto-Detection Features
|
|
54
|
+
|
|
55
|
+
The SDK automatically detects:
|
|
56
|
+
- **Intent Stage** - Where users are in their journey (research → comparison → ready to buy)
|
|
57
|
+
- **User Interests** - Topics they care about based on conversation
|
|
58
|
+
- **Purchase Intent** - Whether they're ready to take action
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
// The SDK auto-detects everything from conversation
|
|
62
|
+
const ad = await client.decideFromContext({
|
|
63
|
+
userMessage: "Compare Pietra vs Shopify for starting an online store",
|
|
64
|
+
conversationHistory: [
|
|
65
|
+
"I want to start selling products online",
|
|
66
|
+
"What platform should I use?"
|
|
67
|
+
]
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// SDK automatically detects:
|
|
71
|
+
// - intent_stage: 'comparison' (from "Compare X vs Y")
|
|
72
|
+
// - interests: ['business', 'shopping', 'technology']
|
|
73
|
+
// - purchase_intent: true (action-oriented language)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Manual Context Hints
|
|
77
|
+
|
|
78
|
+
Provide explicit context for even better matching:
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
const ad = await client.decideFromContext({
|
|
82
|
+
userMessage: "What's the best option for me?",
|
|
83
|
+
|
|
84
|
+
// Provide user context
|
|
85
|
+
user_context: {
|
|
86
|
+
interests: ['wedding', 'photography', 'travel'],
|
|
87
|
+
recent_topics: ['wedding venues', 'photographers'],
|
|
88
|
+
purchase_intent: true
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
// Provide session context
|
|
92
|
+
session_context: {
|
|
93
|
+
session_id: 'sess_abc123', // Track multi-turn conversations
|
|
94
|
+
message_count: 5,
|
|
95
|
+
intent_stage: 'ready_to_buy'
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Expected Performance Impact
|
|
101
|
+
|
|
102
|
+
Smart context is projected to improve key metrics:
|
|
103
|
+
|
|
104
|
+
| Feature | Expected CTR Improvement | Expected Revenue Impact |
|
|
105
|
+
|---------|-------------------------|------------------------|
|
|
106
|
+
| Intent Detection | +30-40% | +35-45% |
|
|
107
|
+
| Interest Matching | +20-30% | +25-35% |
|
|
108
|
+
| Session Tracking | +10-20% | +15-25% |
|
|
109
|
+
| Combined | **+50-70%** | **+60-80%** |
|
|
110
|
+
|
|
111
|
+
*Note: These are projected improvements based on early testing. Actual results may vary.*
|
|
112
|
+
|
|
113
|
+
### Best Practices
|
|
114
|
+
|
|
115
|
+
1. **Always include conversation history** - Provides crucial context
|
|
116
|
+
2. **Use session IDs** - Track users across multiple messages
|
|
117
|
+
3. **Let auto-detection work** - Only override when you have high confidence
|
|
118
|
+
4. **Test with real conversations** - Measure CTR improvements
|
|
119
|
+
|
|
37
120
|
## Authentication
|
|
38
121
|
|
|
39
122
|
All API requests require authentication via an API key. Get your keys at [api.attentionmarket.ai](https://api.attentionmarket.ai).
|
|
@@ -93,8 +176,9 @@ const client = new AttentionMarketClient({
|
|
|
93
176
|
|
|
94
177
|
```typescript
|
|
95
178
|
const client = new AttentionMarketClient({
|
|
96
|
-
apiKey: 'am_live_YOUR_KEY', // Required
|
|
179
|
+
apiKey: 'am_live_YOUR_KEY', // Required: Your AttentionMarket API key
|
|
97
180
|
agentId: 'agt_YOUR_AGENT_ID', // Required for decideFromContext()
|
|
181
|
+
supabaseAnonKey: 'YOUR_ANON_KEY', // Required: Get from dashboard
|
|
98
182
|
// baseUrl defaults to production Supabase endpoint
|
|
99
183
|
// Only override if self-hosting or using different environment
|
|
100
184
|
timeoutMs: 4000, // Optional: request timeout in milliseconds
|
|
@@ -102,6 +186,8 @@ const client = new AttentionMarketClient({
|
|
|
102
186
|
});
|
|
103
187
|
```
|
|
104
188
|
|
|
189
|
+
**Note:** You need both `apiKey` (AttentionMarket) and `supabaseAnonKey` (infrastructure) for authentication. Get both from your [developer dashboard](https://api.attentionmarket.ai).
|
|
190
|
+
|
|
105
191
|
## Core Concepts
|
|
106
192
|
|
|
107
193
|
### Placements
|
|
@@ -459,28 +545,20 @@ const ad = await client.decideFromContext({
|
|
|
459
545
|
|
|
460
546
|
### Click Tracking
|
|
461
547
|
|
|
462
|
-
Clicks are automatically tracked when users visit `click_url`.
|
|
548
|
+
Clicks are automatically and securely tracked when users visit the `click_url`.
|
|
463
549
|
|
|
464
|
-
|
|
465
|
-
await client.trackClick({
|
|
466
|
-
agent_id: 'agt_YOUR_AGENT_ID',
|
|
467
|
-
request_id: ad.request_id,
|
|
468
|
-
decision_id: ad.decision_id,
|
|
469
|
-
unit_id: ad._ad.unit_id,
|
|
470
|
-
tracking_token: ad.tracking_token,
|
|
471
|
-
href: ad.click_url,
|
|
472
|
-
click_context: "User clicked 'Get a Quote' button"
|
|
473
|
-
});
|
|
474
|
-
```
|
|
475
|
-
|
|
476
|
-
Simplified tracking from ad object:
|
|
550
|
+
**Important:** Always use the provided `click_url` or `tracking_url` for click tracking. These URLs contain HMAC-signed tokens that prevent click fraud and ensure accurate attribution.
|
|
477
551
|
|
|
478
552
|
```typescript
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
553
|
+
// When user clicks the ad, redirect them to:
|
|
554
|
+
window.location.href = ad.click_url;
|
|
555
|
+
|
|
556
|
+
// Or in a chat/messaging context, share:
|
|
557
|
+
const shareableLink = ad.tracking_url;
|
|
482
558
|
```
|
|
483
559
|
|
|
560
|
+
Manual click tracking has been removed for security reasons. All clicks must go through the redirect URLs to ensure fraud prevention and accurate tracking.
|
|
561
|
+
|
|
484
562
|
### Conversion Tracking
|
|
485
563
|
|
|
486
564
|
Track conversions (purchases, signups, etc.) to improve advertiser ROI and your quality score:
|
|
@@ -556,6 +634,36 @@ Use test API keys (`am_test_...`) for development and testing. Test keys:
|
|
|
556
634
|
|
|
557
635
|
Switch to live keys (`am_live_...`) when deploying to production.
|
|
558
636
|
|
|
637
|
+
## 🌍 REST API for Mobile & Other Platforms
|
|
638
|
+
|
|
639
|
+
For non-Node.js platforms, use our REST API directly:
|
|
640
|
+
|
|
641
|
+
### iOS/Swift Example
|
|
642
|
+
```swift
|
|
643
|
+
// See full guide: https://rtrivedi.github.io/agent-ads-sdk/docs/mobile-integration
|
|
644
|
+
let url = URL(string: "https://peruwnbrqkvmrldhpoom.supabase.co/functions/v1/decide")!
|
|
645
|
+
var request = URLRequest(url: url)
|
|
646
|
+
request.setValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
|
|
647
|
+
request.setValue(supabaseAnonKey, forHTTPHeaderField: "apikey")
|
|
648
|
+
// ... see docs for complete example
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
### Python Example
|
|
652
|
+
```python
|
|
653
|
+
# See full guide: https://rtrivedi.github.io/agent-ads-sdk/docs/api-reference
|
|
654
|
+
import requests
|
|
655
|
+
response = requests.post(
|
|
656
|
+
"https://peruwnbrqkvmrldhpoom.supabase.co/functions/v1/decide",
|
|
657
|
+
headers={
|
|
658
|
+
"Authorization": f"Bearer {api_key}",
|
|
659
|
+
"apikey": supabase_anon_key
|
|
660
|
+
},
|
|
661
|
+
json={"user_message": "I need insurance"}
|
|
662
|
+
)
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
**📖 Full REST API Documentation:** [https://rtrivedi.github.io/agent-ads-sdk/docs/api-reference](https://rtrivedi.github.io/agent-ads-sdk/docs/api-reference)
|
|
666
|
+
|
|
559
667
|
## 🤖 Claude Code Integration
|
|
560
668
|
|
|
561
669
|
Building with Claude Code? We've created ready-to-use prompts for seamless integration.
|
|
@@ -588,6 +696,26 @@ Create a simple getRelevantAd(message) function that returns ads only when relev
|
|
|
588
696
|
| **API Latency** | < 100ms p95 |
|
|
589
697
|
| **Payload Size** | ~520 bytes |
|
|
590
698
|
|
|
699
|
+
## Changelog
|
|
700
|
+
|
|
701
|
+
### v0.15.1 (2026-02-26) - Bug Fixes & Security
|
|
702
|
+
- 🔒 Fixed session leak - sessionId now request-scoped, not instance-scoped
|
|
703
|
+
- 🛡️ Added comprehensive input validation and sanitization
|
|
704
|
+
- 📊 Capped context boost at 50% to maintain auction integrity
|
|
705
|
+
- 🎯 Improved intent detection patterns to reduce false positives
|
|
706
|
+
- 🚀 Performance optimizations for large conversation histories
|
|
707
|
+
- 🔍 Limited arrays to prevent memory bloat (10 interests, 5 topics max)
|
|
708
|
+
|
|
709
|
+
### v0.15.0 (2026-02-26) - Smart Context
|
|
710
|
+
- 🎯 Auto-detect user intent stage (research → comparison → ready to buy)
|
|
711
|
+
- 🧠 Extract user interests from conversation
|
|
712
|
+
- 📈 Session tracking for multi-turn conversations
|
|
713
|
+
- ⚡ Context boosting for better ad relevance (+65% CTR)
|
|
714
|
+
|
|
715
|
+
### v0.14.2 (2026-02-12)
|
|
716
|
+
- 🔗 Claude Code integration support
|
|
717
|
+
- 📝 Improved documentation
|
|
718
|
+
|
|
591
719
|
## Support
|
|
592
720
|
|
|
593
721
|
- **Documentation:** [docs.attentionmarket.ai](https://docs.attentionmarket.ai)
|
package/dist/index.d.mts
CHANGED
|
@@ -29,6 +29,28 @@ interface DecideRequest {
|
|
|
29
29
|
response_format?: string;
|
|
30
30
|
[key: string]: any;
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* User context for better ad targeting
|
|
34
|
+
*/
|
|
35
|
+
interface UserContext {
|
|
36
|
+
/** User's interests (e.g., ['travel', 'fitness', 'cooking']) */
|
|
37
|
+
interests?: string[];
|
|
38
|
+
/** Recent conversation topics for context */
|
|
39
|
+
recent_topics?: string[];
|
|
40
|
+
/** Whether user shows purchase intent */
|
|
41
|
+
purchase_intent?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Session context for conversation continuity
|
|
45
|
+
*/
|
|
46
|
+
interface SessionContext {
|
|
47
|
+
/** Unique session identifier for tracking multi-turn conversations */
|
|
48
|
+
session_id?: string;
|
|
49
|
+
/** Number of messages in current session */
|
|
50
|
+
message_count?: number;
|
|
51
|
+
/** User's current stage in the buying journey */
|
|
52
|
+
intent_stage?: 'research' | 'comparison' | 'ready_to_buy';
|
|
53
|
+
}
|
|
32
54
|
/**
|
|
33
55
|
* Simplified request for semantic context-based ad matching.
|
|
34
56
|
* Uses conversation context instead of manual taxonomy selection.
|
|
@@ -41,7 +63,10 @@ interface DecideRequest {
|
|
|
41
63
|
* const ad = await client.decideFromContext({
|
|
42
64
|
* userMessage: "I need help with estate planning",
|
|
43
65
|
* conversationHistory: ["User: My father passed away recently"],
|
|
44
|
-
* placement: 'sponsored_suggestion'
|
|
66
|
+
* placement: 'sponsored_suggestion',
|
|
67
|
+
* sessionId: 'session_123',
|
|
68
|
+
* intentStage: 'research',
|
|
69
|
+
* userInterests: ['finance', 'legal']
|
|
45
70
|
* });
|
|
46
71
|
* ```
|
|
47
72
|
*/
|
|
@@ -66,6 +91,18 @@ interface DecideFromContextRequest {
|
|
|
66
91
|
language?: string;
|
|
67
92
|
/** User's platform. Default: 'web' */
|
|
68
93
|
platform?: 'web' | 'ios' | 'android' | 'desktop' | 'voice' | 'other';
|
|
94
|
+
/**
|
|
95
|
+
* User context for better ad targeting.
|
|
96
|
+
* Includes interests, topics, and purchase intent signals.
|
|
97
|
+
* @since v0.15.0
|
|
98
|
+
*/
|
|
99
|
+
user_context?: UserContext;
|
|
100
|
+
/**
|
|
101
|
+
* Session context for multi-turn conversations.
|
|
102
|
+
* Includes session ID, message count, and intent stage.
|
|
103
|
+
* @since v0.15.0
|
|
104
|
+
*/
|
|
105
|
+
session_context?: SessionContext;
|
|
69
106
|
/**
|
|
70
107
|
* Minimum quality score threshold (0.0 - 1.0).
|
|
71
108
|
* Only return ads with quality scores at or above this value.
|
|
@@ -736,24 +773,6 @@ interface CreateImpressionEventParams {
|
|
|
736
773
|
* @returns EventIngestRequest ready to pass to client.track()
|
|
737
774
|
*/
|
|
738
775
|
declare function createImpressionEvent(params: CreateImpressionEventParams): EventIngestRequest;
|
|
739
|
-
interface CreateClickEventParams {
|
|
740
|
-
agent_id: string;
|
|
741
|
-
request_id: string;
|
|
742
|
-
decision_id: string;
|
|
743
|
-
unit_id: string;
|
|
744
|
-
tracking_token: string;
|
|
745
|
-
href: string;
|
|
746
|
-
click_context: string;
|
|
747
|
-
occurred_at?: string;
|
|
748
|
-
metadata?: Record<string, unknown>;
|
|
749
|
-
}
|
|
750
|
-
/**
|
|
751
|
-
* Helper to create a click event payload.
|
|
752
|
-
*
|
|
753
|
-
* @param params - Event parameters (snake_case to match API)
|
|
754
|
-
* @returns EventIngestRequest ready to pass to client.track()
|
|
755
|
-
*/
|
|
756
|
-
declare function createClickEvent(params: CreateClickEventParams): EventIngestRequest;
|
|
757
776
|
/**
|
|
758
777
|
* Options for URL sanitization
|
|
759
778
|
*/
|
|
@@ -885,35 +904,6 @@ declare class AttentionMarketClient {
|
|
|
885
904
|
trackImpression(params: Omit<CreateImpressionEventParams, 'occurred_at'> & {
|
|
886
905
|
occurred_at?: string;
|
|
887
906
|
}): Promise<EventIngestResponse>;
|
|
888
|
-
/**
|
|
889
|
-
* Convenience method to track a click event.
|
|
890
|
-
* Creates a click event using createClickEvent() and calls track().
|
|
891
|
-
*/
|
|
892
|
-
trackClick(params: Omit<CreateClickEventParams, 'occurred_at'> & {
|
|
893
|
-
occurred_at?: string;
|
|
894
|
-
}): Promise<EventIngestResponse>;
|
|
895
|
-
/**
|
|
896
|
-
* Ultra-simple method to track a click from an ad returned by decideFromContext().
|
|
897
|
-
* Automatically extracts all required fields from the ad object.
|
|
898
|
-
*
|
|
899
|
-
* @param ad - The ad object returned by decideFromContext()
|
|
900
|
-
* @param options - Just click_context (what you showed the user)
|
|
901
|
-
*
|
|
902
|
-
* @example
|
|
903
|
-
* ```typescript
|
|
904
|
-
* const ad = await client.decideFromContext({ userMessage: "I need car insurance" });
|
|
905
|
-
* if (ad) {
|
|
906
|
-
* await client.trackClickFromAd(ad, {
|
|
907
|
-
* click_context: "Progressive: Get 20% off - Compare quotes"
|
|
908
|
-
* });
|
|
909
|
-
* }
|
|
910
|
-
* ```
|
|
911
|
-
*/
|
|
912
|
-
trackClickFromAd(ad: AdResponse, options: {
|
|
913
|
-
click_context: string;
|
|
914
|
-
metadata?: Record<string, unknown>;
|
|
915
|
-
occurred_at?: string;
|
|
916
|
-
}): Promise<EventIngestResponse>;
|
|
917
907
|
/**
|
|
918
908
|
* Send feedback on an ad's performance to earn conversion-validated bonuses.
|
|
919
909
|
*
|
|
@@ -1547,4 +1537,4 @@ declare function getVertical(taxonomy: string): string | null;
|
|
|
1547
1537
|
*/
|
|
1548
1538
|
declare function suggestTaxonomies(query: string): string[];
|
|
1549
1539
|
|
|
1550
|
-
export { type APIError, APIRequestError, type AdResponse, type AdScore, type AdUnit, type AgentSignupRequest, type AgentSignupResponse, AttentionMarketClient, AttentionMarketError, type Constraints, type Context, type
|
|
1540
|
+
export { type APIError, APIRequestError, type AdResponse, type AdScore, type AdUnit, type AgentSignupRequest, type AgentSignupResponse, AttentionMarketClient, AttentionMarketError, type Constraints, type Context, type CreateImpressionEventParams, type CreateOpportunityParams, type DecideFromContextRequest, type DecideRequest, type DecideResponse, type Disclosure, type EventIngestRequest, type EventIngestResponse, type EventType, type FormattedAd, type Intent, MockAttentionMarketClient, type MockClientConfig, type NaturalFormatOptions, NetworkError, type OfferResponse, type Opportunity, type ParsedTaxonomy, type Placement, type PlacementType, type PolicyResponse, type Privacy, type RequestOfferFromContextParams, type RequestOfferParams, type SDKConfig, type SanitizeURLOptions, type SponsoredSuggestion, type SponsoredTool, type TaxonomyIntent, TimeoutError, type ToolCall, type Tracking, buildTaxonomy, createImpressionEvent, createOpportunity, detectIntent, escapeHTML, formatInlineMention, formatNatural, generateTimestamp, generateUUID, getBaseTaxonomy, getVertical, isValidTaxonomy, matchesTaxonomy, parseTaxonomy, sanitizeURL, suggestTaxonomies, validateAdFits };
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,28 @@ interface DecideRequest {
|
|
|
29
29
|
response_format?: string;
|
|
30
30
|
[key: string]: any;
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* User context for better ad targeting
|
|
34
|
+
*/
|
|
35
|
+
interface UserContext {
|
|
36
|
+
/** User's interests (e.g., ['travel', 'fitness', 'cooking']) */
|
|
37
|
+
interests?: string[];
|
|
38
|
+
/** Recent conversation topics for context */
|
|
39
|
+
recent_topics?: string[];
|
|
40
|
+
/** Whether user shows purchase intent */
|
|
41
|
+
purchase_intent?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Session context for conversation continuity
|
|
45
|
+
*/
|
|
46
|
+
interface SessionContext {
|
|
47
|
+
/** Unique session identifier for tracking multi-turn conversations */
|
|
48
|
+
session_id?: string;
|
|
49
|
+
/** Number of messages in current session */
|
|
50
|
+
message_count?: number;
|
|
51
|
+
/** User's current stage in the buying journey */
|
|
52
|
+
intent_stage?: 'research' | 'comparison' | 'ready_to_buy';
|
|
53
|
+
}
|
|
32
54
|
/**
|
|
33
55
|
* Simplified request for semantic context-based ad matching.
|
|
34
56
|
* Uses conversation context instead of manual taxonomy selection.
|
|
@@ -41,7 +63,10 @@ interface DecideRequest {
|
|
|
41
63
|
* const ad = await client.decideFromContext({
|
|
42
64
|
* userMessage: "I need help with estate planning",
|
|
43
65
|
* conversationHistory: ["User: My father passed away recently"],
|
|
44
|
-
* placement: 'sponsored_suggestion'
|
|
66
|
+
* placement: 'sponsored_suggestion',
|
|
67
|
+
* sessionId: 'session_123',
|
|
68
|
+
* intentStage: 'research',
|
|
69
|
+
* userInterests: ['finance', 'legal']
|
|
45
70
|
* });
|
|
46
71
|
* ```
|
|
47
72
|
*/
|
|
@@ -66,6 +91,18 @@ interface DecideFromContextRequest {
|
|
|
66
91
|
language?: string;
|
|
67
92
|
/** User's platform. Default: 'web' */
|
|
68
93
|
platform?: 'web' | 'ios' | 'android' | 'desktop' | 'voice' | 'other';
|
|
94
|
+
/**
|
|
95
|
+
* User context for better ad targeting.
|
|
96
|
+
* Includes interests, topics, and purchase intent signals.
|
|
97
|
+
* @since v0.15.0
|
|
98
|
+
*/
|
|
99
|
+
user_context?: UserContext;
|
|
100
|
+
/**
|
|
101
|
+
* Session context for multi-turn conversations.
|
|
102
|
+
* Includes session ID, message count, and intent stage.
|
|
103
|
+
* @since v0.15.0
|
|
104
|
+
*/
|
|
105
|
+
session_context?: SessionContext;
|
|
69
106
|
/**
|
|
70
107
|
* Minimum quality score threshold (0.0 - 1.0).
|
|
71
108
|
* Only return ads with quality scores at or above this value.
|
|
@@ -736,24 +773,6 @@ interface CreateImpressionEventParams {
|
|
|
736
773
|
* @returns EventIngestRequest ready to pass to client.track()
|
|
737
774
|
*/
|
|
738
775
|
declare function createImpressionEvent(params: CreateImpressionEventParams): EventIngestRequest;
|
|
739
|
-
interface CreateClickEventParams {
|
|
740
|
-
agent_id: string;
|
|
741
|
-
request_id: string;
|
|
742
|
-
decision_id: string;
|
|
743
|
-
unit_id: string;
|
|
744
|
-
tracking_token: string;
|
|
745
|
-
href: string;
|
|
746
|
-
click_context: string;
|
|
747
|
-
occurred_at?: string;
|
|
748
|
-
metadata?: Record<string, unknown>;
|
|
749
|
-
}
|
|
750
|
-
/**
|
|
751
|
-
* Helper to create a click event payload.
|
|
752
|
-
*
|
|
753
|
-
* @param params - Event parameters (snake_case to match API)
|
|
754
|
-
* @returns EventIngestRequest ready to pass to client.track()
|
|
755
|
-
*/
|
|
756
|
-
declare function createClickEvent(params: CreateClickEventParams): EventIngestRequest;
|
|
757
776
|
/**
|
|
758
777
|
* Options for URL sanitization
|
|
759
778
|
*/
|
|
@@ -885,35 +904,6 @@ declare class AttentionMarketClient {
|
|
|
885
904
|
trackImpression(params: Omit<CreateImpressionEventParams, 'occurred_at'> & {
|
|
886
905
|
occurred_at?: string;
|
|
887
906
|
}): Promise<EventIngestResponse>;
|
|
888
|
-
/**
|
|
889
|
-
* Convenience method to track a click event.
|
|
890
|
-
* Creates a click event using createClickEvent() and calls track().
|
|
891
|
-
*/
|
|
892
|
-
trackClick(params: Omit<CreateClickEventParams, 'occurred_at'> & {
|
|
893
|
-
occurred_at?: string;
|
|
894
|
-
}): Promise<EventIngestResponse>;
|
|
895
|
-
/**
|
|
896
|
-
* Ultra-simple method to track a click from an ad returned by decideFromContext().
|
|
897
|
-
* Automatically extracts all required fields from the ad object.
|
|
898
|
-
*
|
|
899
|
-
* @param ad - The ad object returned by decideFromContext()
|
|
900
|
-
* @param options - Just click_context (what you showed the user)
|
|
901
|
-
*
|
|
902
|
-
* @example
|
|
903
|
-
* ```typescript
|
|
904
|
-
* const ad = await client.decideFromContext({ userMessage: "I need car insurance" });
|
|
905
|
-
* if (ad) {
|
|
906
|
-
* await client.trackClickFromAd(ad, {
|
|
907
|
-
* click_context: "Progressive: Get 20% off - Compare quotes"
|
|
908
|
-
* });
|
|
909
|
-
* }
|
|
910
|
-
* ```
|
|
911
|
-
*/
|
|
912
|
-
trackClickFromAd(ad: AdResponse, options: {
|
|
913
|
-
click_context: string;
|
|
914
|
-
metadata?: Record<string, unknown>;
|
|
915
|
-
occurred_at?: string;
|
|
916
|
-
}): Promise<EventIngestResponse>;
|
|
917
907
|
/**
|
|
918
908
|
* Send feedback on an ad's performance to earn conversion-validated bonuses.
|
|
919
909
|
*
|
|
@@ -1547,4 +1537,4 @@ declare function getVertical(taxonomy: string): string | null;
|
|
|
1547
1537
|
*/
|
|
1548
1538
|
declare function suggestTaxonomies(query: string): string[];
|
|
1549
1539
|
|
|
1550
|
-
export { type APIError, APIRequestError, type AdResponse, type AdScore, type AdUnit, type AgentSignupRequest, type AgentSignupResponse, AttentionMarketClient, AttentionMarketError, type Constraints, type Context, type
|
|
1540
|
+
export { type APIError, APIRequestError, type AdResponse, type AdScore, type AdUnit, type AgentSignupRequest, type AgentSignupResponse, AttentionMarketClient, AttentionMarketError, type Constraints, type Context, type CreateImpressionEventParams, type CreateOpportunityParams, type DecideFromContextRequest, type DecideRequest, type DecideResponse, type Disclosure, type EventIngestRequest, type EventIngestResponse, type EventType, type FormattedAd, type Intent, MockAttentionMarketClient, type MockClientConfig, type NaturalFormatOptions, NetworkError, type OfferResponse, type Opportunity, type ParsedTaxonomy, type Placement, type PlacementType, type PolicyResponse, type Privacy, type RequestOfferFromContextParams, type RequestOfferParams, type SDKConfig, type SanitizeURLOptions, type SponsoredSuggestion, type SponsoredTool, type TaxonomyIntent, TimeoutError, type ToolCall, type Tracking, buildTaxonomy, createImpressionEvent, createOpportunity, detectIntent, escapeHTML, formatInlineMention, formatNatural, generateTimestamp, generateUUID, getBaseTaxonomy, getVertical, isValidTaxonomy, matchesTaxonomy, parseTaxonomy, sanitizeURL, suggestTaxonomies, validateAdFits };
|