@rocapine/react-native-onboarding 1.77.0 → 1.79.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.
Files changed (77) hide show
  1. package/README.md +38 -10
  2. package/dist/OnboardingStudio.d.ts +14 -1
  3. package/dist/OnboardingStudio.d.ts.map +1 -1
  4. package/dist/OnboardingStudio.js +5 -1
  5. package/dist/OnboardingStudio.js.map +1 -1
  6. package/dist/OnboardingStudioClient.d.ts +31 -0
  7. package/dist/OnboardingStudioClient.d.ts.map +1 -1
  8. package/dist/OnboardingStudioClient.js +80 -19
  9. package/dist/OnboardingStudioClient.js.map +1 -1
  10. package/dist/assignmentId.d.ts +107 -0
  11. package/dist/assignmentId.d.ts.map +1 -0
  12. package/dist/assignmentId.js +215 -0
  13. package/dist/assignmentId.js.map +1 -0
  14. package/dist/index.d.ts +5 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +9 -2
  17. package/dist/index.js.map +1 -1
  18. package/dist/paywalls/PaywallProvider.d.ts +8 -1
  19. package/dist/paywalls/PaywallProvider.d.ts.map +1 -1
  20. package/dist/paywalls/PaywallProvider.js +5 -1
  21. package/dist/paywalls/PaywallProvider.js.map +1 -1
  22. package/dist/paywalls/customScreens.d.ts +7 -0
  23. package/dist/paywalls/customScreens.d.ts.map +1 -1
  24. package/dist/paywalls/devHook.d.ts +26 -0
  25. package/dist/paywalls/devHook.d.ts.map +1 -0
  26. package/dist/paywalls/devHook.js +29 -0
  27. package/dist/paywalls/devHook.js.map +1 -0
  28. package/dist/paywalls/observer.d.ts +2 -0
  29. package/dist/paywalls/observer.d.ts.map +1 -1
  30. package/dist/paywalls/observer.js +21 -9
  31. package/dist/paywalls/observer.js.map +1 -1
  32. package/dist/paywalls/types.d.ts +22 -0
  33. package/dist/paywalls/types.d.ts.map +1 -1
  34. package/dist/products/adapters/expoIap.d.ts +34 -13
  35. package/dist/products/adapters/expoIap.d.ts.map +1 -1
  36. package/dist/products/adapters/expoIap.js +136 -21
  37. package/dist/products/adapters/expoIap.js.map +1 -1
  38. package/dist/steps/ComposableScreen/types.d.ts +21 -0
  39. package/dist/steps/ComposableScreen/types.d.ts.map +1 -1
  40. package/dist/steps/ComposableScreen/types.js +14 -0
  41. package/dist/steps/ComposableScreen/types.js.map +1 -1
  42. package/dist/types.d.ts +47 -0
  43. package/dist/types.d.ts.map +1 -1
  44. package/dist/types.js +6 -0
  45. package/dist/types.js.map +1 -1
  46. package/dist/userProperties/reserved.d.ts +8 -5
  47. package/dist/userProperties/reserved.d.ts.map +1 -1
  48. package/dist/userProperties/reserved.js +9 -4
  49. package/dist/userProperties/reserved.js.map +1 -1
  50. package/dist/version.d.ts +1 -1
  51. package/dist/version.js +1 -1
  52. package/package.json +1 -1
  53. package/src/OnboardingStudio.ts +19 -1
  54. package/src/OnboardingStudioClient.ts +84 -31
  55. package/src/__tests__/assignmentId.clear.test.ts +413 -0
  56. package/src/__tests__/assignmentId.client.test.ts +288 -0
  57. package/src/__tests__/assignmentId.test.ts +195 -0
  58. package/src/__tests__/onboardingMetadata.client.test.ts +76 -0
  59. package/src/assignmentId.ts +278 -0
  60. package/src/index.ts +9 -0
  61. package/src/paywalls/PaywallProvider.tsx +13 -0
  62. package/src/paywalls/__tests__/PaywallProvider.observer.test.tsx +51 -0
  63. package/src/paywalls/__tests__/devHook.test.ts +70 -0
  64. package/src/paywalls/__tests__/getPaywalls.test.ts +77 -2
  65. package/src/paywalls/__tests__/observer.test.ts +37 -0
  66. package/src/paywalls/__tests__/present.test.ts +14 -0
  67. package/src/paywalls/customScreens.ts +7 -0
  68. package/src/paywalls/devHook.ts +48 -0
  69. package/src/paywalls/observer.ts +22 -2
  70. package/src/paywalls/types.ts +22 -0
  71. package/src/products/adapters/__tests__/expoIap.contract.test.ts +305 -0
  72. package/src/products/adapters/expoIap.ts +171 -32
  73. package/src/steps/ComposableScreen/types.ts +21 -0
  74. package/src/types.ts +48 -0
  75. package/src/userProperties/__tests__/primitives.test.ts +1 -1
  76. package/src/userProperties/reserved.ts +9 -4
  77. package/src/version.ts +1 -1
package/src/types.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { NextStep } from "./steps/common.types";
2
+ import type { AssignmentIdOption } from "./assignmentId";
2
3
 
3
4
  /**
4
5
  * Base step type that all onboarding steps must conform to.
@@ -37,9 +38,36 @@ export type OnboardingStudioClientOptions<
37
38
  * characters before it is sent. An audience rule can target it.
38
39
  */
39
40
  environment?: string;
41
+ /**
42
+ * The stable per-person id sent as `assignmentId`, so the server can keep a
43
+ * person in the same variant across launches. A string, or a getter called
44
+ * on every request (sync or async) — e.g. `() => Purchases.getAppUserID()`
45
+ * to use the RevenueCat App User ID (call `Purchases.configure()` before
46
+ * the first request). When omitted, or when the value is `undefined`,
47
+ * `null` or `""`, the SDK sends an installation id it generates once and
48
+ * persists. Absent from the request when neither is available.
49
+ *
50
+ * `false` (or a getter returning `false`) opts out: nothing is sent, and the
51
+ * installation id is never read, created or written. Use it until the user
52
+ * has consented. `null` and `""` are not an opt-out.
53
+ *
54
+ * Fails closed: a getter that throws, rejects or takes longer than 2s is
55
+ * treated like `false` for that request — nothing is sent and the
56
+ * installation id is not touched. Resolving it counts against `timeout`.
57
+ *
58
+ * Changing the value (e.g. anonymous → identified on login) can move the
59
+ * person to another variant, once.
60
+ */
61
+ assignmentId?: AssignmentIdOption;
40
62
  isSandbox?: boolean;
41
63
  baseUrl?: string;
42
64
  fallbackOnboarding?: Onboarding<StepType>;
65
+ /**
66
+ * End-to-end budget in ms for each `getSteps` / `getPaywalls` request:
67
+ * resolving the request identity (including the `assignmentId` getter) and
68
+ * the fetch together. On expiry `getSteps` returns `fallbackOnboarding` if
69
+ * set; otherwise both reject with `Error("timeout")`.
70
+ */
43
71
  timeout?: number;
44
72
  /**
45
73
  * Optional custom cache key. When provided, the fetched onboarding is
@@ -61,6 +89,12 @@ export type UserDefinedParams = {
61
89
  [key: string]: string;
62
90
  };
63
91
 
92
+ /**
93
+ * Reserved `OnboardingMetadata.variantKey` reported by the parent (main)
94
+ * onboarding, as opposed to one of its variants.
95
+ */
96
+ export const MAIN_VARIANT_KEY = "main" as const;
97
+
64
98
  export interface OnboardingMetadata {
65
99
  id: string;
66
100
  name?: string;
@@ -69,6 +103,20 @@ export interface OnboardingMetadata {
69
103
  audienceOrder?: number;
70
104
  locale?: string;
71
105
  draft?: boolean;
106
+ /**
107
+ * Which variant of the onboarding this user was served. The parent (main)
108
+ * onboarding reports the reserved key `MAIN_VARIANT_KEY` (`"main"`).
109
+ * `null` and absent mean the same thing — the server sent no variant
110
+ * information (e.g. an older server) — and hosts should treat them
111
+ * identically (e.g. `metadata.variantKey ?? undefined`).
112
+ */
113
+ variantKey?: string | null;
114
+ /**
115
+ * Id of the published deployment that was served. `null` for a draft
116
+ * (sandbox) payload, which has no deployment; absent when the server does
117
+ * not send it.
118
+ */
119
+ deploymentId?: number | null;
72
120
  }
73
121
 
74
122
  /**
@@ -6,7 +6,7 @@ import { applyUserPropertyPatch } from "../applyPatch";
6
6
  describe("reserved keys", () => {
7
7
  it("names every key the client itself puts on the querystring", () => {
8
8
  expect([...RESERVED_USER_PROPERTY_KEYS].sort()).toEqual(
9
- ["appVersion", "build", "draft", "environment", "locale", "moment", "now", "omitNulls", "platform", "projectId", "sdkVersion"],
9
+ ["appVersion", "appleReview", "assignmentId", "build", "draft", "environment", "locale", "moment", "now", "omitNulls", "platform", "projectId", "sdkVersion"],
10
10
  );
11
11
  });
12
12
 
@@ -2,13 +2,16 @@
2
2
  * Property names a host may NOT use, because `OnboardingStudioClient` puts them
3
3
  * on the querystring itself.
4
4
  *
5
- * Two of them — `moment` and `now` — mirror the server's own
6
- * `RESERVED_AUDIENCE_VARS`, which strips them because they are server-owned (a
7
- * client supplying `now` is self-selecting into a time-gated audience).
5
+ * Three of them — `moment`, `now` and `appleReview` — are server-owned audience
6
+ * variables: the server sets them per request. They mirror the server's own
7
+ * list of server-owned names (`moment`, `now`, `appleReview`), which strips
8
+ * any client-supplied value (a client supplying `now` is self-selecting into a
9
+ * time-gated audience).
8
10
  *
9
11
  * The others are the params the client writes on every request: `projectId`,
10
12
  * `platform`, the request identity (`appVersion`, `build`, `sdkVersion`,
11
- * `environment` — see `requestIdentity.ts`), `draft`, `locale`, `omitNulls`.
13
+ * `environment` — see `requestIdentity.ts`), `assignmentId` (see
14
+ * `assignmentId.ts`), `draft`, `locale`, `omitNulls`.
12
15
  * The client adds user params FIRST, then writes its own with
13
16
  * `URLSearchParams.set`, which replaces any same-named user param (and removes
14
17
  * a user `appVersion`/`build` when it has none of its own to send):
@@ -34,11 +37,13 @@ export const RESERVED_USER_PROPERTY_KEYS = [
34
37
  "build",
35
38
  "sdkVersion",
36
39
  "environment",
40
+ "assignmentId",
37
41
  "draft",
38
42
  "locale",
39
43
  "omitNulls",
40
44
  "moment",
41
45
  "now",
46
+ "appleReview",
42
47
  ] as const;
43
48
 
44
49
  export type ReservedUserPropertyKey = (typeof RESERVED_USER_PROPERTY_KEYS)[number];
package/src/version.ts CHANGED
@@ -6,4 +6,4 @@
6
6
  * the file. `npm run check:versions` fails when this disagrees with
7
7
  * `package.json`, and the `bump-version` skill updates it.
8
8
  */
9
- export const SDK_VERSION = "1.77.0";
9
+ export const SDK_VERSION = "1.79.0";