react-native-revnix 1.9.0 → 2.0.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 +1 -1
- package/dist/client.d.ts +5 -1
- package/dist/client.js +10 -0
- package/dist/esm/client.js +10 -0
- package/dist/esm/ui/RevnixPaywall.js +23 -4
- package/dist/esm/version.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/ui/RevnixPaywall.d.ts +2 -1
- package/dist/ui/RevnixPaywall.js +23 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/client.ts +21 -0
- package/src/index.ts +1 -0
- package/src/types.ts +10 -0
- package/src/ui/RevnixPaywall.tsx +34 -5
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -175,7 +175,7 @@ It runs once per customer, waits at most 10 seconds and never blocks the report.
|
|
|
175
175
|
|
|
176
176
|
- **React Native** 0.72 or later, New Architecture and legacy architecture alike. iOS 15.1 or later (StoreKit 2), Android with Google Play Billing 8.
|
|
177
177
|
- **Expo**: supported with a development build. Expo Go cannot load the store module.
|
|
178
|
-
- **React and Next.js**: the same package powers web apps; the store module is mobile only, web registers purchases from your server. See [React](https://www.revnix.io/docs/react).
|
|
178
|
+
- **React and Next.js**: the same package powers web apps; the store module is mobile only, web registers purchases from your server. In a browser pass `fetch: (input, init) => fetch(input, init)` to `configure`, and note the `/v1` API does not answer CORS preflight today, so route calls through your own backend (set `baseUrl` to your proxy) or gate server-side over REST. See [React](https://www.revnix.io/docs/react).
|
|
179
179
|
- **Other platforms**: Revnix also ships SDKs for [iOS](https://www.revnix.io/docs/ios), [Android](https://www.revnix.io/docs/android), [Flutter](https://www.revnix.io/docs/flutter), [Capacitor](https://www.revnix.io/docs/capacitor) and [Unity](https://www.revnix.io/docs/unity).
|
|
180
180
|
- Ships CommonJS and ESM builds, tree-shakeable, with full TypeScript types.
|
|
181
181
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AdRevenue, AliasResult, CustomerEntitlements, IdentifyResult, IdentifyStrategy, IdentityInfo, LastDeepLink, MmpAttribution, PaywallInteraction, PlacementResolution, RegisterPurchaseInput, RegisterPurchaseResult, RevnixAttribution, RevnixConfig } from "./types.js";
|
|
1
|
+
import type { AdRevenue, AliasResult, CustomerEntitlements, IdentifyResult, IdentifyStrategy, IdentityInfo, LastDeepLink, MmpAttribution, PaywallInteraction, PaywallProductShown, PlacementResolution, RegisterPurchaseInput, RegisterPurchaseResult, RevnixAttribution, RevnixConfig } from "./types.js";
|
|
2
2
|
export declare function paywallImageUrls(value: unknown): string[];
|
|
3
3
|
export declare class RevnixClient {
|
|
4
4
|
private readonly apiKey;
|
|
@@ -195,6 +195,10 @@ export declare class RevnixClient {
|
|
|
195
195
|
logPaywallShown(options?: {
|
|
196
196
|
placementKey?: string;
|
|
197
197
|
paywallId?: string;
|
|
198
|
+
/** The plans the paywall drew, with the localized price each showed.
|
|
199
|
+
* RevnixPaywall fills this from its packages; a headless paywall passes
|
|
200
|
+
* what it rendered. */
|
|
201
|
+
productsShown?: PaywallProductShown[];
|
|
198
202
|
}): string;
|
|
199
203
|
/** Report that the customer dismissed a paywall (REV-252) — the other half
|
|
200
204
|
* of a display's life. Fire-and-forget and idempotent per view id, exactly
|
package/dist/client.js
CHANGED
|
@@ -143,6 +143,13 @@ function wellFormedIntegrity(evidence) {
|
|
|
143
143
|
}
|
|
144
144
|
return undefined;
|
|
145
145
|
}
|
|
146
|
+
const MAX_PRODUCTS_SHOWN = 20;
|
|
147
|
+
const MAX_PRICE_LABEL_LENGTH = 64;
|
|
148
|
+
function boundedProductsShown(products) {
|
|
149
|
+
return products.slice(0, MAX_PRODUCTS_SHOWN).map((product) => product.priceLabel !== undefined
|
|
150
|
+
? { ...product, priceLabel: product.priceLabel.slice(0, MAX_PRICE_LABEL_LENGTH) }
|
|
151
|
+
: product);
|
|
152
|
+
}
|
|
146
153
|
class RevnixClient {
|
|
147
154
|
constructor(config) {
|
|
148
155
|
/** True while the current id is a generated anon id living on
|
|
@@ -774,6 +781,9 @@ class RevnixClient {
|
|
|
774
781
|
sdkVersion: version_js_1.SDK_VERSION,
|
|
775
782
|
...(options?.placementKey ? { placementKey: options.placementKey } : {}),
|
|
776
783
|
...(options?.paywallId ? { paywallId: options.paywallId } : {}),
|
|
784
|
+
...(options?.productsShown?.length
|
|
785
|
+
? { productsShown: boundedProductsShown(options.productsShown) }
|
|
786
|
+
: {}),
|
|
777
787
|
}))
|
|
778
788
|
.catch((err) => this.diag("logPaywallShown", err));
|
|
779
789
|
return viewId;
|
package/dist/esm/client.js
CHANGED
|
@@ -139,6 +139,13 @@ function wellFormedIntegrity(evidence) {
|
|
|
139
139
|
}
|
|
140
140
|
return undefined;
|
|
141
141
|
}
|
|
142
|
+
const MAX_PRODUCTS_SHOWN = 20;
|
|
143
|
+
const MAX_PRICE_LABEL_LENGTH = 64;
|
|
144
|
+
function boundedProductsShown(products) {
|
|
145
|
+
return products.slice(0, MAX_PRODUCTS_SHOWN).map((product) => product.priceLabel !== undefined
|
|
146
|
+
? { ...product, priceLabel: product.priceLabel.slice(0, MAX_PRICE_LABEL_LENGTH) }
|
|
147
|
+
: product);
|
|
148
|
+
}
|
|
142
149
|
export class RevnixClient {
|
|
143
150
|
constructor(config) {
|
|
144
151
|
/** True while the current id is a generated anon id living on
|
|
@@ -770,6 +777,9 @@ export class RevnixClient {
|
|
|
770
777
|
sdkVersion: SDK_VERSION,
|
|
771
778
|
...(options?.placementKey ? { placementKey: options.placementKey } : {}),
|
|
772
779
|
...(options?.paywallId ? { paywallId: options.paywallId } : {}),
|
|
780
|
+
...(options?.productsShown?.length
|
|
781
|
+
? { productsShown: boundedProductsShown(options.productsShown) }
|
|
782
|
+
: {}),
|
|
773
783
|
}))
|
|
774
784
|
.catch((err) => this.diag("logPaywallShown", err));
|
|
775
785
|
return viewId;
|
|
@@ -82,6 +82,23 @@ const CARD_BG = { dark: "#181b22", light: "#f4f5f7" };
|
|
|
82
82
|
export async function prefetchPaywallImages(resolution) {
|
|
83
83
|
await Promise.all(paywallImageUrls(resolution?.paywall).map((url) => Image.prefetch(url).catch(() => false)));
|
|
84
84
|
}
|
|
85
|
+
function visiblePackages(config, packages) {
|
|
86
|
+
return config.template === "minimal" && config.highlightPackageId
|
|
87
|
+
? packages.filter((p) => p.packageId === config.highlightPackageId)
|
|
88
|
+
: packages;
|
|
89
|
+
}
|
|
90
|
+
function productsShownFrom(packages) {
|
|
91
|
+
return packages.flatMap((pkg) => pkg.productId
|
|
92
|
+
? [
|
|
93
|
+
{
|
|
94
|
+
productId: pkg.productId,
|
|
95
|
+
priceLabel: pkg.priceLabel,
|
|
96
|
+
amountMinor: pkg.amountMinor,
|
|
97
|
+
currency: pkg.currency,
|
|
98
|
+
},
|
|
99
|
+
]
|
|
100
|
+
: []);
|
|
101
|
+
}
|
|
85
102
|
export function RevnixPaywall(props) {
|
|
86
103
|
// One view per mount: remounting (a re-shown paywall) is a genuine new
|
|
87
104
|
// display; re-renders are not.
|
|
@@ -92,7 +109,11 @@ export function RevnixPaywall(props) {
|
|
|
92
109
|
React.useEffect(() => {
|
|
93
110
|
if (!client || disableViewTracking)
|
|
94
111
|
return;
|
|
95
|
-
const id = client.logPaywallShown({
|
|
112
|
+
const id = client.logPaywallShown({
|
|
113
|
+
placementKey,
|
|
114
|
+
paywallId,
|
|
115
|
+
productsShown: productsShownFrom(visiblePackages(props.config, props.packages)),
|
|
116
|
+
});
|
|
96
117
|
// Pre-REV-252 clients return void; the close then still fires the host
|
|
97
118
|
// callback, it just cannot be paired with this display.
|
|
98
119
|
if (typeof id === "string")
|
|
@@ -322,9 +343,7 @@ function ClassicPaywall(props) {
|
|
|
322
343
|
const layout = config.template;
|
|
323
344
|
// Same template semantics as the dashboard preview: "minimal" shows only
|
|
324
345
|
// the highlighted package; feature bullets render on the feature layouts.
|
|
325
|
-
const shown =
|
|
326
|
-
? packages.filter((p) => p.packageId === config.highlightPackageId)
|
|
327
|
-
: packages;
|
|
346
|
+
const shown = visiblePackages(config, packages);
|
|
328
347
|
const [internalSelected, setInternalSelected] = React.useState(undefined);
|
|
329
348
|
const fallbackSelected = shown.find((p) => p.packageId === config.highlightPackageId)?.packageId ??
|
|
330
349
|
shown[0]?.packageId;
|
package/dist/esm/version.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// L3: the single source of the SDK version inside src/. Must match
|
|
2
2
|
// package.json "version" — version.test.ts fails the build when they drift
|
|
3
3
|
// (they had: client.ts said 0.7.0 while the package shipped 0.9.0).
|
|
4
|
-
export const SDK_VERSION = "
|
|
4
|
+
export const SDK_VERSION = "2.0.0";
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export { memoryStorage, generateAnonymousId } from "./storage.js";
|
|
|
9
9
|
export { SDK_VERSION } from "./version.js";
|
|
10
10
|
export { DEVICE_HEADER, encodeDeviceHeader } from "./device.js";
|
|
11
11
|
export { browserLifecycle, DEFAULT_SESSION_TIMEOUT_MS, HOST_CALL_PLACEMENT, IMPLICIT_PLACEMENTS, PREVIEW_PLACEMENT_KEY, type ImplicitPlacement, type ImplicitSkipReason, type ImplicitTrigger, type ImplicitTriggerResponse, type RevnixLifecycle, } from "./implicit.js";
|
|
12
|
-
export type { AdRevenue, AliasResult, CustomerEntitlements, DeviceFacts, Entitlement, EntitlementSource, Environment, IdentifyResult, IdentifyStrategy, IdentityInfo, ImplicitResolution, IntegrityEvidence, LastDeepLink, MmpAttribution, MmpProvider, PaywallConfig, PaywallInteraction, PaywallPurchaseOutcome, PlacementOffering, PlacementPackage, PlacementPaywall, PlacementProduct, PlacementResolution, RegisterPurchaseInput, RegisterPurchaseResult, RevnixAttribution, RevnixConfig, RevnixDiagnostic, RevnixStorage, Store, } from "./types.js";
|
|
12
|
+
export type { AdRevenue, AliasResult, CustomerEntitlements, DeviceFacts, Entitlement, EntitlementSource, Environment, IdentifyResult, IdentifyStrategy, IdentityInfo, ImplicitResolution, IntegrityEvidence, LastDeepLink, MmpAttribution, MmpProvider, PaywallConfig, PaywallInteraction, PaywallProductShown, PaywallPurchaseOutcome, PlacementOffering, PlacementPackage, PlacementPaywall, PlacementProduct, PlacementResolution, RegisterPurchaseInput, RegisterPurchaseResult, RevnixAttribution, RevnixConfig, RevnixDiagnostic, RevnixStorage, Store, } from "./types.js";
|
|
13
13
|
/** Singleton facade — configure once at app start, then import `Revnix`
|
|
14
14
|
* anywhere. Prefer constructing RevnixClient directly in tests. */
|
|
15
15
|
export declare const Revnix: {
|
package/dist/types.d.ts
CHANGED
|
@@ -343,6 +343,15 @@ export interface PlacementPackage {
|
|
|
343
343
|
metadata?: Record<string, unknown>;
|
|
344
344
|
product: PlacementProduct | null;
|
|
345
345
|
}
|
|
346
|
+
/** One plan as a paywall drew it, for `logPaywallShown`'s `productsShown`:
|
|
347
|
+
* the localized label the customer actually read, and the catalog price
|
|
348
|
+
* behind it. */
|
|
349
|
+
export interface PaywallProductShown {
|
|
350
|
+
productId: string;
|
|
351
|
+
priceLabel?: string;
|
|
352
|
+
amountMinor?: number;
|
|
353
|
+
currency?: string;
|
|
354
|
+
}
|
|
346
355
|
export interface PlacementProduct {
|
|
347
356
|
productId: string;
|
|
348
357
|
displayName: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type StyleProp, type ViewStyle } from "react-native";
|
|
3
|
-
import type { PaywallConfig, PaywallInteraction, PaywallPurchaseOutcome, PlacementResolution, RegisterPurchaseResult } from "../types.js";
|
|
3
|
+
import type { PaywallConfig, PaywallInteraction, PaywallProductShown, PaywallPurchaseOutcome, PlacementResolution, RegisterPurchaseResult } from "../types.js";
|
|
4
4
|
import { type RevnixClient } from "../client.js";
|
|
5
5
|
import type { FontFamilyMap } from "../blocks/style.js";
|
|
6
6
|
import { type RevnixBlurComponent, type RevnixGradientComponent } from "./RevnixBlockPaywall.js";
|
|
@@ -90,6 +90,7 @@ export interface RevnixPaywallProps {
|
|
|
90
90
|
logPaywallShown: (options?: {
|
|
91
91
|
placementKey?: string;
|
|
92
92
|
paywallId?: string;
|
|
93
|
+
productsShown?: PaywallProductShown[];
|
|
93
94
|
}) => string | void;
|
|
94
95
|
/** Older clients predate close reporting; the paywall still closes. */
|
|
95
96
|
logPaywallClosed?: (viewId: string, options?: {
|
package/dist/ui/RevnixPaywall.js
CHANGED
|
@@ -120,6 +120,23 @@ const CARD_BG = { dark: "#181b22", light: "#f4f5f7" };
|
|
|
120
120
|
async function prefetchPaywallImages(resolution) {
|
|
121
121
|
await Promise.all((0, client_js_1.paywallImageUrls)(resolution?.paywall).map((url) => react_native_1.Image.prefetch(url).catch(() => false)));
|
|
122
122
|
}
|
|
123
|
+
function visiblePackages(config, packages) {
|
|
124
|
+
return config.template === "minimal" && config.highlightPackageId
|
|
125
|
+
? packages.filter((p) => p.packageId === config.highlightPackageId)
|
|
126
|
+
: packages;
|
|
127
|
+
}
|
|
128
|
+
function productsShownFrom(packages) {
|
|
129
|
+
return packages.flatMap((pkg) => pkg.productId
|
|
130
|
+
? [
|
|
131
|
+
{
|
|
132
|
+
productId: pkg.productId,
|
|
133
|
+
priceLabel: pkg.priceLabel,
|
|
134
|
+
amountMinor: pkg.amountMinor,
|
|
135
|
+
currency: pkg.currency,
|
|
136
|
+
},
|
|
137
|
+
]
|
|
138
|
+
: []);
|
|
139
|
+
}
|
|
123
140
|
function RevnixPaywall(props) {
|
|
124
141
|
// One view per mount: remounting (a re-shown paywall) is a genuine new
|
|
125
142
|
// display; re-renders are not.
|
|
@@ -130,7 +147,11 @@ function RevnixPaywall(props) {
|
|
|
130
147
|
React.useEffect(() => {
|
|
131
148
|
if (!client || disableViewTracking)
|
|
132
149
|
return;
|
|
133
|
-
const id = client.logPaywallShown({
|
|
150
|
+
const id = client.logPaywallShown({
|
|
151
|
+
placementKey,
|
|
152
|
+
paywallId,
|
|
153
|
+
productsShown: productsShownFrom(visiblePackages(props.config, props.packages)),
|
|
154
|
+
});
|
|
134
155
|
// Pre-REV-252 clients return void; the close then still fires the host
|
|
135
156
|
// callback, it just cannot be paired with this display.
|
|
136
157
|
if (typeof id === "string")
|
|
@@ -360,9 +381,7 @@ function ClassicPaywall(props) {
|
|
|
360
381
|
const layout = config.template;
|
|
361
382
|
// Same template semantics as the dashboard preview: "minimal" shows only
|
|
362
383
|
// the highlighted package; feature bullets render on the feature layouts.
|
|
363
|
-
const shown =
|
|
364
|
-
? packages.filter((p) => p.packageId === config.highlightPackageId)
|
|
365
|
-
: packages;
|
|
384
|
+
const shown = visiblePackages(config, packages);
|
|
366
385
|
const [internalSelected, setInternalSelected] = React.useState(undefined);
|
|
367
386
|
const fallbackSelected = shown.find((p) => p.packageId === config.highlightPackageId)?.packageId ??
|
|
368
387
|
shown[0]?.packageId;
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "
|
|
1
|
+
export declare const SDK_VERSION = "2.0.0";
|
package/dist/version.js
CHANGED
|
@@ -4,4 +4,4 @@ exports.SDK_VERSION = void 0;
|
|
|
4
4
|
// L3: the single source of the SDK version inside src/. Must match
|
|
5
5
|
// package.json "version" — version.test.ts fails the build when they drift
|
|
6
6
|
// (they had: client.ts said 0.7.0 while the package shipped 0.9.0).
|
|
7
|
-
exports.SDK_VERSION = "
|
|
7
|
+
exports.SDK_VERSION = "2.0.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-revnix",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Revnix SDK for React, React Native & Next.js: purchase registration, entitlements, identity, and placements over the Revnix /v1 API.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/src/client.ts
CHANGED
|
@@ -50,6 +50,7 @@ import type {
|
|
|
50
50
|
LastDeepLink,
|
|
51
51
|
MmpAttribution,
|
|
52
52
|
PaywallInteraction,
|
|
53
|
+
PaywallProductShown,
|
|
53
54
|
PlacementResolution,
|
|
54
55
|
RegisterPurchaseInput,
|
|
55
56
|
RegisterPurchaseResult,
|
|
@@ -246,6 +247,19 @@ function wellFormedIntegrity(evidence: unknown): IntegrityEvidence | undefined {
|
|
|
246
247
|
return undefined;
|
|
247
248
|
}
|
|
248
249
|
|
|
250
|
+
const MAX_PRODUCTS_SHOWN = 20;
|
|
251
|
+
const MAX_PRICE_LABEL_LENGTH = 64;
|
|
252
|
+
|
|
253
|
+
function boundedProductsShown(
|
|
254
|
+
products: PaywallProductShown[]
|
|
255
|
+
): PaywallProductShown[] {
|
|
256
|
+
return products.slice(0, MAX_PRODUCTS_SHOWN).map((product) =>
|
|
257
|
+
product.priceLabel !== undefined
|
|
258
|
+
? { ...product, priceLabel: product.priceLabel.slice(0, MAX_PRICE_LABEL_LENGTH) }
|
|
259
|
+
: product
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
249
263
|
export class RevnixClient {
|
|
250
264
|
private readonly apiKey: string;
|
|
251
265
|
private readonly baseUrl: string;
|
|
@@ -996,6 +1010,10 @@ export class RevnixClient {
|
|
|
996
1010
|
logPaywallShown(options?: {
|
|
997
1011
|
placementKey?: string;
|
|
998
1012
|
paywallId?: string;
|
|
1013
|
+
/** The plans the paywall drew, with the localized price each showed.
|
|
1014
|
+
* RevnixPaywall fills this from its packages; a headless paywall passes
|
|
1015
|
+
* what it rendered. */
|
|
1016
|
+
productsShown?: PaywallProductShown[];
|
|
999
1017
|
}): string {
|
|
1000
1018
|
const viewId = generateViewId();
|
|
1001
1019
|
// REV-272 LOOP GUARD: a display whose placement is one of the six came
|
|
@@ -1020,6 +1038,9 @@ export class RevnixClient {
|
|
|
1020
1038
|
sdkVersion: SDK_VERSION,
|
|
1021
1039
|
...(options?.placementKey ? { placementKey: options.placementKey } : {}),
|
|
1022
1040
|
...(options?.paywallId ? { paywallId: options.paywallId } : {}),
|
|
1041
|
+
...(options?.productsShown?.length
|
|
1042
|
+
? { productsShown: boundedProductsShown(options.productsShown) }
|
|
1043
|
+
: {}),
|
|
1023
1044
|
})
|
|
1024
1045
|
)
|
|
1025
1046
|
.catch((err) => this.diag("logPaywallShown", err));
|
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -378,6 +378,16 @@ export interface PlacementPackage {
|
|
|
378
378
|
product: PlacementProduct | null;
|
|
379
379
|
}
|
|
380
380
|
|
|
381
|
+
/** One plan as a paywall drew it, for `logPaywallShown`'s `productsShown`:
|
|
382
|
+
* the localized label the customer actually read, and the catalog price
|
|
383
|
+
* behind it. */
|
|
384
|
+
export interface PaywallProductShown {
|
|
385
|
+
productId: string;
|
|
386
|
+
priceLabel?: string;
|
|
387
|
+
amountMinor?: number;
|
|
388
|
+
currency?: string;
|
|
389
|
+
}
|
|
390
|
+
|
|
381
391
|
export interface PlacementProduct {
|
|
382
392
|
productId: string;
|
|
383
393
|
displayName: string;
|
package/src/ui/RevnixPaywall.tsx
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
import type {
|
|
34
34
|
PaywallConfig,
|
|
35
35
|
PaywallInteraction,
|
|
36
|
+
PaywallProductShown,
|
|
36
37
|
PaywallPurchaseOutcome,
|
|
37
38
|
PlacementResolution,
|
|
38
39
|
RegisterPurchaseResult,
|
|
@@ -195,6 +196,7 @@ export interface RevnixPaywallProps {
|
|
|
195
196
|
logPaywallShown: (options?: {
|
|
196
197
|
placementKey?: string;
|
|
197
198
|
paywallId?: string;
|
|
199
|
+
productsShown?: PaywallProductShown[];
|
|
198
200
|
}) => string | void;
|
|
199
201
|
/** Older clients predate close reporting; the paywall still closes. */
|
|
200
202
|
logPaywallClosed?: (
|
|
@@ -278,6 +280,32 @@ export async function prefetchPaywallImages(
|
|
|
278
280
|
);
|
|
279
281
|
}
|
|
280
282
|
|
|
283
|
+
function visiblePackages(
|
|
284
|
+
config: PaywallConfig,
|
|
285
|
+
packages: RevnixPaywallPackage[]
|
|
286
|
+
): RevnixPaywallPackage[] {
|
|
287
|
+
return config.template === "minimal" && config.highlightPackageId
|
|
288
|
+
? packages.filter((p) => p.packageId === config.highlightPackageId)
|
|
289
|
+
: packages;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function productsShownFrom(
|
|
293
|
+
packages: RevnixPaywallPackage[]
|
|
294
|
+
): PaywallProductShown[] {
|
|
295
|
+
return packages.flatMap((pkg) =>
|
|
296
|
+
pkg.productId
|
|
297
|
+
? [
|
|
298
|
+
{
|
|
299
|
+
productId: pkg.productId,
|
|
300
|
+
priceLabel: pkg.priceLabel,
|
|
301
|
+
amountMinor: pkg.amountMinor,
|
|
302
|
+
currency: pkg.currency,
|
|
303
|
+
},
|
|
304
|
+
]
|
|
305
|
+
: []
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
|
|
281
309
|
export function RevnixPaywall(props: RevnixPaywallProps) {
|
|
282
310
|
// One view per mount: remounting (a re-shown paywall) is a genuine new
|
|
283
311
|
// display; re-renders are not.
|
|
@@ -287,7 +315,11 @@ export function RevnixPaywall(props: RevnixPaywallProps) {
|
|
|
287
315
|
const viewIdRef = React.useRef<string | undefined>(undefined);
|
|
288
316
|
React.useEffect(() => {
|
|
289
317
|
if (!client || disableViewTracking) return;
|
|
290
|
-
const id = client.logPaywallShown({
|
|
318
|
+
const id = client.logPaywallShown({
|
|
319
|
+
placementKey,
|
|
320
|
+
paywallId,
|
|
321
|
+
productsShown: productsShownFrom(visiblePackages(props.config, props.packages)),
|
|
322
|
+
});
|
|
291
323
|
// Pre-REV-252 clients return void; the close then still fires the host
|
|
292
324
|
// callback, it just cannot be paired with this display.
|
|
293
325
|
if (typeof id === "string") viewIdRef.current = id;
|
|
@@ -605,10 +637,7 @@ function ClassicPaywall(
|
|
|
605
637
|
|
|
606
638
|
// Same template semantics as the dashboard preview: "minimal" shows only
|
|
607
639
|
// the highlighted package; feature bullets render on the feature layouts.
|
|
608
|
-
const shown =
|
|
609
|
-
layout === "minimal" && config.highlightPackageId
|
|
610
|
-
? packages.filter((p) => p.packageId === config.highlightPackageId)
|
|
611
|
-
: packages;
|
|
640
|
+
const shown = visiblePackages(config, packages);
|
|
612
641
|
|
|
613
642
|
const [internalSelected, setInternalSelected] = React.useState<
|
|
614
643
|
string | undefined
|
package/src/version.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// L3: the single source of the SDK version inside src/. Must match
|
|
2
2
|
// package.json "version" — version.test.ts fails the build when they drift
|
|
3
3
|
// (they had: client.ts said 0.7.0 while the package shipped 0.9.0).
|
|
4
|
-
export const SDK_VERSION = "
|
|
4
|
+
export const SDK_VERSION = "2.0.0";
|