@octopus-community/react-native 1.0.7 → 1.9.1

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 (112) hide show
  1. package/OctopusReactNativeSdk.podspec +1 -1
  2. package/README.md +40 -35
  3. package/android/build.gradle +2 -0
  4. package/android/gradle.properties +2 -2
  5. package/android/src/main/AndroidManifest.xml +2 -1
  6. package/android/src/main/AndroidManifestNew.xml +2 -1
  7. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusActivity.kt +56 -0
  8. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusContent.kt +396 -0
  9. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusEventEmitter.kt +22 -0
  10. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusEventSerializer.kt +339 -0
  11. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusReactModule.kt +326 -0
  12. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/{OctopusReactNativeSdkPackage.kt → OctopusReactPackage.kt} +3 -3
  13. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusSDKInitializer.kt +53 -9
  14. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusSSOAuthenticator.kt +5 -15
  15. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusUIConfiguration.kt +6 -0
  16. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusUIConfigurationManager.kt +12 -0
  17. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusUIController.kt +17 -2
  18. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusUIViewManager.kt +63 -0
  19. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/ProfileFieldMapper.kt +2 -2
  20. package/ios/OctopusEventManager.swift +27 -0
  21. package/ios/OctopusEventSerializer.swift +271 -0
  22. package/ios/OctopusReactNativeSdk.mm +26 -1
  23. package/ios/OctopusReactNativeSdk.swift +225 -3
  24. package/ios/OctopusSDKInitializer.swift +32 -0
  25. package/ios/OctopusSSOAuthenticator.swift +1 -5
  26. package/ios/OctopusUIConfiguration.swift +6 -0
  27. package/ios/OctopusUIManager.swift +134 -10
  28. package/ios/OctopusUIViewManager.m +7 -0
  29. package/ios/OctopusUIViewManager.swift +37 -0
  30. package/lib/module/OctopusUIView.js +39 -0
  31. package/lib/module/OctopusUIView.js.map +1 -0
  32. package/lib/module/addHasAccessToCommunityListener.js +33 -0
  33. package/lib/module/addHasAccessToCommunityListener.js.map +1 -0
  34. package/lib/module/addNavigateToUrlListener.js +41 -0
  35. package/lib/module/addNavigateToUrlListener.js.map +1 -0
  36. package/lib/module/addNotSeenNotificationsCountListener.js +30 -0
  37. package/lib/module/addNotSeenNotificationsCountListener.js.map +1 -0
  38. package/lib/module/addSDKEventListener.js +48 -0
  39. package/lib/module/addSDKEventListener.js.map +1 -0
  40. package/lib/module/connectUser.js +24 -3
  41. package/lib/module/connectUser.js.map +1 -1
  42. package/lib/module/index.js +12 -0
  43. package/lib/module/index.js.map +1 -1
  44. package/lib/module/initialize.js +13 -12
  45. package/lib/module/initialize.js.map +1 -1
  46. package/lib/module/openUI.js +23 -2
  47. package/lib/module/openUI.js.map +1 -1
  48. package/lib/module/overrideCommunityAccess.js +36 -0
  49. package/lib/module/overrideCommunityAccess.js.map +1 -0
  50. package/lib/module/overrideDefaultLocale.js +75 -0
  51. package/lib/module/overrideDefaultLocale.js.map +1 -0
  52. package/lib/module/trackCommunityAccess.js +33 -0
  53. package/lib/module/trackCommunityAccess.js.map +1 -0
  54. package/lib/module/trackCustomEvent.js +36 -0
  55. package/lib/module/trackCustomEvent.js.map +1 -0
  56. package/lib/module/types/sdkEvents.js +2 -0
  57. package/lib/module/types/sdkEvents.js.map +1 -0
  58. package/lib/module/types/urlOpeningStrategy.js +23 -0
  59. package/lib/module/types/urlOpeningStrategy.js.map +1 -0
  60. package/lib/module/updateNotSeenNotificationsCount.js +33 -0
  61. package/lib/module/updateNotSeenNotificationsCount.js.map +1 -0
  62. package/lib/typescript/src/OctopusUIView.d.ts +32 -0
  63. package/lib/typescript/src/OctopusUIView.d.ts.map +1 -0
  64. package/lib/typescript/src/addHasAccessToCommunityListener.d.ts +27 -0
  65. package/lib/typescript/src/addHasAccessToCommunityListener.d.ts.map +1 -0
  66. package/lib/typescript/src/addNavigateToUrlListener.d.ts +31 -0
  67. package/lib/typescript/src/addNavigateToUrlListener.d.ts.map +1 -0
  68. package/lib/typescript/src/addNotSeenNotificationsCountListener.d.ts +24 -0
  69. package/lib/typescript/src/addNotSeenNotificationsCountListener.d.ts.map +1 -0
  70. package/lib/typescript/src/addSDKEventListener.d.ts +43 -0
  71. package/lib/typescript/src/addSDKEventListener.d.ts.map +1 -0
  72. package/lib/typescript/src/connectUser.d.ts +24 -8
  73. package/lib/typescript/src/connectUser.d.ts.map +1 -1
  74. package/lib/typescript/src/index.d.ts +13 -0
  75. package/lib/typescript/src/index.d.ts.map +1 -1
  76. package/lib/typescript/src/initialize.d.ts +22 -12
  77. package/lib/typescript/src/initialize.d.ts.map +1 -1
  78. package/lib/typescript/src/openUI.d.ts +28 -1
  79. package/lib/typescript/src/openUI.d.ts.map +1 -1
  80. package/lib/typescript/src/overrideCommunityAccess.d.ts +30 -0
  81. package/lib/typescript/src/overrideCommunityAccess.d.ts.map +1 -0
  82. package/lib/typescript/src/overrideDefaultLocale.d.ts +37 -0
  83. package/lib/typescript/src/overrideDefaultLocale.d.ts.map +1 -0
  84. package/lib/typescript/src/trackCommunityAccess.d.ts +27 -0
  85. package/lib/typescript/src/trackCommunityAccess.d.ts.map +1 -0
  86. package/lib/typescript/src/trackCustomEvent.d.ts +30 -0
  87. package/lib/typescript/src/trackCustomEvent.d.ts.map +1 -0
  88. package/lib/typescript/src/types/sdkEvents.d.ts +222 -0
  89. package/lib/typescript/src/types/sdkEvents.d.ts.map +1 -0
  90. package/lib/typescript/src/types/urlOpeningStrategy.d.ts +20 -0
  91. package/lib/typescript/src/types/urlOpeningStrategy.d.ts.map +1 -0
  92. package/lib/typescript/src/updateNotSeenNotificationsCount.d.ts +27 -0
  93. package/lib/typescript/src/updateNotSeenNotificationsCount.d.ts.map +1 -0
  94. package/package.json +2 -1
  95. package/src/OctopusUIView.tsx +57 -0
  96. package/src/addHasAccessToCommunityListener.ts +38 -0
  97. package/src/addNavigateToUrlListener.ts +54 -0
  98. package/src/addNotSeenNotificationsCountListener.ts +35 -0
  99. package/src/addSDKEventListener.ts +49 -0
  100. package/src/connectUser.ts +24 -8
  101. package/src/index.ts +13 -0
  102. package/src/initialize.ts +23 -12
  103. package/src/openUI.ts +32 -2
  104. package/src/overrideCommunityAccess.ts +33 -0
  105. package/src/overrideDefaultLocale.ts +88 -0
  106. package/src/trackCommunityAccess.ts +30 -0
  107. package/src/trackCustomEvent.ts +36 -0
  108. package/src/types/sdkEvents.ts +315 -0
  109. package/src/types/urlOpeningStrategy.ts +20 -0
  110. package/src/updateNotSeenNotificationsCount.ts +30 -0
  111. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusReactNativeSdkModule.kt +0 -155
  112. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusUIActivity.kt +0 -422
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addHasAccessToCommunityListener.d.ts","sourceRoot":"","sources":["../../../src/addHasAccessToCommunityListener.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,oCAAoC,GAAG,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,oCAAoC,8CAQ/C"}
@@ -0,0 +1,31 @@
1
+ import { type UrlOpeningStrategy } from './types/urlOpeningStrategy';
2
+ export type NavigateToUrlListenerCallback = (url: string) => UrlOpeningStrategy | Promise<UrlOpeningStrategy>;
3
+ /**
4
+ * Adds a listener for URL navigation events from the Octopus Community UI.
5
+ *
6
+ * Only has an effect when the UI was opened with `openUI({ interceptUrls: true })`.
7
+ * When the user taps a link, this callback is invoked with the URL. Return
8
+ * `handledByApp` if your app handles the URL (e.g. in-app web view), or
9
+ * `handledByOctopus` to let the SDK open it in the system browser.
10
+ *
11
+ * @param callback - Function called with the tapped URL. Can be async.
12
+ * Return `UrlOpeningStrategy.handledByApp` or `UrlOpeningStrategy.handledByOctopus`.
13
+ * @returns A subscription object with a `remove()` method to unsubscribe.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const subscription = addNavigateToUrlListener(async (url) => {
18
+ * if (url.startsWith('https://myapp.com/')) {
19
+ * // Handle deep link in-app
20
+ * Linking.openURL(url);
21
+ * return UrlOpeningStrategy.handledByApp;
22
+ * }
23
+ * return UrlOpeningStrategy.handledByOctopus; // Open in system browser
24
+ * });
25
+ *
26
+ * // Later, to unsubscribe:
27
+ * subscription.remove();
28
+ * ```
29
+ */
30
+ export declare function addNavigateToUrlListener(callback: NavigateToUrlListenerCallback): import("react-native").EmitterSubscription;
31
+ //# sourceMappingURL=addNavigateToUrlListener.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addNavigateToUrlListener.d.ts","sourceRoot":"","sources":["../../../src/addNavigateToUrlListener.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,MAAM,6BAA6B,GAAG,CAC1C,GAAG,EAAE,MAAM,KACR,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,6BAA6B,8CAcxC"}
@@ -0,0 +1,24 @@
1
+ export type NotSeenNotificationsCountListenerCallback = (count: number) => void;
2
+ /**
3
+ * Adds a listener for not seen notifications count changes.
4
+ *
5
+ * This listener is triggered whenever the count of unseen notifications changes.
6
+ * The count is automatically updated by the SDK, but can also be manually refreshed
7
+ * using `updateNotSeenNotificationsCount()`.
8
+ *
9
+ * @param callback - Function called when the notification count changes
10
+ * @returns A subscription object with a `remove()` method to unsubscribe
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const subscription = addNotSeenNotificationsCountListener((count) => {
15
+ * console.log(`Unseen notifications: ${count}`);
16
+ * // Update your app's badge or UI
17
+ * });
18
+ *
19
+ * // Later, to unsubscribe:
20
+ * subscription.remove();
21
+ * ```
22
+ */
23
+ export declare function addNotSeenNotificationsCountListener(callback: NotSeenNotificationsCountListenerCallback): import("react-native").EmitterSubscription;
24
+ //# sourceMappingURL=addNotSeenNotificationsCountListener.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addNotSeenNotificationsCountListener.d.ts","sourceRoot":"","sources":["../../../src/addNotSeenNotificationsCountListener.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,yCAAyC,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,oCAAoC,CAClD,QAAQ,EAAE,yCAAyC,8CAQpD"}
@@ -0,0 +1,43 @@
1
+ import type { SDKEvent } from './types/sdkEvents';
2
+ export type SDKEventListenerCallback = (event: SDKEvent) => void;
3
+ /**
4
+ * Adds a listener for SDK events.
5
+ *
6
+ * This listener receives all SDK events including:
7
+ * - Content creation (posts, comments, replies)
8
+ * - Content deletion
9
+ * - Reactions and interactions
10
+ * - Gamification events
11
+ * - Screen navigation
12
+ * - Profile modifications
13
+ * - Session events
14
+ * - And more...
15
+ *
16
+ * Use TypeScript type guards to narrow down specific event types:
17
+ *
18
+ * @param callback - Function called when any SDK event occurs
19
+ * @returns A subscription object with a `remove()` method to unsubscribe
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const subscription = addSDKEventListener((event) => {
24
+ * switch (event.type) {
25
+ * case 'postCreated':
26
+ * console.log(`Post created: ${event.postId}`);
27
+ * break;
28
+ * case 'reactionModified':
29
+ * console.log(`Reaction changed on ${event.contentId}`);
30
+ * break;
31
+ * case 'gamificationPointsGained':
32
+ * console.log(`Gained ${event.points} points for ${event.action}`);
33
+ * break;
34
+ * // ... handle other event types
35
+ * }
36
+ * });
37
+ *
38
+ * // Later, to unsubscribe:
39
+ * subscription.remove();
40
+ * ```
41
+ */
42
+ export declare function addSDKEventListener(callback: SDKEventListenerCallback): import("react-native").EmitterSubscription;
43
+ //# sourceMappingURL=addSDKEventListener.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addSDKEventListener.d.ts","sourceRoot":"","sources":["../../../src/addSDKEventListener.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,MAAM,wBAAwB,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,wBAAwB,8CAIrE"}
@@ -12,19 +12,35 @@ export interface ConnectUserParams {
12
12
  */
13
13
  profilePicture?: string;
14
14
  biography?: string;
15
- /**
16
- * Whether the user has reached legal age.
17
- * Used for age-appropriate content filtering and compliance.
18
- */
19
- legalAgeReached?: boolean;
20
15
  };
21
16
  }
22
17
  /**
23
18
  * Connects a user using SSO authentication.
24
19
  *
25
- * This function establishes a connection between your app's user and Octopus.
26
- * It requires that you have configured SSO mode during SDK initialization
27
- * and have set up a token provider using `useUserTokenProvider` or `addUserTokenRequestListener`.
20
+ * This function establishes a connection between your app's user and Octopus. It requires that you
21
+ * have configured SSO mode during SDK initialization and have set up a token provider using
22
+ * `useUserTokenProvider` or `addUserTokenRequestListener`. The token is obtained via your token
23
+ * provider; you do not pass it directly to `connectUser`. Call `connectUser` after the user logs in;
24
+ * call `disconnectUser` when they log out.
25
+ *
26
+ * @param params - User id and optional profile (username, profilePicture, biography). See {@link ConnectUserParams}.
27
+ * @returns A promise that resolves when the user is connected. Rejects if the SDK is not initialized,
28
+ * SSO is not configured, or the token provider fails.
29
+ * @see {@link useUserTokenProvider} – provide JWT from React components.
30
+ * @see {@link addUserTokenRequestListener} – provide JWT without React.
31
+ * @see {@link disconnectUser} – disconnect the current user.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * await connectUser({
36
+ * userId: 'unique-user-id-from-your-backend',
37
+ * profile: {
38
+ * username: 'john_doe',
39
+ * profilePicture: 'https://example.com/avatar.jpg',
40
+ * biography: 'Software developer'
41
+ * }
42
+ * });
43
+ * ```
28
44
  */
29
45
  export declare function connectUser(params: ConnectUserParams): Promise<void>;
30
46
  //# sourceMappingURL=connectUser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"connectUser.d.ts","sourceRoot":"","sources":["../../../src/connectUser.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB;;;WAGG;QACH,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB;;;WAGG;QACH,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3B,CAAC;CACH;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpE"}
1
+ {"version":3,"file":"connectUser.d.ts","sourceRoot":"","sources":["../../../src/connectUser.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB;;;WAGG;QACH,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpE"}
@@ -3,11 +3,24 @@ export * from './openUI';
3
3
  export * from './closeUI';
4
4
  export * from './connectUser';
5
5
  export * from './disconnectUser';
6
+ export * from './trackCustomEvent';
7
+ export * from './overrideDefaultLocale';
8
+ export * from './updateNotSeenNotificationsCount';
9
+ export * from './overrideCommunityAccess';
10
+ export * from './trackCommunityAccess';
6
11
  export * from './addUserTokenRequestListener';
7
12
  export * from './useUserTokenProvider';
8
13
  export * from './addLoginRequiredListener';
9
14
  export * from './addEditUserListener';
15
+ export * from './addNotSeenNotificationsCountListener';
16
+ export * from './addHasAccessToCommunityListener';
17
+ export * from './addSDKEventListener';
18
+ export * from './addNavigateToUrlListener';
10
19
  export * from './types/userProfileField';
20
+ export * from './types/sdkEvents';
21
+ export * from './types/urlOpeningStrategy';
11
22
  export * from './logger';
12
23
  export * from './enums/LogLevel.enum';
24
+ export { OctopusUIView } from './OctopusUIView';
25
+ export type { OctopusUIViewProps } from './OctopusUIView';
13
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAClD,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -89,6 +89,17 @@ export interface OctopusTheme {
89
89
  image?: ImageResolvedAssetSource;
90
90
  };
91
91
  }
92
+ /**
93
+ * UI customization options for platform-specific layout adjustments.
94
+ */
95
+ export interface OctopusUIOptions {
96
+ /**
97
+ * Additional bottom inset applied to the Octopus UI.
98
+ * - On iOS, mapped to `bottomSafeAreaInset` (points)
99
+ * - On Android, mapped to `contentPadding` bottom (dp)
100
+ */
101
+ bottomSafeAreaInset?: number;
102
+ }
92
103
  /**
93
104
  * Configuration params for initializing the Octopus SDK.
94
105
  */
@@ -111,30 +122,29 @@ export interface InitializeParams {
111
122
  };
112
123
  /** Optional theme customization for the Octopus UI */
113
124
  theme?: OctopusTheme;
125
+ /** Optional UI customization for layout-related tweaks */
126
+ ui?: OctopusUIOptions;
114
127
  }
115
128
  /**
116
129
  * Initializes the Octopus SDK with the provided configuration.
117
130
  *
118
- * This function must be called before using any other Octopus SDK features.
119
- * It sets up the SDK with your API key and configures the authentication mode.
131
+ * This function must be called before using any other Octopus SDK features. It sets up the SDK
132
+ * with your API key, connection mode (SSO or Octopus-managed authentication), and optional theme
133
+ * and UI options. For SSO, you also need to set up a token provider with `useUserTokenProvider` or
134
+ * `addUserTokenRequestListener` before calling `connectUser`.
135
+ *
136
+ * @param params - See {@link InitializeParams} (including `theme`, `ui`). For theming guide see the main README.
137
+ * @see {@link connectUser} – connect a user after initialization (SSO mode).
120
138
  *
121
139
  * @example
122
140
  * ```typescript
123
- * // Initialize with SSO mode
124
141
  * await initialize({
125
142
  * apiKey: 'your-api-key',
126
- * connectionMode: {
127
- * type: 'sso',
128
- * appManagedFields: ['username', 'profilePicture']
129
- * }
143
+ * connectionMode: { type: 'sso', appManagedFields: ['username', 'profilePicture'] }
130
144
  * });
131
- *
132
- * // Initialize with Octopus authentication
133
145
  * await initialize({
134
146
  * apiKey: 'your-api-key',
135
- * connectionMode: {
136
- * type: 'octopus'
137
- * }
147
+ * connectionMode: { type: 'octopus' }
138
148
  * });
139
149
  * ```
140
150
  */
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../../src/initialize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAG7D,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gGAAgG;IAChG,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,+EAA+E;IAC/E,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AAC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AC1D,EAAE,CAAC,EAAE,gBAAgB,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BlE"}
@@ -1,5 +1,32 @@
1
+ /**
2
+ * Options for opening the Octopus UI.
3
+ */
4
+ export interface OpenUIOptions {
5
+ /**
6
+ * When `true`, URLs tapped inside the community UI are not opened by the SDK.
7
+ * Instead, a `navigateToUrl` event is emitted. Subscribe with
8
+ * `addNavigateToUrlListener` to receive the URL and decide whether to handle
9
+ * it in-app or delegate back to the SDK (system browser).
10
+ *
11
+ * @default false
12
+ */
13
+ interceptUrls?: boolean;
14
+ }
1
15
  /**
2
16
  * Opens the Octopus UI home screen.
17
+ *
18
+ * @param options - Optional configuration. Use `interceptUrls: true` to receive
19
+ * URL taps via `addNavigateToUrlListener` instead of having the SDK open them.
20
+ * @returns A promise that resolves when the UI has been opened.
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * // Open UI with default behaviour (SDK opens links in system browser)
25
+ * await openUI();
26
+ *
27
+ * // Open UI with URL interception (app receives links via addNavigateToUrlListener)
28
+ * await openUI({ interceptUrls: true });
29
+ * ```
3
30
  */
4
- export declare function openUI(): Promise<void>;
31
+ export declare function openUI(options?: OpenUIOptions): Promise<void>;
5
32
  //# sourceMappingURL=openUI.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"openUI.d.ts","sourceRoot":"","sources":["../../../src/openUI.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAEtC"}
1
+ {"version":3,"file":"openUI.d.ts","sourceRoot":"","sources":["../../../src/openUI.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAI7D"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Override the community access cohort for the current user.
3
+ *
4
+ * **When to use:** When the **Octopus SDK manages the A/B logic** — i.e. Octopus assigns
5
+ * the cohort and decides who has access to the community. In that case, the "Has access
6
+ * to community" state is the cohort value. Use this function to override that cohort
7
+ * (e.g. for testing or feature gating). The new state is reflected via `addHasAccessToCommunityListener`.
8
+ *
9
+ * **When not to use:** If **your app** decides who has access (e.g. your own feature flag or A/B logic),
10
+ * do not use `overrideCommunityAccess`. Use `trackCommunityAccess` instead to report the access
11
+ * value to Octopus for analytics only; that does not change the actual access state in the SDK.
12
+ *
13
+ * @param hasAccess - `true` to grant access, `false` to deny access.
14
+ * @returns A promise that resolves when the override has been applied.
15
+ * @throws An error if the SDK is not initialized or the call fails.
16
+ * @see {@link addHasAccessToCommunityListener} – subscribe to the Octopus-managed community access state.
17
+ * @see {@link trackCommunityAccess} – when your app manages access, report it for analytics only (no change to SDK state).
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const subscription = addHasAccessToCommunityListener((hasAccess) => {
22
+ * console.log(`Has access to community: ${hasAccess}`);
23
+ * });
24
+ * await overrideCommunityAccess(true);
25
+ * await overrideCommunityAccess(false);
26
+ * subscription.remove();
27
+ * ```
28
+ */
29
+ export declare function overrideCommunityAccess(hasAccess: boolean): Promise<void>;
30
+ //# sourceMappingURL=overrideCommunityAccess.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overrideCommunityAccess.d.ts","sourceRoot":"","sources":["../../../src/overrideCommunityAccess.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAEzE"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Parameters for overriding the default locale used by the Octopus SDK UI.
3
+ * Uses ISO 639-1 language code and optional ISO 3166-1 alpha-2 country code.
4
+ */
5
+ export interface OverrideLocaleParams {
6
+ /** ISO 639-1 language code (e.g. `"en"`, `"fr"`). */
7
+ languageCode: string;
8
+ /** Optional ISO 3166-1 alpha-2 country code (e.g. `"US"`, `"FR"`). */
9
+ countryCode?: string;
10
+ }
11
+ /**
12
+ * Override the default locale used by the Octopus SDK for its UI.
13
+ *
14
+ * The change takes effect immediately for subsequently displayed SDK screens.
15
+ * Pass `null` to reset to the system default locale.
16
+ *
17
+ * @param locale - Object with `languageCode` and optional `countryCode`
18
+ * (e.g. `{ languageCode: 'fr' }` or `{ languageCode: 'en', countryCode: 'US' }`).
19
+ * Pass `null` to use the system default (no override).
20
+ * @returns A promise that resolves when the override has been applied.
21
+ * @throws An error if the SDK is not initialized or the call fails.
22
+ * @throws An error if locale is invalid (e.g. non-ISO language/country codes).
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * // Use French
27
+ * await overrideDefaultLocale({ languageCode: 'fr' });
28
+ *
29
+ * // Use English (US)
30
+ * await overrideDefaultLocale({ languageCode: 'en', countryCode: 'US' });
31
+ *
32
+ * // Reset to system default
33
+ * await overrideDefaultLocale(null);
34
+ * ```
35
+ */
36
+ export declare function overrideDefaultLocale(locale: OverrideLocaleParams | null): Promise<void>;
37
+ //# sourceMappingURL=overrideDefaultLocale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overrideDefaultLocale.d.ts","sourceRoot":"","sources":["../../../src/overrideDefaultLocale.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,qDAAqD;IACrD,YAAY,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAoCD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,oBAAoB,GAAG,IAAI,GAClC,OAAO,CAAC,IAAI,CAAC,CAaf"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Track community access for analytics without changing the actual access.
3
+ *
4
+ * **When to use:** When **your app manages its own A/B logic** — i.e. your app decides who can see
5
+ * the community (e.g. via your own feature flag or experiment). Call this to report that decision
6
+ * to Octopus for analytics only. It does not grant or restrict access in the SDK; it only records
7
+ * the value for reporting.
8
+ *
9
+ * **When not to use:** If the **Octopus SDK manages the cohort** (Octopus assigns who has access),
10
+ * use `overrideCommunityAccess` to change the cohort and `addHasAccessToCommunityListener` to react
11
+ * to it. Use `trackCommunityAccess` only when the access decision is owned by your app and you just
12
+ * need to report it.
13
+ *
14
+ * @param hasAccess - The access value to report (e.g. the variant your app decided).
15
+ * @returns A promise that resolves when the tracking call has completed.
16
+ * @throws An error if the SDK is not initialized or the call fails.
17
+ * @see {@link overrideCommunityAccess} – when Octopus manages the cohort, override it (and use addHasAccessToCommunityListener to react).
18
+ * @see {@link addHasAccessToCommunityListener} – subscribe to the Octopus-managed access state (relevant when Octopus or override sets it).
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * await trackCommunityAccess(true);
23
+ * await trackCommunityAccess(false);
24
+ * ```
25
+ */
26
+ export declare function trackCommunityAccess(hasAccess: boolean): Promise<void>;
27
+ //# sourceMappingURL=trackCommunityAccess.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trackCommunityAccess.d.ts","sourceRoot":"","sources":["../../../src/trackCommunityAccess.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAEtE"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Track custom events that are merged into Octopus analytics reports.
3
+ *
4
+ * Use this to send app-specific business events (e.g. purchases, feature usage)
5
+ * so they appear alongside Octopus Community analytics.
6
+ *
7
+ * All property values must be strings. Non-string values should be stringified
8
+ * before calling (e.g. numbers as `"123"`, booleans as `"true"`).
9
+ *
10
+ * @param name - The name of the custom event (e.g. `"purchase"`, `"screen_view"`).
11
+ * @param properties - Optional map of string key-value pairs attached to the event.
12
+ * @returns A promise that resolves when the event has been tracked.
13
+ * @throws An error if the SDK is not initialized or tracking fails.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * await trackCustomEvent('purchase', {
18
+ * product_id: '123',
19
+ * price: '9.99',
20
+ * currency: 'EUR',
21
+ * });
22
+ *
23
+ * await trackCustomEvent('feature_used', {
24
+ * feature: 'community_search',
25
+ * source: 'home_screen',
26
+ * });
27
+ * ```
28
+ */
29
+ export declare function trackCustomEvent(name: string, properties?: Record<string, string>): Promise<void>;
30
+ //# sourceMappingURL=trackCustomEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trackCustomEvent.d.ts","sourceRoot":"","sources":["../../../src/trackCustomEvent.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAClC,OAAO,CAAC,IAAI,CAAC,CAEf"}