@thealteroffice/react-native-adgeist 0.0.20 → 0.0.22

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.
Files changed (136) hide show
  1. package/Adgeist.podspec +1 -1
  2. package/README.md +70 -521
  3. package/android/build.gradle +6 -3
  4. package/android/generated/java/com/adgeist/NativeAdgeistSpec.java +11 -11
  5. package/android/generated/java/com/facebook/react/viewmanagers/HTML5AdNativeComponentManagerDelegate.java +55 -0
  6. package/android/generated/java/com/facebook/react/viewmanagers/HTML5AdNativeComponentManagerInterface.java +24 -0
  7. package/android/generated/jni/RNAdgeistSpec-generated.cpp +12 -12
  8. package/android/generated/jni/react/renderer/components/RNAdgeistSpec/ComponentDescriptors.cpp +22 -0
  9. package/android/generated/jni/react/renderer/components/RNAdgeistSpec/ComponentDescriptors.h +24 -0
  10. package/android/generated/jni/react/renderer/components/RNAdgeistSpec/EventEmitters.cpp +60 -0
  11. package/android/generated/jni/react/renderer/components/RNAdgeistSpec/EventEmitters.h +49 -0
  12. package/android/generated/jni/react/renderer/components/RNAdgeistSpec/Props.cpp +28 -0
  13. package/android/generated/jni/react/renderer/components/RNAdgeistSpec/Props.h +52 -0
  14. package/android/generated/jni/react/renderer/components/RNAdgeistSpec/RNAdgeistSpecJSI-generated.cpp +14 -22
  15. package/android/generated/jni/react/renderer/components/RNAdgeistSpec/RNAdgeistSpecJSI.h +36 -36
  16. package/android/generated/jni/react/renderer/components/RNAdgeistSpec/ShadowNodes.cpp +17 -0
  17. package/android/generated/jni/react/renderer/components/RNAdgeistSpec/ShadowNodes.h +32 -0
  18. package/android/generated/jni/react/renderer/components/RNAdgeistSpec/States.cpp +16 -0
  19. package/android/generated/jni/react/renderer/components/RNAdgeistSpec/States.h +29 -0
  20. package/android/src/main/java/com/adgeist/AdgeistPackage.kt +8 -7
  21. package/android/src/main/java/com/adgeist/components/HTML5AdViewManagerImpl.kt +125 -0
  22. package/android/src/main/java/com/adgeist/modules/AdgeistImpl.kt +114 -0
  23. package/android/src/main/java/com/adgeist/utils/CreativeExtensions.kt +151 -0
  24. package/android/src/newarch/java/com/Adgeist.kt +119 -0
  25. package/android/src/newarch/java/com/HTML5AdViewManager.kt +77 -0
  26. package/android/src/oldarch/java/com/Adgeist.kt +132 -0
  27. package/android/src/oldarch/java/com/HTML5AdViewManager.kt +63 -0
  28. package/ios/Adgeist-Bridging-Header.h +3 -0
  29. package/ios/Adgeist.h +1 -1
  30. package/ios/Adgeist.mm +71 -65
  31. package/ios/AdgeistImpl.swift +127 -132
  32. package/ios/NativeHTML5AdManager.h +9 -0
  33. package/ios/NativeHTML5AdManager.mm +178 -0
  34. package/ios/NativeHTML5AdView.swift +136 -0
  35. package/ios/generated/RNAdgeistSpec/ComponentDescriptors.cpp +22 -0
  36. package/ios/generated/RNAdgeistSpec/ComponentDescriptors.h +24 -0
  37. package/ios/generated/RNAdgeistSpec/EventEmitters.cpp +60 -0
  38. package/ios/generated/RNAdgeistSpec/EventEmitters.h +49 -0
  39. package/ios/generated/RNAdgeistSpec/Props.cpp +28 -0
  40. package/ios/generated/RNAdgeistSpec/Props.h +52 -0
  41. package/ios/generated/RNAdgeistSpec/RCTComponentViewHelpers.h +65 -0
  42. package/ios/generated/RNAdgeistSpec/RNAdgeistSpec-generated.mm +17 -17
  43. package/ios/generated/RNAdgeistSpec/RNAdgeistSpec.h +17 -25
  44. package/ios/generated/RNAdgeistSpec/ShadowNodes.cpp +17 -0
  45. package/ios/generated/RNAdgeistSpec/ShadowNodes.h +32 -0
  46. package/ios/generated/RNAdgeistSpec/States.cpp +16 -0
  47. package/ios/generated/RNAdgeistSpec/States.h +29 -0
  48. package/ios/generated/RNAdgeistSpecJSI-generated.cpp +14 -22
  49. package/ios/generated/RNAdgeistSpecJSI.h +36 -36
  50. package/lib/module/cdpclient/index.js +1 -25
  51. package/lib/module/cdpclient/index.js.map +1 -1
  52. package/lib/module/components/HTML5AdView.js +128 -0
  53. package/lib/module/components/HTML5AdView.js.map +1 -0
  54. package/lib/module/components/{BannerAd.js → deprecated/BannerAdView.js} +50 -79
  55. package/lib/module/components/deprecated/BannerAdView.js.map +1 -0
  56. package/lib/module/components/{ConsentModal.js → deprecated/ConsentModal.js} +2 -2
  57. package/lib/module/components/deprecated/ConsentModal.js.map +1 -0
  58. package/lib/module/constants.js +14 -0
  59. package/lib/module/constants.js.map +1 -0
  60. package/lib/module/index.js +3 -2
  61. package/lib/module/index.js.map +1 -1
  62. package/lib/module/{components → providers}/AdgeistProvider.js +10 -35
  63. package/lib/module/providers/AdgeistProvider.js.map +1 -0
  64. package/lib/module/specs/HTML5AdNativeComponent.ts +46 -0
  65. package/lib/module/specs/NativeAdgeist.js.map +1 -0
  66. package/lib/module/types/AdSize.js +2 -0
  67. package/lib/module/types/AdSize.js.map +1 -0
  68. package/lib/module/types/CPMAdResponse.js +2 -0
  69. package/lib/module/types/CPMAdResponse.js.map +1 -0
  70. package/lib/module/types/FixedAdResponse.js +2 -0
  71. package/lib/module/types/FixedAdResponse.js.map +1 -0
  72. package/lib/module/types/HTML5AdNativeComponentProps.js +4 -0
  73. package/lib/module/types/HTML5AdNativeComponentProps.js.map +1 -0
  74. package/lib/module/types/Provider.js +2 -0
  75. package/lib/module/types/Provider.js.map +1 -0
  76. package/lib/typescript/src/cdpclient/index.d.ts +1 -21
  77. package/lib/typescript/src/cdpclient/index.d.ts.map +1 -1
  78. package/lib/typescript/src/components/HTML5AdView.d.ts +3 -0
  79. package/lib/typescript/src/components/HTML5AdView.d.ts.map +1 -0
  80. package/lib/typescript/src/components/deprecated/BannerAdView.d.ts +17 -0
  81. package/lib/typescript/src/components/deprecated/BannerAdView.d.ts.map +1 -0
  82. package/lib/typescript/src/components/deprecated/ConsentModal.d.ts.map +1 -0
  83. package/lib/typescript/src/constants.d.ts +10 -0
  84. package/lib/typescript/src/constants.d.ts.map +1 -0
  85. package/lib/typescript/src/index.d.ts +3 -2
  86. package/lib/typescript/src/index.d.ts.map +1 -1
  87. package/lib/typescript/src/providers/AdgeistProvider.d.ts +9 -0
  88. package/lib/typescript/src/providers/AdgeistProvider.d.ts.map +1 -0
  89. package/lib/typescript/src/specs/HTML5AdNativeComponent.d.ts +29 -0
  90. package/lib/typescript/src/specs/HTML5AdNativeComponent.d.ts.map +1 -0
  91. package/lib/typescript/src/specs/NativeAdgeist.d.ts +28 -0
  92. package/lib/typescript/src/specs/NativeAdgeist.d.ts.map +1 -0
  93. package/lib/typescript/src/types/AdSize.d.ts +5 -0
  94. package/lib/typescript/src/types/AdSize.d.ts.map +1 -0
  95. package/lib/typescript/src/types/CPMAdResponse.d.ts +25 -0
  96. package/lib/typescript/src/types/CPMAdResponse.d.ts.map +1 -0
  97. package/lib/typescript/src/types/FixedAdResponse.d.ts +50 -0
  98. package/lib/typescript/src/types/FixedAdResponse.d.ts.map +1 -0
  99. package/lib/typescript/src/types/HTML5AdNativeComponentProps.d.ts +24 -0
  100. package/lib/typescript/src/types/HTML5AdNativeComponentProps.d.ts.map +1 -0
  101. package/lib/typescript/src/types/Provider.d.ts +16 -0
  102. package/lib/typescript/src/types/Provider.d.ts.map +1 -0
  103. package/package.json +8 -3
  104. package/react-native.config.js +1 -1
  105. package/src/cdpclient/index.ts +1 -21
  106. package/src/components/HTML5AdView.tsx +161 -0
  107. package/src/components/{BannerAd.tsx → deprecated/BannerAdView.tsx} +80 -115
  108. package/src/components/{ConsentModal.tsx → deprecated/ConsentModal.tsx} +2 -2
  109. package/src/constants.ts +8 -0
  110. package/src/index.tsx +4 -2
  111. package/src/{components → providers}/AdgeistProvider.tsx +26 -60
  112. package/src/specs/HTML5AdNativeComponent.ts +46 -0
  113. package/src/{NativeAdgeist.ts → specs/NativeAdgeist.ts} +26 -25
  114. package/src/types/AdSize.ts +4 -0
  115. package/src/types/CPMAdResponse.ts +26 -0
  116. package/src/types/FixedAdResponse.ts +51 -0
  117. package/src/types/HTML5AdNativeComponentProps.ts +28 -0
  118. package/src/types/Provider.ts +16 -0
  119. package/android/src/main/AndroidManifestNew.xml +0 -2
  120. package/android/src/main/java/com/adgeist/implementation/AdgeistModuleImpl.kt +0 -252
  121. package/android/src/newarch/java/com/AdgeistModule.kt +0 -135
  122. package/android/src/oldarch/java/com/AdgeistModule.kt +0 -148
  123. package/ios/adgeist-Bridging-Header.h +0 -1
  124. package/lib/module/NativeAdgeist.js.map +0 -1
  125. package/lib/module/components/AdgeistProvider.js.map +0 -1
  126. package/lib/module/components/BannerAd.js.map +0 -1
  127. package/lib/module/components/ConsentModal.js.map +0 -1
  128. package/lib/typescript/src/NativeAdgeist.d.ts +0 -28
  129. package/lib/typescript/src/NativeAdgeist.d.ts.map +0 -1
  130. package/lib/typescript/src/components/AdgeistProvider.d.ts +0 -50
  131. package/lib/typescript/src/components/AdgeistProvider.d.ts.map +0 -1
  132. package/lib/typescript/src/components/BannerAd.d.ts +0 -64
  133. package/lib/typescript/src/components/BannerAd.d.ts.map +0 -1
  134. package/lib/typescript/src/components/ConsentModal.d.ts.map +0 -1
  135. /package/lib/module/{NativeAdgeist.js → specs/NativeAdgeist.js} +0 -0
  136. /package/lib/typescript/src/components/{ConsentModal.d.ts → deprecated/ConsentModal.d.ts} +0 -0
@@ -1,8 +1,3 @@
1
- /**
2
- * @module AdgeistProvider
3
- * @description Context provider for Adgeist ad-serving configuration and initialization
4
- */
5
-
6
1
  import React, {
7
2
  createContext,
8
3
  useContext,
@@ -10,64 +5,25 @@ import React, {
10
5
  useState,
11
6
  useCallback,
12
7
  } from 'react';
13
- import Adgeist from '../NativeAdgeist';
14
- import { ConsentModal } from './ConsentModal';
15
-
16
- /**
17
- * Interface for Adgeist context
18
- */
19
- interface AdgeistContextType {
20
- publisherId: string;
21
- apiKey: string;
22
- domain: string;
23
- isTestEnvironment: boolean;
24
- isInitialized: boolean;
25
- initializationError?: Error;
26
- setAdgeistConsentModal: (value: boolean) => void;
27
- }
28
-
29
- /**
30
- * Props for AdgeistProvider
31
- */
32
- interface AdgeistProviderProps {
33
- children: React.ReactNode;
34
- /** Custom API origin for Adgeist SDK */
35
- customAdgeistApiOrigin?: string;
36
- /** Publisher identifier */
37
- publisherId: string;
38
- /** API key for authentication */
39
- apiKey: string;
40
- /** Domain for ad serving */
41
- domain: string;
42
- /** Enable test environment mode */
43
- isTestEnvironment?: boolean;
44
- /** Callback for initialization errors */
45
- onInitializationError?: (error: Error) => void;
46
- /** Callback for successful initialization */
47
- onInitializationSuccess?: () => void;
48
- }
8
+ import Adgeist from '../specs/NativeAdgeist';
9
+ import { ConsentModal } from '../components/deprecated/ConsentModal';
10
+ import type {
11
+ AdgeistContextType,
12
+ AdgeistProviderProps,
13
+ } from '../types/Provider';
49
14
 
50
15
  const AdgeistContext = createContext<AdgeistContextType>({
51
- publisherId: '',
52
- apiKey: '',
53
- domain: '',
54
- isTestEnvironment: true,
16
+ isTestEnvironment: false,
55
17
  isInitialized: false,
56
18
  setAdgeistConsentModal: () => {},
57
19
  });
58
20
 
59
- /**
60
- * AdgeistProvider component for managing ad-serving configuration
61
- * @param props - Component properties
62
- * @returns JSX.Element
63
- */
64
21
  export const AdgeistProvider: React.FC<AdgeistProviderProps> = ({
65
22
  children,
66
- publisherId = '',
67
- apiKey = '',
68
- domain = '',
69
- customAdgeistApiOrigin = 'bg-services-qa-api.adgeist.ai',
70
- isTestEnvironment = true,
23
+ customBidRequestBackendDomain = 'https://beta.v2.bg-services.adgeist.ai',
24
+ customPackageOrBundleID = '',
25
+ customAdgeistAppID = '',
26
+ isTestEnvironment = false,
71
27
  onInitializationError,
72
28
  onInitializationSuccess,
73
29
  }) => {
@@ -86,7 +42,14 @@ export const AdgeistProvider: React.FC<AdgeistProviderProps> = ({
86
42
  setIsInitialized(false);
87
43
 
88
44
  try {
89
- await Adgeist.initializeSdk(customAdgeistApiOrigin);
45
+ await Adgeist.destroySdk();
46
+
47
+ await Adgeist.initializeSdk(
48
+ customBidRequestBackendDomain,
49
+ customPackageOrBundleID,
50
+ customAdgeistAppID
51
+ );
52
+
90
53
  setIsInitialized(true);
91
54
  onInitializationSuccess?.();
92
55
  } catch (error: unknown) {
@@ -96,7 +59,13 @@ export const AdgeistProvider: React.FC<AdgeistProviderProps> = ({
96
59
  setIsInitialized(false);
97
60
  onInitializationError?.(err);
98
61
  }
99
- }, [customAdgeistApiOrigin, onInitializationError, onInitializationSuccess]);
62
+ }, [
63
+ customBidRequestBackendDomain,
64
+ onInitializationError,
65
+ onInitializationSuccess,
66
+ customPackageOrBundleID,
67
+ customAdgeistAppID,
68
+ ]);
100
69
 
101
70
  useEffect(() => {
102
71
  initializeAdgeist();
@@ -105,9 +74,6 @@ export const AdgeistProvider: React.FC<AdgeistProviderProps> = ({
105
74
  return (
106
75
  <AdgeistContext.Provider
107
76
  value={{
108
- publisherId,
109
- apiKey,
110
- domain,
111
77
  isTestEnvironment,
112
78
  isInitialized,
113
79
  initializationError,
@@ -0,0 +1,46 @@
1
+ import type { HostComponent, ViewProps } from 'react-native';
2
+ import type {
3
+ DirectEventHandler,
4
+ Double,
5
+ } from 'react-native/Libraries/Types/CodegenTypes';
6
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
7
+ import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
8
+ import * as React from 'react';
9
+
10
+ export interface AdSize {
11
+ width?: Double;
12
+ height?: Double;
13
+ }
14
+
15
+ export interface AdFailedToLoadEvent {
16
+ error: string;
17
+ }
18
+
19
+ export interface NativeProps extends ViewProps {
20
+ adUnitID: string;
21
+ adIsResponsive?: boolean;
22
+ adSize?: AdSize;
23
+ adType: string;
24
+
25
+ onAdLoaded?: DirectEventHandler<null>;
26
+ onAdFailedToLoad?: DirectEventHandler<AdFailedToLoadEvent>;
27
+ onAdOpened?: DirectEventHandler<null>;
28
+ onAdClosed?: DirectEventHandler<null>;
29
+ onAdClicked?: DirectEventHandler<null>;
30
+ }
31
+
32
+ interface NativeCommands {
33
+ loadAd: (
34
+ viewRef: React.ElementRef<HostComponent<NativeProps>>,
35
+ isTestMode: boolean
36
+ ) => void;
37
+ destroy: (viewRef: React.ElementRef<HostComponent<NativeProps>>) => void;
38
+ }
39
+
40
+ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
41
+ supportedCommands: ['loadAd', 'destroy'],
42
+ });
43
+
44
+ export default codegenNativeComponent<NativeProps>(
45
+ 'HTML5AdNativeComponent'
46
+ ) as HostComponent<NativeProps>;
@@ -13,13 +13,17 @@ export interface Event {
13
13
  eventProperties: Object;
14
14
  }
15
15
  export interface Spec extends TurboModule {
16
- initializeSdk(customDomain: string): Promise<boolean>;
16
+ initializeSdk(
17
+ customBidRequestBackendDomain: string,
18
+ customPackageOrBundleID: string,
19
+ customAdgeistAppID: string
20
+ ): Promise<boolean>;
21
+
22
+ destroySdk(): Promise<boolean>;
17
23
 
18
24
  fetchCreative(
19
- apiKey: string,
20
- origin: string,
21
25
  adSpaceId: string,
22
- publisherId: string,
26
+ buyType: string,
23
27
  isTestEnvironment: boolean
24
28
  ): Promise<Object>;
25
29
 
@@ -34,9 +38,9 @@ export interface Spec extends TurboModule {
34
38
  trackImpression(
35
39
  campaignId: string,
36
40
  adSpaceId: string,
37
- publisherId: string,
38
- apiKey: string,
39
41
  bidId: string,
42
+ bidMeta: string,
43
+ buyType: string,
40
44
  isTestEnvironment: boolean,
41
45
  renderTime: number
42
46
  ): Promise<string>;
@@ -44,9 +48,9 @@ export interface Spec extends TurboModule {
44
48
  trackView(
45
49
  campaignId: string,
46
50
  adSpaceId: string,
47
- publisherId: string,
48
- apiKey: string,
49
51
  bidId: string,
52
+ bidMeta: string,
53
+ buyType: string,
50
54
  isTestEnvironment: boolean,
51
55
  viewTime: number,
52
56
  visibilityRatio: number,
@@ -57,42 +61,39 @@ export interface Spec extends TurboModule {
57
61
  trackTotalView(
58
62
  campaignId: string,
59
63
  adSpaceId: string,
60
- publisherId: string,
61
- apiKey: string,
62
64
  bidId: string,
65
+ bidMeta: string,
66
+ buyType: string,
63
67
  isTestEnvironment: boolean,
64
- totalViewTime: number,
65
- visibilityRatio: number
68
+ totalViewTime: number
66
69
  ): Promise<string>;
67
70
 
68
71
  trackClick(
69
72
  campaignId: string,
70
73
  adSpaceId: string,
71
- publisherId: string,
72
- apiKey: string,
73
74
  bidId: string,
75
+ bidMeta: string,
76
+ buyType: string,
74
77
  isTestEnvironment: boolean
75
78
  ): Promise<string>;
76
79
 
77
80
  trackVideoPlayback(
78
81
  campaignId: string,
79
82
  adSpaceId: string,
80
- publisherId: string,
81
- apiKey: string,
82
83
  bidId: string,
84
+ bidMeta: string,
85
+ buyType: string,
83
86
  isTestEnvironment: boolean,
84
87
  totalPlaybackTime: number
85
88
  ): Promise<string>;
86
89
 
87
- trackVideoQuartile(
88
- campaignId: string,
89
- adSpaceId: string,
90
- publisherId: string,
91
- apiKey: string,
92
- bidId: string,
93
- isTestEnvironment: boolean,
94
- quartile: string
95
- ): Promise<string>;
90
+ // trackVideoQuartile(
91
+ // campaignId: string,
92
+ // adSpaceId: string,
93
+ // bidId: string,
94
+ // isTestEnvironment: boolean,
95
+ // quartile: string
96
+ // ): Promise<string>;
96
97
  }
97
98
 
98
99
  export default TurboModuleRegistry.getEnforcing<Spec>('Adgeist');
@@ -0,0 +1,4 @@
1
+ export interface AdSize {
2
+ width?: number;
3
+ height?: number;
4
+ }
@@ -0,0 +1,26 @@
1
+ export interface CPMADRESPONSE {
2
+ id: string;
3
+ bidId: string;
4
+ cur: string;
5
+ seatBid: SeatBid[];
6
+ }
7
+
8
+ interface SeatBid {
9
+ bidId: string;
10
+ bid: Bid[];
11
+ }
12
+
13
+ interface Bid {
14
+ id: string;
15
+ impId: string;
16
+ price: number;
17
+ ext: BidExtension;
18
+ }
19
+
20
+ interface BidExtension {
21
+ creativeUrl: string;
22
+ ctaUrl: string;
23
+ creativeTitle: string;
24
+ creativeDescription: string;
25
+ creativeBrandName?: string;
26
+ }
@@ -0,0 +1,51 @@
1
+ export interface FIXEDADRESPONSE {
2
+ metaData: string;
3
+ id: string;
4
+ generatedAt: string;
5
+ signature: string;
6
+ campaignId: string;
7
+ advertiser: Advertiser;
8
+ type: 'FIXED' | string;
9
+ loadType: 'QUICK' | string;
10
+ displayOptions: DisplayOptions;
11
+ campaignValidity: {
12
+ startTime: string;
13
+ endTime: string;
14
+ };
15
+ creatives: Creative[];
16
+ frontendCacheDurationSeconds: number;
17
+ impressionRequirements: {
18
+ impressionType: ('VIEW' | 'CLICK')[];
19
+ minViewDurationSeconds: number;
20
+ };
21
+ }
22
+
23
+ interface Advertiser {
24
+ id: string;
25
+ name: string;
26
+ logoUrl: string;
27
+ }
28
+
29
+ interface DisplayOptions {
30
+ isResponsive: boolean;
31
+ dimensions: {
32
+ width: number;
33
+ height: number;
34
+ };
35
+ styleOptions: {
36
+ fontFamily: string;
37
+ fontColor: string;
38
+ };
39
+ allowedFormats: string[];
40
+ }
41
+
42
+ interface Creative {
43
+ ctaUrl: string;
44
+ title: string;
45
+ description: string;
46
+ type: 'image' | string;
47
+ fileName: string;
48
+ fileSize: number;
49
+ fileUrl: string;
50
+ thumbnailUrl: string;
51
+ }
@@ -0,0 +1,28 @@
1
+ import type { NativeSyntheticEvent } from 'react-native';
2
+ import type { AdSize } from './AdSize';
3
+
4
+ export interface HTML5AdNativeComponentProps {
5
+ adUnitID: string;
6
+ adIsResponsive?: boolean;
7
+ adSize?: AdSize;
8
+ adType: string;
9
+
10
+ onAdLoaded?: () => void;
11
+ onAdFailedToLoad?: (event: NativeSyntheticEvent<AdFailedToLoadEvent>) => void;
12
+ onAdOpened?: () => void;
13
+ onAdClosed?: () => void;
14
+ onAdClicked?: () => void;
15
+ }
16
+
17
+ export interface AdFailedToLoadEvent {
18
+ error: string;
19
+ }
20
+
21
+ export interface HTML5AdRequest {
22
+ isTestMode?: boolean;
23
+ }
24
+
25
+ export interface HTML5AdViewRef {
26
+ loadAd: (adRequest?: HTML5AdRequest) => void;
27
+ destroy: () => void;
28
+ }
@@ -0,0 +1,16 @@
1
+ export interface AdgeistContextType {
2
+ isTestEnvironment: boolean;
3
+ isInitialized: boolean;
4
+ initializationError?: Error;
5
+ setAdgeistConsentModal: (value: boolean) => void;
6
+ }
7
+
8
+ export interface AdgeistProviderProps {
9
+ children: React.ReactNode;
10
+ customBidRequestBackendDomain?: string;
11
+ customPackageOrBundleID?: string;
12
+ customAdgeistAppID?: string;
13
+ isTestEnvironment?: boolean;
14
+ onInitializationError?: (error: Error) => void;
15
+ onInitializationSuccess?: () => void;
16
+ }
@@ -1,2 +0,0 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
- </manifest>
@@ -1,252 +0,0 @@
1
- package com.adgeist.implementation
2
-
3
- import com.facebook.react.bridge.Promise
4
- import com.facebook.react.bridge.ReactApplicationContext
5
- import com.facebook.react.bridge.Arguments
6
- import com.facebook.react.bridge.WritableMap
7
- import com.adgeistkit.AdgeistCore
8
- import com.adgeistkit.FetchCreative
9
- import com.adgeistkit.CreativeAnalytics
10
- import com.adgeistkit.CreativeDataModel
11
- import com.adgeistkit.BidResponseData
12
- import com.adgeistkit.SeatBid
13
- import com.adgeistkit.Bid
14
- import com.adgeistkit.BidExtension
15
- import com.adgeistkit.UserDetails
16
- import com.adgeistkit.Event
17
- import com.facebook.react.bridge.ReadableMap
18
-
19
- class AdgeistModuleImpl internal constructor(private val context: ReactApplicationContext) {
20
-
21
- private var adgeistInstance: AdgeistCore? = null
22
- private var getAd: FetchCreative? = null
23
- private var postCreativeAnalytic: CreativeAnalytics? = null
24
-
25
- fun initializeSdk(customDomain: String?, promise: Promise) {
26
- try {
27
- adgeistInstance = AdgeistCore.initialize(context.applicationContext, customDomain)
28
- getAd = adgeistInstance?.getCreative()
29
- postCreativeAnalytic = adgeistInstance?.postCreativeAnalytics()
30
- promise.resolve("SDK initialized with domain: ${customDomain ?: "default"}")
31
- } catch (e: Exception) {
32
- promise.reject("INIT_FAILED", "SDK initialization failed", e)
33
- }
34
- }
35
-
36
- fun fetchCreative(apiKey: String, origin: String, adSpaceId: String, publisherId: String, isTestEnvironment: Boolean, promise: Promise) {
37
- getAd?.fetchCreative(apiKey, origin, adSpaceId, publisherId, isTestEnvironment) { adData ->
38
- if (adData != null) {
39
- promise.resolve(adData.toWritableMap())
40
- } else {
41
- promise.reject("NO_AD", "Ad data not available")
42
- }
43
- } ?: promise.reject("NOT_INITIALIZED", "SDK not initialized")
44
- }
45
-
46
-
47
- fun setUserDetails(userDetailsMap: ReadableMap) {
48
- val userDetails = UserDetails(
49
- userId = userDetailsMap.getStringSafe("userId"),
50
- userName = userDetailsMap.getStringSafe("userName"),
51
- email = userDetailsMap.getStringSafe("email"),
52
- phone = userDetailsMap.getStringSafe("phone")
53
- )
54
- adgeistInstance?.setUserDetails(userDetails)
55
- }
56
-
57
- fun logEvent(eventMap: ReadableMap) {
58
- val eventType = eventMap.getStringSafe("eventType")
59
-
60
- if (eventType.isNullOrEmpty()) {
61
- throw IllegalArgumentException("Event must have a non-empty eventType")
62
- }
63
-
64
- val props = if (eventMap.hasKey("eventProperties")) eventMap.getMap("eventProperties") else null
65
- val eventProps = props?.toHashMap() ?: emptyMap<String, Any>()
66
-
67
- val event = Event(
68
- eventType = eventType,
69
- eventProperties = eventProps
70
- )
71
- adgeistInstance?.logEvent(event)
72
- }
73
-
74
- fun getConsentStatus(promise: Promise) {
75
- try {
76
- val consent = adgeistInstance?.getConsentStatus() ?: false
77
- promise.resolve(consent)
78
- } catch (e: Exception) {
79
- promise.reject("CONSENT_ERROR", "Failed to get consent status", e)
80
- }
81
- }
82
-
83
- fun updateConsentStatus(consent: Boolean) {
84
- adgeistInstance?.updateConsentStatus(consent)
85
- }
86
-
87
- fun trackImpression(
88
- campaignId: String,
89
- adSpaceId: String,
90
- publisherId: String,
91
- apiKey: String,
92
- bidId: String,
93
- isTestEnvironment: Boolean,
94
- renderTime: Float,
95
- promise: Promise
96
- ) {
97
- postCreativeAnalytic?.trackImpression(
98
- campaignId, adSpaceId, publisherId, apiKey, bidId, isTestEnvironment, renderTime
99
- )
100
- promise.resolve("Impression event sent")
101
- }
102
-
103
- fun trackView(
104
- campaignId: String,
105
- adSpaceId: String,
106
- publisherId: String,
107
- apiKey: String,
108
- bidId: String,
109
- isTestEnvironment: Boolean,
110
- viewTime: Float,
111
- visibilityRatio: Float,
112
- scrollDepth: Float,
113
- timeToVisible: Float,
114
- promise: Promise
115
- ) {
116
- postCreativeAnalytic?.trackView(
117
- campaignId, adSpaceId, publisherId, apiKey, bidId, isTestEnvironment,
118
- viewTime, visibilityRatio, scrollDepth, timeToVisible
119
- )
120
- promise.resolve("View event sent")
121
- }
122
-
123
- fun trackTotalView(
124
- campaignId: String,
125
- adSpaceId: String,
126
- publisherId: String,
127
- apiKey: String,
128
- bidId: String,
129
- isTestEnvironment: Boolean,
130
- totalViewTime: Float,
131
- visibilityRatio: Float,
132
- promise: Promise
133
- ) {
134
- postCreativeAnalytic?.trackTotalView(
135
- campaignId, adSpaceId, publisherId, apiKey, bidId, isTestEnvironment,
136
- totalViewTime, visibilityRatio
137
- )
138
- promise.resolve("Total view event sent")
139
- }
140
-
141
- fun trackClick(
142
- campaignId: String,
143
- adSpaceId: String,
144
- publisherId: String,
145
- apiKey: String,
146
- bidId: String,
147
- isTestEnvironment: Boolean,
148
- promise: Promise
149
- ) {
150
- postCreativeAnalytic?.trackClick(
151
- campaignId, adSpaceId, publisherId, apiKey, bidId, isTestEnvironment
152
- )
153
- promise.resolve("Click event sent")
154
- }
155
-
156
- fun trackVideoPlayback(
157
- campaignId: String,
158
- adSpaceId: String,
159
- publisherId: String,
160
- apiKey: String,
161
- bidId: String,
162
- isTestEnvironment: Boolean,
163
- totalPlaybackTime: Float,
164
- promise: Promise
165
- ) {
166
- postCreativeAnalytic?.trackVideoPlayback(
167
- campaignId, adSpaceId, publisherId, apiKey, bidId, isTestEnvironment, totalPlaybackTime
168
- )
169
- promise.resolve("Video playback event sent")
170
- }
171
-
172
- fun trackVideoQuartile(
173
- campaignId: String,
174
- adSpaceId: String,
175
- publisherId: String,
176
- apiKey: String,
177
- bidId: String,
178
- isTestEnvironment: Boolean,
179
- quartile: String,
180
- promise: Promise
181
- ) {
182
- postCreativeAnalytic?.trackVideoQuartile(
183
- campaignId, adSpaceId, publisherId, apiKey, bidId, isTestEnvironment, quartile
184
- )
185
- promise.resolve("Video quartile event sent")
186
- }
187
-
188
- companion object {
189
- const val NAME = "Adgeist"
190
- }
191
- }
192
-
193
- fun ReadableMap.getStringSafe(key: String): String? =
194
- if (this.hasKey(key) && !this.isNull(key)) this.getString(key) else null
195
-
196
-
197
- // Extension function to convert CreativeDataModel to WritableMap
198
- fun CreativeDataModel.toWritableMap(): WritableMap {
199
- val map = Arguments.createMap()
200
-
201
- map.putBoolean("success", this.success)
202
- map.putString("message", this.message)
203
-
204
- // Handle null data - store in local variable for smart casting
205
- val dataValue = this.data
206
- if (dataValue != null) {
207
- val dataMap = Arguments.createMap()
208
- dataMap.putString("id", dataValue.id)
209
- dataMap.putString("bidId", dataValue.bidId)
210
- dataMap.putString("cur", dataValue.cur)
211
-
212
- // Handle null seatBid list - store in local variable
213
- val seatBidArray = Arguments.createArray()
214
- val seatBidList = dataValue.seatBid
215
- if (seatBidList != null) {
216
- for (seatBid in seatBidList) {
217
- val seatBidMap = Arguments.createMap()
218
- seatBidMap.putString("bidId", seatBid.bidId)
219
-
220
- // Handle null bid list - store in local variable
221
- val bidArray = Arguments.createArray()
222
- val bidList = seatBid.bid
223
- if (bidList != null) {
224
- for (bid in bidList) {
225
- val bidMap = Arguments.createMap()
226
- bidMap.putString("id", bid.id)
227
- bidMap.putString("impId", bid.impId)
228
- bidMap.putDouble("price", bid.price)
229
-
230
- // Handle extension
231
- val extMap = Arguments.createMap()
232
- extMap.putString("creativeUrl", bid.ext.creativeUrl)
233
- extMap.putString("ctaUrl", bid.ext.ctaUrl)
234
- extMap.putString("creativeTitle", bid.ext.creativeTitle)
235
- extMap.putString("creativeDescription", bid.ext.creativeDescription)
236
-
237
- bidMap.putMap("ext", extMap)
238
- bidArray.pushMap(bidMap)
239
- }
240
- }
241
- seatBidMap.putArray("bid", bidArray)
242
- seatBidArray.pushMap(seatBidMap)
243
- }
244
- }
245
- dataMap.putArray("seatBid", seatBidArray)
246
- map.putMap("data", dataMap)
247
- } else {
248
- map.putNull("data")
249
- }
250
-
251
- return map
252
- }