@bigcrunch/react-native-ads 0.1.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 +417 -0
- package/android/build.gradle +70 -0
- package/android/settings.gradle +6 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/com/bigcrunch/ads/react/BigCrunchAdsModule.kt +653 -0
- package/android/src/main/java/com/bigcrunch/ads/react/BigCrunchAdsPackage.kt +20 -0
- package/android/src/main/java/com/bigcrunch/ads/react/BigCrunchBannerViewManager.kt +296 -0
- package/ios/BigCrunchAdsModule.swift +588 -0
- package/ios/BigCrunchBannerViewManager.swift +270 -0
- package/ios/react-native-bigcrunch-ads-Bridging-Header.h +8 -0
- package/lib/BigCrunchAds.d.ts +168 -0
- package/lib/BigCrunchAds.d.ts.map +1 -0
- package/lib/BigCrunchAds.js +241 -0
- package/lib/BigCrunchBannerView.d.ts +21 -0
- package/lib/BigCrunchBannerView.d.ts.map +1 -0
- package/lib/BigCrunchBannerView.js +176 -0
- package/lib/BigCrunchInterstitial.d.ts +66 -0
- package/lib/BigCrunchInterstitial.d.ts.map +1 -0
- package/lib/BigCrunchInterstitial.js +222 -0
- package/lib/BigCrunchRewarded.d.ts +85 -0
- package/lib/BigCrunchRewarded.d.ts.map +1 -0
- package/lib/BigCrunchRewarded.js +257 -0
- package/lib/NativeBigCrunchAds.d.ts +71 -0
- package/lib/NativeBigCrunchAds.d.ts.map +1 -0
- package/lib/NativeBigCrunchAds.js +54 -0
- package/lib/index.d.ts +28 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +32 -0
- package/lib/types/ads.d.ts +101 -0
- package/lib/types/ads.d.ts.map +1 -0
- package/lib/types/ads.js +4 -0
- package/lib/types/config.d.ts +137 -0
- package/lib/types/config.d.ts.map +1 -0
- package/lib/types/config.js +4 -0
- package/lib/types/events.d.ts +306 -0
- package/lib/types/events.d.ts.map +1 -0
- package/lib/types/events.js +4 -0
- package/lib/types/index.d.ts +175 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +23 -0
- package/package.json +88 -0
- package/react-native-bigcrunch-ads.podspec +27 -0
- package/src/BigCrunchAds.ts +298 -0
- package/src/BigCrunchBannerView.tsx +262 -0
- package/src/BigCrunchInterstitial.ts +266 -0
- package/src/BigCrunchRewarded.ts +307 -0
- package/src/NativeBigCrunchAds.ts +120 -0
- package/src/index.ts +71 -0
- package/src/types/ads.ts +112 -0
- package/src/types/config.ts +145 -0
- package/src/types/events.ts +337 -0
- package/src/types/index.ts +193 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BigCrunch Mobile Ads SDK for React Native
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Main SDK API
|
|
8
|
+
export { BigCrunchAds, default as BigCrunchAdsDefault } from './BigCrunchAds';
|
|
9
|
+
|
|
10
|
+
// Ad Components and APIs
|
|
11
|
+
export { BigCrunchBannerView, default as BigCrunchBannerViewDefault } from './BigCrunchBannerView';
|
|
12
|
+
export { BigCrunchInterstitial, default as BigCrunchInterstitialDefault } from './BigCrunchInterstitial';
|
|
13
|
+
export { BigCrunchRewarded, default as BigCrunchRewardedDefault } from './BigCrunchRewarded';
|
|
14
|
+
|
|
15
|
+
// Import defaults for the default export
|
|
16
|
+
import BigCrunchAds from './BigCrunchAds';
|
|
17
|
+
import BigCrunchBannerView from './BigCrunchBannerView';
|
|
18
|
+
import BigCrunchInterstitial from './BigCrunchInterstitial';
|
|
19
|
+
import BigCrunchRewarded from './BigCrunchRewarded';
|
|
20
|
+
|
|
21
|
+
// Export all types
|
|
22
|
+
export * from './types';
|
|
23
|
+
|
|
24
|
+
// Re-export commonly used types at top level for convenience
|
|
25
|
+
export type {
|
|
26
|
+
// Initialization
|
|
27
|
+
InitializationOptions,
|
|
28
|
+
Environment,
|
|
29
|
+
|
|
30
|
+
// Ad formats and sizes
|
|
31
|
+
AdFormat,
|
|
32
|
+
BannerSize,
|
|
33
|
+
CustomSize,
|
|
34
|
+
|
|
35
|
+
// Ad components
|
|
36
|
+
BigCrunchBannerViewProps,
|
|
37
|
+
InterstitialAd,
|
|
38
|
+
RewardedAd,
|
|
39
|
+
|
|
40
|
+
// Events
|
|
41
|
+
AdEvent,
|
|
42
|
+
AdEventListener,
|
|
43
|
+
EventSubscription,
|
|
44
|
+
AdError,
|
|
45
|
+
AdRevenue,
|
|
46
|
+
|
|
47
|
+
// Configuration
|
|
48
|
+
AppConfig,
|
|
49
|
+
PlacementConfig,
|
|
50
|
+
|
|
51
|
+
// Analytics
|
|
52
|
+
SessionInfo,
|
|
53
|
+
DeviceContext,
|
|
54
|
+
} from './types';
|
|
55
|
+
|
|
56
|
+
// Export error codes enum
|
|
57
|
+
export { AdErrorCode } from './types';
|
|
58
|
+
|
|
59
|
+
// Version
|
|
60
|
+
export const SDK_VERSION = '0.1.0';
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Default export for convenience
|
|
64
|
+
*/
|
|
65
|
+
export default {
|
|
66
|
+
BigCrunchAds,
|
|
67
|
+
BigCrunchBannerView,
|
|
68
|
+
BigCrunchInterstitial,
|
|
69
|
+
BigCrunchRewarded,
|
|
70
|
+
SDK_VERSION,
|
|
71
|
+
};
|
package/src/types/ads.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ad-specific types for BigCrunch Mobile Ads SDK
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { BannerSize, CustomSize, AdRequestOptions, AdEventListener, EventSubscription } from './index';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Banner view props for React component
|
|
9
|
+
*/
|
|
10
|
+
export interface BigCrunchBannerViewProps {
|
|
11
|
+
/** Placement ID configured in BigCrunch dashboard */
|
|
12
|
+
placementId: string;
|
|
13
|
+
/** Banner size (optional, will use placement config if not specified) */
|
|
14
|
+
size?: BannerSize | CustomSize;
|
|
15
|
+
/** Whether to load ad automatically when component mounts */
|
|
16
|
+
autoLoad?: boolean;
|
|
17
|
+
/** Auto-refresh interval in seconds (0 = disabled) */
|
|
18
|
+
refreshInterval?: number;
|
|
19
|
+
/** Custom targeting parameters */
|
|
20
|
+
customTargeting?: Record<string, string>;
|
|
21
|
+
/** Style for the banner container */
|
|
22
|
+
style?: any;
|
|
23
|
+
/** Callback when ad loads successfully */
|
|
24
|
+
onAdLoaded?: () => void;
|
|
25
|
+
/** Callback when ad fails to load */
|
|
26
|
+
onAdFailedToLoad?: (error: AdError) => void;
|
|
27
|
+
/** Callback when ad impression is recorded */
|
|
28
|
+
onAdImpression?: () => void;
|
|
29
|
+
/** Callback when ad is clicked */
|
|
30
|
+
onAdClicked?: () => void;
|
|
31
|
+
/** Callback when ad opens overlay */
|
|
32
|
+
onAdOpened?: () => void;
|
|
33
|
+
/** Callback when ad closes overlay */
|
|
34
|
+
onAdClosed?: () => void;
|
|
35
|
+
/** Callback when ad revenue is received */
|
|
36
|
+
onAdRevenue?: (revenue: AdRevenue) => void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Interstitial ad interface
|
|
41
|
+
*/
|
|
42
|
+
export interface InterstitialAd {
|
|
43
|
+
/** Load an interstitial ad */
|
|
44
|
+
load(options: AdRequestOptions): Promise<void>;
|
|
45
|
+
/** Show the loaded interstitial */
|
|
46
|
+
show(): Promise<void>;
|
|
47
|
+
/** Check if ad is loaded and ready to show */
|
|
48
|
+
isLoaded(): Promise<boolean>;
|
|
49
|
+
/** Destroy the ad instance */
|
|
50
|
+
destroy(): void;
|
|
51
|
+
/** Add event listener */
|
|
52
|
+
addEventListener<T extends AdEvent>(
|
|
53
|
+
eventType: T['type'],
|
|
54
|
+
listener: AdEventListener<T>
|
|
55
|
+
): EventSubscription;
|
|
56
|
+
/** Remove all event listeners */
|
|
57
|
+
removeAllListeners(): void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Rewarded ad interface
|
|
62
|
+
*/
|
|
63
|
+
export interface RewardedAd {
|
|
64
|
+
/** Load a rewarded ad */
|
|
65
|
+
load(options: AdRequestOptions): Promise<void>;
|
|
66
|
+
/** Show the loaded rewarded ad */
|
|
67
|
+
show(): Promise<void>;
|
|
68
|
+
/** Check if ad is loaded and ready to show */
|
|
69
|
+
isLoaded(): Promise<boolean>;
|
|
70
|
+
/** Destroy the ad instance */
|
|
71
|
+
destroy(): void;
|
|
72
|
+
/** Add event listener */
|
|
73
|
+
addEventListener<T extends AdEvent>(
|
|
74
|
+
eventType: T['type'],
|
|
75
|
+
listener: AdEventListener<T>
|
|
76
|
+
): EventSubscription;
|
|
77
|
+
/** Remove all event listeners */
|
|
78
|
+
removeAllListeners(): void;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Native ad data
|
|
83
|
+
*/
|
|
84
|
+
export interface NativeAdData {
|
|
85
|
+
/** Placement ID */
|
|
86
|
+
placementId: string;
|
|
87
|
+
/** Headline text */
|
|
88
|
+
headline?: string;
|
|
89
|
+
/** Body text */
|
|
90
|
+
body?: string;
|
|
91
|
+
/** Call to action text */
|
|
92
|
+
callToAction?: string;
|
|
93
|
+
/** Icon image URL */
|
|
94
|
+
icon?: string;
|
|
95
|
+
/** Main image URL */
|
|
96
|
+
image?: string;
|
|
97
|
+
/** Advertiser name */
|
|
98
|
+
advertiser?: string;
|
|
99
|
+
/** Star rating */
|
|
100
|
+
starRating?: number;
|
|
101
|
+
/** Price text */
|
|
102
|
+
price?: string;
|
|
103
|
+
/** Store name */
|
|
104
|
+
store?: string;
|
|
105
|
+
/** Ad choices icon URL */
|
|
106
|
+
adChoicesIcon?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Import required types
|
|
111
|
+
*/
|
|
112
|
+
import { AdError, AdRevenue, AdEvent } from './index';
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration types for BigCrunch Mobile Ads SDK
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { AdFormat } from './index';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* App configuration from BigCrunch backend
|
|
9
|
+
*/
|
|
10
|
+
export interface AppConfig {
|
|
11
|
+
/** Property ID */
|
|
12
|
+
propertyId: string;
|
|
13
|
+
/** Property name */
|
|
14
|
+
propertyName: string;
|
|
15
|
+
/** List of configured placements */
|
|
16
|
+
placements: PlacementConfig[];
|
|
17
|
+
/** Global settings */
|
|
18
|
+
settings?: GlobalSettings;
|
|
19
|
+
/** Last updated timestamp */
|
|
20
|
+
lastUpdated?: string;
|
|
21
|
+
/** Config version */
|
|
22
|
+
version?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Individual placement configuration
|
|
27
|
+
*/
|
|
28
|
+
export interface PlacementConfig {
|
|
29
|
+
/** Unique placement ID */
|
|
30
|
+
placementId: string;
|
|
31
|
+
/** Placement name for reporting */
|
|
32
|
+
placementName?: string;
|
|
33
|
+
/** Ad format type */
|
|
34
|
+
format: AdFormat;
|
|
35
|
+
/** Google Ad Manager ad unit ID */
|
|
36
|
+
gamAdUnit: string;
|
|
37
|
+
/** Ad size configuration */
|
|
38
|
+
size?: AdSizeConfig;
|
|
39
|
+
/** Prebid configuration */
|
|
40
|
+
prebidConfig?: PrebidConfig;
|
|
41
|
+
/** Amazon APS configuration */
|
|
42
|
+
amazonConfig?: AmazonConfig;
|
|
43
|
+
/** Placement-specific settings */
|
|
44
|
+
settings?: PlacementSettings;
|
|
45
|
+
/** Whether placement is active */
|
|
46
|
+
enabled: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Ad size configuration
|
|
51
|
+
*/
|
|
52
|
+
export interface AdSizeConfig {
|
|
53
|
+
/** Width in dp/points */
|
|
54
|
+
width: number;
|
|
55
|
+
/** Height in dp/points */
|
|
56
|
+
height: number;
|
|
57
|
+
/** Whether to use adaptive sizing */
|
|
58
|
+
adaptive?: boolean;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Prebid configuration
|
|
63
|
+
*/
|
|
64
|
+
export interface PrebidConfig {
|
|
65
|
+
/** Prebid account ID */
|
|
66
|
+
accountId: string;
|
|
67
|
+
/** Config ID for server-side configuration */
|
|
68
|
+
configId: string;
|
|
69
|
+
/** Timeout for prebid requests in milliseconds */
|
|
70
|
+
timeout?: number;
|
|
71
|
+
/** Enable debug mode for prebid */
|
|
72
|
+
debug?: boolean;
|
|
73
|
+
/** Custom targeting parameters */
|
|
74
|
+
customTargeting?: Record<string, string>;
|
|
75
|
+
/** Price granularity */
|
|
76
|
+
priceGranularity?: 'low' | 'medium' | 'high' | 'auto' | 'dense' | 'custom';
|
|
77
|
+
/** Custom price granularity buckets */
|
|
78
|
+
customPriceGranularity?: PriceGranularityBucket[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Price granularity bucket configuration
|
|
83
|
+
*/
|
|
84
|
+
export interface PriceGranularityBucket {
|
|
85
|
+
/** Minimum price */
|
|
86
|
+
min: number;
|
|
87
|
+
/** Maximum price */
|
|
88
|
+
max: number;
|
|
89
|
+
/** Increment */
|
|
90
|
+
increment: number;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Amazon APS configuration
|
|
95
|
+
*/
|
|
96
|
+
export interface AmazonConfig {
|
|
97
|
+
/** Amazon slot ID */
|
|
98
|
+
slotId: string;
|
|
99
|
+
/** Enable Amazon integration */
|
|
100
|
+
enabled: boolean;
|
|
101
|
+
/** Timeout for Amazon requests */
|
|
102
|
+
timeout?: number;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Global settings
|
|
107
|
+
*/
|
|
108
|
+
export interface GlobalSettings {
|
|
109
|
+
/** Enable test mode */
|
|
110
|
+
testMode?: boolean;
|
|
111
|
+
/** Test device IDs */
|
|
112
|
+
testDeviceIds?: string[];
|
|
113
|
+
/** Enable verbose logging */
|
|
114
|
+
verboseLogging?: boolean;
|
|
115
|
+
/** Session timeout in seconds */
|
|
116
|
+
sessionTimeout?: number;
|
|
117
|
+
/** Analytics batch size */
|
|
118
|
+
analyticsBatchSize?: number;
|
|
119
|
+
/** Analytics flush interval in seconds */
|
|
120
|
+
analyticsFlushInterval?: number;
|
|
121
|
+
/** Enable crash reporting */
|
|
122
|
+
crashReporting?: boolean;
|
|
123
|
+
/** GDPR consent string */
|
|
124
|
+
gdprConsent?: string;
|
|
125
|
+
/** CCPA compliance string */
|
|
126
|
+
ccpaString?: string;
|
|
127
|
+
/** COPPA compliance */
|
|
128
|
+
coppaCompliant?: boolean;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Placement-specific settings
|
|
133
|
+
*/
|
|
134
|
+
export interface PlacementSettings {
|
|
135
|
+
/** Auto-refresh interval in seconds (0 = disabled) */
|
|
136
|
+
refreshInterval?: number;
|
|
137
|
+
/** Maximum refresh count */
|
|
138
|
+
maxRefreshCount?: number;
|
|
139
|
+
/** Enable viewability tracking */
|
|
140
|
+
viewabilityTracking?: boolean;
|
|
141
|
+
/** Viewability threshold percentage */
|
|
142
|
+
viewabilityThreshold?: number;
|
|
143
|
+
/** Custom targeting for this placement */
|
|
144
|
+
customTargeting?: Record<string, string>;
|
|
145
|
+
}
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event types for BigCrunch Mobile Ads SDK
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { AdError, AdRevenue, AdFormat } from './index';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Base event data
|
|
9
|
+
*/
|
|
10
|
+
export interface BaseAdEvent {
|
|
11
|
+
/** Placement ID */
|
|
12
|
+
placementId: string;
|
|
13
|
+
/** Ad format */
|
|
14
|
+
format: AdFormat;
|
|
15
|
+
/** Timestamp of the event */
|
|
16
|
+
timestamp: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Ad loaded event
|
|
21
|
+
*/
|
|
22
|
+
export interface AdLoadedEvent extends BaseAdEvent {
|
|
23
|
+
type: 'adLoaded';
|
|
24
|
+
/** Ad network that filled the ad */
|
|
25
|
+
adNetwork?: string;
|
|
26
|
+
/** Ad unit ID */
|
|
27
|
+
adUnitId?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Ad failed to load event
|
|
32
|
+
*/
|
|
33
|
+
export interface AdFailedToLoadEvent extends BaseAdEvent {
|
|
34
|
+
type: 'adFailedToLoad';
|
|
35
|
+
/** Error details */
|
|
36
|
+
error: AdError;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Ad impression event
|
|
41
|
+
*/
|
|
42
|
+
export interface AdImpressionEvent extends BaseAdEvent {
|
|
43
|
+
type: 'adImpression';
|
|
44
|
+
/** Ad network that served the impression */
|
|
45
|
+
adNetwork?: string;
|
|
46
|
+
/** Unique impression ID (UUID) */
|
|
47
|
+
impressionId?: string;
|
|
48
|
+
/** GAM ad unit path */
|
|
49
|
+
gamAdUnit?: string;
|
|
50
|
+
/** Ad size (e.g., "320x50") */
|
|
51
|
+
adSize?: string;
|
|
52
|
+
/** Auction ID from Prebid */
|
|
53
|
+
auctionId?: string;
|
|
54
|
+
/** Winning bidder name */
|
|
55
|
+
bidder?: string;
|
|
56
|
+
/** Bid price in CPM */
|
|
57
|
+
bidPriceCpm?: number;
|
|
58
|
+
/** Advertiser ID from GAM metadata */
|
|
59
|
+
advertiserId?: string;
|
|
60
|
+
/** Campaign ID from GAM metadata (not available in mobile SDKs) */
|
|
61
|
+
campaignId?: string;
|
|
62
|
+
/** Line item ID from GAM metadata (not available in mobile SDKs) */
|
|
63
|
+
lineItemId?: string;
|
|
64
|
+
/** Creative ID from GAM metadata */
|
|
65
|
+
creativeId?: string;
|
|
66
|
+
/** Refresh count for this placement */
|
|
67
|
+
refreshCount?: number;
|
|
68
|
+
/** Demand channel (e.g., "Prebid Header", "GAM Direct") */
|
|
69
|
+
demandChannel?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Ad clicked event
|
|
74
|
+
*/
|
|
75
|
+
export interface AdClickedEvent extends BaseAdEvent {
|
|
76
|
+
type: 'adClicked';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Ad opened event (for overlays/modals)
|
|
81
|
+
*/
|
|
82
|
+
export interface AdOpenedEvent extends BaseAdEvent {
|
|
83
|
+
type: 'adOpened';
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Ad closed event
|
|
88
|
+
*/
|
|
89
|
+
export interface AdClosedEvent extends BaseAdEvent {
|
|
90
|
+
type: 'adClosed';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Ad revenue event (ILRD)
|
|
95
|
+
*/
|
|
96
|
+
export interface AdRevenueEvent extends BaseAdEvent {
|
|
97
|
+
type: 'adRevenue';
|
|
98
|
+
/** Revenue data */
|
|
99
|
+
revenue: AdRevenue;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Ad viewable event
|
|
104
|
+
*/
|
|
105
|
+
export interface AdViewableEvent extends BaseAdEvent {
|
|
106
|
+
type: 'adViewable';
|
|
107
|
+
/** Duration in view (milliseconds) */
|
|
108
|
+
viewDuration?: number;
|
|
109
|
+
/** Percentage of ad visible */
|
|
110
|
+
visiblePercentage?: number;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Rewarded ad events
|
|
115
|
+
*/
|
|
116
|
+
export interface RewardedAdEarnedEvent extends BaseAdEvent {
|
|
117
|
+
type: 'rewardEarned';
|
|
118
|
+
/** Reward type */
|
|
119
|
+
rewardType: string;
|
|
120
|
+
/** Reward amount */
|
|
121
|
+
rewardAmount: number;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Union type of all ad events
|
|
126
|
+
*/
|
|
127
|
+
export type AdEvent =
|
|
128
|
+
| AdLoadedEvent
|
|
129
|
+
| AdFailedToLoadEvent
|
|
130
|
+
| AdImpressionEvent
|
|
131
|
+
| AdClickedEvent
|
|
132
|
+
| AdOpenedEvent
|
|
133
|
+
| AdClosedEvent
|
|
134
|
+
| AdRevenueEvent
|
|
135
|
+
| AdViewableEvent
|
|
136
|
+
| RewardedAdEarnedEvent;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Event listener callback
|
|
140
|
+
*/
|
|
141
|
+
export type AdEventListener<T extends AdEvent = AdEvent> = (event: T) => void;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Event subscription
|
|
145
|
+
*/
|
|
146
|
+
export interface EventSubscription {
|
|
147
|
+
/** Remove the event listener */
|
|
148
|
+
remove: () => void;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Analytics event for backend
|
|
153
|
+
*
|
|
154
|
+
* Note: This represents the legacy event format. The SDK now uses web schema events
|
|
155
|
+
* with flattened structure (PageViewEvent, ImpressionEvent, ClickEvent, etc.)
|
|
156
|
+
*
|
|
157
|
+
* @deprecated Use web schema event types instead
|
|
158
|
+
*/
|
|
159
|
+
export interface AnalyticsEvent {
|
|
160
|
+
/** Event type */
|
|
161
|
+
eventType: 'screen_view' | 'ad_request' | 'ad_impression' | 'ad_click' | 'ad_revenue' | 'ad_viewable' | 'session_start' | 'session_end';
|
|
162
|
+
/** Event timestamp (milliseconds since epoch) */
|
|
163
|
+
timestamp: number;
|
|
164
|
+
/** Session ID */
|
|
165
|
+
sessionId: string;
|
|
166
|
+
/** Event-specific data */
|
|
167
|
+
data: Record<string, any>;
|
|
168
|
+
/** Device context */
|
|
169
|
+
deviceContext?: Partial<DeviceContext>;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Web schema common fields (present in all events)
|
|
174
|
+
*/
|
|
175
|
+
export interface WebSchemaCommonFields {
|
|
176
|
+
/** Payload version identifier */
|
|
177
|
+
payloadVersion: string;
|
|
178
|
+
/** Config version from backend */
|
|
179
|
+
configVersion?: string;
|
|
180
|
+
/** Event timestamp in ISO 8601 format (e.g., "2025-01-15T10:30:00Z") */
|
|
181
|
+
browserTimestamp: string;
|
|
182
|
+
/** Session ID (UUID) */
|
|
183
|
+
sessionId: string;
|
|
184
|
+
/** User ID (UUID, persistent across sessions) */
|
|
185
|
+
userId: string;
|
|
186
|
+
/** Property ID from BigCrunch dashboard */
|
|
187
|
+
propertyId: string;
|
|
188
|
+
/** True if this is user's first session */
|
|
189
|
+
newUser: boolean;
|
|
190
|
+
/** Current page/screen ID (UUID) */
|
|
191
|
+
pageId: string;
|
|
192
|
+
/** Number of page views in current session */
|
|
193
|
+
sessionDepth: number;
|
|
194
|
+
/** Browser/SDK identifier (e.g., "BigCrunch iOS SDK 1.0.0") */
|
|
195
|
+
browser: string;
|
|
196
|
+
/** Device type (e.g., "iPhone 14", "Samsung Galaxy S21") */
|
|
197
|
+
device: string;
|
|
198
|
+
/** Operating system (e.g., "iOS 16.0", "Android 13") */
|
|
199
|
+
os: string;
|
|
200
|
+
/** Country code (ISO 3166-1 alpha-2, e.g., "US") */
|
|
201
|
+
country: string;
|
|
202
|
+
/** Region/state code */
|
|
203
|
+
region: string;
|
|
204
|
+
/** Session attribution source */
|
|
205
|
+
sessionSource: string;
|
|
206
|
+
/** Session attribution medium */
|
|
207
|
+
sessionMedium: string;
|
|
208
|
+
/** UTM source parameter */
|
|
209
|
+
utmSource?: string;
|
|
210
|
+
/** UTM medium parameter */
|
|
211
|
+
utmMedium?: string;
|
|
212
|
+
/** UTM campaign parameter */
|
|
213
|
+
utmCampaign?: string;
|
|
214
|
+
/** UTM term parameter */
|
|
215
|
+
utmTerm?: string;
|
|
216
|
+
/** UTM content parameter */
|
|
217
|
+
utmContent?: string;
|
|
218
|
+
/** Google Click ID for attribution */
|
|
219
|
+
gclid?: string;
|
|
220
|
+
/** Facebook Click ID for attribution */
|
|
221
|
+
fbclid?: string;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Page view event (web schema)
|
|
226
|
+
* Sent to /pageviews endpoint
|
|
227
|
+
*/
|
|
228
|
+
export interface PageViewEvent extends WebSchemaCommonFields {
|
|
229
|
+
/** Screen/page name */
|
|
230
|
+
screenName: string;
|
|
231
|
+
/** Referrer (previous screen) */
|
|
232
|
+
referrer?: string;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Impression event (web schema)
|
|
237
|
+
* Sent to /impressions endpoint
|
|
238
|
+
* Consolidates ad request, impression, and revenue tracking
|
|
239
|
+
*/
|
|
240
|
+
export interface ImpressionEvent extends WebSchemaCommonFields {
|
|
241
|
+
/** Unique impression ID (UUID) */
|
|
242
|
+
impressionId: string;
|
|
243
|
+
/** Placement identifier */
|
|
244
|
+
placementId: string;
|
|
245
|
+
/** GAM ad unit path */
|
|
246
|
+
gamAdUnit: string;
|
|
247
|
+
/** Ad format (banner, interstitial, rewarded) */
|
|
248
|
+
format: string;
|
|
249
|
+
/** Auction ID from Prebid */
|
|
250
|
+
auctionId?: string;
|
|
251
|
+
/** Refresh count for this placement */
|
|
252
|
+
refreshCount?: number;
|
|
253
|
+
/** Winning bidder name */
|
|
254
|
+
bidder?: string;
|
|
255
|
+
/** Ad size (e.g., "320x50") */
|
|
256
|
+
adSize?: string;
|
|
257
|
+
/** Bid price/revenue in CPM */
|
|
258
|
+
bidPriceCpm?: number;
|
|
259
|
+
/** Floor price */
|
|
260
|
+
floorPrice?: number;
|
|
261
|
+
/** Minimum bid to win */
|
|
262
|
+
minBidToWin?: number;
|
|
263
|
+
/** Advertiser ID from GAM */
|
|
264
|
+
advertiserId?: string;
|
|
265
|
+
/** Campaign ID from GAM (not available in mobile SDKs) */
|
|
266
|
+
campaignId?: string;
|
|
267
|
+
/** Line item ID from GAM (not available in mobile SDKs) */
|
|
268
|
+
lineItemId?: string;
|
|
269
|
+
/** Creative ID from GAM response */
|
|
270
|
+
creativeId?: string;
|
|
271
|
+
/** Amazon bid data */
|
|
272
|
+
amznBid?: string;
|
|
273
|
+
/** Amazon price data */
|
|
274
|
+
amznPrice?: string;
|
|
275
|
+
/** Demand type (banner, video, etc.) */
|
|
276
|
+
demandType?: string;
|
|
277
|
+
/** Demand channel (e.g., "Prebid Header", "GAM Direct") */
|
|
278
|
+
demandChannel?: string;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Click event (web schema)
|
|
283
|
+
* Sent to /clicks endpoint
|
|
284
|
+
*/
|
|
285
|
+
export interface ClickEvent extends WebSchemaCommonFields {
|
|
286
|
+
/** Reference to the impression that was clicked */
|
|
287
|
+
impressionId: string;
|
|
288
|
+
/** Placement identifier */
|
|
289
|
+
placementId: string;
|
|
290
|
+
/** Ad format */
|
|
291
|
+
format: string;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Viewability event (web schema)
|
|
296
|
+
* Sent to /viewability endpoint
|
|
297
|
+
*/
|
|
298
|
+
export interface ViewabilityEvent extends WebSchemaCommonFields {
|
|
299
|
+
/** Reference to the impression */
|
|
300
|
+
impressionId: string;
|
|
301
|
+
/** Placement identifier */
|
|
302
|
+
placementId: string;
|
|
303
|
+
/** Ad format */
|
|
304
|
+
format: string;
|
|
305
|
+
/** Time ad was viewable in milliseconds */
|
|
306
|
+
viewableTimeMs: number;
|
|
307
|
+
/** Percentage of ad that was visible */
|
|
308
|
+
percentVisible: number;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Engagement event (web schema)
|
|
313
|
+
* Sent to /engagement endpoint
|
|
314
|
+
*/
|
|
315
|
+
export interface EngagementEvent extends WebSchemaCommonFields {
|
|
316
|
+
/** Time actively engaged in seconds */
|
|
317
|
+
engagedTime: number;
|
|
318
|
+
/** Total time on page/screen in seconds */
|
|
319
|
+
timeOnPage: number;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Screen view event data
|
|
324
|
+
*/
|
|
325
|
+
export interface ScreenViewData {
|
|
326
|
+
/** Screen name */
|
|
327
|
+
screenName: string;
|
|
328
|
+
/** Screen class/component name */
|
|
329
|
+
screenClass?: string;
|
|
330
|
+
/** Previous screen */
|
|
331
|
+
previousScreen?: string;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Device context (imported from index)
|
|
336
|
+
*/
|
|
337
|
+
import { DeviceContext } from './index';
|