@uptick-ads/react-native-web-sdk 0.2.8 → 0.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/README.md +2 -2
- package/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/UptickFlow.js +5 -5
- package/src/embedUrl.js +13 -10
- package/src/version.js +1 -1
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ Because both presentations work from the same mount point, Uptick can switch a p
|
|
|
50
50
|
| `callback` | | `(event, data)`, the same events as the web SDK callback |
|
|
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
|
-
| `modal` | | Presentation options for the popup. Any option set here is reported to Uptick with the flow
|
|
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
54
|
| `webViewProps` | | Extra props passed through to `WebView` |
|
|
55
55
|
| `host` | `api.uptick.com` | API host, only for testing against other environments |
|
|
56
56
|
|
|
@@ -66,7 +66,7 @@ They travel in the URL fragment, which is never sent to a server, so they do not
|
|
|
66
66
|
|
|
67
67
|
### Events
|
|
68
68
|
|
|
69
|
-
`callback` receives the web SDK's lifecycle events with the same names and payloads: `init`, `flow_initialized`, `flow_delayed`, `offer_requested`, `offer_viewed`, `offer_accepted`, `offer_rejected`, `flow_complete`,
|
|
69
|
+
`callback` receives the web SDK's lifecycle events with the same names and payloads: `init`, `flow_initialized`, `flow_delayed`, `offer_requested`, `offer_viewed`, `offer_accepted`, `offer_rejected`, `flow_complete`, and `flow_closed` when the user closes the offer.
|
|
70
70
|
The component adds `render_type` (`{ rendered: "inline" | "popup" }`) once the first offer renders, `popup_dismissed`, `webview_error`, `webview_http_error` and `open_url_failed`.
|
|
71
71
|
|
|
72
72
|
## How click-out works
|
package/index.d.ts
CHANGED
|
@@ -42,8 +42,8 @@ export interface UptickFlowProps extends UptickFlowParams {
|
|
|
42
42
|
export function UptickFlow(props: UptickFlowProps): JSX.Element;
|
|
43
43
|
|
|
44
44
|
export const version: string;
|
|
45
|
-
export function customizations(modal?: UptickModalOptions): string
|
|
45
|
+
export function customizations(modal?: UptickModalOptions): Record<string, string>;
|
|
46
46
|
export const FLOW_PARAMS: ReadonlyArray<keyof UptickFlowParams>;
|
|
47
47
|
export function pickFlowParams(props: Record<string, unknown>): UptickFlowParams;
|
|
48
|
-
export function buildEmbedUrl(options: { host: string; integrationId: string; placement?: string; params?: UptickFlowParams; version?: string;
|
|
48
|
+
export function buildEmbedUrl(options: { host: string; integrationId: string; placement?: string; params?: UptickFlowParams; version?: string; customization?: Record<string, string> }): string;
|
|
49
49
|
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
|
+
"version": "0.3.0",
|
|
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",
|
package/src/UptickFlow.js
CHANGED
|
@@ -9,7 +9,7 @@ const MAX_HEIGHT = 1400;
|
|
|
9
9
|
|
|
10
10
|
// Messages from the host page that the component acts on itself; every message is also forwarded to `callback`.
|
|
11
11
|
const SHOW_EVENTS = ["offer_viewed"];
|
|
12
|
-
const HIDE_EVENTS = ["flow_complete", "
|
|
12
|
+
const HIDE_EVENTS = ["flow_complete", "flow_closed"];
|
|
13
13
|
|
|
14
14
|
const FILL = { position: "absolute", top: 0, left: 0, right: 0, bottom: 0 };
|
|
15
15
|
|
|
@@ -34,13 +34,13 @@ export function UptickFlow({
|
|
|
34
34
|
|
|
35
35
|
const params = pickFlowParams(flowProps);
|
|
36
36
|
const paramsKey = JSON.stringify(params);
|
|
37
|
-
const
|
|
38
|
-
const
|
|
37
|
+
const customization = customizations(modal);
|
|
38
|
+
const customizationKey = JSON.stringify(customization);
|
|
39
39
|
const source = useMemo(
|
|
40
|
-
() => ({ uri: buildEmbedUrl({ host, integrationId, placement, params, version: SDK_VERSION,
|
|
40
|
+
() => ({ uri: buildEmbedUrl({ host, integrationId, placement, params, version: SDK_VERSION, customization }) }),
|
|
41
41
|
// Callers pass fresh prop values each render; key on the serialised params so the page does not reload on every parent render.
|
|
42
42
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
43
|
-
[host, integrationId, placement, paramsKey,
|
|
43
|
+
[host, integrationId, placement, paramsKey, customizationKey]
|
|
44
44
|
);
|
|
45
45
|
const ownPath = embedPath(host, integrationId);
|
|
46
46
|
|
package/src/embedUrl.js
CHANGED
|
@@ -41,21 +41,24 @@ export function embedPath(host, integrationId) {
|
|
|
41
41
|
return `https://${host}/v1/places/${encodeURIComponent(integrationId)}/embed`;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
//
|
|
44
|
+
// The presentation options a host customised, with their values. They travel as a nested flow parameter, so every event stores them under `customization` in its data like any other extra parameter, and reporting can read a tuned integration's actual settings when performance differs.
|
|
45
45
|
export function customizations(modal) {
|
|
46
|
-
if (!modal) return
|
|
47
|
-
const
|
|
48
|
-
if (modal.backgroundColor !== undefined)
|
|
49
|
-
if (modal.cardStyle !== undefined)
|
|
50
|
-
if (modal.insets !== undefined)
|
|
51
|
-
if (modal.maxCardHeight !== undefined)
|
|
52
|
-
return
|
|
46
|
+
if (!modal) return {};
|
|
47
|
+
const out = {};
|
|
48
|
+
if (modal.backgroundColor !== undefined) out.backgroundColor = String(modal.backgroundColor);
|
|
49
|
+
if (modal.cardStyle !== undefined) out.cardStyle = JSON.stringify(modal.cardStyle);
|
|
50
|
+
if (modal.insets !== undefined) out.insets = JSON.stringify(modal.insets);
|
|
51
|
+
if (modal.maxCardHeight !== undefined) out.maxCardHeight = String(modal.maxCardHeight);
|
|
52
|
+
return out;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
export function buildEmbedUrl({ host, integrationId, placement, params, version,
|
|
55
|
+
export function buildEmbedUrl({ host, integrationId, placement, params, version, customization }) {
|
|
56
56
|
if (!integrationId) throw new Error("UptickFlow: integrationId is required");
|
|
57
57
|
// The page renders whatever presentation the placement's template defines; `native` only asks it to leave the popup chrome to the app.
|
|
58
58
|
const search = encodeQuery({ placement, variant: "native", integration_version: version });
|
|
59
|
-
|
|
59
|
+
// Nested with bracket keys, the same shape the API stores for any other nested parameter.
|
|
60
|
+
const nested = {};
|
|
61
|
+
Object.keys(customization || {}).forEach((key) => { nested[`customization[${key}]`] = customization[key]; });
|
|
62
|
+
const fragment = encodeQuery({ ...(params || {}), ...nested });
|
|
60
63
|
return `${embedPath(host, integrationId)}?${search}${fragment ? `#${fragment}` : ""}`;
|
|
61
64
|
}
|
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.
|
|
2
|
+
export const version = "0.3.0";
|