@ai-ad-network/frontend-sdk 1.0.6 → 1.0.7
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 +80 -1
- package/dist/index.esm.js +49 -1
- package/dist/index.js +49 -1
- package/dist/style.css +13 -0
- package/docs/CLIENT_INFO_COLLECTION.md +747 -714
- package/docs/COMPONENT_DOCUMENTATION.md +32 -0
- package/docs/QUICK_START.md +375 -356
- package/docs/README.md +312 -61
- package/docs/UNIVERSAL_SDK_GUIDE.md +802 -0
- package/package.json +22 -3
package/README.md
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
# AI Ad Network Frontend SDK
|
|
2
2
|
|
|
3
|
-
> 🚀 **Zero-config**
|
|
3
|
+
> 🚀 **Zero-config** SDK for AI-powered native ads with automatic client info collection
|
|
4
|
+
>
|
|
5
|
+
> 📦 **Dual Support**: React SDK + Universal Framework-Agnostic SDK
|
|
6
|
+
|
|
7
|
+
## 🎯 Choose Your Integration
|
|
8
|
+
|
|
9
|
+
### React Projects (Original SDK)
|
|
10
|
+
```bash
|
|
11
|
+
npm install @ai-ad-network/frontend-sdk
|
|
12
|
+
```
|
|
13
|
+
```tsx
|
|
14
|
+
import { AdProvider, useAiAds } from '@ai-ad-network/frontend-sdk';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Any Other Framework (Universal SDK) ⭐ NEW
|
|
18
|
+
```bash
|
|
19
|
+
npm install @ai-ad-network/frontend-sdk
|
|
20
|
+
```
|
|
21
|
+
```javascript
|
|
22
|
+
import { AdManager, DOMRenderer } from '@ai-ad-network/frontend-sdk/universal';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Universal SDK Works With:**
|
|
26
|
+
- ✅ Vanilla JavaScript
|
|
27
|
+
- ✅ Vue 2 & 3
|
|
28
|
+
- ✅ Angular
|
|
29
|
+
- ✅ Svelte
|
|
30
|
+
- ✅ SolidJS
|
|
31
|
+
- ✅ Any other framework
|
|
32
|
+
|
|
33
|
+
📖 **[Universal SDK Guide](./docs/UNIVERSAL_SDK_GUIDE.md)** for non-React frameworks
|
|
4
34
|
|
|
5
35
|
## ✨ Key Features
|
|
6
36
|
|
|
@@ -53,6 +83,55 @@ function ChatApp() {
|
|
|
53
83
|
- 👤 **User Info**: Unique ID (auto-generated & persistent)
|
|
54
84
|
- 🌍 **Geo Info**: Country, language (from timezone/locale)
|
|
55
85
|
|
|
86
|
+
📖 **See [ClientInfo Documentation](./docs/CLIENT_INFO_COLLECTION.md)**
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 🆕 ClientInfo API ⭐ NEW
|
|
91
|
+
|
|
92
|
+
**Direct access to client information for your own use!**
|
|
93
|
+
|
|
94
|
+
The SDK now exposes convenient functions to access client info for analytics, personalization, A/B testing, and more.
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
// React SDK
|
|
98
|
+
import { getUserId, getDeviceInfo, getClientInfo } from '@ai-ad-network/frontend-sdk';
|
|
99
|
+
|
|
100
|
+
// Universal SDK (Vue, Angular, etc.)
|
|
101
|
+
import { getUserId, getDeviceInfo, getClientInfo } from '@ai-ad-network/frontend-sdk/universal';
|
|
102
|
+
|
|
103
|
+
// Get user ID for analytics
|
|
104
|
+
const userId = getUserId();
|
|
105
|
+
analytics.identify(userId);
|
|
106
|
+
|
|
107
|
+
// Get device info for conditional features
|
|
108
|
+
const device = getDeviceInfo();
|
|
109
|
+
if (device.devicetype === 1) {
|
|
110
|
+
// Mobile - enable mobile optimizations
|
|
111
|
+
} else {
|
|
112
|
+
// Desktop - enable desktop features
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Get complete info for personalization
|
|
116
|
+
const info = getClientInfo();
|
|
117
|
+
if (info.geo?.country === 'CN') {
|
|
118
|
+
loadChinesePaymentMethods();
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Available Functions:**
|
|
123
|
+
- `getClientInfo()` - Get complete client information
|
|
124
|
+
- `getUserId()` - Get persistent user ID
|
|
125
|
+
- `getDeviceInfo()` - Get device info only
|
|
126
|
+
- `getUserInfo()` - Get user info only
|
|
127
|
+
- `getAppInfo()` - Get app info only
|
|
128
|
+
- `getGeoInfo()` - Get geo info only
|
|
129
|
+
- `getClientInfoJSON()` - Get as JSON string
|
|
130
|
+
- `getClientInfoSummary()` - Get human-readable summary
|
|
131
|
+
- `clearClientInfoCache()` - Force re-collection
|
|
132
|
+
|
|
133
|
+
📖 **[Universal SDK Guide - ClientInfo API](./docs/UNIVERSAL_SDK_GUIDE.md#clientinfo-api--new)**
|
|
134
|
+
|
|
56
135
|
📖 **See [Quick Start Guide](./docs/QUICK_START.md) for complete integration docs.**
|
|
57
136
|
|
|
58
137
|
## Installation
|
package/dist/index.esm.js
CHANGED
|
@@ -3,7 +3,7 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import React, { useState, useRef, useCallback, useEffect, createContext, useContext, useMemo, Component } from "react";
|
|
5
5
|
import useSWR from "swr";
|
|
6
|
-
const SDK_VERSION = "1.0.
|
|
6
|
+
const SDK_VERSION = "1.0.7";
|
|
7
7
|
var IntentType = /* @__PURE__ */ ((IntentType2) => {
|
|
8
8
|
IntentType2["SHOPPING"] = "shopping";
|
|
9
9
|
IntentType2["LEAD_GEN"] = "lead_gen";
|
|
@@ -649,6 +649,45 @@ const _ClientInfoCollector = class _ClientInfoCollector {
|
|
|
649
649
|
__publicField(_ClientInfoCollector, "instance");
|
|
650
650
|
let ClientInfoCollector = _ClientInfoCollector;
|
|
651
651
|
const getClientInfoCollector = () => ClientInfoCollector.getInstance();
|
|
652
|
+
function getClientInfo(options) {
|
|
653
|
+
const collector = getClientInfoCollector();
|
|
654
|
+
return collector.collect(options);
|
|
655
|
+
}
|
|
656
|
+
function getDeviceInfo() {
|
|
657
|
+
return getClientInfo().device;
|
|
658
|
+
}
|
|
659
|
+
function getUserInfo() {
|
|
660
|
+
return getClientInfo().user;
|
|
661
|
+
}
|
|
662
|
+
function getAppInfo() {
|
|
663
|
+
return getClientInfo().app;
|
|
664
|
+
}
|
|
665
|
+
function getGeoInfo() {
|
|
666
|
+
return getClientInfo().geo;
|
|
667
|
+
}
|
|
668
|
+
function getUserId() {
|
|
669
|
+
return getUserInfo().id;
|
|
670
|
+
}
|
|
671
|
+
function clearClientInfoCache() {
|
|
672
|
+
const collector = getClientInfoCollector();
|
|
673
|
+
collector.clearCache();
|
|
674
|
+
}
|
|
675
|
+
function getClientInfoJSON(options) {
|
|
676
|
+
const info = getClientInfo(options);
|
|
677
|
+
return JSON.stringify(info, null, 2);
|
|
678
|
+
}
|
|
679
|
+
function getClientInfoSummary() {
|
|
680
|
+
var _a;
|
|
681
|
+
const info = getClientInfo();
|
|
682
|
+
const parts = [
|
|
683
|
+
info.device.os,
|
|
684
|
+
info.device.osv,
|
|
685
|
+
info.app.name,
|
|
686
|
+
info.user.id.slice(0, 8) + "...",
|
|
687
|
+
((_a = info.geo) == null ? void 0 : _a.country) || "Unknown"
|
|
688
|
+
];
|
|
689
|
+
return parts.join(" / ");
|
|
690
|
+
}
|
|
652
691
|
function adaptAdToKoahAd(adaptedAd) {
|
|
653
692
|
var _a, _b;
|
|
654
693
|
return {
|
|
@@ -7660,15 +7699,24 @@ export {
|
|
|
7660
7699
|
TextWeaver,
|
|
7661
7700
|
adaptAdToKoahAd,
|
|
7662
7701
|
checkFrequencyControl,
|
|
7702
|
+
clearClientInfoCache,
|
|
7663
7703
|
cn,
|
|
7664
7704
|
createLogger,
|
|
7665
7705
|
fetchAds,
|
|
7666
7706
|
getAdById,
|
|
7667
7707
|
getAdsByCategory,
|
|
7668
7708
|
getAdsBySource,
|
|
7709
|
+
getAppInfo,
|
|
7710
|
+
getClientInfo,
|
|
7669
7711
|
getClientInfoCollector,
|
|
7712
|
+
getClientInfoJSON,
|
|
7713
|
+
getClientInfoSummary,
|
|
7714
|
+
getDeviceInfo,
|
|
7715
|
+
getGeoInfo,
|
|
7670
7716
|
getRandomAds,
|
|
7671
7717
|
getSessionId,
|
|
7718
|
+
getUserId,
|
|
7719
|
+
getUserInfo,
|
|
7672
7720
|
hashUserId,
|
|
7673
7721
|
mockAds,
|
|
7674
7722
|
mockAnalyticsData,
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
5
5
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
6
|
const React = require("react");
|
|
7
7
|
const useSWR = require("swr");
|
|
8
|
-
const SDK_VERSION = "1.0.
|
|
8
|
+
const SDK_VERSION = "1.0.7";
|
|
9
9
|
var IntentType = /* @__PURE__ */ ((IntentType2) => {
|
|
10
10
|
IntentType2["SHOPPING"] = "shopping";
|
|
11
11
|
IntentType2["LEAD_GEN"] = "lead_gen";
|
|
@@ -651,6 +651,45 @@ const _ClientInfoCollector = class _ClientInfoCollector {
|
|
|
651
651
|
__publicField(_ClientInfoCollector, "instance");
|
|
652
652
|
let ClientInfoCollector = _ClientInfoCollector;
|
|
653
653
|
const getClientInfoCollector = () => ClientInfoCollector.getInstance();
|
|
654
|
+
function getClientInfo(options) {
|
|
655
|
+
const collector = getClientInfoCollector();
|
|
656
|
+
return collector.collect(options);
|
|
657
|
+
}
|
|
658
|
+
function getDeviceInfo() {
|
|
659
|
+
return getClientInfo().device;
|
|
660
|
+
}
|
|
661
|
+
function getUserInfo() {
|
|
662
|
+
return getClientInfo().user;
|
|
663
|
+
}
|
|
664
|
+
function getAppInfo() {
|
|
665
|
+
return getClientInfo().app;
|
|
666
|
+
}
|
|
667
|
+
function getGeoInfo() {
|
|
668
|
+
return getClientInfo().geo;
|
|
669
|
+
}
|
|
670
|
+
function getUserId() {
|
|
671
|
+
return getUserInfo().id;
|
|
672
|
+
}
|
|
673
|
+
function clearClientInfoCache() {
|
|
674
|
+
const collector = getClientInfoCollector();
|
|
675
|
+
collector.clearCache();
|
|
676
|
+
}
|
|
677
|
+
function getClientInfoJSON(options) {
|
|
678
|
+
const info = getClientInfo(options);
|
|
679
|
+
return JSON.stringify(info, null, 2);
|
|
680
|
+
}
|
|
681
|
+
function getClientInfoSummary() {
|
|
682
|
+
var _a;
|
|
683
|
+
const info = getClientInfo();
|
|
684
|
+
const parts = [
|
|
685
|
+
info.device.os,
|
|
686
|
+
info.device.osv,
|
|
687
|
+
info.app.name,
|
|
688
|
+
info.user.id.slice(0, 8) + "...",
|
|
689
|
+
((_a = info.geo) == null ? void 0 : _a.country) || "Unknown"
|
|
690
|
+
];
|
|
691
|
+
return parts.join(" / ");
|
|
692
|
+
}
|
|
654
693
|
function adaptAdToKoahAd(adaptedAd) {
|
|
655
694
|
var _a, _b;
|
|
656
695
|
return {
|
|
@@ -7661,15 +7700,24 @@ exports.SuffixAdMinimal = SuffixAdMinimal;
|
|
|
7661
7700
|
exports.TextWeaver = TextWeaver;
|
|
7662
7701
|
exports.adaptAdToKoahAd = adaptAdToKoahAd;
|
|
7663
7702
|
exports.checkFrequencyControl = checkFrequencyControl;
|
|
7703
|
+
exports.clearClientInfoCache = clearClientInfoCache;
|
|
7664
7704
|
exports.cn = cn;
|
|
7665
7705
|
exports.createLogger = createLogger;
|
|
7666
7706
|
exports.fetchAds = fetchAds;
|
|
7667
7707
|
exports.getAdById = getAdById;
|
|
7668
7708
|
exports.getAdsByCategory = getAdsByCategory;
|
|
7669
7709
|
exports.getAdsBySource = getAdsBySource;
|
|
7710
|
+
exports.getAppInfo = getAppInfo;
|
|
7711
|
+
exports.getClientInfo = getClientInfo;
|
|
7670
7712
|
exports.getClientInfoCollector = getClientInfoCollector;
|
|
7713
|
+
exports.getClientInfoJSON = getClientInfoJSON;
|
|
7714
|
+
exports.getClientInfoSummary = getClientInfoSummary;
|
|
7715
|
+
exports.getDeviceInfo = getDeviceInfo;
|
|
7716
|
+
exports.getGeoInfo = getGeoInfo;
|
|
7671
7717
|
exports.getRandomAds = getRandomAds;
|
|
7672
7718
|
exports.getSessionId = getSessionId;
|
|
7719
|
+
exports.getUserId = getUserId;
|
|
7720
|
+
exports.getUserInfo = getUserInfo;
|
|
7673
7721
|
exports.hashUserId = hashUserId;
|
|
7674
7722
|
exports.mockAds = mockAds;
|
|
7675
7723
|
exports.mockAnalyticsData = mockAnalyticsData;
|
package/dist/style.css
CHANGED
|
@@ -675,6 +675,9 @@ video {
|
|
|
675
675
|
.list-item {
|
|
676
676
|
display: list-item;
|
|
677
677
|
}
|
|
678
|
+
.hidden {
|
|
679
|
+
display: none;
|
|
680
|
+
}
|
|
678
681
|
.aspect-\[4\/3\] {
|
|
679
682
|
aspect-ratio: 4/3;
|
|
680
683
|
}
|
|
@@ -1607,6 +1610,11 @@ video {
|
|
|
1607
1610
|
.opacity-\[0\.02\] {
|
|
1608
1611
|
opacity: 0.02;
|
|
1609
1612
|
}
|
|
1613
|
+
.shadow {
|
|
1614
|
+
--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
|
|
1615
|
+
--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);
|
|
1616
|
+
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
|
|
1617
|
+
}
|
|
1610
1618
|
.shadow-glass {
|
|
1611
1619
|
--tw-shadow: 0 4px 24px -1px rgba(0, 0, 0, 0.06), 0 2px 8px -1px rgba(0, 0, 0, 0.04);
|
|
1612
1620
|
--tw-shadow-colored: 0 4px 24px -1px var(--tw-shadow-color), 0 2px 8px -1px var(--tw-shadow-color);
|
|
@@ -1638,6 +1646,11 @@ video {
|
|
|
1638
1646
|
--tw-backdrop-blur: blur(4px);
|
|
1639
1647
|
backdrop-filter: var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);
|
|
1640
1648
|
}
|
|
1649
|
+
.transition {
|
|
1650
|
+
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
|
|
1651
|
+
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
|
1652
|
+
transition-duration: 150ms;
|
|
1653
|
+
}
|
|
1641
1654
|
.transition-all {
|
|
1642
1655
|
transition-property: all;
|
|
1643
1656
|
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|