admesh-ui-sdk 0.17.0 → 0.19.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 +147 -0
- package/dist/components/AdMeshProductCard.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +256 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26620 -1173
- package/dist/index.mjs.map +1 -1
- package/dist/sdk/AdMeshRecommendationFetcher.d.ts +25 -0
- package/dist/sdk/AdMeshRecommendationFetcher.d.ts.map +1 -0
- package/dist/sdk/AdMeshRenderer.d.ts +28 -0
- package/dist/sdk/AdMeshRenderer.d.ts.map +1 -0
- package/dist/sdk/AdMeshSDK.d.ts +67 -0
- package/dist/sdk/AdMeshSDK.d.ts.map +1 -0
- package/dist/sdk/AdMeshSessionManager.d.ts +40 -0
- package/dist/sdk/AdMeshSessionManager.d.ts.map +1 -0
- package/dist/sdk/AdMeshTracker.d.ts +33 -0
- package/dist/sdk/AdMeshTracker.d.ts.map +1 -0
- package/dist/sdk/index.d.ts +15 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/hooks/useExposureTracking.d.ts +0 -20
- package/dist/hooks/useExposureTracking.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -32,6 +32,153 @@ A comprehensive React + TypeScript component library for displaying AdMesh produ
|
|
|
32
32
|
npm install admesh-ui-sdk
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
+
## 🚀 Zero-Code Integration (Recommended for Platforms)
|
|
36
|
+
|
|
37
|
+
The AdMesh SDK provides a **zero-code integration experience** that handles everything automatically. Perfect for platforms that want to add monetized recommendations without writing custom code.
|
|
38
|
+
|
|
39
|
+
### 3-Step Integration
|
|
40
|
+
|
|
41
|
+
**Step 1: Install the SDK**
|
|
42
|
+
```bash
|
|
43
|
+
npm install admesh-ui-sdk
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Step 2: Add a container element**
|
|
47
|
+
```html
|
|
48
|
+
<!-- Place this div where you want recommendations to appear -->
|
|
49
|
+
<div id="admesh-recommendations"></div>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Step 3: Initialize and fetch recommendations**
|
|
53
|
+
```typescript
|
|
54
|
+
import { AdMeshSDK } from 'admesh-ui-sdk';
|
|
55
|
+
|
|
56
|
+
// Initialize once with your API key
|
|
57
|
+
const admesh = new AdMeshSDK({
|
|
58
|
+
apiKey: 'your-api-key-here'
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Fetch and render recommendations automatically
|
|
62
|
+
await admesh.showRecommendations({
|
|
63
|
+
query: userQuery,
|
|
64
|
+
containerId: 'admesh-recommendations',
|
|
65
|
+
format: 'auto' // optional: auto-detects best format
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Close session when conversation ends
|
|
69
|
+
admesh.closeSession();
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Complete Example
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { AdMeshSDK } from 'admesh-ui-sdk';
|
|
76
|
+
|
|
77
|
+
const admesh = new AdMeshSDK({
|
|
78
|
+
apiKey: 'admesh_prod_your_key_here',
|
|
79
|
+
debug: true // optional: enable debug logging
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// When user searches or asks a question
|
|
83
|
+
async function handleUserQuery(query: string) {
|
|
84
|
+
try {
|
|
85
|
+
await admesh.showRecommendations({
|
|
86
|
+
query: query,
|
|
87
|
+
containerId: 'admesh-recommendations',
|
|
88
|
+
format: 'auto',
|
|
89
|
+
onRecommendationClick: (adId, admeshLink) => {
|
|
90
|
+
console.log('User clicked recommendation:', adId);
|
|
91
|
+
// Optional: custom handling before opening link
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.error('Failed to fetch recommendations:', error);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// When conversation ends
|
|
100
|
+
function handleConversationEnd() {
|
|
101
|
+
admesh.closeSession();
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Session Management
|
|
106
|
+
|
|
107
|
+
The SDK automatically manages sessions for you:
|
|
108
|
+
|
|
109
|
+
- **Automatic Session Creation**: A new session is created on first recommendation fetch
|
|
110
|
+
- **Session Persistence**: Sessions are stored in localStorage and reused across page reloads
|
|
111
|
+
- **Session Timeout**: Sessions expire after 30 minutes of inactivity
|
|
112
|
+
- **Manual Control**: You can create new sessions or set custom session IDs
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
// Create a new session (e.g., for a new conversation)
|
|
116
|
+
const newSessionId = admesh.createNewSession();
|
|
117
|
+
|
|
118
|
+
// Get current session ID
|
|
119
|
+
const sessionId = admesh.getSessionId();
|
|
120
|
+
|
|
121
|
+
// Set a custom session ID
|
|
122
|
+
admesh.setSessionId('custom-session-id');
|
|
123
|
+
|
|
124
|
+
// Close session when done
|
|
125
|
+
admesh.closeSession();
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Configuration Options
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
const admesh = new AdMeshSDK({
|
|
132
|
+
apiKey: 'your-api-key', // Required
|
|
133
|
+
apiBaseUrl: 'https://api.useadmesh.com', // Optional: defaults to production
|
|
134
|
+
debug: false, // Optional: enable debug logging
|
|
135
|
+
theme: { // Optional: customize appearance
|
|
136
|
+
mode: 'light',
|
|
137
|
+
primaryColor: '#3b82f6',
|
|
138
|
+
borderRadius: '8px'
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### What the SDK Handles Automatically
|
|
144
|
+
|
|
145
|
+
- ✅ API authentication with your API key
|
|
146
|
+
- ✅ Recommendation fetching from `/agent/recommend` endpoint
|
|
147
|
+
- ✅ Session creation and management
|
|
148
|
+
- ✅ Automatic rendering with appropriate UI components
|
|
149
|
+
- ✅ Exposure tracking (when recommendations are shown)
|
|
150
|
+
- ✅ Click tracking (when users click recommendations)
|
|
151
|
+
- ✅ Conversion tracking (when users complete actions)
|
|
152
|
+
- ✅ Error handling and logging
|
|
153
|
+
- ✅ Responsive design and theming
|
|
154
|
+
|
|
155
|
+
### Advanced: Custom Rendering
|
|
156
|
+
|
|
157
|
+
If you need more control over rendering, you can use the individual components:
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import { AdMeshLayout } from 'admesh-ui-sdk';
|
|
161
|
+
|
|
162
|
+
// Fetch recommendations manually
|
|
163
|
+
const response = await admesh.fetcher.fetchRecommendations({
|
|
164
|
+
query: 'best CRM for small business',
|
|
165
|
+
session_id: admesh.getSessionId()
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// Render with custom configuration
|
|
169
|
+
<AdMeshLayout
|
|
170
|
+
response={{
|
|
171
|
+
layout_type: response.response?.layout_type,
|
|
172
|
+
recommendations: response.response?.recommendations || [],
|
|
173
|
+
citation_summary: response.response?.summary
|
|
174
|
+
}}
|
|
175
|
+
theme={{ mode: 'dark' }}
|
|
176
|
+
onRecommendationClick={(rec) => {
|
|
177
|
+
// Custom click handling
|
|
178
|
+
}}
|
|
179
|
+
/>
|
|
180
|
+
```
|
|
181
|
+
|
|
35
182
|
## ✨ Self-Contained Design
|
|
36
183
|
|
|
37
184
|
**Zero configuration required!** The AdMesh UI SDK is completely self-contained and works like Google Ads or any professional SDK:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdMeshProductCard.d.ts","sourceRoot":"","sources":["../../src/components/AdMeshProductCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,OAAO,KAAK,EAAE,sBAAsB,EAAa,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"AdMeshProductCard.d.ts","sourceRoot":"","sources":["../../src/components/AdMeshProductCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,OAAO,KAAK,EAAE,sBAAsB,EAAa,MAAM,gBAAgB,CAAC;AASxE,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAoV9D,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { AdMeshLayout, AdMeshProductCard, AdMeshInlineCard, AdMeshEcommerceCards, AdMeshSummaryUnit, AdMeshSummaryLayout, AdMeshLinkTracker, AdMeshBadge } from './components';
|
|
2
2
|
export { AdMeshViewabilityTracker } from './components/AdMeshViewabilityTracker';
|
|
3
|
+
export { AdMeshSDK, AdMeshSessionManager, AdMeshRecommendationFetcher, AdMeshTracker, AdMeshRenderer } from './sdk';
|
|
4
|
+
export type { AdMeshSDKConfig, ShowRecommendationsOptions, FetchRecommendationsParams, FetcherConfig, TrackerConfig, RenderOptions } from './sdk';
|
|
3
5
|
export { useAdMeshTracker, setAdMeshTrackerConfig, buildAdMeshLink, extractTrackingData } from './hooks/useAdMeshTracker';
|
|
4
6
|
export { useAdMeshStyles } from './hooks/useAdMeshStyles';
|
|
5
7
|
export { useViewabilityTracker, setViewabilityTrackerConfig } from './hooks/useViewabilityTracker';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACZ,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AAGjF,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,eAAe,EACf,mBAAmB,EACpB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,eAAe,EAChB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,qBAAqB,EACrB,2BAA2B,EAC5B,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,WAAW,EACX,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EACV,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAGjC,YAAY,EACV,oBAAoB,EACpB,WAAW,EACX,UAAU,EACV,SAAS,EACT,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,EAC3B,YAAY,EACb,MAAM,eAAe,CAAC;AAGvB,YAAY,EACV,uBAAuB,EACvB,oBAAoB,EACpB,UAAU,EACV,sBAAsB,EACtB,4BAA4B,EAC5B,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC7B,MAAM,mBAAmB,CAAC;AAG3B,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,eAAO,MAAM,cAAc;;;;;;;CAO1B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACZ,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,wBAA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