@uptick-ads/react-native-web-sdk 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/index.d.ts +16 -3
- package/package.json +17 -3
- package/src/UptickFlow.js +9 -7
- package/src/version.js +1 -1
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ Because both presentations work from the same mount point, Uptick can switch a p
|
|
|
51
51
|
| `openUrl` | `Linking.openURL` | How accepted offers open; supply your own to use an in-app browser |
|
|
52
52
|
| `style` | | Style for the inline slot |
|
|
53
53
|
| `modal` | | Presentation options for the popup. Any option set here is reported to Uptick with the flow, with its value, so performance can be read against it. |
|
|
54
|
-
| `webViewProps` | | Extra props passed through to `WebView` |
|
|
54
|
+
| `webViewProps` | | Extra props passed through to `WebView`, except the ones the component sets itself: `source`, `originWhitelist`, `javaScriptEnabled`, `domStorageEnabled`, `setSupportMultipleWindows`, `onMessage`, `onShouldStartLoadWithRequest` and `onOpenWindow` |
|
|
55
55
|
| `host` | `api.uptick.com` | API host, only for testing against other environments |
|
|
56
56
|
|
|
57
57
|
### Flow parameters
|
|
@@ -71,7 +71,7 @@ The component adds `render_type` (`{ rendered: "inline" | "popup" }`) once the f
|
|
|
71
71
|
|
|
72
72
|
## How click-out works
|
|
73
73
|
|
|
74
|
-
When a user accepts an offer the SDK opens the advertiser link with `window.open`. The component receives that through `onOpenWindow`, hands the URL to `openUrl`, and the page inside the WebView stays put, so the SDK moves on to the next offer while the user is in the browser.
|
|
74
|
+
When a user accepts an offer the SDK opens the advertiser link with `window.open`. The component receives that through `onOpenWindow`, hands the URL to `openUrl`, and the page inside the WebView stays put, so the SDK moves on to the next offer while the user is in the browser.
|
|
75
75
|
|
|
76
76
|
## Demo
|
|
77
77
|
|
package/index.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ export interface UptickFlowParams {
|
|
|
20
20
|
country_code?: string;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
export type UptickPlacement = "checkout" | "order_confirmation" | "order_status" | (string & {});
|
|
24
|
+
|
|
23
25
|
export interface UptickModalOptions {
|
|
24
26
|
/** Colour of the dimmed layer behind the card. */
|
|
25
27
|
backgroundColor?: string;
|
|
@@ -28,14 +30,25 @@ export interface UptickModalOptions {
|
|
|
28
30
|
maxCardHeight?: number;
|
|
29
31
|
}
|
|
30
32
|
|
|
33
|
+
/** Props the component sets on the WebView itself, which webViewProps cannot override. */
|
|
34
|
+
export type ReservedWebViewProp =
|
|
35
|
+
| "source"
|
|
36
|
+
| "originWhitelist"
|
|
37
|
+
| "javaScriptEnabled"
|
|
38
|
+
| "domStorageEnabled"
|
|
39
|
+
| "setSupportMultipleWindows"
|
|
40
|
+
| "onMessage"
|
|
41
|
+
| "onShouldStartLoadWithRequest"
|
|
42
|
+
| "onOpenWindow";
|
|
43
|
+
|
|
31
44
|
export interface UptickFlowProps extends UptickFlowParams {
|
|
32
45
|
integrationId: string;
|
|
33
|
-
placement?:
|
|
46
|
+
placement?: UptickPlacement;
|
|
34
47
|
callback?: (event: string, data: unknown) => void;
|
|
35
48
|
openUrl?: (url: string) => void | Promise<unknown>;
|
|
36
49
|
style?: StyleProp<ViewStyle>;
|
|
37
50
|
modal?: UptickModalOptions;
|
|
38
|
-
webViewProps?: Partial<ComponentProps<typeof WebView
|
|
51
|
+
webViewProps?: Omit<Partial<ComponentProps<typeof WebView>>, ReservedWebViewProp>;
|
|
39
52
|
host?: string;
|
|
40
53
|
}
|
|
41
54
|
|
|
@@ -45,5 +58,5 @@ export const version: string;
|
|
|
45
58
|
export function customizations(modal?: UptickModalOptions): Record<string, string>;
|
|
46
59
|
export const FLOW_PARAMS: ReadonlyArray<keyof UptickFlowParams>;
|
|
47
60
|
export function pickFlowParams(props: Record<string, unknown>): UptickFlowParams;
|
|
48
|
-
export function buildEmbedUrl(options: { host: string; integrationId: string; placement?:
|
|
61
|
+
export function buildEmbedUrl(options: { host: string; integrationId: string; placement?: UptickPlacement; params?: UptickFlowParams; version?: string; customization?: Record<string, string> }): string;
|
|
49
62
|
export function embedPath(host: string, integrationId: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uptick-ads/react-native-web-sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "React Native component that runs the Uptick web SDK inside a WebView, inline or as a popup, with the web integration's parameters",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"uptick",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"types": "index.d.ts",
|
|
24
24
|
"files": [
|
|
25
25
|
"src",
|
|
26
|
+
"!src/**/*.test.js",
|
|
26
27
|
"index.d.ts",
|
|
27
28
|
"README.md",
|
|
28
29
|
"LICENSE"
|
|
@@ -41,7 +42,20 @@
|
|
|
41
42
|
},
|
|
42
43
|
"scripts": {
|
|
43
44
|
"check": "node --check src/index.js && node --check src/UptickFlow.js && node --check src/embedUrl.js && node --check src/version.js && node -e \"const p=require('./package.json');const v=require('fs').readFileSync('src/version.js','utf8');if(!v.includes('\\\"'+p.version+'\\\"'))throw new Error('src/version.js is out of step with package.json')\" && npm pack --dry-run",
|
|
44
|
-
"prepublishOnly": "npm run check"
|
|
45
|
+
"prepublishOnly": "npm run check && npm test",
|
|
46
|
+
"test": "jest --selectProjects unit",
|
|
47
|
+
"test:e2e": "jest --selectProjects e2e"
|
|
45
48
|
},
|
|
46
|
-
"private": false
|
|
49
|
+
"private": false,
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@react-native/babel-preset": "^0.88.0",
|
|
52
|
+
"@react-native/jest-preset": "^0.88.0",
|
|
53
|
+
"@testing-library/react-native": "^14.1.0",
|
|
54
|
+
"jest": "^29.7.0",
|
|
55
|
+
"playwright": "^1.64.1",
|
|
56
|
+
"react": "^19.3.1",
|
|
57
|
+
"react-native": "^0.88.0",
|
|
58
|
+
"react-native-webview": "^13.17.0",
|
|
59
|
+
"test-renderer": "^1.3.1"
|
|
60
|
+
}
|
|
47
61
|
}
|
package/src/UptickFlow.js
CHANGED
|
@@ -7,7 +7,7 @@ import { version as SDK_VERSION } from "./version";
|
|
|
7
7
|
const DEFAULT_HOST = "api.uptick.com";
|
|
8
8
|
const MAX_HEIGHT = 1400;
|
|
9
9
|
|
|
10
|
-
// Messages from the host page that the component acts on itself; every message is also forwarded to `callback`.
|
|
10
|
+
// Messages from the host page that the component acts on itself; every message except `height` is also forwarded to `callback`.
|
|
11
11
|
const SHOW_EVENTS = ["offer_viewed"];
|
|
12
12
|
const HIDE_EVENTS = ["flow_complete", "flow_closed"];
|
|
13
13
|
|
|
@@ -65,6 +65,7 @@ export function UptickFlow({
|
|
|
65
65
|
} catch (error) {
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
|
+
if (!message || typeof message !== "object") return;
|
|
68
69
|
const { name, data } = message;
|
|
69
70
|
if (name === "height") {
|
|
70
71
|
setHeight(Math.min(Math.max(Number(data && data.height) || 0, 0), MAX_HEIGHT));
|
|
@@ -113,6 +114,13 @@ export function UptickFlow({
|
|
|
113
114
|
|
|
114
115
|
const webView = (
|
|
115
116
|
<WebView
|
|
117
|
+
onError={(event) => emit.current && emit.current("webview_error", { description: event.nativeEvent.description })}
|
|
118
|
+
onHttpError={(event) => emit.current && emit.current("webview_http_error", { status: event.nativeEvent.statusCode, url: event.nativeEvent.url })}
|
|
119
|
+
scrollEnabled={false}
|
|
120
|
+
nestedScrollEnabled
|
|
121
|
+
opaque={false}
|
|
122
|
+
{...webViewProps}
|
|
123
|
+
// These follow the spread so webViewProps can't break messaging or click-out.
|
|
116
124
|
source={source}
|
|
117
125
|
originWhitelist={["*"]}
|
|
118
126
|
javaScriptEnabled
|
|
@@ -121,12 +129,6 @@ export function UptickFlow({
|
|
|
121
129
|
onMessage={onMessage}
|
|
122
130
|
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
|
|
123
131
|
onOpenWindow={onOpenWindow}
|
|
124
|
-
onError={(event) => emit.current && emit.current("webview_error", { description: event.nativeEvent.description })}
|
|
125
|
-
onHttpError={(event) => emit.current && emit.current("webview_http_error", { status: event.nativeEvent.statusCode, url: event.nativeEvent.url })}
|
|
126
|
-
scrollEnabled={false}
|
|
127
|
-
nestedScrollEnabled
|
|
128
|
-
opaque={false}
|
|
129
|
-
{...webViewProps}
|
|
130
132
|
style={[styles.transparent, { height: isPopup ? Math.min(contentHeight, maxCardHeight) : contentHeight }, webViewProps && webViewProps.style]}
|
|
131
133
|
/>
|
|
132
134
|
);
|
package/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Kept in step with package.json by the release pipeline; the API records it on every event as integration_version.
|
|
2
|
-
export const version = "0.3.
|
|
2
|
+
export const version = "0.3.2";
|