@thealteroffice/react-native-adgeist 0.0.14 → 0.0.16
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/ios/generated/RNAdgeistSpec/RNAdgeistSpec-generated.mm +81 -0
- package/ios/generated/RNAdgeistSpec/RNAdgeistSpec.h +86 -0
- package/{android/app/build/generated/source/codegen/jni/react/renderer/components/RNAdgeistSpec → ios/generated}/RNAdgeistSpecJSI.h +1 -118
- package/lib/module/cdpclient/index.js +60 -4
- package/lib/module/cdpclient/index.js.map +1 -1
- package/lib/module/components/AdgeistProvider.js +57 -17
- package/lib/module/components/AdgeistProvider.js.map +1 -1
- package/lib/module/components/BannerAd.js +141 -58
- package/lib/module/components/BannerAd.js.map +1 -1
- package/lib/typescript/src/cdpclient/index.d.ts +20 -0
- package/lib/typescript/src/cdpclient/index.d.ts.map +1 -1
- package/lib/typescript/src/components/AdgeistProvider.d.ts +32 -3
- package/lib/typescript/src/components/AdgeistProvider.d.ts.map +1 -1
- package/lib/typescript/src/components/BannerAd.d.ts +56 -4
- package/lib/typescript/src/components/BannerAd.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/cdpclient/index.ts +71 -8
- package/src/components/AdgeistProvider.tsx +77 -23
- package/src/components/BannerAd.tsx +177 -82
- package/android/app/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeAdgeistSpec.java +0 -63
- package/android/app/build/generated/source/codegen/jni/CMakeLists.txt +0 -36
- package/android/app/build/generated/source/codegen/jni/RNAdgeistSpec-generated.cpp +0 -68
- package/android/app/build/generated/source/codegen/jni/RNAdgeistSpec.h +0 -31
- /package/{android/app/build/generated/source/codegen/jni/react/renderer/components/RNAdgeistSpec → ios/generated}/RNAdgeistSpecJSI-generated.cpp +0 -0
|
@@ -1,20 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @module BannerAd
|
|
5
|
+
* @description A React Native component for displaying banner and video ads with robust error handling and analytics.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
4
9
|
import { Image, Linking, StyleSheet, Text, View, TouchableWithoutFeedback, ActivityIndicator } from 'react-native';
|
|
10
|
+
import Video from 'react-native-video';
|
|
5
11
|
import Adgeist from "../NativeAdgeist.js";
|
|
6
12
|
import { useAdgeistContext } from "./AdgeistProvider.js";
|
|
7
|
-
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Interface for ad data structure
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Interface for seat bid data
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Interface for individual bid
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Interface for bid extension data
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Props for the BannerAd component
|
|
32
|
+
*/
|
|
8
33
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
34
|
export const BannerAd = ({
|
|
10
35
|
dataAdSlot,
|
|
11
36
|
dataSlotType = 'banner',
|
|
12
37
|
width = 0,
|
|
13
38
|
height = 0,
|
|
14
|
-
isResponsive = false
|
|
39
|
+
isResponsive = false,
|
|
15
40
|
// responsiveType = 'SQUARE',
|
|
41
|
+
onAdLoadError,
|
|
42
|
+
onAdLoadSuccess
|
|
16
43
|
}) => {
|
|
17
44
|
const [adData, setAdData] = useState(null);
|
|
45
|
+
const [isMuted, setIsMuted] = useState(false);
|
|
46
|
+
const [error, setError] = useState(null);
|
|
18
47
|
const [isLoading, setIsLoading] = useState(false);
|
|
19
48
|
const {
|
|
20
49
|
isInitialized,
|
|
@@ -24,30 +53,60 @@ export const BannerAd = ({
|
|
|
24
53
|
isTestEnvironment
|
|
25
54
|
} = useAdgeistContext();
|
|
26
55
|
const creativeData = adData?.seatBid?.[0]?.bid?.[0]?.ext;
|
|
27
|
-
|
|
28
|
-
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Fetches ad creative and sends impression analytics
|
|
59
|
+
*/
|
|
60
|
+
const fetchAd = useCallback(async () => {
|
|
61
|
+
if (!isInitialized) return;
|
|
62
|
+
try {
|
|
63
|
+
setIsLoading(true);
|
|
64
|
+
setError(null);
|
|
65
|
+
const response = await Adgeist.fetchCreative(apiKey, domain, dataAdSlot, publisherId, isTestEnvironment);
|
|
66
|
+
const creative = response;
|
|
67
|
+
setAdData(creative.data);
|
|
68
|
+
onAdLoadSuccess?.(creative.data);
|
|
69
|
+
|
|
70
|
+
// if (creative.data.seatBid.length > 0) {
|
|
71
|
+
// await Adgeist.sendCreativeAnalytic(
|
|
72
|
+
// creative.data.seatBid?.[0]?.bid?.[0]?.id || '',
|
|
73
|
+
// dataAdSlot,
|
|
74
|
+
// publisherId,
|
|
75
|
+
// 'IMPRESSION',
|
|
76
|
+
// domain,
|
|
77
|
+
// apiKey,
|
|
78
|
+
// creative.data.id,
|
|
79
|
+
// isTestEnvironment
|
|
80
|
+
// );
|
|
81
|
+
// }
|
|
82
|
+
} catch (err) {
|
|
83
|
+
const error = err instanceof Error ? err : new Error('Ad load failed');
|
|
84
|
+
setError(error);
|
|
85
|
+
onAdLoadError?.(error);
|
|
86
|
+
console.error('Ad load failed:', error);
|
|
87
|
+
} finally {
|
|
88
|
+
setIsLoading(false);
|
|
89
|
+
}
|
|
90
|
+
}, [isInitialized, publisherId, dataAdSlot, apiKey, domain, isTestEnvironment, onAdLoadError, onAdLoadSuccess]);
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Handles ad click and sends click analytics
|
|
94
|
+
*/
|
|
95
|
+
const handleClick = useCallback(async () => {
|
|
96
|
+
if (adData && adData.seatBid.length > 0) {
|
|
97
|
+
const bidId = adData.seatBid[0]?.bid[0]?.id;
|
|
98
|
+
if (!bidId) return;
|
|
29
99
|
try {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
setAdData(creative.data);
|
|
35
|
-
setIsLoading(false);
|
|
36
|
-
if (creative.data.seatBid.length > 0) {
|
|
37
|
-
await Adgeist.sendCreativeAnalytic(creative.data.seatBid?.[0]?.bid?.[0]?.id || '', dataAdSlot, publisherId, 'IMPRESSION', domain, apiKey, creative.data.id, isTestEnvironment);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
} catch (error) {
|
|
41
|
-
console.error('Ad load failed:', error);
|
|
100
|
+
await Adgeist.sendCreativeAnalytic(bidId, dataAdSlot, publisherId, 'CLICK', domain, apiKey, adData.id, isTestEnvironment);
|
|
101
|
+
await Linking.openURL(creativeData.ctaUrl);
|
|
102
|
+
} catch (err) {
|
|
103
|
+
console.error('Failed to handle ad click:', err);
|
|
42
104
|
}
|
|
43
|
-
})();
|
|
44
|
-
}, [isInitialized, publisherId, dataAdSlot, apiKey, domain, isTestEnvironment]);
|
|
45
|
-
const handleClick = async () => {
|
|
46
|
-
if (adData && adData?.seatBid.length > 0) {
|
|
47
|
-
await Adgeist.sendCreativeAnalytic(adData?.seatBid?.[0]?.bid?.[0]?.id || '', dataAdSlot, publisherId, 'CLICK', domain, apiKey, adData.id, isTestEnvironment);
|
|
48
|
-
Linking.openURL(creativeData.ctaUrl).catch(err => console.error('Failed to open URL:', err));
|
|
49
105
|
}
|
|
50
|
-
};
|
|
106
|
+
}, [adData, dataAdSlot, publisherId, domain, apiKey, isTestEnvironment, creativeData]);
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
fetchAd();
|
|
109
|
+
}, [fetchAd]);
|
|
51
110
|
if (isLoading) {
|
|
52
111
|
return /*#__PURE__*/_jsx(View, {
|
|
53
112
|
style: [styles.loadingOverlayContainer, !isResponsive && {
|
|
@@ -60,7 +119,7 @@ export const BannerAd = ({
|
|
|
60
119
|
})
|
|
61
120
|
});
|
|
62
121
|
}
|
|
63
|
-
if (!creativeData?.creativeUrl) return null;
|
|
122
|
+
if (!creativeData?.creativeUrl || error) return null;
|
|
64
123
|
return /*#__PURE__*/_jsx(TouchableWithoutFeedback, {
|
|
65
124
|
accessible: true,
|
|
66
125
|
accessibilityLabel: "Ad Banner",
|
|
@@ -74,23 +133,37 @@ export const BannerAd = ({
|
|
|
74
133
|
height: height
|
|
75
134
|
}],
|
|
76
135
|
children: [dataSlotType === 'banner' ? /*#__PURE__*/_jsx(Image, {
|
|
77
|
-
style:
|
|
78
|
-
width: '100%',
|
|
79
|
-
height: '70%'
|
|
80
|
-
}],
|
|
81
|
-
source: {
|
|
82
|
-
uri: creativeData.creativeUrl
|
|
83
|
-
}
|
|
84
|
-
}) : /*#__PURE__*/_jsx(Video, {
|
|
136
|
+
style: styles.creative,
|
|
85
137
|
source: {
|
|
86
138
|
uri: creativeData.creativeUrl
|
|
87
139
|
},
|
|
140
|
+
accessibilityLabel: "Ad Creative",
|
|
88
141
|
resizeMode: "contain",
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
142
|
+
onError: e => console.error('Image load error:', e.nativeEvent.error)
|
|
143
|
+
}) : /*#__PURE__*/_jsxs(View, {
|
|
144
|
+
style: styles.videoCreative,
|
|
145
|
+
children: [/*#__PURE__*/_jsx(Video, {
|
|
146
|
+
source: {
|
|
147
|
+
uri: creativeData.creativeUrl
|
|
148
|
+
},
|
|
149
|
+
resizeMode: "contain",
|
|
150
|
+
style: {
|
|
151
|
+
width: '100%',
|
|
152
|
+
height: '100%'
|
|
153
|
+
},
|
|
154
|
+
repeat: true,
|
|
155
|
+
muted: isMuted,
|
|
156
|
+
onError: e => console.error('Video load error:', e)
|
|
157
|
+
}), /*#__PURE__*/_jsx(TouchableWithoutFeedback, {
|
|
158
|
+
onPress: () => setIsMuted(!isMuted),
|
|
159
|
+
children: /*#__PURE__*/_jsx(Image, {
|
|
160
|
+
style: styles.soundIcon,
|
|
161
|
+
source: {
|
|
162
|
+
uri: isMuted ? 'https://d2cfeg6k9cklz9.cloudfront.net/ad-icons/Muted.png' : 'https://d2cfeg6k9cklz9.cloudfront.net/ad-icons/Unmuted.png'
|
|
163
|
+
},
|
|
164
|
+
accessibilityLabel: isMuted ? 'Unmute video' : 'Mute video'
|
|
165
|
+
})
|
|
166
|
+
})]
|
|
94
167
|
}), /*#__PURE__*/_jsxs(View, {
|
|
95
168
|
style: styles.adContent,
|
|
96
169
|
children: [/*#__PURE__*/_jsxs(View, {
|
|
@@ -112,16 +185,13 @@ export const BannerAd = ({
|
|
|
112
185
|
children: creativeData?.creativeBrandName || 'Brand Name'
|
|
113
186
|
})]
|
|
114
187
|
}), /*#__PURE__*/_jsx(TouchableWithoutFeedback, {
|
|
115
|
-
onPress:
|
|
116
|
-
handleClick();
|
|
117
|
-
},
|
|
118
|
-
accessible: true,
|
|
119
|
-
accessibilityLabel: "Visit Site Button",
|
|
188
|
+
onPress: handleClick,
|
|
120
189
|
children: /*#__PURE__*/_jsx(Image, {
|
|
121
|
-
style:
|
|
190
|
+
style: styles.linkButton,
|
|
122
191
|
source: {
|
|
123
192
|
uri: 'https://d2cfeg6k9cklz9.cloudfront.net/onboarding-icons/Button.png'
|
|
124
|
-
}
|
|
193
|
+
},
|
|
194
|
+
accessibilityLabel: "Visit Advertiser Site"
|
|
125
195
|
})
|
|
126
196
|
})]
|
|
127
197
|
})]
|
|
@@ -130,7 +200,7 @@ export const BannerAd = ({
|
|
|
130
200
|
};
|
|
131
201
|
const styles = StyleSheet.create({
|
|
132
202
|
adContainer: {
|
|
133
|
-
backgroundColor: '
|
|
203
|
+
backgroundColor: '#FFFFFF',
|
|
134
204
|
borderRadius: 5
|
|
135
205
|
},
|
|
136
206
|
loadingOverlayContainer: {
|
|
@@ -140,13 +210,27 @@ const styles = StyleSheet.create({
|
|
|
140
210
|
creative: {
|
|
141
211
|
resizeMode: 'contain',
|
|
142
212
|
borderTopLeftRadius: 5,
|
|
143
|
-
backgroundColor: '
|
|
144
|
-
borderTopRightRadius: 5
|
|
213
|
+
backgroundColor: '#FFFFFF',
|
|
214
|
+
borderTopRightRadius: 5,
|
|
215
|
+
width: '100%',
|
|
216
|
+
height: '70%'
|
|
217
|
+
},
|
|
218
|
+
videoCreative: {
|
|
219
|
+
position: 'relative',
|
|
220
|
+
width: '100%',
|
|
221
|
+
height: '70%'
|
|
222
|
+
},
|
|
223
|
+
soundIcon: {
|
|
224
|
+
position: 'absolute',
|
|
225
|
+
bottom: 10,
|
|
226
|
+
right: 10,
|
|
227
|
+
width: 30,
|
|
228
|
+
height: 30
|
|
145
229
|
},
|
|
146
230
|
adContent: {
|
|
147
231
|
width: '100%',
|
|
148
232
|
height: '30%',
|
|
149
|
-
backgroundColor: '
|
|
233
|
+
backgroundColor: '#FFFFFF',
|
|
150
234
|
flexDirection: 'row',
|
|
151
235
|
justifyContent: 'space-between',
|
|
152
236
|
paddingVertical: 10,
|
|
@@ -159,20 +243,19 @@ const styles = StyleSheet.create({
|
|
|
159
243
|
width: '80%'
|
|
160
244
|
},
|
|
161
245
|
title: {
|
|
162
|
-
color: '
|
|
246
|
+
color: '#1A1A1A',
|
|
163
247
|
fontSize: 18,
|
|
164
|
-
fontWeight: '
|
|
248
|
+
fontWeight: '600'
|
|
165
249
|
},
|
|
166
250
|
description: {
|
|
167
|
-
color: '
|
|
168
|
-
fontSize: 16
|
|
251
|
+
color: '#4A4A4A',
|
|
252
|
+
fontSize: 16,
|
|
253
|
+
marginBottom: 4
|
|
169
254
|
},
|
|
170
255
|
brandName: {
|
|
171
|
-
color: '
|
|
172
|
-
fontSize:
|
|
173
|
-
|
|
174
|
-
marginTop: 5,
|
|
175
|
-
fontWeight: 'semibold'
|
|
256
|
+
color: '#6B7280',
|
|
257
|
+
fontSize: 14,
|
|
258
|
+
textTransform: 'uppercase'
|
|
176
259
|
},
|
|
177
260
|
linkButton: {
|
|
178
261
|
width: 40,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useState","Image","Linking","StyleSheet","Text","View","TouchableWithoutFeedback","ActivityIndicator","
|
|
1
|
+
{"version":3,"names":["React","useCallback","useEffect","useState","Image","Linking","StyleSheet","Text","View","TouchableWithoutFeedback","ActivityIndicator","Video","Adgeist","useAdgeistContext","jsx","_jsx","jsxs","_jsxs","BannerAd","dataAdSlot","dataSlotType","width","height","isResponsive","onAdLoadError","onAdLoadSuccess","adData","setAdData","isMuted","setIsMuted","error","setError","isLoading","setIsLoading","isInitialized","publisherId","apiKey","domain","isTestEnvironment","creativeData","seatBid","bid","ext","fetchAd","response","fetchCreative","creative","data","err","Error","console","handleClick","length","bidId","id","sendCreativeAnalytic","openURL","ctaUrl","style","styles","loadingOverlayContainer","children","size","color","creativeUrl","accessible","accessibilityLabel","adContainer","source","uri","resizeMode","onError","e","nativeEvent","videoCreative","repeat","muted","onPress","soundIcon","adContent","contentContainer","title","numberOfLines","ellipsizeMode","creativeTitle","description","creativeDescription","brandName","creativeBrandName","linkButton","create","backgroundColor","borderRadius","alignItems","justifyContent","borderTopLeftRadius","borderTopRightRadius","position","bottom","right","flexDirection","paddingVertical","paddingHorizontal","borderBottomLeftRadius","borderBottomRightRadius","fontSize","fontWeight","marginBottom","textTransform"],"sourceRoot":"../../../src","sources":["components/BannerAd.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC/D,SACEC,KAAK,EACLC,OAAO,EACPC,UAAU,EACVC,IAAI,EACJC,IAAI,EACJC,wBAAwB,EACxBC,iBAAiB,QACZ,cAAc;AACrB,OAAOC,KAAK,MAAM,oBAAoB;AACtC,OAAOC,OAAO,MAAM,qBAAkB;AACtC,SAASC,iBAAiB,QAAQ,sBAAmB;;AAErD;AACA;AACA;;AAQA;AACA;AACA;;AAMA;AACA;AACA;;AAQA;AACA;AACA;;AASA;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA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AE,eAAe;IAC/BO,eAAe,EAAE,EAAE;IACnBC,iBAAiB,EAAE,EAAE;IACrBT,UAAU,EAAE,QAAQ;IACpBU,sBAAsB,EAAE,CAAC;IACzBC,uBAAuB,EAAE;EAC3B,CAAC;EACDxB,gBAAgB,EAAE;IAChB3D,KAAK,EAAE;EACT,CAAC;EACD4D,KAAK,EAAE;IACLlB,KAAK,EAAE,SAAS;IAChB0C,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd,CAAC;EACDrB,WAAW,EAAE;IACXtB,KAAK,EAAE,SAAS;IAChB0C,QAAQ,EAAE,EAAE;IACZE,YAAY,EAAE;EAChB,CAAC;EACDpB,SAAS,EAAE;IACTxB,KAAK,EAAE,SAAS;IAChB0C,QAAQ,EAAE,EAAE;IACZG,aAAa,EAAE;EACjB,CAAC;EACDnB,UAAU,EAAE;IACVpE,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE;EACV;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
import { type UserDetails, type Event } from '../NativeAdgeist';
|
|
2
|
+
/**
|
|
3
|
+
* Sets user details in the Adgeist SDK
|
|
4
|
+
* @param userDetails - User details object
|
|
5
|
+
* @throws AdgeistError if the operation fails
|
|
6
|
+
*/
|
|
2
7
|
export declare const setUserDetails: (userDetails: UserDetails) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Logs an event in the Adgeist SDK
|
|
10
|
+
* @param event - Event object to log
|
|
11
|
+
* @throws AdgeistError if the event is invalid or logging fails
|
|
12
|
+
*/
|
|
3
13
|
export declare const logEvent: (event: Event) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Retrieves the consent status from the Adgeist SDK
|
|
16
|
+
* @returns Promise resolving to 'ACCEPTED' or 'DENIED'
|
|
17
|
+
* @throws AdgeistError if the operation fails
|
|
18
|
+
*/
|
|
4
19
|
export declare const getConsentStatus: () => Promise<"ACCEPTED" | "DENIED">;
|
|
20
|
+
/**
|
|
21
|
+
* Updates the consent status in the Adgeist SDK
|
|
22
|
+
* @param consent - Boolean indicating user consent
|
|
23
|
+
* @throws AdgeistError if the operation fails
|
|
24
|
+
*/
|
|
5
25
|
export declare const updateConsentStatus: (consent: boolean) => void;
|
|
6
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cdpclient/index.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,KAAK,WAAW,EAAE,KAAK,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cdpclient/index.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,KAAK,WAAW,EAAE,KAAK,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAazE;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,aAAa,WAAW,KAAG,IAQzD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,KAAK,KAAG,IAWvC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QAAa,OAAO,CAAC,UAAU,GAAG,QAAQ,CAWtE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,OAAO,KAAG,IAUtD,CAAC"}
|
|
@@ -1,21 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module AdgeistProvider
|
|
3
|
+
* @description Context provider for Adgeist ad-serving configuration and initialization
|
|
4
|
+
*/
|
|
1
5
|
import React from 'react';
|
|
6
|
+
/**
|
|
7
|
+
* Interface for Adgeist context
|
|
8
|
+
*/
|
|
2
9
|
interface AdgeistContextType {
|
|
3
10
|
publisherId: string;
|
|
4
11
|
apiKey: string;
|
|
5
12
|
domain: string;
|
|
6
13
|
isTestEnvironment: boolean;
|
|
7
14
|
isInitialized: boolean;
|
|
15
|
+
initializationError?: Error;
|
|
8
16
|
setAdgeistConsentModal: (value: boolean) => void;
|
|
9
17
|
}
|
|
10
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Props for AdgeistProvider
|
|
20
|
+
*/
|
|
21
|
+
interface AdgeistProviderProps {
|
|
11
22
|
children: React.ReactNode;
|
|
23
|
+
/** Custom API origin for Adgeist SDK */
|
|
12
24
|
customAdgeistApiOrigin?: string;
|
|
25
|
+
/** Publisher identifier */
|
|
13
26
|
publisherId: string;
|
|
27
|
+
/** API key for authentication */
|
|
14
28
|
apiKey: string;
|
|
29
|
+
/** Domain for ad serving */
|
|
15
30
|
domain: string;
|
|
16
|
-
|
|
31
|
+
/** Enable test environment mode */
|
|
32
|
+
isTestEnvironment?: boolean;
|
|
33
|
+
/** Callback for initialization errors */
|
|
34
|
+
onInitializationError?: (error: Error) => void;
|
|
35
|
+
/** Callback for successful initialization */
|
|
36
|
+
onInitializationSuccess?: () => void;
|
|
17
37
|
}
|
|
18
|
-
|
|
38
|
+
/**
|
|
39
|
+
* AdgeistProvider component for managing ad-serving configuration
|
|
40
|
+
* @param props - Component properties
|
|
41
|
+
* @returns JSX.Element
|
|
42
|
+
*/
|
|
43
|
+
export declare const AdgeistProvider: React.FC<AdgeistProviderProps>;
|
|
44
|
+
/**
|
|
45
|
+
* Hook to access Adgeist context
|
|
46
|
+
* @returns AdgeistContextType
|
|
47
|
+
*/
|
|
19
48
|
export declare const useAdgeistContext: () => AdgeistContextType;
|
|
20
49
|
export {};
|
|
21
50
|
//# sourceMappingURL=AdgeistProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdgeistProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/AdgeistProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AdgeistProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/AdgeistProvider.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAMN,MAAM,OAAO,CAAC;AAIf;;GAEG;AACH,UAAU,kBAAkB;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,OAAO,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,mBAAmB,CAAC,EAAE,KAAK,CAAC;IAC5B,sBAAsB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAClD;AAED;;GAEG;AACH,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,wCAAwC;IACxC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,yCAAyC;IACzC,qBAAqB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC/C,6CAA6C;IAC7C,uBAAuB,CAAC,EAAE,MAAM,IAAI,CAAC;CACtC;AAWD;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA+D1D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,0BAM7B,CAAC"}
|
|
@@ -1,12 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module BannerAd
|
|
3
|
+
* @description A React Native component for displaying banner and video ads with robust error handling and analytics.
|
|
4
|
+
*/
|
|
1
5
|
import React from 'react';
|
|
2
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Interface for ad data structure
|
|
8
|
+
*/
|
|
9
|
+
interface AdData {
|
|
10
|
+
id: string;
|
|
11
|
+
bidId: string;
|
|
12
|
+
cur: string;
|
|
13
|
+
seatBid: SeatBid[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Interface for seat bid data
|
|
17
|
+
*/
|
|
18
|
+
interface SeatBid {
|
|
19
|
+
bidId: string;
|
|
20
|
+
bid: Bid[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Interface for individual bid
|
|
24
|
+
*/
|
|
25
|
+
interface Bid {
|
|
26
|
+
id: string;
|
|
27
|
+
impId: string;
|
|
28
|
+
price: number;
|
|
29
|
+
ext: BidExtension;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Interface for bid extension data
|
|
33
|
+
*/
|
|
34
|
+
interface BidExtension {
|
|
35
|
+
creativeUrl: string;
|
|
36
|
+
ctaUrl: string;
|
|
37
|
+
creativeTitle: string;
|
|
38
|
+
creativeDescription: string;
|
|
39
|
+
creativeBrandName?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Props for the BannerAd component
|
|
43
|
+
*/
|
|
44
|
+
interface AdBannerProps {
|
|
45
|
+
/** Unique identifier for the ad slot */
|
|
3
46
|
dataAdSlot: string;
|
|
4
|
-
|
|
47
|
+
/** Type of ad to display */
|
|
48
|
+
dataSlotType?: 'banner' | 'video';
|
|
49
|
+
/** Width of the ad container */
|
|
5
50
|
width?: number;
|
|
51
|
+
/** Height of the ad container */
|
|
6
52
|
height?: number;
|
|
7
|
-
|
|
53
|
+
/** Enable responsive layout */
|
|
54
|
+
isResponsive?: boolean;
|
|
55
|
+
/** Responsive layout type */
|
|
8
56
|
responsiveType?: 'SQUARE' | 'VERTICAL' | 'WIDE';
|
|
57
|
+
/** Callback for ad load errors */
|
|
58
|
+
onAdLoadError?: (error: Error) => void;
|
|
59
|
+
/** Callback for ad load success */
|
|
60
|
+
onAdLoadSuccess?: (adData: AdData) => void;
|
|
9
61
|
}
|
|
10
|
-
export declare const BannerAd: React.FC<
|
|
62
|
+
export declare const BannerAd: React.FC<AdBannerProps>;
|
|
11
63
|
export {};
|
|
12
64
|
//# sourceMappingURL=BannerAd.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BannerAd.d.ts","sourceRoot":"","sources":["../../../../src/components/BannerAd.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"BannerAd.d.ts","sourceRoot":"","sources":["../../../../src/components/BannerAd.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAA2C,MAAM,OAAO,CAAC;AAchE;;GAEG;AACH,UAAU,MAAM;IACd,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,UAAU,OAAO;IACf,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,GAAG,EAAE,CAAC;CACZ;AAED;;GAEG;AACH,UAAU,GAAG;IACX,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,YAAY,CAAC;CACnB;AAED;;GAEG;AACH,UAAU,YAAY;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,UAAU,aAAa;IACrB,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,4BAA4B;IAC5B,YAAY,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAClC,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+BAA+B;IAC/B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,6BAA6B;IAC7B,cAAc,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;IAChD,kCAAkC;IAClC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACvC,mCAAmC;IACnC,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAgN5C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thealteroffice/react-native-adgeist",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "Publishers can integrate our SDK to connect their ad spaces to the AdGeist marketplace.",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"module": "./lib/module/index.js",
|
package/src/cdpclient/index.ts
CHANGED
|
@@ -1,17 +1,80 @@
|
|
|
1
1
|
import Adgeist, { type UserDetails, type Event } from '../NativeAdgeist';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
class AdgeistError extends Error {
|
|
4
|
+
code?: string;
|
|
5
|
+
|
|
6
|
+
constructor(message: string, code?: string) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = 'AdgeistError';
|
|
9
|
+
this.code = code;
|
|
10
|
+
Object.setPrototypeOf(this, AdgeistError.prototype);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Sets user details in the Adgeist SDK
|
|
16
|
+
* @param userDetails - User details object
|
|
17
|
+
* @throws AdgeistError if the operation fails
|
|
18
|
+
*/
|
|
19
|
+
export const setUserDetails = (userDetails: UserDetails): void => {
|
|
20
|
+
try {
|
|
21
|
+
Adgeist.setUserDetails(userDetails);
|
|
22
|
+
} catch (error: unknown) {
|
|
23
|
+
const err =
|
|
24
|
+
error instanceof Error ? error : new Error('Failed to set user details');
|
|
25
|
+
throw new AdgeistError(err.message);
|
|
26
|
+
}
|
|
5
27
|
};
|
|
6
28
|
|
|
7
|
-
|
|
8
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Logs an event in the Adgeist SDK
|
|
31
|
+
* @param event - Event object to log
|
|
32
|
+
* @throws AdgeistError if the event is invalid or logging fails
|
|
33
|
+
*/
|
|
34
|
+
export const logEvent = (event: Event): void => {
|
|
35
|
+
if (!event || typeof event !== 'object') {
|
|
36
|
+
throw new AdgeistError('Event must be a valid object');
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
Adgeist.logEvent(event);
|
|
40
|
+
} catch (error: unknown) {
|
|
41
|
+
const err =
|
|
42
|
+
error instanceof Error ? error : new Error('Failed to log event');
|
|
43
|
+
throw new AdgeistError(err.message);
|
|
44
|
+
}
|
|
9
45
|
};
|
|
10
46
|
|
|
11
|
-
|
|
12
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves the consent status from the Adgeist SDK
|
|
49
|
+
* @returns Promise resolving to 'ACCEPTED' or 'DENIED'
|
|
50
|
+
* @throws AdgeistError if the operation fails
|
|
51
|
+
*/
|
|
52
|
+
export const getConsentStatus = async (): Promise<'ACCEPTED' | 'DENIED'> => {
|
|
53
|
+
try {
|
|
54
|
+
const status = await Adgeist.getConsentStatus();
|
|
55
|
+
return status === true ? 'ACCEPTED' : 'DENIED';
|
|
56
|
+
} catch (error: unknown) {
|
|
57
|
+
const err =
|
|
58
|
+
error instanceof Error
|
|
59
|
+
? error
|
|
60
|
+
: new Error('Failed to get consent status');
|
|
61
|
+
throw new AdgeistError(err.message);
|
|
62
|
+
}
|
|
13
63
|
};
|
|
14
64
|
|
|
15
|
-
|
|
16
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Updates the consent status in the Adgeist SDK
|
|
67
|
+
* @param consent - Boolean indicating user consent
|
|
68
|
+
* @throws AdgeistError if the operation fails
|
|
69
|
+
*/
|
|
70
|
+
export const updateConsentStatus = (consent: boolean): void => {
|
|
71
|
+
try {
|
|
72
|
+
Adgeist.updateConsentStatus(consent);
|
|
73
|
+
} catch (error: unknown) {
|
|
74
|
+
const err =
|
|
75
|
+
error instanceof Error
|
|
76
|
+
? error
|
|
77
|
+
: new Error('Failed to update consent status');
|
|
78
|
+
throw new AdgeistError(err.message);
|
|
79
|
+
}
|
|
17
80
|
};
|