@adadapted/react-native-sdk 3.2.0 → 3.3.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/android/.project +1 -1
- package/android/.settings/org.eclipse.buildship.core.prefs +2 -2
- package/android/bin/build.gradle +6 -5
- package/android/bin/gradle.properties +4 -4
- package/android/build.gradle +6 -5
- package/android/gradle.properties +3 -3
- package/android/src/main/AndroidManifest.xml +1 -3
- package/lib/commonjs/api/adadaptedApiRequests.js.map +1 -1
- package/lib/commonjs/api/adadaptedApiRequests.mock.js +25 -8
- package/lib/commonjs/api/adadaptedApiRequests.mock.js.map +1 -1
- package/lib/commonjs/api/adadaptedApiTypes.js +71 -26
- package/lib/commonjs/api/adadaptedApiTypes.js.map +1 -1
- package/lib/commonjs/components/AdZone.js +53 -14
- package/lib/commonjs/components/AdZone.js.map +1 -1
- package/lib/commonjs/components/ReportAdButton.js +38 -0
- package/lib/commonjs/components/ReportAdButton.js.map +1 -0
- package/lib/commonjs/images/ReportIcon.png +0 -0
- package/lib/commonjs/index.js +139 -89
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js +4 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/util.js +13 -0
- package/lib/commonjs/util.js.map +1 -1
- package/lib/module/api/adadaptedApiRequests.js.map +1 -1
- package/lib/module/api/adadaptedApiRequests.mock.js +25 -9
- package/lib/module/api/adadaptedApiRequests.mock.js.map +1 -1
- package/lib/module/api/adadaptedApiTypes.js +69 -24
- package/lib/module/api/adadaptedApiTypes.js.map +1 -1
- package/lib/module/components/AdZone.js +49 -14
- package/lib/module/components/AdZone.js.map +1 -1
- package/lib/module/components/ReportAdButton.js +30 -0
- package/lib/module/components/ReportAdButton.js.map +1 -0
- package/lib/module/images/ReportIcon.png +0 -0
- package/lib/module/index.js +139 -88
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/util.js +14 -2
- package/lib/module/util.js.map +1 -1
- package/lib/typescript/example/index.d.ts +1 -0
- package/lib/typescript/example/index.d.ts.map +1 -0
- package/lib/typescript/example/src/App.d.ts +22 -2
- package/lib/typescript/example/src/App.d.ts.map +1 -0
- package/lib/typescript/example/src/OffScreenAdZone.d.ts +38 -0
- package/lib/typescript/example/src/OffScreenAdZone.d.ts.map +1 -0
- package/lib/typescript/example/src/StandardAdZone.d.ts +38 -0
- package/lib/typescript/example/src/StandardAdZone.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +2 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/jest.setup.d.ts +2 -1
- package/lib/typescript/jest.setup.d.ts.map +1 -0
- package/lib/typescript/src/api/adadaptedApiRequests.d.ts +1 -0
- package/lib/typescript/src/api/adadaptedApiRequests.d.ts.map +1 -0
- package/lib/typescript/src/api/adadaptedApiRequests.mock.d.ts +1 -0
- package/lib/typescript/src/api/adadaptedApiRequests.mock.d.ts.map +1 -0
- package/lib/typescript/src/api/adadaptedApiTypes.d.ts +1 -0
- package/lib/typescript/src/api/adadaptedApiTypes.d.ts.map +1 -0
- package/lib/typescript/src/components/AdZone.d.ts +5 -4
- package/lib/typescript/src/components/AdZone.d.ts.map +1 -0
- package/lib/typescript/src/components/ReportAdButton.d.ts +19 -0
- package/lib/typescript/src/components/ReportAdButton.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +23 -6
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +3 -2
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/util.d.ts +13 -0
- package/lib/typescript/src/util.d.ts.map +1 -0
- package/package.json +155 -155
- package/src/api/adadaptedApiRequests.mock.ts +25 -9
- package/src/components/AdZone.tsx +52 -20
- package/src/components/ReportAdButton.tsx +46 -0
- package/src/images/ReportIcon.png +0 -0
- package/src/index.tsx +134 -68
- package/src/util.ts +13 -0
|
@@ -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 * 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;AACA,WAAYA,sBAAsB;;AAOlC;AACA;AACA;AAFA,WAPYA,sBAAsB;EAAtBA,sBAAsB;AAAA,GAAtBA,sBAAsB,KAAtBA,sBAAsB;AAUlC,WAAYC,oBAAoB;;AAehC;AACA;AACA;AAFA,WAfYA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;AAAA,GAApBA,oBAAoB,KAApBA,oBAAoB;AAkBhC,WAAYC,YAAY;;AAyBxB;AACA;AACA;AAFA,WAzBYA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;AAAA,GAAZA,YAAY,KAAZA,YAAY;AA4BxB,WAAYC,iBAAiB;;AAgC7B;AACA;AACA;AAFA,WAhCYA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;AAAA,GAAjBA,iBAAiB,KAAjBA,iBAAiB;AAmC7B,WAAYC,aAAa;;AAWzB;AACA;AACA;AACA;AACA;AACA;AAFA,WAdYA,aAAa;EAAbA,aAAa;EAAbA,aAAa;AAAA,GAAbA,aAAa,KAAbA,aAAa"}
|
|
1
|
+
{"version":3,"names":["ListManagerEventSource","ListManagerEventName","AdActionType","ReportedEventType","PayloadStatus"],"sourceRoot":"../../../src","sources":["api/adadaptedApiTypes.ts"],"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;AACA,WAAYA,sBAAsB,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;;AAOlC;AACA;AACA;AACA,WAAYC,oBAAoB,0BAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA;;AAehC;AACA;AACA;AACA,WAAYC,YAAY,0BAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAA,OAAZA,YAAY;AAAA;;AAyBxB;AACA;AACA;AACA,WAAYC,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;;AAgC7B;AACA;AACA;AACA,WAAYC,aAAa,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;;AAWzB;AACA;AACA;AACA;AACA;AACA;AAgBA;AACA;AACA;AA4EA;AACA;AACA;AAgBA;AACA;AACA;AAQA;AACA;AACA;AAgBA;AACA;AACA;AAQA;AACA;AACA;AAQA;AACA;AACA;AAQA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAGA;AACA;AACA;AASA;AACA;AACA;AAGA;AACA;AACA;AASA;AACA;AACA"}
|
|
@@ -9,11 +9,20 @@ import { AdActionType, ReportedEventType } from "../api/adadaptedApiTypes";
|
|
|
9
9
|
import { WebView } from "react-native-webview";
|
|
10
10
|
import { safeInvoke } from "../util";
|
|
11
11
|
import { useEffect, useState } from "react";
|
|
12
|
+
import { ReportAdButton } from "./ReportAdButton";
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Props interface for {@link AdZone}.
|
|
15
16
|
*/
|
|
16
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Interface for tracking "touch" coordinates.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Defines the style typing for the component.
|
|
24
|
+
*/
|
|
25
|
+
|
|
17
26
|
/**
|
|
18
27
|
* Timer used for cycling through ads in the zone
|
|
19
28
|
* based on the ad "refresh time" for each ad.
|
|
@@ -43,9 +52,9 @@ export function AdZone(props) {
|
|
|
43
52
|
/**
|
|
44
53
|
* Track ad visibility (for off-screen ads).
|
|
45
54
|
*/
|
|
46
|
-
const [isAdVisible, setIsAdVisibile] = useState(props.
|
|
55
|
+
const [isAdVisible, setIsAdVisibile] = useState(props.isAdZoneVisible);
|
|
47
56
|
|
|
48
|
-
//
|
|
57
|
+
// Setup device listeners.
|
|
49
58
|
useEffect(() => {
|
|
50
59
|
DeviceEventEmitter.addListener("visibility-event", event => {
|
|
51
60
|
setIsAdVisibile(event);
|
|
@@ -53,22 +62,38 @@ export function AdZone(props) {
|
|
|
53
62
|
DeviceEventEmitter.addListener("acknowledge", itemName => {
|
|
54
63
|
acknowledge(itemName);
|
|
55
64
|
});
|
|
65
|
+
if (props.offScreenAdZone && isAdVisible) {
|
|
66
|
+
sendAdImpression();
|
|
67
|
+
} else if (!props.offScreenAdZone) {
|
|
68
|
+
sendAdImpression();
|
|
69
|
+
}
|
|
56
70
|
return () => {
|
|
57
71
|
clearTimeout(cycleAdTimer);
|
|
58
72
|
DeviceEventEmitter.removeAllListeners("visibility-event");
|
|
59
73
|
DeviceEventEmitter.removeAllListeners("acknowledge");
|
|
60
74
|
};
|
|
75
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
76
|
}, []);
|
|
77
|
+
|
|
78
|
+
// Send impression on ad cycle.
|
|
62
79
|
useEffect(() => {
|
|
63
80
|
startAdTimer();
|
|
64
|
-
if (isAdVisible) {
|
|
81
|
+
if (props.offScreenAdZone && isAdVisible) {
|
|
82
|
+
sendAdImpression();
|
|
83
|
+
} else if (!props.offScreenAdZone) {
|
|
65
84
|
sendAdImpression();
|
|
66
85
|
}
|
|
86
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
67
87
|
}, [adIndexShown]);
|
|
88
|
+
|
|
89
|
+
// Send impression based on visibility change. (for off-screen ads)
|
|
68
90
|
useEffect(() => {
|
|
69
|
-
if (isAdVisible) {
|
|
91
|
+
if (props.offScreenAdZone && isAdVisible) {
|
|
92
|
+
sendAdImpression();
|
|
93
|
+
} else if (!props.offScreenAdZone) {
|
|
70
94
|
sendAdImpression();
|
|
71
95
|
}
|
|
96
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
97
|
}, [isAdVisible]);
|
|
73
98
|
|
|
74
99
|
/**
|
|
@@ -84,6 +109,11 @@ export function AdZone(props) {
|
|
|
84
109
|
webView: {
|
|
85
110
|
width: "100%",
|
|
86
111
|
height: "100%"
|
|
112
|
+
},
|
|
113
|
+
reportAd: {
|
|
114
|
+
position: "absolute",
|
|
115
|
+
top: 10,
|
|
116
|
+
right: 10
|
|
87
117
|
}
|
|
88
118
|
});
|
|
89
119
|
}
|
|
@@ -95,8 +125,8 @@ export function AdZone(props) {
|
|
|
95
125
|
const finalMainViewStyle = styles.mainView;
|
|
96
126
|
if (!currentAd || !currentAd.creative_url) {
|
|
97
127
|
// If there is no ad to display, make the view take up no space.
|
|
98
|
-
finalMainViewStyle.width =
|
|
99
|
-
finalMainViewStyle.height =
|
|
128
|
+
finalMainViewStyle.width = 0;
|
|
129
|
+
finalMainViewStyle.height = 0;
|
|
100
130
|
}
|
|
101
131
|
|
|
102
132
|
/**
|
|
@@ -121,11 +151,13 @@ export function AdZone(props) {
|
|
|
121
151
|
function acknowledge(itemName) {
|
|
122
152
|
if (props.adZoneData.ads) {
|
|
123
153
|
props.adZoneData.ads.forEach(ad => {
|
|
124
|
-
ad.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
154
|
+
if (ad.action_type === "c") {
|
|
155
|
+
ad.payload.detailed_list_items.forEach(item => {
|
|
156
|
+
if (item.product_title === itemName) {
|
|
157
|
+
triggerReportAdEvent(ad, ReportedEventType.INTERACTION);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
129
161
|
});
|
|
130
162
|
}
|
|
131
163
|
}
|
|
@@ -191,8 +223,6 @@ export function AdZone(props) {
|
|
|
191
223
|
*/
|
|
192
224
|
function sendAdImpression() {
|
|
193
225
|
const ad = props.adZoneData.ads[adIndexShown];
|
|
194
|
-
|
|
195
|
-
// Trigger an impression event for the ad.
|
|
196
226
|
if (!ad.impression_tracked) {
|
|
197
227
|
triggerReportAdEvent(ad, ReportedEventType.IMPRESSION);
|
|
198
228
|
ad.impression_tracked = true;
|
|
@@ -232,6 +262,11 @@ export function AdZone(props) {
|
|
|
232
262
|
});
|
|
233
263
|
}
|
|
234
264
|
}
|
|
235
|
-
}) : undefined
|
|
265
|
+
}) : undefined, /*#__PURE__*/React.createElement(View, {
|
|
266
|
+
style: styles.reportAd
|
|
267
|
+
}, /*#__PURE__*/React.createElement(ReportAdButton, {
|
|
268
|
+
adId: currentAd.ad_id,
|
|
269
|
+
udid: props.udid
|
|
270
|
+
})));
|
|
236
271
|
}
|
|
237
272
|
//# sourceMappingURL=AdZone.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","DeviceEventEmitter","Linking","StyleSheet","View","adadaptedApiRequests","AdActionType","ReportedEventType","WebView","safeInvoke","useEffect","useState","cycleAdTimer","AdZone","props","startingAdIndex","Math","floor","random","adZoneData","ads","length","adIndexShown","setAdIndexShown","touchStartCoords","setTouchStartCoords","x","y","isAdVisible","setIsAdVisibile","defaultToInvisibleAdZone","addListener","event","itemName","acknowledge","clearTimeout","removeAllListeners","startAdTimer","sendAdImpression","generateStyles","create","mainView","width","height","webView","styles","currentAd","undefined","finalMainViewStyle","creative_url","onAdZoneSelected","currentlyDisplayedAd","action_type","EXTERNAL","action_path","openURL","then","CONTENT","payload","detailed_list_items","onAddToListTriggered","cycleDisplayedAd","forEach","ad","item","product_title","triggerReportAdEvent","INTERACTION","eventType","currentTs","round","Date","getTime","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":"AAAA;AACA;AACA;AACA;AACA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SACIC,kBAAkB,EAClBC,OAAO,EACPC,UAAU,EACVC,IAAI,QAED,cAAc;AAC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,oBACI,oBAAC,IAAI;IAAC,KAAK,EAAE3C;EAAmB,GAC3BF,SAAS,IAAIA,SAAS,CAACG,YAAY,gBAChC,oBAAC,OAAO;IACJ,MAAM,EAAE;MACJ6C,GAAG,EAAEhD,SAAS,CAACG;IACnB,CAAE;IACF,gBAAgB,EAAC,UAAU;IAC3B,gCAAgC,EAAE,KAAM;IACxC,KAAK,EAAEJ,MAAM,CAACD,OAAQ;IACtB,YAAY,EAAGmD,CAAC,IAAK;MACjBtE,mBAAmB,CAAC;QAChBC,CAAC,EAAEqE,CAAC,CAACC,WAAW,CAACC,KAAK;QACtBtE,CAAC,EAAEoE,CAAC,CAACC,WAAW,CAACE;MACrB,CAAC,CAAC;IACN,CAAE;IACF,UAAU,EAAGH,CAAC,IAAK;MACf,IAAIvE,gBAAgB,EAAE;QAClB,MAAM2E,cAAgC,GAAG;UACrCzE,CAAC,EAAEqE,CAAC,CAACC,WAAW,CAACC,KAAK;UACtBtE,CAAC,EAAEoE,CAAC,CAACC,WAAW,CAACE;QACrB,CAAC;QAED,IACIlF,IAAI,CAACoF,GAAG,CACJ5E,gBAAgB,CAACE,CAAC,GAAGyE,cAAc,CAACzE,CAAC,CACxC,GAAGZ,KAAK,CAACuF,qBAAqB,IAC/BrF,IAAI,CAACoF,GAAG,CACJ5E,gBAAgB,CAACG,CAAC,GAAGwE,cAAc,CAACxE,CAAC,CACxC,GAAGb,KAAK,CAACuF,qBAAqB,EACjC;UACEnD,gBAAgB,CAACJ,SAAS,CAAC;QAC/B;;QAEA;QACArB,mBAAmB,CAAC;UAAEC,CAAC,EAAE,CAAC;UAAEC,CAAC,EAAE;QAAE,CAAC,CAAC;MACvC;IACJ;EAAE,EACJ,GACFoB,SAAS,CACV;AAEf"}
|
|
1
|
+
{"version":3,"names":["React","DeviceEventEmitter","Linking","StyleSheet","View","adadaptedApiRequests","AdActionType","ReportedEventType","WebView","safeInvoke","useEffect","useState","ReportAdButton","cycleAdTimer","AdZone","props","startingAdIndex","Math","floor","random","adZoneData","ads","length","adIndexShown","setAdIndexShown","touchStartCoords","setTouchStartCoords","x","y","isAdVisible","setIsAdVisibile","isAdZoneVisible","addListener","event","itemName","acknowledge","offScreenAdZone","sendAdImpression","clearTimeout","removeAllListeners","startAdTimer","generateStyles","create","mainView","width","height","webView","reportAd","position","top","right","styles","currentAd","undefined","finalMainViewStyle","creative_url","onAdZoneSelected","currentlyDisplayedAd","action_type","EXTERNAL","action_path","openURL","then","CONTENT","payload","detailed_list_items","onAddToListTriggered","cycleDisplayedAd","forEach","ad","item","product_title","triggerReportAdEvent","INTERACTION","eventType","currentTs","round","Date","getTime","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","createElement","style","source","uri","androidLayerType","automaticallyAdjustContentInsets","onTouchStart","e","nativeEvent","pageX","pageY","onTouchEnd","touchEndCoords","abs","xyDragDistanceAllowed","adId"],"sourceRoot":"../../../src","sources":["components/AdZone.tsx"],"mappings":"AAAA;AACA;AACA;AACA;AACA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SACIC,kBAAkB,EAClBC,OAAO,EACPC,UAAU,EACVC,IAAI,QAED,cAAc;AACrB,OAAO,KAAKC,oBAAoB,MAAM,6BAA6B;AACnE,SAEIC,YAAY,EAEZC,iBAAiB,QAEd,0BAA0B;AACjC,SAASC,OAAO,QAAQ,sBAAsB;AAE9C,SAASC,UAAU,QAAQ,SAAS;AACpC,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,cAAc,QAAQ,kBAAkB;;AAEjD;AACA;AACA;;AAkDA;AACA;AACA;;AAYA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA,IAAIC,YAAuD;;AAE3D;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,MAAMA,CAACC,KAAY,EAAe;EAC9C;EACA,MAA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AqB,EACjC;UACE1D,gBAAgB,CAACJ,SAAS,CAAC;QAC/B;;QAEA;QACA1B,mBAAmB,CAAC;UAAEC,CAAC,EAAE,CAAC;UAAEC,CAAC,EAAE;QAAE,CAAC,CAAC;MACvC;IACJ;EAAE,CACL,CAAC,GACFyB,SAAS,eACbrD,KAAA,CAAAoG,aAAA,CAAChG,IAAI;IAACiG,KAAK,EAAElD,MAAM,CAACJ;EAAS,gBACzB/C,KAAA,CAAAoG,aAAA,CAACxF,cAAc;IAACuG,IAAI,EAAE/D,SAAS,CAACkC,KAAM;IAACF,IAAI,EAAErE,KAAK,CAACqE;EAAK,CAAE,CACxD,CACJ,CAAC;AAEf"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
import { Image, Linking, StyleSheet, TouchableOpacity } from "react-native";
|
|
3
|
+
/**
|
|
4
|
+
* Creates the ReportAdButton component.
|
|
5
|
+
* @param props The component's props.
|
|
6
|
+
* @returns a reportSdButton JSX Element.
|
|
7
|
+
*/
|
|
8
|
+
export function ReportAdButton(props) {
|
|
9
|
+
const reportAdUrlBase = new URL("https://feedback.add-it.io/");
|
|
10
|
+
const styles = StyleSheet.create({
|
|
11
|
+
buttonStyle: {
|
|
12
|
+
width: 14,
|
|
13
|
+
height: 14
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
reportAdUrlBase.searchParams.append("aid", props.adId);
|
|
18
|
+
reportAdUrlBase.searchParams.append("uid", props.udid);
|
|
19
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
20
|
+
}, [props]);
|
|
21
|
+
return /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
22
|
+
style: styles.buttonStyle,
|
|
23
|
+
onPress: () => {
|
|
24
|
+
Linking.openURL(reportAdUrlBase.toString());
|
|
25
|
+
}
|
|
26
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
27
|
+
source: require("../images/ReportIcon.png")
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=ReportAdButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useEffect","Image","Linking","StyleSheet","TouchableOpacity","ReportAdButton","props","reportAdUrlBase","URL","styles","create","buttonStyle","width","height","searchParams","append","adId","udid","createElement","style","onPress","openURL","toString","source","require"],"sourceRoot":"../../../src","sources":["components/ReportAdButton.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,SAASC,KAAK,EAAEC,OAAO,EAAEC,UAAU,EAAEC,gBAAgB,QAAQ,cAAc;AAa3E;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,KAAY,EAAe;EACtD,MAAMC,eAAe,GAAG,IAAIC,GAAG,CAAC,6BAA6B,CAAC;EAE9D,MAAMC,MAAM,GAAGN,UAAU,CAACO,MAAM,CAAC;IAC7BC,WAAW,EAAE;MACTC,KAAK,EAAE,EAAE;MACTC,MAAM,EAAE;IACZ;EACJ,CAAC,CAAC;EAEFb,SAAS,CAAC,MAAM;IACZO,eAAe,CAACO,YAAY,CAACC,MAAM,CAAC,KAAK,EAAET,KAAK,CAACU,IAAI,CAAC;IACtDT,eAAe,CAACO,YAAY,CAACC,MAAM,CAAC,KAAK,EAAET,KAAK,CAACW,IAAI,CAAC;IACtD;EACJ,CAAC,EAAE,CAACX,KAAK,CAAC,CAAC;EAEX,oBACIP,KAAA,CAAAmB,aAAA,CAACd,gBAAgB;IACbe,KAAK,EAAEV,MAAM,CAACE,WAAY;IAC1BS,OAAO,EAAEA,CAAA,KAAM;MACXlB,OAAO,CAACmB,OAAO,CAACd,eAAe,CAACe,QAAQ,CAAC,CAAC,CAAC;IAC/C;EAAE,gBAEFvB,KAAA,CAAAmB,aAAA,CAACjB,KAAK;IAACsB,MAAM,EAAEC,OAAO,CAAC,0BAA0B;EAAE,CAAE,CACvC,CAAC;AAE3B"}
|
|
Binary file
|
package/lib/module/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
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; }
|
|
2
1
|
/**
|
|
3
2
|
* The AdadaptedReactNativeSdk package/module definition.
|
|
4
3
|
*/
|
|
5
4
|
import * as React from "react";
|
|
6
|
-
import {
|
|
5
|
+
import { DeviceEventEmitter, Linking, NativeModules, Platform } from "react-native";
|
|
7
6
|
import * as adadaptedApiRequests from "./api/adadaptedApiRequests";
|
|
8
7
|
import { ListManagerEventName, ListManagerEventSource, PayloadStatus, ReportedEventType } from "./api/adadaptedApiTypes";
|
|
9
8
|
import { AdZone } from "./components/AdZone";
|
|
@@ -14,45 +13,61 @@ import base64 from "react-native-base64";
|
|
|
14
13
|
/**
|
|
15
14
|
* Enum representing possible device operating systems.
|
|
16
15
|
*/
|
|
17
|
-
export let DeviceOS
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Enum defining the different API environments.
|
|
21
|
-
*/
|
|
22
|
-
(function (DeviceOS) {
|
|
16
|
+
export let DeviceOS = /*#__PURE__*/function (DeviceOS) {
|
|
23
17
|
DeviceOS["ANDROID"] = "android";
|
|
24
18
|
DeviceOS["IOS"] = "ios";
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
return DeviceOS;
|
|
20
|
+
}({});
|
|
27
21
|
|
|
28
22
|
/**
|
|
29
|
-
* Enum defining the different API environments
|
|
23
|
+
* Enum defining the different API environments.
|
|
30
24
|
*/
|
|
31
|
-
|
|
25
|
+
export let ApiEnv = /*#__PURE__*/function (ApiEnv) {
|
|
32
26
|
ApiEnv["Prod"] = "https://ads.adadapted.com";
|
|
33
27
|
ApiEnv["Dev"] = "https://sandbox.adadapted.com";
|
|
34
28
|
ApiEnv["Mock"] = "MOCK_DATA";
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
return ApiEnv;
|
|
30
|
+
}({});
|
|
37
31
|
|
|
38
32
|
/**
|
|
39
|
-
* Enum defining the different API environments for
|
|
33
|
+
* Enum defining the different API environments for List Manager.
|
|
40
34
|
*/
|
|
41
|
-
|
|
35
|
+
export let ListManagerApiEnv = /*#__PURE__*/function (ListManagerApiEnv) {
|
|
42
36
|
ListManagerApiEnv["Prod"] = "https://ec.adadapted.com";
|
|
43
37
|
ListManagerApiEnv["Dev"] = "https://sandec.adadapted.com";
|
|
44
38
|
ListManagerApiEnv["Mock"] = "MOCK_DATA";
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
return ListManagerApiEnv;
|
|
40
|
+
}({});
|
|
47
41
|
|
|
48
42
|
/**
|
|
49
|
-
*
|
|
43
|
+
* Enum defining the different API environments for the Payload Server.
|
|
50
44
|
*/
|
|
51
|
-
|
|
45
|
+
export let PayloadApiEnv = /*#__PURE__*/function (PayloadApiEnv) {
|
|
52
46
|
PayloadApiEnv["Prod"] = "https://payload.adadapted.com";
|
|
53
47
|
PayloadApiEnv["Dev"] = "https://sandpayload.adadapted.com";
|
|
54
48
|
PayloadApiEnv["Mock"] = "MOCK_DATA";
|
|
55
|
-
|
|
49
|
+
return PayloadApiEnv;
|
|
50
|
+
}({});
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Interface defining inputs to the {@link Sdk.initialize: AdadaptedReactNativeSdk} method.
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Interface defining properties of a user's Device.
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Interface defining a wrapper for an {@link AdZone}.
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Interface defining a keyword search result.
|
|
66
|
+
* This is primarily used to export an interface directly from
|
|
67
|
+
* {@link AdadaptedReactNativeSdk} so the interaction with the SDK all be
|
|
68
|
+
* done through this namespace.
|
|
69
|
+
*/
|
|
70
|
+
|
|
56
71
|
/**
|
|
57
72
|
* Class that acts as the AdAdapted SDK for react-native.
|
|
58
73
|
*/
|
|
@@ -60,7 +75,7 @@ export class AdadaptedReactNativeSdk {
|
|
|
60
75
|
/**
|
|
61
76
|
* The client app ID used to send to API endpoints.
|
|
62
77
|
*/
|
|
63
|
-
|
|
78
|
+
appId = "";
|
|
64
79
|
/**
|
|
65
80
|
* The API environment to use when making API calls.
|
|
66
81
|
*/
|
|
@@ -94,6 +109,10 @@ export class AdadaptedReactNativeSdk {
|
|
|
94
109
|
* The available ad zones.
|
|
95
110
|
*/
|
|
96
111
|
|
|
112
|
+
/**
|
|
113
|
+
* The available off-screen ad zones.
|
|
114
|
+
*/
|
|
115
|
+
offScreenAdZones = [];
|
|
97
116
|
/**
|
|
98
117
|
* The touch sensitivity of the Ad Zone in both the X and Y directions.
|
|
99
118
|
* This is used to determine the click/press sensitivity when the
|
|
@@ -149,9 +168,9 @@ export class AdadaptedReactNativeSdk {
|
|
|
149
168
|
/**
|
|
150
169
|
* Track ad zone visibility for off-screen ads.
|
|
151
170
|
*/
|
|
152
|
-
|
|
171
|
+
isAdZoneVisible = true;
|
|
153
172
|
/**
|
|
154
|
-
*
|
|
173
|
+
* Ad zones that contain off-screen ads..
|
|
155
174
|
*/
|
|
156
175
|
|
|
157
176
|
/**
|
|
@@ -178,30 +197,18 @@ export class AdadaptedReactNativeSdk {
|
|
|
178
197
|
return this.adZones;
|
|
179
198
|
}
|
|
180
199
|
|
|
200
|
+
/**
|
|
201
|
+
* Gets the list of available off-screen Ad Zones.
|
|
202
|
+
* @returns all available off-screen ad zones.
|
|
203
|
+
*/
|
|
204
|
+
getOffScreenAdZones() {
|
|
205
|
+
return this.offScreenAdZones;
|
|
206
|
+
}
|
|
207
|
+
|
|
181
208
|
/**
|
|
182
209
|
* @inheritDoc
|
|
183
210
|
*/
|
|
184
211
|
constructor() {
|
|
185
|
-
_defineProperty(this, "appId", "");
|
|
186
|
-
_defineProperty(this, "apiEnv", void 0);
|
|
187
|
-
_defineProperty(this, "listManagerApiEnv", void 0);
|
|
188
|
-
_defineProperty(this, "payloadApiEnv", void 0);
|
|
189
|
-
_defineProperty(this, "deviceOs", void 0);
|
|
190
|
-
_defineProperty(this, "sessionId", void 0);
|
|
191
|
-
_defineProperty(this, "deviceInfo", void 0);
|
|
192
|
-
_defineProperty(this, "sessionInfo", void 0);
|
|
193
|
-
_defineProperty(this, "adZones", void 0);
|
|
194
|
-
_defineProperty(this, "xyAdZoneDragDistanceAllowed", void 0);
|
|
195
|
-
_defineProperty(this, "onAdZonesRefreshed", void 0);
|
|
196
|
-
_defineProperty(this, "refreshAdZonesTimer", void 0);
|
|
197
|
-
_defineProperty(this, "keywordInterceptSearchValue", void 0);
|
|
198
|
-
_defineProperty(this, "keywordIntercepts", void 0);
|
|
199
|
-
_defineProperty(this, "onAddToListTriggered", void 0);
|
|
200
|
-
_defineProperty(this, "onOutOfAppPayloadAvailable", void 0);
|
|
201
|
-
_defineProperty(this, "deepLinkOnEventListener", void 0);
|
|
202
|
-
_defineProperty(this, "AppStateOnEventListener", void 0);
|
|
203
|
-
_defineProperty(this, "isAdZoneVisible", true);
|
|
204
|
-
_defineProperty(this, "defaultAdZoneVisibility", void 0);
|
|
205
212
|
this.apiEnv = ApiEnv.Prod;
|
|
206
213
|
this.listManagerApiEnv = ListManagerApiEnv.Prod;
|
|
207
214
|
this.payloadApiEnv = PayloadApiEnv.Prod;
|
|
@@ -242,23 +249,63 @@ export class AdadaptedReactNativeSdk {
|
|
|
242
249
|
const adZoneInfoList = [];
|
|
243
250
|
for (const adZoneId in adZones) {
|
|
244
251
|
if (Object.prototype.hasOwnProperty.call(adZones, adZoneId)) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
252
|
+
this.offScreenAdZone?.forEach(zone => {
|
|
253
|
+
if (Number(adZones[adZoneId].id) !== zone) {
|
|
254
|
+
adZoneInfoList.push({
|
|
255
|
+
zoneId: adZones[adZoneId].id,
|
|
256
|
+
adZone: /*#__PURE__*/React.createElement(AdZone, {
|
|
257
|
+
key: adZoneId,
|
|
258
|
+
appId: this.appId,
|
|
259
|
+
sessionId: this.sessionId,
|
|
260
|
+
udid: this.deviceInfo.udid,
|
|
261
|
+
deviceOs: this.deviceOs,
|
|
262
|
+
apiEnv: this.apiEnv,
|
|
263
|
+
xyDragDistanceAllowed: this.xyAdZoneDragDistanceAllowed || 25,
|
|
264
|
+
adZoneData: adZones[adZoneId],
|
|
265
|
+
onAddToListTriggered: items => {
|
|
266
|
+
safeInvoke(this.onAddToListTriggered, items);
|
|
267
|
+
},
|
|
268
|
+
isAdZoneVisible: true,
|
|
269
|
+
offScreenAdZone: false
|
|
270
|
+
})
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return adZoneInfoList;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Creates all off-screen Ad Zone Info objects based on provided off-screen Ad Zones.
|
|
281
|
+
* @param adZones - The object of available zones.
|
|
282
|
+
* @returns the array of off-screen Ad Zone Info objects.
|
|
283
|
+
*/
|
|
284
|
+
generateOffScreenAdZones(adZones) {
|
|
285
|
+
const adZoneInfoList = [];
|
|
286
|
+
for (const adZoneId in adZones) {
|
|
287
|
+
if (Object.prototype.hasOwnProperty.call(adZones, adZoneId)) {
|
|
288
|
+
this.offScreenAdZone?.forEach(zone => {
|
|
289
|
+
if (Number(adZones[adZoneId].id) === zone) {
|
|
290
|
+
adZoneInfoList.push({
|
|
291
|
+
zoneId: adZones[adZoneId].id,
|
|
292
|
+
adZone: /*#__PURE__*/React.createElement(AdZone, {
|
|
293
|
+
key: adZoneId,
|
|
294
|
+
appId: this.appId,
|
|
295
|
+
sessionId: this.sessionId,
|
|
296
|
+
udid: this.deviceInfo.udid,
|
|
297
|
+
deviceOs: this.deviceOs,
|
|
298
|
+
apiEnv: this.apiEnv,
|
|
299
|
+
xyDragDistanceAllowed: this.xyAdZoneDragDistanceAllowed || 25,
|
|
300
|
+
adZoneData: adZones[adZoneId],
|
|
301
|
+
onAddToListTriggered: items => {
|
|
302
|
+
safeInvoke(this.onAddToListTriggered, items);
|
|
303
|
+
},
|
|
304
|
+
isAdZoneVisible: this.isAdZoneVisible,
|
|
305
|
+
offScreenAdZone: true
|
|
306
|
+
})
|
|
307
|
+
});
|
|
308
|
+
}
|
|
262
309
|
});
|
|
263
310
|
}
|
|
264
311
|
}
|
|
@@ -282,6 +329,7 @@ export class AdadaptedReactNativeSdk {
|
|
|
282
329
|
}, this.deviceOs, this.apiEnv).then(response => {
|
|
283
330
|
this.sessionInfo = response.data;
|
|
284
331
|
this.adZones = this.generateAdZones(response.data.zones);
|
|
332
|
+
this.offScreenAdZones = this.generateOffScreenAdZones(response.data.zones);
|
|
285
333
|
|
|
286
334
|
// Call the user defined callback indicating
|
|
287
335
|
// the session data has been refreshed.
|
|
@@ -374,25 +422,25 @@ export class AdadaptedReactNativeSdk {
|
|
|
374
422
|
*/
|
|
375
423
|
handleDeepLink(event) {
|
|
376
424
|
const searchStr = "data=";
|
|
377
|
-
const dataIndex = event
|
|
425
|
+
const dataIndex = event.url.indexOf(searchStr);
|
|
378
426
|
if (dataIndex !== -1) {
|
|
379
|
-
const encodedData = event.url.substr(dataIndex
|
|
427
|
+
const encodedData = event.url.substr(`${dataIndex}${searchStr.length}`);
|
|
380
428
|
const payloadData = JSON.parse(base64.decode(encodedData));
|
|
381
|
-
const payloadId = payloadData
|
|
382
|
-
const itemDataList = payloadData
|
|
429
|
+
const payloadId = payloadData.payload_id;
|
|
430
|
+
const itemDataList = payloadData.detailed_list_items;
|
|
383
431
|
if (itemDataList && itemDataList.length > 0) {
|
|
384
432
|
const finalItemList = [];
|
|
385
433
|
for (const itemData of itemDataList) {
|
|
386
434
|
finalItemList.push({
|
|
387
435
|
payload_id: payloadId,
|
|
388
436
|
detailed_list_items: [{
|
|
389
|
-
product_title: itemData
|
|
390
|
-
product_brand: itemData
|
|
391
|
-
product_category: itemData
|
|
392
|
-
product_barcode: itemData
|
|
393
|
-
product_discount: itemData
|
|
394
|
-
product_image: itemData
|
|
395
|
-
product_sku: itemData
|
|
437
|
+
product_title: itemData.product_title,
|
|
438
|
+
product_brand: itemData.product_brand,
|
|
439
|
+
product_category: itemData.product_category,
|
|
440
|
+
product_barcode: itemData.product_barcode,
|
|
441
|
+
product_discount: itemData.product_discount,
|
|
442
|
+
product_image: itemData.product_image,
|
|
443
|
+
product_sku: itemData.product_sku
|
|
396
444
|
}]
|
|
397
445
|
});
|
|
398
446
|
}
|
|
@@ -428,13 +476,13 @@ export class AdadaptedReactNativeSdk {
|
|
|
428
476
|
finalItemList.push({
|
|
429
477
|
payload_id: payload.payload_id,
|
|
430
478
|
detailed_list_items: [{
|
|
431
|
-
product_title: itemData
|
|
432
|
-
product_brand: itemData
|
|
433
|
-
product_category: itemData
|
|
434
|
-
product_barcode: itemData
|
|
435
|
-
product_discount: itemData
|
|
436
|
-
product_image: itemData
|
|
437
|
-
product_sku: itemData
|
|
479
|
+
product_title: itemData.product_title,
|
|
480
|
+
product_brand: itemData.product_brand,
|
|
481
|
+
product_category: itemData.product_category,
|
|
482
|
+
product_barcode: itemData.product_barcode,
|
|
483
|
+
product_discount: itemData.product_discount,
|
|
484
|
+
product_image: itemData.product_image,
|
|
485
|
+
product_sku: itemData.product_sku
|
|
438
486
|
}]
|
|
439
487
|
});
|
|
440
488
|
}
|
|
@@ -449,9 +497,9 @@ export class AdadaptedReactNativeSdk {
|
|
|
449
497
|
|
|
450
498
|
/**
|
|
451
499
|
* Notify the ad zone of visibility status change for off-screen ads.
|
|
500
|
+
* @param isVisible - Ad Zone visibility tracking.
|
|
452
501
|
*/
|
|
453
|
-
onAdZoneVisibilityChanged() {
|
|
454
|
-
const isVisible = !this.isAdZoneVisible;
|
|
502
|
+
onAdZoneVisibilityChanged(isVisible) {
|
|
455
503
|
this.isAdZoneVisible = isVisible;
|
|
456
504
|
DeviceEventEmitter.emit("visibility-event", isVisible);
|
|
457
505
|
}
|
|
@@ -516,10 +564,9 @@ export class AdadaptedReactNativeSdk {
|
|
|
516
564
|
this.onOutOfAppPayloadAvailable = props.onOutOfAppPayloadAvailable;
|
|
517
565
|
}
|
|
518
566
|
|
|
519
|
-
// If provided
|
|
520
|
-
if (props.
|
|
521
|
-
this.
|
|
522
|
-
this.onAdZoneVisibilityChanged();
|
|
567
|
+
// If provided set any off-screen ad zones.
|
|
568
|
+
if (props.offScreenAdZone) {
|
|
569
|
+
this.offScreenAdZone = props.offScreenAdZone;
|
|
523
570
|
}
|
|
524
571
|
return new Promise((resolve, reject) => {
|
|
525
572
|
this.getDeviceInformation().then(deviceInfoObj => {
|
|
@@ -555,6 +602,7 @@ export class AdadaptedReactNativeSdk {
|
|
|
555
602
|
this.sessionId = response.data.session_id;
|
|
556
603
|
this.sessionInfo = response.data;
|
|
557
604
|
this.adZones = this.generateAdZones(response.data.zones);
|
|
605
|
+
this.offScreenAdZones = this.generateOffScreenAdZones(response.data.zones);
|
|
558
606
|
|
|
559
607
|
// Start the session data refresh timer.
|
|
560
608
|
this.onRefreshAdZones();
|
|
@@ -580,12 +628,15 @@ export class AdadaptedReactNativeSdk {
|
|
|
580
628
|
this.getPayloadItemData();
|
|
581
629
|
|
|
582
630
|
// Initialize an event listener to intercept deep links while the app is running.
|
|
583
|
-
|
|
584
631
|
this.deepLinkOnEventListener = Linking.addEventListener("url", this.handleDeepLink);
|
|
585
632
|
|
|
586
|
-
// Initialize an event listener to intercept App state changes.
|
|
633
|
+
// // Initialize an event listener to intercept App state changes.
|
|
634
|
+
// this.AppStateOnEventListener =
|
|
635
|
+
// AppState.addEventListener(
|
|
636
|
+
// "change",
|
|
637
|
+
// this.handleAppStateChange
|
|
638
|
+
// );
|
|
587
639
|
|
|
588
|
-
this.AppStateOnEventListener = AppState.addEventListener("change", this.handleAppStateChange);
|
|
589
640
|
resolve();
|
|
590
641
|
}).catch(err => {
|
|
591
642
|
reject(err);
|