@adadapted/react-native-sdk 3.1.12 → 3.2.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.
@@ -86,6 +86,7 @@ let ReportedEventType;
86
86
  exports.ReportedEventType = ReportedEventType;
87
87
  (function (ReportedEventType) {
88
88
  ReportedEventType["IMPRESSION"] = "impression";
89
+ ReportedEventType["INVISIBLE_IMPRESSION"] = "invisible_impression";
89
90
  ReportedEventType["INTERACTION"] = "interaction";
90
91
  ReportedEventType["NOT_MATCHED"] = "not_matched";
91
92
  ReportedEventType["MATCHED"] = "matched";
@@ -1 +1 @@
1
- {"version":3,"names":["ListManagerEventSource","ListManagerEventName","AdActionType","ReportedEventType","PayloadStatus"],"sources":["adadaptedApiTypes.ts"],"sourcesContent":["// =============================================================================\n// API TYPE MODELS\n// =============================================================================\n/**\n * The definition of an ad session data object.\n */\nexport interface AdSession {\n /**\n * The session ID.\n */\n session_id: string;\n /**\n * If true, ads will be served.\n */\n will_serve_ads: boolean;\n /**\n * If true, there are active campaigns.\n */\n active_campaigns: boolean;\n /**\n * How often to refresh session/ad data?\n */\n polling_interval_ms: number;\n /**\n * The time at which the session will expire.\n */\n session_expires_at: number;\n /**\n * All ad zones.\n */\n zones: { [key: number]: Zone };\n}\n\n/**\n * The definition of a zone.\n */\nexport interface Zone {\n /**\n * The zone ID.\n */\n id: string;\n /**\n * ?\n */\n land_height: number;\n /**\n * ?\n */\n land_width: number;\n /**\n * ?\n */\n port_height: number;\n /**\n * ?\n */\n port_width: number;\n /**\n * The available ads.\n */\n ads: Ad[];\n}\n\n/**\n * The definition of an Ad.\n */\nexport interface Ad {\n /**\n * The ad ID.\n */\n ad_id: string;\n /**\n * The impression ID.\n */\n impression_id: string;\n /**\n * The type of ad this is.\n */\n type: string;\n /**\n * How often the ad refreshes? Swaps out for another?\n * Length of time in seconds.\n */\n refresh_time: number;\n /**\n * The URL for the ad image to display.\n */\n creative_url: string;\n /**\n * The tracking pixel to include in the zone view for this ad?\n */\n tracking_html: string;\n /**\n * ?\n */\n action_path: string;\n /**\n * ?\n */\n action_type: AdActionType;\n /**\n * If true, the ad will be hidden after interaction.\n */\n hide_after_interaction: boolean;\n /**\n * ?\n */\n payload: AdPayload;\n}\n\n/**\n * The definition of an Ad Payload.\n */\nexport interface AdPayload {\n /**\n * The array of list items.\n */\n detailed_list_items: DetailedListItem[];\n}\n\n/**\n * The definition of an \"out of app\" data payload.\n */\nexport interface OutOfAppDataPayload {\n /**\n * The payload ID associated to the provided list items.\n */\n payload_id: string;\n /**\n * The payload message.\n */\n payload_message?: string;\n /**\n * The payload image.\n */\n payload_image?: string;\n /**\n * The campaign ID.\n */\n campaign_id?: string;\n /**\n * The app ID.\n */\n app_id?: string;\n /**\n * Expiration time in seconds.\n */\n expire_seconds?: number;\n /**\n * The array of list items.\n */\n detailed_list_items: DetailedListItem[];\n}\n\n/**\n * The definition of a Detailed List Item.\n */\nexport interface DetailedListItem {\n /**\n * The barcode of the product.\n */\n product_barcode: string;\n /**\n * The brand of the product.\n */\n product_brand: string;\n /**\n * The category of the product.\n */\n product_category: string;\n /**\n * The discount given for the product.\n */\n product_discount: string;\n /**\n * The image used for display of the product.\n */\n product_image: string;\n /**\n * The SKU of the product.\n */\n product_sku: string;\n /**\n * The name/title of the product.\n */\n product_title: string;\n /**\n * The tracking ID.\n */\n tracking_id?: string;\n}\n\n/**\n * The definition of a Keyword Intercepts object.\n */\nexport interface KeywordIntercepts {\n /**\n * The search ID.\n * Automatically assigned by the API.\n */\n search_id: string;\n /**\n * The minimum number of characters required to perform\n * a search against all available search terms.\n */\n min_match_length: number;\n /**\n * All available search terms.\n */\n terms: KeywordSearchTerm[];\n}\n\n/**\n * The definition of a Keyword Search Term.\n */\nexport interface KeywordSearchTerm {\n /**\n * The search term ID.\n */\n term_id: string;\n /**\n * The search term to validate a search string against.\n */\n term: string;\n /**\n * The display string a client can use to display in a list.\n */\n replacement: string;\n /**\n * The display priority of this item.\n * Compare this to other {@link KeywordSearchTerm} items to determine\n * the final priority order during display.\n * The lower the number, the higher the priority.\n */\n priority: number;\n}\n\n/**\n * The definition of a Reported Ad Event.\n */\nexport interface ReportedAdEvent {\n /**\n * The add ID.\n */\n ad_id: string;\n /**\n * The impression ID.\n */\n impression_id: string;\n /**\n * The event type to report\n */\n event_type: ReportedEventType;\n /**\n * The timestamp at which the event occurred.\n */\n created_at: number;\n}\n\n/**\n * The definition of a Reported Intercept Event.\n */\nexport interface ReportedInterceptEvent {\n /**\n * The intercept search ID.\n */\n search_id: string;\n /**\n * The term ID.\n */\n term_id: string;\n /**\n * The term.\n */\n term: string;\n /**\n * The user input provided that ultimately\n * resulted in the event triggering.\n */\n user_input: string;\n /**\n * The event type to report\n */\n event_type: ReportedEventType;\n /**\n * The timestamp at which the event occurred.\n */\n created_at: number;\n}\n\n/**\n * Interface defining the structure of an event to send when using List Manager.\n */\nexport interface ListManagerEvent {\n /**\n * The source of the list manager event.\n */\n event_source: ListManagerEventSource;\n /**\n * The timestamp this event occurred (unix time).\n */\n event_timestamp: number;\n /**\n * The event name.\n */\n event_name: ListManagerEventName;\n /**\n * The parameter the event is triggered for.\n */\n event_params: ListManagerEventParam;\n}\n\n/**\n * Interface defining the structure of a payload tracking event.\n */\nexport interface PayloadTrackingEvent {\n /**\n * The source of the list manager event.\n */\n payload_id: string;\n /**\n * The status to report.\n */\n status: PayloadStatus;\n /**\n * The timestamp this event occurred (unix time).\n */\n event_timestamp: number;\n}\n\n/**\n * Interface defining the structure of an Event Param for List Manager.\n */\nexport interface ListManagerEventParam {\n /**\n * The item name being reported.\n */\n item_name: string;\n /**\n * The list name being reported.\n */\n list_name?: string;\n}\n\n/**\n * Enumeration that defines the possible values for a List Manager Event Source.\n */\nexport enum ListManagerEventSource {\n /**\n * The event was triggered from the app.\n */\n APP = \"app\",\n}\n\n/**\n * Enumeration that defines the possible values for a List Manager Event Name.\n */\nexport enum ListManagerEventName {\n /**\n * The user added an item to their list.\n */\n ADDED_TO_LIST = \"user_added_to_list\",\n /**\n * The user crossed off an item from their list.\n */\n CROSSED_OFF_LIST = \"user_crossed_off_list\",\n /**\n * The user deleted an item from their list.\n */\n DELETED_FROM_LIST = \"user_deleted_from_list\",\n}\n\n/**\n * Enum defining the available ad action types.\n */\nexport enum AdActionType {\n /**\n * Used for Add To List.\n */\n CONTENT = \"c\",\n /**\n * Used for opening URLs in an external browser.\n */\n EXTERNAL = \"e\",\n /**\n * Used for opening URLs in a web view within the app.\n * NOTE: This one should probably be deprecated with the new\n * platform redesign, since its not as obvious what it does.\n */\n LINK = \"l\",\n /**\n * Used for opening app store URLs in the app store.\n */\n APP = \"a\",\n /**\n * ?\n */\n NONE = \"n\",\n}\n\n/**\n * Enum defining the different types of events that can be reported.\n */\nexport enum ReportedEventType {\n /**\n * Occurs when an ad is displayed to the user.\n */\n IMPRESSION = \"impression\",\n /**\n * Occurs when the user interacts with an ad.\n */\n INTERACTION = \"interaction\",\n /**\n * Occurs when the user's search term did not\n * match an available keyword intercept term.\n */\n NOT_MATCHED = \"not_matched\",\n /**\n * Occurs when the user's search term has matched a keyword intercept term.\n */\n MATCHED = \"matched\",\n /**\n * Occurs when the user was presented a keyword intercept term.\n */\n PRESENTED = \"presented\",\n /**\n * Occurs when the user has selected a keyword intercept term.\n */\n SELECTED = \"selected\",\n}\n\n/**\n * Enumeration defining the possible payload acknowledgment status values.\n */\nexport enum PayloadStatus {\n /**\n * The delivered status.\n */\n DELIVERED = \"delivered\",\n /**\n * The rejected status.\n */\n REJECTED = \"rejected\",\n}\n\n// =============================================================================\n// REQUEST MODELS\n// =============================================================================\n/**\n * The base request inputs that most requests will use.\n */\nexport interface BaseRequestInputs {\n /**\n * The app ID provided by the client using the API.\n */\n app_id: string;\n /**\n * The unique device ID.\n */\n udid: string;\n /**\n * The current session ID.\n */\n session_id: string;\n}\n\n/**\n * Interface for the request of the Initialize Session API call.\n */\nexport interface InitializeSessionRequest {\n /**\n * The app ID provided by the client using the API.\n */\n app_id: string;\n /**\n * The unique device ID of the users device.\n */\n udid: string;\n /**\n * The bundle ID.\n */\n bundle_id?: string;\n /**\n * The bundle version.\n */\n bundle_version?: string;\n /**\n * The name of the device.\n */\n device_name?: string;\n /**\n * The unique device ID of the users device.\n */\n device_udid?: string;\n /**\n * The OS of the device.\n */\n device_os?: string;\n /**\n * The OS version of the device.\n */\n device_osv?: string;\n /**\n * The locale the device is currently set for.\n */\n device_locale?: string;\n /**\n * The timezone the device is currently set for.\n */\n device_timezone?: string;\n /**\n * The device carrier name.\n */\n device_carrier?: string;\n /**\n * The height of the devices screen in pixels.\n */\n device_height?: number;\n /**\n * The width of the devices screen in pixels.\n */\n device_width?: number;\n /**\n * The density of the devices screen.\n */\n device_density?: string;\n /**\n * If true, the device allows for ad retargeting.\n */\n allow_retargeting?: boolean;\n /**\n * ?\n */\n created_at?: number;\n /**\n * The AdAdapted SDK version number.\n */\n sdk_version?: string;\n /**\n * ?\n */\n params?: { [key: string]: string };\n}\n\n/**\n * Interface for the request of the Refresh Session Data API call.\n */\nexport interface RefreshSessionDataRequest {\n /**\n * The app ID provided by the client using the API.\n */\n aid: string;\n /**\n * The unique device ID.\n */\n uid: string;\n /**\n * The current session ID.\n */\n sid: string;\n}\n\n/**\n * Interface for the request that reports an ad event.\n */\nexport interface ReportAdEventRequest extends BaseRequestInputs {\n /**\n * Events to report.\n */\n events: ReportedAdEvent[];\n}\n\n/**\n * Interface for the request of the Refresh Session Data API call.\n */\nexport interface KeywordInterceptsRequest {\n /**\n * The app ID provided by the client using the API.\n */\n aid: string;\n /**\n * The unique device ID.\n */\n uid: string;\n /**\n * The current session ID.\n */\n sid: string;\n}\n\n/**\n * Interface for the request that reports an intercept event.\n */\nexport interface ReportInterceptEventRequest extends BaseRequestInputs {\n /**\n * Events to report.\n */\n events: ReportedInterceptEvent[];\n}\n\n/**\n * Interface for the request that reports List Manager data.\n */\nexport interface ReportListManagerDataRequest extends BaseRequestInputs {\n /**\n * The events to report.\n */\n events: ListManagerEvent[];\n}\n\n/**\n * Interface for the request that reports Payload tracking data.\n */\nexport interface ReportPayloadDataRequest extends BaseRequestInputs {\n /**\n * The payload tracking events.\n */\n tracking: PayloadTrackingEvent[];\n}\n\n/**\n * Interface for the request that gets Payload server data.\n */\nexport interface RetrievePayloadItemDataRequest extends BaseRequestInputs {}\n\n// =============================================================================\n// RESPONSE MODELS\n// =============================================================================\n/**\n * Interface for the response of the Campaign API request.\n */\nexport interface InitializeSessionResponse extends AdSession {}\n\n/**\n * Interface for the response of the Campaign API request.\n */\nexport interface RefreshSessionDataResponse extends AdSession {}\n\n/**\n * Interface for the response of the Report Ad Event API request.\n */\nexport interface ReportAdEventResponse {\n /**\n * Array that contains response strings of \"Ok\" or \"Failed\" based\n * on the same order of the events sent to the request.\n */\n results: string[];\n}\n\n/**\n * Interface for the response of the Keyword Intercepts API request.\n */\nexport interface KeywordInterceptsResponse extends KeywordIntercepts {}\n\n/**\n * Interface for the response of the Report Intercept Event API request.\n */\nexport interface ReportInterceptEventResponse {\n /**\n * Array that contains response strings of \"Ok\" or \"Failed\" based\n * on the same order of the events sent to the request.\n */\n results: string[];\n}\n\n/**\n * Interface for the response of the Retrieve Payload Item Data API request.\n */\nexport interface RetrievePayloadItemDataResponse {\n /**\n * Array containing all current payloads for the provided user.\n */\n payloads: OutOfAppDataPayload[];\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AA4BA;AACA;AACA;AA4BA;AACA;AACA;AA6CA;AACA;AACA;AAQA;AACA;AACA;AAgCA;AACA;AACA;AAoCA;AACA;AACA;AAkBA;AACA;AACA;AAuBA;AACA;AACA;AAoBA;AACA;AACA;AA6BA;AACA;AACA;AAoBA;AACA;AACA;AAgBA;AACA;AACA;AAYA;AACA;AACA;AAFA,IAGYA,sBAAsB;AAOlC;AACA;AACA;AAFA;AAAA,WAPYA,sBAAsB;EAAtBA,sBAAsB;AAAA,GAAtBA,sBAAsB,sCAAtBA,sBAAsB;AAAA,IAUtBC,oBAAoB;AAehC;AACA;AACA;AAFA;AAAA,WAfYA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;AAAA,GAApBA,oBAAoB,oCAApBA,oBAAoB;AAAA,IAkBpBC,YAAY;AAyBxB;AACA;AACA;AAFA;AAAA,WAzBYA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;AAAA,GAAZA,YAAY,4BAAZA,YAAY;AAAA,IA4BZC,iBAAiB;AA4B7B;AACA;AACA;AAFA;AAAA,WA5BYA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;AAAA,GAAjBA,iBAAiB,iCAAjBA,iBAAiB;AAAA,IA+BjBC,aAAa,EAWzB;AACA;AACA;AACA;AACA;AACA;AAFA;AAAA,WAdYA,aAAa;EAAbA,aAAa;EAAbA,aAAa;AAAA,GAAbA,aAAa,6BAAbA,aAAa"}
1
+ {"version":3,"names":["ListManagerEventSource","ListManagerEventName","AdActionType","ReportedEventType","PayloadStatus"],"sources":["adadaptedApiTypes.ts"],"sourcesContent":["// =============================================================================\n// API TYPE MODELS\n// =============================================================================\n/**\n * The definition of an ad session data object.\n */\nexport interface AdSession {\n /**\n * The session ID.\n */\n session_id: string;\n /**\n * If true, ads will be served.\n */\n will_serve_ads: boolean;\n /**\n * If true, there are active campaigns.\n */\n active_campaigns: boolean;\n /**\n * How often to refresh session/ad data?\n */\n polling_interval_ms: number;\n /**\n * The time at which the session will expire.\n */\n session_expires_at: number;\n /**\n * All ad zones.\n */\n zones: { [key: number]: Zone };\n}\n\n/**\n * The definition of a zone.\n */\nexport interface Zone {\n /**\n * The zone ID.\n */\n id: string;\n /**\n * ?\n */\n land_height: number;\n /**\n * ?\n */\n land_width: number;\n /**\n * ?\n */\n port_height: number;\n /**\n * ?\n */\n port_width: number;\n /**\n * The available ads.\n */\n ads: Ad[];\n}\n\n/**\n * The definition of an Ad.\n */\nexport interface Ad {\n /**\n * The ad ID.\n */\n ad_id: string;\n /**\n * The impression ID.\n */\n impression_id: string;\n /**\n * The type of ad this is.\n */\n type: string;\n /**\n * How often the ad refreshes? Swaps out for another?\n * Length of time in seconds.\n */\n refresh_time: number;\n /**\n * The URL for the ad image to display.\n */\n creative_url: string;\n /**\n * The tracking pixel to include in the zone view for this ad?\n */\n tracking_html: string;\n /**\n * ?\n */\n action_path: string;\n /**\n * ?\n */\n action_type: AdActionType;\n /**\n * If true, the ad will be hidden after interaction.\n */\n hide_after_interaction: boolean;\n /**\n * ?\n */\n payload: AdPayload;\n /**\n * Track impression status.\n */\n impression_tracked?: boolean;\n}\n\n/**\n * The definition of an Ad Payload.\n */\nexport interface AdPayload {\n /**\n * The array of list items.\n */\n detailed_list_items: DetailedListItem[];\n}\n\n/**\n * The definition of an \"out of app\" data payload.\n */\nexport interface OutOfAppDataPayload {\n /**\n * The payload ID associated to the provided list items.\n */\n payload_id: string;\n /**\n * The payload message.\n */\n payload_message?: string;\n /**\n * The payload image.\n */\n payload_image?: string;\n /**\n * The campaign ID.\n */\n campaign_id?: string;\n /**\n * The app ID.\n */\n app_id?: string;\n /**\n * Expiration time in seconds.\n */\n expire_seconds?: number;\n /**\n * The array of list items.\n */\n detailed_list_items: DetailedListItem[];\n}\n\n/**\n * The definition of a Detailed List Item.\n */\nexport interface DetailedListItem {\n /**\n * The barcode of the product.\n */\n product_barcode: string;\n /**\n * The brand of the product.\n */\n product_brand: string;\n /**\n * The category of the product.\n */\n product_category: string;\n /**\n * The discount given for the product.\n */\n product_discount: string;\n /**\n * The image used for display of the product.\n */\n product_image: string;\n /**\n * The SKU of the product.\n */\n product_sku: string;\n /**\n * The name/title of the product.\n */\n product_title: string;\n /**\n * The tracking ID.\n */\n tracking_id?: string;\n}\n\n/**\n * The definition of a Keyword Intercepts object.\n */\nexport interface KeywordIntercepts {\n /**\n * The search ID.\n * Automatically assigned by the API.\n */\n search_id: string;\n /**\n * The minimum number of characters required to perform\n * a search against all available search terms.\n */\n min_match_length: number;\n /**\n * All available search terms.\n */\n terms: KeywordSearchTerm[];\n}\n\n/**\n * The definition of a Keyword Search Term.\n */\nexport interface KeywordSearchTerm {\n /**\n * The search term ID.\n */\n term_id: string;\n /**\n * The search term to validate a search string against.\n */\n term: string;\n /**\n * The display string a client can use to display in a list.\n */\n replacement: string;\n /**\n * The display priority of this item.\n * Compare this to other {@link KeywordSearchTerm} items to determine\n * the final priority order during display.\n * The lower the number, the higher the priority.\n */\n priority: number;\n}\n\n/**\n * The definition of a Reported Ad Event.\n */\nexport interface ReportedAdEvent {\n /**\n * The add ID.\n */\n ad_id: string;\n /**\n * The impression ID.\n */\n impression_id: string;\n /**\n * The event type to report\n */\n event_type: ReportedEventType;\n /**\n * The timestamp at which the event occurred.\n */\n created_at: number;\n}\n\n/**\n * The definition of a Reported Intercept Event.\n */\nexport interface ReportedInterceptEvent {\n /**\n * The intercept search ID.\n */\n search_id: string;\n /**\n * The term ID.\n */\n term_id: string;\n /**\n * The term.\n */\n term: string;\n /**\n * The user input provided that ultimately\n * resulted in the event triggering.\n */\n user_input: string;\n /**\n * The event type to report\n */\n event_type: ReportedEventType;\n /**\n * The timestamp at which the event occurred.\n */\n created_at: number;\n}\n\n/**\n * Interface defining the structure of an event to send when using List Manager.\n */\nexport interface ListManagerEvent {\n /**\n * The source of the list manager event.\n */\n event_source: ListManagerEventSource;\n /**\n * The timestamp this event occurred (unix time).\n */\n event_timestamp: number;\n /**\n * The event name.\n */\n event_name: ListManagerEventName;\n /**\n * The parameter the event is triggered for.\n */\n event_params: ListManagerEventParam;\n}\n\n/**\n * Interface defining the structure of a payload tracking event.\n */\nexport interface PayloadTrackingEvent {\n /**\n * The source of the list manager event.\n */\n payload_id: string;\n /**\n * The status to report.\n */\n status: PayloadStatus;\n /**\n * The timestamp this event occurred (unix time).\n */\n event_timestamp: number;\n}\n\n/**\n * Interface defining the structure of an Event Param for List Manager.\n */\nexport interface ListManagerEventParam {\n /**\n * The item name being reported.\n */\n item_name: string;\n /**\n * The list name being reported.\n */\n list_name?: string;\n}\n\n/**\n * Enumeration that defines the possible values for a List Manager Event Source.\n */\nexport enum ListManagerEventSource {\n /**\n * The event was triggered from the app.\n */\n APP = \"app\",\n}\n\n/**\n * Enumeration that defines the possible values for a List Manager Event Name.\n */\nexport enum ListManagerEventName {\n /**\n * The user added an item to their list.\n */\n ADDED_TO_LIST = \"user_added_to_list\",\n /**\n * The user crossed off an item from their list.\n */\n CROSSED_OFF_LIST = \"user_crossed_off_list\",\n /**\n * The user deleted an item from their list.\n */\n DELETED_FROM_LIST = \"user_deleted_from_list\",\n}\n\n/**\n * Enum defining the available ad action types.\n */\nexport enum AdActionType {\n /**\n * Used for Add To List.\n */\n CONTENT = \"c\",\n /**\n * Used for opening URLs in an external browser.\n */\n EXTERNAL = \"e\",\n /**\n * Used for opening URLs in a web view within the app.\n * NOTE: This one should probably be deprecated with the new\n * platform redesign, since its not as obvious what it does.\n */\n LINK = \"l\",\n /**\n * Used for opening app store URLs in the app store.\n */\n APP = \"a\",\n /**\n * ?\n */\n NONE = \"n\",\n}\n\n/**\n * Enum defining the different types of events that can be reported.\n */\nexport enum ReportedEventType {\n /**\n * Occurs when an ad is displayed to the user.\n */\n IMPRESSION = \"impression\",\n /**\n * Occurs when an ad is not viewable before timimg out.\n */\n INVISIBLE_IMPRESSION = \"invisible_impression\",\n /**\n * Occurs when the user interacts with an ad.\n */\n INTERACTION = \"interaction\",\n /**\n * Occurs when the user's search term did not\n * match an available keyword intercept term.\n */\n NOT_MATCHED = \"not_matched\",\n /**\n * Occurs when the user's search term has matched a keyword intercept term.\n */\n MATCHED = \"matched\",\n /**\n * Occurs when the user was presented a keyword intercept term.\n */\n PRESENTED = \"presented\",\n /**\n * Occurs when the user has selected a keyword intercept term.\n */\n SELECTED = \"selected\",\n}\n\n/**\n * Enumeration defining the possible payload acknowledgment status values.\n */\nexport enum PayloadStatus {\n /**\n * The delivered status.\n */\n DELIVERED = \"delivered\",\n /**\n * The rejected status.\n */\n REJECTED = \"rejected\",\n}\n\n// =============================================================================\n// REQUEST MODELS\n// =============================================================================\n/**\n * The base request inputs that most requests will use.\n */\nexport interface BaseRequestInputs {\n /**\n * The app ID provided by the client using the API.\n */\n app_id: string;\n /**\n * The unique device ID.\n */\n udid: string;\n /**\n * The current session ID.\n */\n session_id: string;\n}\n\n/**\n * Interface for the request of the Initialize Session API call.\n */\nexport interface InitializeSessionRequest {\n /**\n * The app ID provided by the client using the API.\n */\n app_id: string;\n /**\n * The unique device ID of the users device.\n */\n udid: string;\n /**\n * The bundle ID.\n */\n bundle_id?: string;\n /**\n * The bundle version.\n */\n bundle_version?: string;\n /**\n * The name of the device.\n */\n device_name?: string;\n /**\n * The unique device ID of the users device.\n */\n device_udid?: string;\n /**\n * The OS of the device.\n */\n device_os?: string;\n /**\n * The OS version of the device.\n */\n device_osv?: string;\n /**\n * The locale the device is currently set for.\n */\n device_locale?: string;\n /**\n * The timezone the device is currently set for.\n */\n device_timezone?: string;\n /**\n * The device carrier name.\n */\n device_carrier?: string;\n /**\n * The height of the devices screen in pixels.\n */\n device_height?: number;\n /**\n * The width of the devices screen in pixels.\n */\n device_width?: number;\n /**\n * The density of the devices screen.\n */\n device_density?: string;\n /**\n * If true, the device allows for ad retargeting.\n */\n allow_retargeting?: boolean;\n /**\n * ?\n */\n created_at?: number;\n /**\n * The AdAdapted SDK version number.\n */\n sdk_version?: string;\n /**\n * ?\n */\n params?: { [key: string]: string };\n}\n\n/**\n * Interface for the request of the Refresh Session Data API call.\n */\nexport interface RefreshSessionDataRequest {\n /**\n * The app ID provided by the client using the API.\n */\n aid: string;\n /**\n * The unique device ID.\n */\n uid: string;\n /**\n * The current session ID.\n */\n sid: string;\n}\n\n/**\n * Interface for the request that reports an ad event.\n */\nexport interface ReportAdEventRequest extends BaseRequestInputs {\n /**\n * Events to report.\n */\n events: ReportedAdEvent[];\n}\n\n/**\n * Interface for the request of the Refresh Session Data API call.\n */\nexport interface KeywordInterceptsRequest {\n /**\n * The app ID provided by the client using the API.\n */\n aid: string;\n /**\n * The unique device ID.\n */\n uid: string;\n /**\n * The current session ID.\n */\n sid: string;\n}\n\n/**\n * Interface for the request that reports an intercept event.\n */\nexport interface ReportInterceptEventRequest extends BaseRequestInputs {\n /**\n * Events to report.\n */\n events: ReportedInterceptEvent[];\n}\n\n/**\n * Interface for the request that reports List Manager data.\n */\nexport interface ReportListManagerDataRequest extends BaseRequestInputs {\n /**\n * The events to report.\n */\n events: ListManagerEvent[];\n}\n\n/**\n * Interface for the request that reports Payload tracking data.\n */\nexport interface ReportPayloadDataRequest extends BaseRequestInputs {\n /**\n * The payload tracking events.\n */\n tracking: PayloadTrackingEvent[];\n}\n\n/**\n * Interface for the request that gets Payload server data.\n */\nexport interface RetrievePayloadItemDataRequest extends BaseRequestInputs {}\n\n// =============================================================================\n// RESPONSE MODELS\n// =============================================================================\n/**\n * Interface for the response of the Campaign API request.\n */\nexport interface InitializeSessionResponse extends AdSession {}\n\n/**\n * Interface for the response of the Campaign API request.\n */\nexport interface RefreshSessionDataResponse extends AdSession {}\n\n/**\n * Interface for the response of the Report Ad Event API request.\n */\nexport interface ReportAdEventResponse {\n /**\n * Array that contains response strings of \"Ok\" or \"Failed\" based\n * on the same order of the events sent to the request.\n */\n results: string[];\n}\n\n/**\n * Interface for the response of the Keyword Intercepts API request.\n */\nexport interface KeywordInterceptsResponse extends KeywordIntercepts {}\n\n/**\n * Interface for the response of the Report Intercept Event API request.\n */\nexport interface ReportInterceptEventResponse {\n /**\n * Array that contains response strings of \"Ok\" or \"Failed\" based\n * on the same order of the events sent to the request.\n */\n results: string[];\n}\n\n/**\n * Interface for the response of the Retrieve Payload Item Data API request.\n */\nexport interface RetrievePayloadItemDataResponse {\n /**\n * Array containing all current payloads for the provided user.\n */\n payloads: OutOfAppDataPayload[];\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AA4BA;AACA;AACA;AA4BA;AACA;AACA;AAiDA;AACA;AACA;AAQA;AACA;AACA;AAgCA;AACA;AACA;AAoCA;AACA;AACA;AAkBA;AACA;AACA;AAuBA;AACA;AACA;AAoBA;AACA;AACA;AA6BA;AACA;AACA;AAoBA;AACA;AACA;AAgBA;AACA;AACA;AAYA;AACA;AACA;AAFA,IAGYA,sBAAsB;AAOlC;AACA;AACA;AAFA;AAAA,WAPYA,sBAAsB;EAAtBA,sBAAsB;AAAA,GAAtBA,sBAAsB,sCAAtBA,sBAAsB;AAAA,IAUtBC,oBAAoB;AAehC;AACA;AACA;AAFA;AAAA,WAfYA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;AAAA,GAApBA,oBAAoB,oCAApBA,oBAAoB;AAAA,IAkBpBC,YAAY;AAyBxB;AACA;AACA;AAFA;AAAA,WAzBYA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;AAAA,GAAZA,YAAY,4BAAZA,YAAY;AAAA,IA4BZC,iBAAiB;AAgC7B;AACA;AACA;AAFA;AAAA,WAhCYA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;AAAA,GAAjBA,iBAAiB,iCAAjBA,iBAAiB;AAAA,IAmCjBC,aAAa,EAWzB;AACA;AACA;AACA;AACA;AACA;AAFA;AAAA,WAdYA,aAAa;EAAbA,aAAa;EAAbA,aAAa;AAAA,GAAbA,aAAa,6BAAbA,aAAa"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.AdZone = void 0;
6
+ exports.AdZone = AdZone;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _reactNative = require("react-native");
9
9
  var adadaptedApiRequests = _interopRequireWildcard(require("../api/adadaptedApiRequests"));
@@ -12,197 +12,229 @@ var _reactNativeWebview = require("react-native-webview");
12
12
  var _util = require("../util");
13
13
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
+ /**
16
+ * Component for creating an {@link AdZone}.
17
+ * @module
18
+ */
19
+
20
+ /**
21
+ * Timer used for cycling through ads in the zone
22
+ * based on the ad "refresh time" for each ad.
23
+ */
24
+ let cycleAdTimer;
25
+
16
26
  /**
17
27
  * Creates the AdZone component.
28
+ * @param props - properties passed to AdZone.
29
+ * @returns an AdZone JSX Element.
18
30
  */
19
- class AdZone extends React.Component {
20
- /**
21
- * Timer used for cycling through ads in the zone
22
- * based on the ad "refresh time" for each ad.
23
- */
31
+ function AdZone(props) {
32
+ // Generates a random number between 0 and (number of available ads - 1).
33
+ const startingAdIndex = Math.floor(Math.random() * props.adZoneData.ads.length);
24
34
 
25
35
  /**
26
- * @inheritDoc
36
+ * Tracks the current ad index being shown.
27
37
  */
28
- constructor(props, context) {
29
- super(props, context);
30
-
31
- // Generates a random number between 0 and (number of available ads - 1).
32
- _defineProperty(this, "cycleAdTimer", void 0);
33
- const startingAdIndex = Math.floor(Math.random() * this.props.adZoneData.ads.length);
34
- this.state = {
35
- adIndexShown: startingAdIndex,
36
- touchStartCoords: undefined
37
- };
38
- }
39
-
38
+ const [adIndexShown, setAdIndexShown] = (0, React.useState)(startingAdIndex);
40
39
  /**
41
- * @inheritDoc
40
+ * Tracks the coordinates when the user started touching the Ad View.
42
41
  */
43
- componentDidMount() {
44
- this.initializeAd();
45
- }
46
-
42
+ const [touchStartCoords, setTouchStartCoords] = (0, React.useState)({
43
+ x: 0,
44
+ y: 0
45
+ });
47
46
  /**
48
- * @inheritDoc
47
+ * Track ad visibility (for off-screen ads).
49
48
  */
50
- componentWillUnmount() {
51
- if (this.cycleAdTimer) {
52
- clearTimeout(this.cycleAdTimer);
49
+ const [isAdVisible, setIsAdVisibile] = (0, React.useState)(props.defaultToInvisibleAdZone ? false : true);
50
+
51
+ // - Define all useEffect triggers.
52
+ (0, React.useEffect)(() => {
53
+ _reactNative.DeviceEventEmitter.addListener("visibility-event", event => {
54
+ setIsAdVisibile(event);
55
+ });
56
+ _reactNative.DeviceEventEmitter.addListener("acknowledge", itemName => {
57
+ acknowledge(itemName);
58
+ });
59
+ return () => {
60
+ clearTimeout(cycleAdTimer);
61
+ _reactNative.DeviceEventEmitter.removeAllListeners("visibility-event");
62
+ _reactNative.DeviceEventEmitter.removeAllListeners("acknowledge");
63
+ };
64
+ }, []);
65
+ (0, React.useEffect)(() => {
66
+ startAdTimer();
67
+ if (isAdVisible) {
68
+ sendAdImpression();
53
69
  }
54
- }
70
+ }, [adIndexShown]);
71
+ (0, React.useEffect)(() => {
72
+ if (isAdVisible) {
73
+ sendAdImpression();
74
+ }
75
+ }, [isAdVisible]);
55
76
 
56
77
  /**
57
- * @inheritDoc
78
+ * Generates all component related styles.
79
+ * @returns the styles needed for the component.
58
80
  */
59
- render() {
60
- // Generate the styles each render in case the ad is updated with
61
- // new settings that need to be reflected in the styles of the view.
62
- const styles = this.generateStyles();
63
- const currentAd = this.props.adZoneData.ads[this.state.adIndexShown] || undefined;
64
- const finalMainViewStyle = styles.mainView;
65
- if (!currentAd || !currentAd.creative_url) {
66
- // If there is no ad to display, make the view take up no space.
67
- finalMainViewStyle.width = 0;
68
- finalMainViewStyle.height = 0;
69
- }
70
- return /*#__PURE__*/React.createElement(_reactNative.View, {
71
- style: finalMainViewStyle
72
- }, currentAd && currentAd.creative_url ? /*#__PURE__*/React.createElement(_reactNativeWebview.WebView, {
73
- source: {
74
- uri: currentAd.creative_url
75
- },
76
- androidLayerType: "hardware",
77
- automaticallyAdjustContentInsets: false,
78
- style: styles.webView,
79
- onTouchStart: e => {
80
- this.setState({
81
- touchStartCoords: {
82
- x: e.nativeEvent.pageX,
83
- y: e.nativeEvent.pageY
84
- }
85
- });
81
+ function generateStyles() {
82
+ return _reactNative.StyleSheet.create({
83
+ mainView: {
84
+ width: "100%",
85
+ height: "100%"
86
86
  },
87
- onTouchEnd: e => {
88
- if (this.state.touchStartCoords) {
89
- const touchEndCoords = {
90
- x: e.nativeEvent.pageX,
91
- y: e.nativeEvent.pageY
92
- };
93
- if (Math.abs(this.state.touchStartCoords.x - touchEndCoords.x) < this.props.xyDragDistanceAllowed && Math.abs(this.state.touchStartCoords.y - touchEndCoords.y) < this.props.xyDragDistanceAllowed) {
94
- this.onAdZoneSelected(currentAd);
95
- }
96
-
97
- // Make sure to reset the start coords
98
- this.setState({
99
- touchStartCoords: undefined
100
- });
101
- }
87
+ webView: {
88
+ width: "100%",
89
+ height: "100%"
102
90
  }
103
- }) : undefined);
91
+ });
92
+ }
93
+
94
+ // Generate the styles each render in case the ad is updated with
95
+ // new settings that need to be reflected in the styles of the view.
96
+ const styles = generateStyles();
97
+ const currentAd = props.adZoneData.ads[adIndexShown] || undefined;
98
+ const finalMainViewStyle = styles.mainView;
99
+ if (!currentAd || !currentAd.creative_url) {
100
+ // If there is no ad to display, make the view take up no space.
101
+ finalMainViewStyle.width = "0";
102
+ finalMainViewStyle.height = "0";
104
103
  }
105
104
 
106
105
  /**
107
106
  * Triggers when the user selects the ad zone.
108
- * @param currentAd - The ad currently displayed.
107
+ * @param currentlyDisplayedAd - The ad currently displayed.
109
108
  */
110
- onAdZoneSelected(currentAd) {
109
+ function onAdZoneSelected(currentlyDisplayedAd) {
111
110
  // Determine the "action type" and perform that specific action.
112
- if (currentAd.action_type === _adadaptedApiTypes.AdActionType.EXTERNAL && currentAd.action_path) {
111
+ if (currentlyDisplayedAd.action_type === _adadaptedApiTypes.AdActionType.EXTERNAL && currentlyDisplayedAd.action_path) {
113
112
  // Action Type: EXTERNAL
114
- _reactNative.Linking.openURL(currentAd.action_path).then();
115
- } else if (currentAd.action_type === _adadaptedApiTypes.AdActionType.CONTENT && currentAd.payload && currentAd.payload.detailed_list_items) {
116
- (0, _util.safeInvoke)(this.props.onAddToListTriggered, currentAd.payload.detailed_list_items);
113
+ _reactNative.Linking.openURL(currentlyDisplayedAd.action_path).then();
114
+ } else if (currentlyDisplayedAd.action_type === _adadaptedApiTypes.AdActionType.CONTENT && currentlyDisplayedAd.payload && currentlyDisplayedAd.payload.detailed_list_items) {
115
+ (0, _util.safeInvoke)(props.onAddToListTriggered, currentlyDisplayedAd.payload.detailed_list_items);
117
116
  }
118
- this.triggerReportAdEvent(currentAd, _adadaptedApiTypes.ReportedEventType.INTERACTION);
119
- if (this.cycleAdTimer) {
120
- clearTimeout(this.cycleAdTimer);
117
+ cycleDisplayedAd();
118
+ }
119
+
120
+ /**
121
+ * Call to acknowledge ATL item(s) added to user list.
122
+ * @param itemName - Detailed list item title from ad that was clicked.
123
+ */
124
+ function acknowledge(itemName) {
125
+ if (props.adZoneData.ads) {
126
+ props.adZoneData.ads.forEach(ad => {
127
+ ad.payload.detailed_list_items.forEach(item => {
128
+ if (item.product_title === itemName) {
129
+ triggerReportAdEvent(ad, _adadaptedApiTypes.ReportedEventType.INTERACTION);
130
+ }
131
+ });
132
+ });
121
133
  }
122
- this.cycleDisplayedAd();
123
134
  }
124
135
 
125
136
  /**
126
137
  * Triggered when we need to report an ad event to the API.
127
- * @param currentAd - The ad to send an event for.
138
+ * @param ad - The ad to send an event for.
128
139
  * @param eventType - The event type for the reported event.
129
140
  */
130
- triggerReportAdEvent(currentAd, eventType) {
141
+ function triggerReportAdEvent(ad, eventType) {
131
142
  // The event timestamp has to be sent as a unix timestamp.
132
143
  const currentTs = Math.round(new Date().getTime() / 1000);
133
144
 
134
145
  // Log the taken action/event with the API.
135
146
  adadaptedApiRequests.reportAdEvent({
136
- app_id: this.props.appId,
137
- session_id: this.props.sessionId,
138
- udid: this.props.udid,
147
+ app_id: props.appId,
148
+ session_id: props.sessionId,
149
+ udid: props.udid,
139
150
  events: [{
140
- ad_id: currentAd.ad_id,
141
- impression_id: currentAd.impression_id,
151
+ ad_id: ad.ad_id,
152
+ impression_id: ad.impression_id,
142
153
  event_type: eventType,
143
154
  created_at: currentTs
144
155
  }]
145
- }, this.props.deviceOs, this.props.apiEnv).then(() => {
156
+ }, props.deviceOs, props.apiEnv).then(() => {
146
157
  // Do nothing with the response for now...
147
158
  });
148
159
  }
149
160
 
150
161
  /**
151
162
  * Generates a new timer for cycling to the next ad.
152
- * @param timerLength - The length of time(in milliseconds) to initialize
153
- * the timer with.
154
163
  */
155
- createAdTimer(timerLength) {
156
- if (this.props.adZoneData.ads.length > 0) {
157
- this.cycleAdTimer = setTimeout(() => {
158
- this.cycleDisplayedAd();
159
- }, timerLength);
164
+ function startAdTimer() {
165
+ clearTimeout(cycleAdTimer);
166
+ if (props.adZoneData.ads.length > 0) {
167
+ const refreshTime = props.adZoneData.ads[adIndexShown].refresh_time * 1000;
168
+ cycleAdTimer = setTimeout(cycleDisplayedAd, refreshTime);
160
169
  }
161
170
  }
162
171
 
163
172
  /**
164
173
  * Cycles to the next ad to display in the current available sequence of ads.
165
174
  */
166
- cycleDisplayedAd() {
175
+ function cycleDisplayedAd() {
167
176
  // Start by determining the next ad index to display.
168
177
  let nextAdIndex = 0;
169
- if (this.state.adIndexShown < this.props.adZoneData.ads.length - 1) {
170
- nextAdIndex = this.state.adIndexShown + 1;
178
+ const lastAd = props.adZoneData.ads[adIndexShown];
179
+ if (adIndexShown < props.adZoneData.ads.length - 1) {
180
+ nextAdIndex = adIndexShown + 1;
171
181
  }
172
- this.setState({
173
- adIndexShown: nextAdIndex
174
- }, () => {
175
- this.initializeAd();
176
- });
182
+ if (nextAdIndex !== adIndexShown && lastAd.impression_tracked) {
183
+ // Reset ad impression tracking status.
184
+ lastAd.impression_tracked = false;
185
+ } else {
186
+ // Send invisible ad impression if ad was not visible before end of timer cycle.
187
+ triggerReportAdEvent(lastAd, _adadaptedApiTypes.ReportedEventType.INVISIBLE_IMPRESSION);
188
+ }
189
+ setAdIndexShown(nextAdIndex);
177
190
  }
178
191
 
179
192
  /**
180
- * Performs all ad initialization tasks when a new ad is being displayed.
193
+ * Send ad tracking impression.
181
194
  */
182
- initializeAd() {
183
- // Create the new timer based on the new ad index.
184
- this.createAdTimer(this.props.adZoneData.ads[this.state.adIndexShown].refresh_time * 1000);
195
+ function sendAdImpression() {
196
+ const ad = props.adZoneData.ads[adIndexShown];
185
197
 
186
198
  // Trigger an impression event for the ad.
187
- this.triggerReportAdEvent(this.props.adZoneData.ads[this.state.adIndexShown], _adadaptedApiTypes.ReportedEventType.IMPRESSION);
199
+ if (!ad.impression_tracked) {
200
+ triggerReportAdEvent(ad, _adadaptedApiTypes.ReportedEventType.IMPRESSION);
201
+ ad.impression_tracked = true;
202
+ }
188
203
  }
189
204
 
190
- /**
191
- * Generates all component related styles.
192
- * @returns the styles needed for the component.
193
- */
194
- generateStyles() {
195
- return _reactNative.StyleSheet.create({
196
- mainView: {
197
- width: "100%",
198
- height: "100%"
199
- },
200
- webView: {
201
- width: "100%",
202
- height: "100%"
205
+ // Returned JSX.
206
+ return /*#__PURE__*/React.createElement(_reactNative.View, {
207
+ style: finalMainViewStyle
208
+ }, currentAd && currentAd.creative_url ? /*#__PURE__*/React.createElement(_reactNativeWebview.WebView, {
209
+ source: {
210
+ uri: currentAd.creative_url
211
+ },
212
+ androidLayerType: "hardware",
213
+ automaticallyAdjustContentInsets: false,
214
+ style: styles.webView,
215
+ onTouchStart: e => {
216
+ setTouchStartCoords({
217
+ x: e.nativeEvent.pageX,
218
+ y: e.nativeEvent.pageY
219
+ });
220
+ },
221
+ onTouchEnd: e => {
222
+ if (touchStartCoords) {
223
+ const touchEndCoords = {
224
+ x: e.nativeEvent.pageX,
225
+ y: e.nativeEvent.pageY
226
+ };
227
+ if (Math.abs(touchStartCoords.x - touchEndCoords.x) < props.xyDragDistanceAllowed && Math.abs(touchStartCoords.y - touchEndCoords.y) < props.xyDragDistanceAllowed) {
228
+ onAdZoneSelected(currentAd);
229
+ }
230
+
231
+ // Make sure to reset the start coords
232
+ setTouchStartCoords({
233
+ x: 0,
234
+ y: 0
235
+ });
203
236
  }
204
- });
205
- }
237
+ }
238
+ }) : undefined);
206
239
  }
207
- exports.AdZone = AdZone;
208
240
  //# sourceMappingURL=AdZone.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["AdZone","React","Component","constructor","props","context","startingAdIndex","Math","floor","random","adZoneData","ads","length","state","adIndexShown","touchStartCoords","undefined","componentDidMount","initializeAd","componentWillUnmount","cycleAdTimer","clearTimeout","render","styles","generateStyles","currentAd","finalMainViewStyle","mainView","creative_url","width","height","uri","webView","e","setState","x","nativeEvent","pageX","y","pageY","touchEndCoords","abs","xyDragDistanceAllowed","onAdZoneSelected","action_type","AdActionType","EXTERNAL","action_path","Linking","openURL","then","CONTENT","payload","detailed_list_items","safeInvoke","onAddToListTriggered","triggerReportAdEvent","ReportedEventType","INTERACTION","cycleDisplayedAd","eventType","currentTs","round","Date","getTime","adadaptedApiRequests","reportAdEvent","app_id","appId","session_id","sessionId","udid","events","ad_id","impression_id","event_type","created_at","deviceOs","apiEnv","createAdTimer","timerLength","setTimeout","nextAdIndex","refresh_time","IMPRESSION","StyleSheet","create"],"sources":["AdZone.tsx"],"sourcesContent":["/**\n * Component for creating an {@link AdZone}.\n * @module\n */\nimport * as React from \"react\";\nimport { Linking, StyleSheet, View, ViewStyle } from \"react-native\";\nimport * as adadaptedApiRequests from \"../api/adadaptedApiRequests\";\nimport {\n Ad,\n AdActionType,\n DetailedListItem,\n ReportedEventType,\n Zone,\n} from \"../api/adadaptedApiTypes\";\nimport { WebView } from \"react-native-webview\";\nimport { ApiEnv, DeviceOS } from \"../index\";\nimport { safeInvoke } from \"../util\";\n\n/**\n * Props interface for {@link AdZone}.\n */\ninterface Props {\n /**\n * The app ID.\n */\n appId: string;\n /**\n * The session ID.\n */\n sessionId: string;\n /**\n * The UDID.\n */\n udid: string;\n /**\n * The touch sensitivity of the Ad Zone in both the X and Y directions.\n * This is used to determine the click/press sensitivity when the\n * Ad Zone is being touched by the user as a regular touch or while\n * scrolling the view. If the amount of touch \"drag\" distance in either\n * X or Y direction is less than this value, we will treat the action as\n * a click/press on the Ad Zone.\n */\n xyDragDistanceAllowed: number;\n /**\n * The device OS used for API requests.\n */\n deviceOs: DeviceOS;\n /**\n * The API environment to use when making an API request.\n */\n apiEnv: ApiEnv;\n /**\n * The ad zone data.\n */\n adZoneData: Zone;\n /**\n * Callback that gets triggered when an \"add to list\" item/items are clicked.\n * @param items - The array of items to \"add to list\".\n */\n onAddToListTriggered?(items: DetailedListItem[]): void;\n}\n\n/**\n * State interface for {@link AdZone}.\n */\ninterface State {\n /**\n * Tracks the current ad index being shown.\n */\n adIndexShown: number;\n /**\n * Tracks the coordinates when the user started touching the Ad View.\n */\n touchStartCoords: TouchCoordinates | undefined;\n}\n\n/**\n * Interface for tracking \"touch\" coordinates.\n */\ninterface TouchCoordinates {\n /**\n * The X coordinate for the touch.\n */\n x: number;\n /**\n * The Y coordinate for the touch.\n */\n y: number;\n}\n\n/**\n * Defines the style typing for the component.\n */\ninterface StyleDef {\n /**\n * Styles for the main View element.\n */\n mainView: ViewStyle;\n /**\n * Styles for the WebView element.\n */\n webView: ViewStyle;\n}\n\n/**\n * Creates the AdZone component.\n */\nexport class AdZone extends React.Component<Props, State> {\n /**\n * Timer used for cycling through ads in the zone\n * based on the ad \"refresh time\" for each ad.\n */\n private cycleAdTimer: ReturnType<typeof setTimeout> | undefined;\n\n /**\n * @inheritDoc\n */\n constructor(props: Props, context?: any) {\n super(props, context);\n\n // Generates a random number between 0 and (number of available ads - 1).\n const startingAdIndex = Math.floor(\n Math.random() * this.props.adZoneData.ads.length\n );\n\n this.state = {\n adIndexShown: startingAdIndex,\n touchStartCoords: undefined,\n };\n }\n\n /**\n * @inheritDoc\n */\n public componentDidMount(): void {\n this.initializeAd();\n }\n\n /**\n * @inheritDoc\n */\n public componentWillUnmount(): void {\n if (this.cycleAdTimer) {\n clearTimeout(this.cycleAdTimer);\n }\n }\n\n /**\n * @inheritDoc\n */\n public render(): JSX.Element {\n // Generate the styles each render in case the ad is updated with\n // new settings that need to be reflected in the styles of the view.\n const styles = this.generateStyles();\n const currentAd: Ad | undefined =\n this.props.adZoneData.ads[this.state.adIndexShown] || undefined;\n const finalMainViewStyle = styles.mainView;\n\n if (!currentAd || !currentAd.creative_url) {\n // If there is no ad to display, make the view take up no space.\n finalMainViewStyle.width = 0;\n finalMainViewStyle.height = 0;\n }\n\n return (\n <View style={finalMainViewStyle}>\n {currentAd && currentAd.creative_url ? (\n <WebView\n source={{\n uri: currentAd.creative_url,\n }}\n androidLayerType=\"hardware\"\n automaticallyAdjustContentInsets={false}\n style={styles.webView}\n onTouchStart={(e) => {\n this.setState({\n touchStartCoords: {\n x: e.nativeEvent.pageX,\n y: e.nativeEvent.pageY,\n },\n });\n }}\n onTouchEnd={(e) => {\n if (this.state.touchStartCoords) {\n const touchEndCoords: TouchCoordinates = {\n x: e.nativeEvent.pageX,\n y: e.nativeEvent.pageY,\n };\n\n if (\n Math.abs(\n this.state.touchStartCoords.x -\n touchEndCoords.x\n ) < this.props.xyDragDistanceAllowed &&\n Math.abs(\n this.state.touchStartCoords.y -\n touchEndCoords.y\n ) < this.props.xyDragDistanceAllowed\n ) {\n this.onAdZoneSelected(currentAd);\n }\n\n // Make sure to reset the start coords\n this.setState({\n touchStartCoords: undefined,\n });\n }\n }}\n />\n ) : undefined}\n </View>\n );\n }\n\n /**\n * Triggers when the user selects the ad zone.\n * @param currentAd - The ad currently displayed.\n */\n private onAdZoneSelected(currentAd: Ad): void {\n // Determine the \"action type\" and perform that specific action.\n if (\n currentAd.action_type === AdActionType.EXTERNAL &&\n currentAd.action_path\n ) {\n // Action Type: EXTERNAL\n Linking.openURL(currentAd.action_path).then();\n } else if (\n currentAd.action_type === AdActionType.CONTENT &&\n currentAd.payload &&\n currentAd.payload.detailed_list_items\n ) {\n safeInvoke(\n this.props.onAddToListTriggered,\n currentAd.payload.detailed_list_items\n );\n }\n\n this.triggerReportAdEvent(currentAd, ReportedEventType.INTERACTION);\n if (this.cycleAdTimer) {\n clearTimeout(this.cycleAdTimer);\n }\n this.cycleDisplayedAd();\n }\n\n /**\n * Triggered when we need to report an ad event to the API.\n * @param currentAd - The ad to send an event for.\n * @param eventType - The event type for the reported event.\n */\n private triggerReportAdEvent(\n currentAd: Ad,\n eventType: ReportedEventType\n ): void {\n // The event timestamp has to be sent as a unix timestamp.\n const currentTs = Math.round(new Date().getTime() / 1000);\n\n // Log the taken action/event with the API.\n adadaptedApiRequests\n .reportAdEvent(\n {\n app_id: this.props.appId,\n session_id: this.props.sessionId,\n udid: this.props.udid,\n events: [\n {\n ad_id: currentAd.ad_id,\n impression_id: currentAd.impression_id,\n event_type: eventType,\n created_at: currentTs,\n },\n ],\n },\n this.props.deviceOs,\n this.props.apiEnv\n )\n .then(() => {\n // Do nothing with the response for now...\n });\n }\n\n /**\n * Generates a new timer for cycling to the next ad.\n * @param timerLength - The length of time(in milliseconds) to initialize\n * the timer with.\n */\n private createAdTimer(timerLength: number): void {\n if (this.props.adZoneData.ads.length > 0) {\n this.cycleAdTimer = setTimeout(() => {\n this.cycleDisplayedAd();\n }, timerLength);\n }\n }\n\n /**\n * Cycles to the next ad to display in the current available sequence of ads.\n */\n private cycleDisplayedAd(): void {\n // Start by determining the next ad index to display.\n let nextAdIndex = 0;\n\n if (this.state.adIndexShown < this.props.adZoneData.ads.length - 1) {\n nextAdIndex = this.state.adIndexShown + 1;\n }\n\n this.setState(\n {\n adIndexShown: nextAdIndex,\n },\n () => {\n this.initializeAd();\n }\n );\n }\n\n /**\n * Performs all ad initialization tasks when a new ad is being displayed.\n */\n private initializeAd(): void {\n // Create the new timer based on the new ad index.\n this.createAdTimer(\n this.props.adZoneData.ads[this.state.adIndexShown].refresh_time *\n 1000\n );\n\n // Trigger an impression event for the ad.\n this.triggerReportAdEvent(\n this.props.adZoneData.ads[this.state.adIndexShown],\n ReportedEventType.IMPRESSION\n );\n }\n\n /**\n * Generates all component related styles.\n * @returns the styles needed for the component.\n */\n private generateStyles(): StyleDef {\n return StyleSheet.create({\n mainView: {\n width: \"100%\",\n height: \"100%\",\n },\n webView: {\n width: \"100%\",\n height: \"100%\",\n },\n });\n }\n}\n"],"mappings":";;;;;;AAIA;AACA;AACA;AACA;AAOA;AAEA;AAAqC;AAAA;AAAA;AAwFrC;AACA;AACA;AACO,MAAMA,MAAM,SAASC,KAAK,CAACC,SAAS,CAAe;EACtD;AACJ;AACA;AACA;;EAGI;AACJ;AACA;EACIC,WAAW,CAACC,KAAY,EAAEC,OAAa,EAAE;IACrC,KAAK,CAACD,KAAK,EAAEC,OAAO,CAAC;;IAErB;IAAA;IACA,MAAMC,eAAe,GAAGC,IAAI,CAACC,KAAK,CAC9BD,IAAI,CAACE,MAAM,EAAE,GAAG,IAAI,CAACL,KAAK,CAACM,UAAU,CAACC,GAAG,CAACC,MAAM,CACnD;IAED,IAAI,CAACC,KAAK,GAAG;MACTC,YAAY,EAAER,eAAe;MAC7BS,gBAAgB,EAAEC;IACtB,CAAC;EACL;;EAE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EAAE;MAChEsE,WAAW,GAAG,IAAI,CAACrE,KAAK,CAACC,YAAY,GAAG,CAAC;IAC7C;IAEA,IAAI,CAACoB,QAAQ,CACT;MACIpB,YAAY,EAAEoE;IAClB,CAAC,EACD,MAAM;MACF,IAAI,CAAChE,YAAY,EAAE;IACvB,CAAC,CACJ;EACL;;EAEA;AACJ;AACA;EACYA,YAAY,GAAS;IACzB;IACA,IAAI,CAAC6D,aAAa,CACd,IAAI,CAAC3E,KAAK,CAACM,UAAU,CAACC,GAAG,CAAC,IAAI,CAACE,KAAK,CAACC,YAAY,CAAC,CAACqE,YAAY,GAC3D,IAAI,CACX;;IAED;IACA,IAAI,CAAC3B,oBAAoB,CACrB,IAAI,CAACpD,KAAK,CAACM,UAAU,CAACC,GAAG,CAAC,IAAI,CAACE,KAAK,CAACC,YAAY,CAAC,EAClD2C,oCAAiB,CAAC2B,UAAU,CAC/B;EACL;;EAEA;AACJ;AACA;AACA;EACY5D,cAAc,GAAa;IAC/B,OAAO6D,uBAAU,CAACC,MAAM,CAAC;MACrB3D,QAAQ,EAAE;QACNE,KAAK,EAAE,MAAM;QACbC,MAAM,EAAE;MACZ,CAAC;MACDE,OAAO,EAAE;QACLH,KAAK,EAAE,MAAM;QACbC,MAAM,EAAE;MACZ;IACJ,CAAC,CAAC;EACN;AACJ;AAAC"}
1
+ {"version":3,"names":["cycleAdTimer","AdZone","props","startingAdIndex","Math","floor","random","adZoneData","ads","length","adIndexShown","setAdIndexShown","useState","touchStartCoords","setTouchStartCoords","x","y","isAdVisible","setIsAdVisibile","defaultToInvisibleAdZone","useEffect","DeviceEventEmitter","addListener","event","itemName","acknowledge","clearTimeout","removeAllListeners","startAdTimer","sendAdImpression","generateStyles","StyleSheet","create","mainView","width","height","webView","styles","currentAd","undefined","finalMainViewStyle","creative_url","onAdZoneSelected","currentlyDisplayedAd","action_type","AdActionType","EXTERNAL","action_path","Linking","openURL","then","CONTENT","payload","detailed_list_items","safeInvoke","onAddToListTriggered","cycleDisplayedAd","forEach","ad","item","product_title","triggerReportAdEvent","ReportedEventType","INTERACTION","eventType","currentTs","round","Date","getTime","adadaptedApiRequests","reportAdEvent","app_id","appId","session_id","sessionId","udid","events","ad_id","impression_id","event_type","created_at","deviceOs","apiEnv","refreshTime","refresh_time","setTimeout","nextAdIndex","lastAd","impression_tracked","INVISIBLE_IMPRESSION","IMPRESSION","uri","e","nativeEvent","pageX","pageY","touchEndCoords","abs","xyDragDistanceAllowed"],"sources":["AdZone.tsx"],"sourcesContent":["/**\n * Component for creating an {@link AdZone}.\n * @module\n */\nimport * as React from \"react\";\nimport {\n DeviceEventEmitter,\n Linking,\n StyleSheet,\n View,\n ViewStyle,\n} from \"react-native\";\nimport * as adadaptedApiRequests from \"../api/adadaptedApiRequests\";\nimport {\n Ad,\n AdActionType,\n DetailedListItem,\n ReportedEventType,\n Zone,\n} from \"../api/adadaptedApiTypes\";\nimport { WebView } from \"react-native-webview\";\nimport { ApiEnv, DeviceOS } from \"../index\";\nimport { safeInvoke } from \"../util\";\nimport { useEffect, useState } from \"react\";\n\n/**\n * Props interface for {@link AdZone}.\n */\ninterface Props {\n /**\n * The app ID.\n */\n appId: string;\n /**\n * The session ID.\n */\n sessionId: string;\n /**\n * The UDID.\n */\n udid: string;\n /**\n * The touch sensitivity of the Ad Zone in both the X and Y directions.\n * This is used to determine the click/press sensitivity when the\n * Ad Zone is being touched by the user as a regular touch or while\n * scrolling the view. If the amount of touch \"drag\" distance in either\n * X or Y direction is less than this value, we will treat the action as\n * a click/press on the Ad Zone.\n */\n xyDragDistanceAllowed: number;\n /**\n * The device OS used for API requests.\n */\n deviceOs: DeviceOS;\n /**\n * The API environment to use when making an API request.\n */\n apiEnv: ApiEnv;\n /**\n * The ad zone data.\n */\n adZoneData: Zone;\n /**\n * Callback that gets triggered when an \"add to list\" item/items are clicked.\n * @param items - The array of items to \"add to list\".\n */\n onAddToListTriggered?(items: DetailedListItem[]): void;\n /**\n * Track the ad zone visibility in parent component.\n */\n isAdZoneVisible?: boolean;\n /**\n * Set default ad zone visibility to false.\n */\n defaultToInvisibleAdZone?: boolean;\n}\n\n/**\n * Interface for tracking \"touch\" coordinates.\n */\ninterface TouchCoordinates {\n /**\n * The X coordinate for the touch.\n */\n x: number;\n /**\n * The Y coordinate for the touch.\n */\n y: number;\n}\n\n/**\n * Defines the style typing for the component.\n */\ninterface StyleDef {\n /**\n * Styles for the main View element.\n */\n mainView: ViewStyle;\n /**\n * Styles for the WebView element.\n */\n webView: ViewStyle;\n}\n/**\n * Timer used for cycling through ads in the zone\n * based on the ad \"refresh time\" for each ad.\n */\nlet cycleAdTimer: ReturnType<typeof setTimeout> | undefined;\n\n/**\n * Creates the AdZone component.\n * @param props - properties passed to AdZone.\n * @returns an AdZone JSX Element.\n */\nexport function AdZone(props: Props): JSX.Element {\n // Generates a random number between 0 and (number of available ads - 1).\n const startingAdIndex = Math.floor(\n Math.random() * props.adZoneData.ads.length\n );\n\n /**\n * Tracks the current ad index being shown.\n */\n const [adIndexShown, setAdIndexShown] = useState(startingAdIndex);\n /**\n * Tracks the coordinates when the user started touching the Ad View.\n */\n const [touchStartCoords, setTouchStartCoords] = useState({ x: 0, y: 0 });\n /**\n * Track ad visibility (for off-screen ads).\n */\n const [isAdVisible, setIsAdVisibile] = useState(\n props.defaultToInvisibleAdZone ? false : true\n );\n\n // - Define all useEffect triggers.\n useEffect(() => {\n DeviceEventEmitter.addListener(\"visibility-event\", (event) => {\n setIsAdVisibile(event);\n });\n DeviceEventEmitter.addListener(\"acknowledge\", (itemName) => {\n acknowledge(itemName);\n });\n return () => {\n clearTimeout(cycleAdTimer);\n DeviceEventEmitter.removeAllListeners(\"visibility-event\");\n DeviceEventEmitter.removeAllListeners(\"acknowledge\");\n };\n }, []);\n\n useEffect(() => {\n startAdTimer();\n if (isAdVisible) {\n sendAdImpression();\n }\n }, [adIndexShown]);\n\n useEffect(() => {\n if (isAdVisible) {\n sendAdImpression();\n }\n }, [isAdVisible]);\n\n /**\n * Generates all component related styles.\n * @returns the styles needed for the component.\n */\n function generateStyles(): StyleDef {\n return StyleSheet.create({\n mainView: {\n width: \"100%\",\n height: \"100%\",\n },\n webView: {\n width: \"100%\",\n height: \"100%\",\n },\n });\n }\n\n // Generate the styles each render in case the ad is updated with\n // new settings that need to be reflected in the styles of the view.\n const styles = generateStyles();\n const currentAd: Ad | undefined =\n props.adZoneData.ads[adIndexShown] || undefined;\n const finalMainViewStyle = styles.mainView;\n\n if (!currentAd || !currentAd.creative_url) {\n // If there is no ad to display, make the view take up no space.\n finalMainViewStyle.width = \"0\";\n finalMainViewStyle.height = \"0\";\n }\n\n /**\n * Triggers when the user selects the ad zone.\n * @param currentlyDisplayedAd - The ad currently displayed.\n */\n function onAdZoneSelected(currentlyDisplayedAd: Ad): void {\n // Determine the \"action type\" and perform that specific action.\n if (\n currentlyDisplayedAd.action_type === AdActionType.EXTERNAL &&\n currentlyDisplayedAd.action_path\n ) {\n // Action Type: EXTERNAL\n Linking.openURL(currentlyDisplayedAd.action_path).then();\n } else if (\n currentlyDisplayedAd.action_type === AdActionType.CONTENT &&\n currentlyDisplayedAd.payload &&\n currentlyDisplayedAd.payload.detailed_list_items\n ) {\n safeInvoke(\n props.onAddToListTriggered,\n currentlyDisplayedAd.payload.detailed_list_items\n );\n }\n\n cycleDisplayedAd();\n }\n\n /**\n * Call to acknowledge ATL item(s) added to user list.\n * @param itemName - Detailed list item title from ad that was clicked.\n */\n function acknowledge(itemName: string): void {\n if (props.adZoneData.ads) {\n props.adZoneData.ads.forEach((ad) => {\n ad.payload.detailed_list_items.forEach((item) => {\n if (item.product_title === itemName) {\n triggerReportAdEvent(ad, ReportedEventType.INTERACTION);\n }\n });\n });\n }\n }\n\n /**\n * Triggered when we need to report an ad event to the API.\n * @param ad - The ad to send an event for.\n * @param eventType - The event type for the reported event.\n */\n function triggerReportAdEvent(ad: Ad, eventType: ReportedEventType): void {\n // The event timestamp has to be sent as a unix timestamp.\n const currentTs = Math.round(new Date().getTime() / 1000);\n\n // Log the taken action/event with the API.\n adadaptedApiRequests\n .reportAdEvent(\n {\n app_id: props.appId,\n session_id: props.sessionId,\n udid: props.udid,\n events: [\n {\n ad_id: ad.ad_id,\n impression_id: ad.impression_id,\n event_type: eventType,\n created_at: currentTs,\n },\n ],\n },\n props.deviceOs,\n props.apiEnv\n )\n .then(() => {\n // Do nothing with the response for now...\n });\n }\n\n /**\n * Generates a new timer for cycling to the next ad.\n */\n function startAdTimer(): void {\n clearTimeout(cycleAdTimer);\n\n if (props.adZoneData.ads.length > 0) {\n const refreshTime: number =\n props.adZoneData.ads[adIndexShown].refresh_time * 1000;\n cycleAdTimer = setTimeout(cycleDisplayedAd, refreshTime);\n }\n }\n\n /**\n * Cycles to the next ad to display in the current available sequence of ads.\n */\n function cycleDisplayedAd(): void {\n // Start by determining the next ad index to display.\n let nextAdIndex = 0;\n const lastAd = props.adZoneData.ads[adIndexShown];\n\n if (adIndexShown < props.adZoneData.ads.length - 1) {\n nextAdIndex = adIndexShown + 1;\n }\n\n if (nextAdIndex !== adIndexShown && lastAd.impression_tracked) {\n // Reset ad impression tracking status.\n lastAd.impression_tracked = false;\n } else {\n // Send invisible ad impression if ad was not visible before end of timer cycle.\n triggerReportAdEvent(\n lastAd,\n ReportedEventType.INVISIBLE_IMPRESSION\n );\n }\n\n setAdIndexShown(nextAdIndex);\n }\n\n /**\n * Send ad tracking impression.\n */\n function sendAdImpression(): void {\n const ad = props.adZoneData.ads[adIndexShown];\n\n // Trigger an impression event for the ad.\n if (!ad.impression_tracked) {\n triggerReportAdEvent(ad, ReportedEventType.IMPRESSION);\n ad.impression_tracked = true;\n }\n }\n\n // Returned JSX.\n return (\n <View style={finalMainViewStyle}>\n {currentAd && currentAd.creative_url ? (\n <WebView\n source={{\n uri: currentAd.creative_url,\n }}\n androidLayerType=\"hardware\"\n automaticallyAdjustContentInsets={false}\n style={styles.webView}\n onTouchStart={(e) => {\n setTouchStartCoords({\n x: e.nativeEvent.pageX,\n y: e.nativeEvent.pageY,\n });\n }}\n onTouchEnd={(e) => {\n if (touchStartCoords) {\n const touchEndCoords: TouchCoordinates = {\n x: e.nativeEvent.pageX,\n y: e.nativeEvent.pageY,\n };\n\n if (\n Math.abs(\n touchStartCoords.x - touchEndCoords.x\n ) < props.xyDragDistanceAllowed &&\n Math.abs(\n touchStartCoords.y - touchEndCoords.y\n ) < props.xyDragDistanceAllowed\n ) {\n onAdZoneSelected(currentAd);\n }\n\n // Make sure to reset the start coords\n setTouchStartCoords({ x: 0, y: 0 });\n }\n }}\n />\n ) : undefined}\n </View>\n );\n}\n"],"mappings":";;;;;;AAIA;AACA;AAOA;AACA;AAOA;AAEA;AAAqC;AAAA;AAtBrC;AACA;AACA;AACA;;AAqGA;AACA;AACA;AACA;AACA,IAAIA,YAAuD;;AAE3D;AACA;AACA;AACA;AACA;AACO,SAASC,MAAM,CAACC,KAAY,EAAe;EAC9C;EACA,MAAMC,eAAe,GAAGC,IAAI,CAACC,KAAK,CAC9BD,IAAI,CAACE,MAAM,EAAE,GAAGJ,KAAK,CAACK,UAAU,CAACC,GAAG,CAACC,MAAM,CAC9C;;EAED;AACJ;AACA;EACI,MAAM,CAACC,YAAY,EAAEC,eAAe,CAAC,GAAG,IAAAC,cAAQ,EAACT,eAAe,CAAC;EACjE;AACJ;AACA;EACI,MAAM,CAACU,gBAAgB,EAAEC,mBAAmB,CAAC,GAAG,IAAAF,cAAQ,EAAC;IAAEG,CAAC,EAAE,CAAC;IAAEC,CAAC,EAAE;EAAE,CAAC,CAAC;EACxE;AACJ;AACA;EACI,MAAM,CAACC,WAAW,EAAEC,eAAe,CAAC,GAAG,IAAAN,cAAQ,EAC3CV,KAAK,CAACiB,wBAAwB,GAAG,KAAK,GAAG,IAAI,CAChD;;EAED;EACA,IAAAC,eAAS,EAAC,MAAM;IACZC,+BAAkB,CAACC,WAAW,CAAC,kBAAkB,EAAGC,KAAK,IAAK;MAC1DL,eAAe,CAACK,KAAK,CAAC;IAC1B,CAAC,CAAC;IACFF,+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CAAC;UAAEC,CAAC,EAAE;QAAE,CAAC,CAAC;MACvC;IACJ;EAAE,EACJ,GACFuB,SAAS,CACV;AAEf"}
@@ -151,6 +151,14 @@ class AdadaptedReactNativeSdk {
151
151
  * AppState event listener.
152
152
  */
153
153
 
154
+ /**
155
+ * Track ad zone visibility for off-screen ads.
156
+ */
157
+
158
+ /**
159
+ * Optional default ad zone visibility for off-screen ads.
160
+ */
161
+
154
162
  /**
155
163
  * Gets the Session ID.
156
164
  * @returns the Session ID.
@@ -197,6 +205,8 @@ class AdadaptedReactNativeSdk {
197
205
  _defineProperty(this, "onOutOfAppPayloadAvailable", void 0);
198
206
  _defineProperty(this, "deepLinkOnEventListener", void 0);
199
207
  _defineProperty(this, "AppStateOnEventListener", void 0);
208
+ _defineProperty(this, "isAdZoneVisible", true);
209
+ _defineProperty(this, "defaultAdZoneVisibility", void 0);
200
210
  this.apiEnv = ApiEnv.Prod;
201
211
  this.listManagerApiEnv = ListManagerApiEnv.Prod;
202
212
  this.payloadApiEnv = PayloadApiEnv.Prod;
@@ -250,7 +260,9 @@ class AdadaptedReactNativeSdk {
250
260
  adZoneData: adZones[adZoneId],
251
261
  onAddToListTriggered: items => {
252
262
  (0, _util.safeInvoke)(this.onAddToListTriggered, items);
253
- }
263
+ },
264
+ isAdZoneVisible: !this.onAdZoneVisibilityChanged,
265
+ defaultToInvisibleAdZone: this.defaultAdZoneVisibility
254
266
  })
255
267
  });
256
268
  }
@@ -303,7 +315,6 @@ class AdadaptedReactNativeSdk {
303
315
  uid: this.deviceInfo.udid
304
316
  }, this.deviceOs, this.apiEnv).then(response => {
305
317
  this.keywordIntercepts = response.data;
306
- this.performKeywordSearch("mil");
307
318
  });
308
319
  }
309
320
 
@@ -441,6 +452,23 @@ class AdadaptedReactNativeSdk {
441
452
  });
442
453
  }
443
454
 
455
+ /**
456
+ * Notify the ad zone of visibility status change for off-screen ads.
457
+ */
458
+ onAdZoneVisibilityChanged() {
459
+ const isVisible = !this.isAdZoneVisible;
460
+ this.isAdZoneVisible = isVisible;
461
+ _reactNative.DeviceEventEmitter.emit("visibility-event", isVisible);
462
+ }
463
+
464
+ /**
465
+ * Notify the adZone to send ad interaction report.
466
+ * @param itemName - Detailed list item title from ad that was clicked.
467
+ */
468
+ acknowledge(itemName) {
469
+ _reactNative.DeviceEventEmitter.emit("acknowledge", itemName);
470
+ }
471
+
444
472
  /**
445
473
  * Initializes the session for the AdAdapted API and sets up the SDK.
446
474
  * @param props - The props used to initialize the SDK.
@@ -492,6 +520,12 @@ class AdadaptedReactNativeSdk {
492
520
  if (props.onOutOfAppPayloadAvailable) {
493
521
  this.onOutOfAppPayloadAvailable = props.onOutOfAppPayloadAvailable;
494
522
  }
523
+
524
+ // If provided for off-screen ads, set the ad zone visibility for ad tracking.
525
+ if (props.defaultToInvisibleAdZone) {
526
+ this.defaultAdZoneVisibility = props.defaultToInvisibleAdZone;
527
+ this.onAdZoneVisibilityChanged();
528
+ }
495
529
  return new Promise((resolve, reject) => {
496
530
  this.getDeviceInformation().then(deviceInfoObj => {
497
531
  const deviceInfo = JSON.parse(deviceInfoObj);