@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.
- package/OctopusReactNativeSdk.podspec +1 -1
- package/README.md +40 -35
- package/android/build.gradle +2 -0
- package/android/gradle.properties +2 -2
- package/android/src/main/AndroidManifest.xml +2 -1
- package/android/src/main/AndroidManifestNew.xml +2 -1
- package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusActivity.kt +56 -0
- package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusContent.kt +396 -0
- package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusEventEmitter.kt +22 -0
- package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusEventSerializer.kt +339 -0
- package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusReactModule.kt +326 -0
- package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/{OctopusReactNativeSdkPackage.kt → OctopusReactPackage.kt} +3 -3
- package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusSDKInitializer.kt +53 -9
- package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusSSOAuthenticator.kt +5 -15
- package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusUIConfiguration.kt +6 -0
- package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusUIConfigurationManager.kt +12 -0
- package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusUIController.kt +17 -2
- package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusUIViewManager.kt +63 -0
- package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/ProfileFieldMapper.kt +2 -2
- package/ios/OctopusEventManager.swift +27 -0
- package/ios/OctopusEventSerializer.swift +271 -0
- package/ios/OctopusReactNativeSdk.mm +26 -1
- package/ios/OctopusReactNativeSdk.swift +225 -3
- package/ios/OctopusSDKInitializer.swift +32 -0
- package/ios/OctopusSSOAuthenticator.swift +1 -5
- package/ios/OctopusUIConfiguration.swift +6 -0
- package/ios/OctopusUIManager.swift +134 -10
- package/ios/OctopusUIViewManager.m +7 -0
- package/ios/OctopusUIViewManager.swift +37 -0
- package/lib/module/OctopusUIView.js +39 -0
- package/lib/module/OctopusUIView.js.map +1 -0
- package/lib/module/addHasAccessToCommunityListener.js +33 -0
- package/lib/module/addHasAccessToCommunityListener.js.map +1 -0
- package/lib/module/addNavigateToUrlListener.js +41 -0
- package/lib/module/addNavigateToUrlListener.js.map +1 -0
- package/lib/module/addNotSeenNotificationsCountListener.js +30 -0
- package/lib/module/addNotSeenNotificationsCountListener.js.map +1 -0
- package/lib/module/addSDKEventListener.js +48 -0
- package/lib/module/addSDKEventListener.js.map +1 -0
- package/lib/module/connectUser.js +24 -3
- package/lib/module/connectUser.js.map +1 -1
- package/lib/module/index.js +12 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/initialize.js +13 -12
- package/lib/module/initialize.js.map +1 -1
- package/lib/module/openUI.js +23 -2
- package/lib/module/openUI.js.map +1 -1
- package/lib/module/overrideCommunityAccess.js +36 -0
- package/lib/module/overrideCommunityAccess.js.map +1 -0
- package/lib/module/overrideDefaultLocale.js +75 -0
- package/lib/module/overrideDefaultLocale.js.map +1 -0
- package/lib/module/trackCommunityAccess.js +33 -0
- package/lib/module/trackCommunityAccess.js.map +1 -0
- package/lib/module/trackCustomEvent.js +36 -0
- package/lib/module/trackCustomEvent.js.map +1 -0
- package/lib/module/types/sdkEvents.js +2 -0
- package/lib/module/types/sdkEvents.js.map +1 -0
- package/lib/module/types/urlOpeningStrategy.js +23 -0
- package/lib/module/types/urlOpeningStrategy.js.map +1 -0
- package/lib/module/updateNotSeenNotificationsCount.js +33 -0
- package/lib/module/updateNotSeenNotificationsCount.js.map +1 -0
- package/lib/typescript/src/OctopusUIView.d.ts +32 -0
- package/lib/typescript/src/OctopusUIView.d.ts.map +1 -0
- package/lib/typescript/src/addHasAccessToCommunityListener.d.ts +27 -0
- package/lib/typescript/src/addHasAccessToCommunityListener.d.ts.map +1 -0
- package/lib/typescript/src/addNavigateToUrlListener.d.ts +31 -0
- package/lib/typescript/src/addNavigateToUrlListener.d.ts.map +1 -0
- package/lib/typescript/src/addNotSeenNotificationsCountListener.d.ts +24 -0
- package/lib/typescript/src/addNotSeenNotificationsCountListener.d.ts.map +1 -0
- package/lib/typescript/src/addSDKEventListener.d.ts +43 -0
- package/lib/typescript/src/addSDKEventListener.d.ts.map +1 -0
- package/lib/typescript/src/connectUser.d.ts +24 -8
- package/lib/typescript/src/connectUser.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +13 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/initialize.d.ts +22 -12
- package/lib/typescript/src/initialize.d.ts.map +1 -1
- package/lib/typescript/src/openUI.d.ts +28 -1
- package/lib/typescript/src/openUI.d.ts.map +1 -1
- package/lib/typescript/src/overrideCommunityAccess.d.ts +30 -0
- package/lib/typescript/src/overrideCommunityAccess.d.ts.map +1 -0
- package/lib/typescript/src/overrideDefaultLocale.d.ts +37 -0
- package/lib/typescript/src/overrideDefaultLocale.d.ts.map +1 -0
- package/lib/typescript/src/trackCommunityAccess.d.ts +27 -0
- package/lib/typescript/src/trackCommunityAccess.d.ts.map +1 -0
- package/lib/typescript/src/trackCustomEvent.d.ts +30 -0
- package/lib/typescript/src/trackCustomEvent.d.ts.map +1 -0
- package/lib/typescript/src/types/sdkEvents.d.ts +222 -0
- package/lib/typescript/src/types/sdkEvents.d.ts.map +1 -0
- package/lib/typescript/src/types/urlOpeningStrategy.d.ts +20 -0
- package/lib/typescript/src/types/urlOpeningStrategy.d.ts.map +1 -0
- package/lib/typescript/src/updateNotSeenNotificationsCount.d.ts +27 -0
- package/lib/typescript/src/updateNotSeenNotificationsCount.d.ts.map +1 -0
- package/package.json +2 -1
- package/src/OctopusUIView.tsx +57 -0
- package/src/addHasAccessToCommunityListener.ts +38 -0
- package/src/addNavigateToUrlListener.ts +54 -0
- package/src/addNotSeenNotificationsCountListener.ts +35 -0
- package/src/addSDKEventListener.ts +49 -0
- package/src/connectUser.ts +24 -8
- package/src/index.ts +13 -0
- package/src/initialize.ts +23 -12
- package/src/openUI.ts +32 -2
- package/src/overrideCommunityAccess.ts +33 -0
- package/src/overrideDefaultLocale.ts +88 -0
- package/src/trackCommunityAccess.ts +30 -0
- package/src/trackCustomEvent.ts +36 -0
- package/src/types/sdkEvents.ts +315 -0
- package/src/types/urlOpeningStrategy.ts +20 -0
- package/src/updateNotSeenNotificationsCount.ts +30 -0
- package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusReactNativeSdkModule.kt +0 -155
- package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusUIActivity.kt +0 -422
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { eventEmitter } from "./internals/eventEmitter.js";
|
|
4
|
+
import { OctopusReactNativeSdk } from "./internals/nativeModule.js";
|
|
5
|
+
import { UrlOpeningStrategy as UrlOpeningStrategyEnum } from "./types/urlOpeningStrategy.js";
|
|
6
|
+
/**
|
|
7
|
+
* Adds a listener for URL navigation events from the Octopus Community UI.
|
|
8
|
+
*
|
|
9
|
+
* Only has an effect when the UI was opened with `openUI({ interceptUrls: true })`.
|
|
10
|
+
* When the user taps a link, this callback is invoked with the URL. Return
|
|
11
|
+
* `handledByApp` if your app handles the URL (e.g. in-app web view), or
|
|
12
|
+
* `handledByOctopus` to let the SDK open it in the system browser.
|
|
13
|
+
*
|
|
14
|
+
* @param callback - Function called with the tapped URL. Can be async.
|
|
15
|
+
* Return `UrlOpeningStrategy.handledByApp` or `UrlOpeningStrategy.handledByOctopus`.
|
|
16
|
+
* @returns A subscription object with a `remove()` method to unsubscribe.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const subscription = addNavigateToUrlListener(async (url) => {
|
|
21
|
+
* if (url.startsWith('https://myapp.com/')) {
|
|
22
|
+
* // Handle deep link in-app
|
|
23
|
+
* Linking.openURL(url);
|
|
24
|
+
* return UrlOpeningStrategy.handledByApp;
|
|
25
|
+
* }
|
|
26
|
+
* return UrlOpeningStrategy.handledByOctopus; // Open in system browser
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* // Later, to unsubscribe:
|
|
30
|
+
* subscription.remove();
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function addNavigateToUrlListener(callback) {
|
|
34
|
+
return eventEmitter.addListener('navigateToUrl', async data => {
|
|
35
|
+
const strategy = await Promise.resolve(callback(data.url));
|
|
36
|
+
if (strategy === UrlOpeningStrategyEnum.handledByOctopus) {
|
|
37
|
+
OctopusReactNativeSdk.handleUrlStrategy(data.url, UrlOpeningStrategyEnum.handledByOctopus);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=addNavigateToUrlListener.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["eventEmitter","OctopusReactNativeSdk","UrlOpeningStrategy","UrlOpeningStrategyEnum","addNavigateToUrlListener","callback","addListener","data","strategy","Promise","resolve","url","handledByOctopus","handleUrlStrategy"],"sourceRoot":"../../src","sources":["addNavigateToUrlListener.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,6BAA0B;AACvD,SAASC,qBAAqB,QAAQ,6BAA0B;AAChE,SAEEC,kBAAkB,IAAIC,sBAAsB,QACvC,+BAA4B;AAMnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,wBAAwBA,CACtCC,QAAuC,EACvC;EACA,OAAOL,YAAY,CAACM,WAAW,CAC7B,eAAe,EACf,MAAOC,IAAqB,IAAK;IAC/B,MAAMC,QAAQ,GAAG,MAAMC,OAAO,CAACC,OAAO,CAACL,QAAQ,CAACE,IAAI,CAACI,GAAG,CAAC,CAAC;IAC1D,IAAIH,QAAQ,KAAKL,sBAAsB,CAACS,gBAAgB,EAAE;MACxDX,qBAAqB,CAACY,iBAAiB,CACrCN,IAAI,CAACI,GAAG,EACRR,sBAAsB,CAACS,gBACzB,CAAC;IACH;EACF,CACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { eventEmitter } from "./internals/eventEmitter.js";
|
|
4
|
+
/**
|
|
5
|
+
* Adds a listener for not seen notifications count changes.
|
|
6
|
+
*
|
|
7
|
+
* This listener is triggered whenever the count of unseen notifications changes.
|
|
8
|
+
* The count is automatically updated by the SDK, but can also be manually refreshed
|
|
9
|
+
* using `updateNotSeenNotificationsCount()`.
|
|
10
|
+
*
|
|
11
|
+
* @param callback - Function called when the notification count changes
|
|
12
|
+
* @returns A subscription object with a `remove()` method to unsubscribe
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const subscription = addNotSeenNotificationsCountListener((count) => {
|
|
17
|
+
* console.log(`Unseen notifications: ${count}`);
|
|
18
|
+
* // Update your app's badge or UI
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // Later, to unsubscribe:
|
|
22
|
+
* subscription.remove();
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function addNotSeenNotificationsCountListener(callback) {
|
|
26
|
+
return eventEmitter.addListener('notSeenNotificationsCountChanged', data => {
|
|
27
|
+
callback(data.count);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=addNotSeenNotificationsCountListener.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["eventEmitter","addNotSeenNotificationsCountListener","callback","addListener","data","count"],"sourceRoot":"../../src","sources":["addNotSeenNotificationsCountListener.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,6BAA0B;AAIvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oCAAoCA,CAClDC,QAAmD,EACnD;EACA,OAAOF,YAAY,CAACG,WAAW,CAC7B,kCAAkC,EACjCC,IAAuB,IAAK;IAC3BF,QAAQ,CAACE,IAAI,CAACC,KAAK,CAAC;EACtB,CACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { eventEmitter } from "./internals/eventEmitter.js";
|
|
4
|
+
/**
|
|
5
|
+
* Adds a listener for SDK events.
|
|
6
|
+
*
|
|
7
|
+
* This listener receives all SDK events including:
|
|
8
|
+
* - Content creation (posts, comments, replies)
|
|
9
|
+
* - Content deletion
|
|
10
|
+
* - Reactions and interactions
|
|
11
|
+
* - Gamification events
|
|
12
|
+
* - Screen navigation
|
|
13
|
+
* - Profile modifications
|
|
14
|
+
* - Session events
|
|
15
|
+
* - And more...
|
|
16
|
+
*
|
|
17
|
+
* Use TypeScript type guards to narrow down specific event types:
|
|
18
|
+
*
|
|
19
|
+
* @param callback - Function called when any SDK event occurs
|
|
20
|
+
* @returns A subscription object with a `remove()` method to unsubscribe
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const subscription = addSDKEventListener((event) => {
|
|
25
|
+
* switch (event.type) {
|
|
26
|
+
* case 'postCreated':
|
|
27
|
+
* console.log(`Post created: ${event.postId}`);
|
|
28
|
+
* break;
|
|
29
|
+
* case 'reactionModified':
|
|
30
|
+
* console.log(`Reaction changed on ${event.contentId}`);
|
|
31
|
+
* break;
|
|
32
|
+
* case 'gamificationPointsGained':
|
|
33
|
+
* console.log(`Gained ${event.points} points for ${event.action}`);
|
|
34
|
+
* break;
|
|
35
|
+
* // ... handle other event types
|
|
36
|
+
* }
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* // Later, to unsubscribe:
|
|
40
|
+
* subscription.remove();
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export function addSDKEventListener(callback) {
|
|
44
|
+
return eventEmitter.addListener('sdkEvent', data => {
|
|
45
|
+
callback(data);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=addSDKEventListener.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["eventEmitter","addSDKEventListener","callback","addListener","data"],"sourceRoot":"../../src","sources":["addSDKEventListener.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,6BAA0B;AAKvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAACC,QAAkC,EAAE;EACtE,OAAOF,YAAY,CAACG,WAAW,CAAC,UAAU,EAAGC,IAAc,IAAK;IAC9DF,QAAQ,CAACE,IAAI,CAAC;EAChB,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -4,9 +4,30 @@ import { OctopusReactNativeSdk } from "./internals/nativeModule.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* Connects a user using SSO authentication.
|
|
6
6
|
*
|
|
7
|
-
* This function establishes a connection between your app's user and Octopus.
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* This function establishes a connection between your app's user and Octopus. It requires that you
|
|
8
|
+
* have configured SSO mode during SDK initialization and have set up a token provider using
|
|
9
|
+
* `useUserTokenProvider` or `addUserTokenRequestListener`. The token is obtained via your token
|
|
10
|
+
* provider; you do not pass it directly to `connectUser`. Call `connectUser` after the user logs in;
|
|
11
|
+
* call `disconnectUser` when they log out.
|
|
12
|
+
*
|
|
13
|
+
* @param params - User id and optional profile (username, profilePicture, biography). See {@link ConnectUserParams}.
|
|
14
|
+
* @returns A promise that resolves when the user is connected. Rejects if the SDK is not initialized,
|
|
15
|
+
* SSO is not configured, or the token provider fails.
|
|
16
|
+
* @see {@link useUserTokenProvider} – provide JWT from React components.
|
|
17
|
+
* @see {@link addUserTokenRequestListener} – provide JWT without React.
|
|
18
|
+
* @see {@link disconnectUser} – disconnect the current user.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* await connectUser({
|
|
23
|
+
* userId: 'unique-user-id-from-your-backend',
|
|
24
|
+
* profile: {
|
|
25
|
+
* username: 'john_doe',
|
|
26
|
+
* profilePicture: 'https://example.com/avatar.jpg',
|
|
27
|
+
* biography: 'Software developer'
|
|
28
|
+
* }
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
10
31
|
*/
|
|
11
32
|
export function connectUser(params) {
|
|
12
33
|
return OctopusReactNativeSdk.connectUser(params);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["OctopusReactNativeSdk","connectUser","params"],"sourceRoot":"../../src","sources":["connectUser.ts"],"mappings":";;AAAA,SAASA,qBAAqB,QAAQ,6BAA0B;
|
|
1
|
+
{"version":3,"names":["OctopusReactNativeSdk","connectUser","params"],"sourceRoot":"../../src","sources":["connectUser.ts"],"mappings":";;AAAA,SAASA,qBAAqB,QAAQ,6BAA0B;AAmBhE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAACC,MAAyB,EAAiB;EACpE,OAAOF,qBAAqB,CAACC,WAAW,CAACC,MAAM,CAAC;AAClD","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -5,11 +5,23 @@ export * from "./openUI.js";
|
|
|
5
5
|
export * from "./closeUI.js";
|
|
6
6
|
export * from "./connectUser.js";
|
|
7
7
|
export * from "./disconnectUser.js";
|
|
8
|
+
export * from "./trackCustomEvent.js";
|
|
9
|
+
export * from "./overrideDefaultLocale.js";
|
|
10
|
+
export * from "./updateNotSeenNotificationsCount.js";
|
|
11
|
+
export * from "./overrideCommunityAccess.js";
|
|
12
|
+
export * from "./trackCommunityAccess.js";
|
|
8
13
|
export * from "./addUserTokenRequestListener.js";
|
|
9
14
|
export * from "./useUserTokenProvider.js";
|
|
10
15
|
export * from "./addLoginRequiredListener.js";
|
|
11
16
|
export * from "./addEditUserListener.js";
|
|
17
|
+
export * from "./addNotSeenNotificationsCountListener.js";
|
|
18
|
+
export * from "./addHasAccessToCommunityListener.js";
|
|
19
|
+
export * from "./addSDKEventListener.js";
|
|
20
|
+
export * from "./addNavigateToUrlListener.js";
|
|
12
21
|
export * from "./types/userProfileField.js";
|
|
22
|
+
export * from "./types/sdkEvents.js";
|
|
23
|
+
export * from "./types/urlOpeningStrategy.js";
|
|
13
24
|
export * from "./logger.js";
|
|
14
25
|
export * from "./enums/LogLevel.enum.js";
|
|
26
|
+
export { OctopusUIView } from "./OctopusUIView.js";
|
|
15
27
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,cAAc,iBAAc;AAC5B,cAAc,aAAU;AACxB,cAAc,cAAW;AACzB,cAAc,kBAAe;AAC7B,cAAc,qBAAkB;AAChC,cAAc,kCAA+B;AAC7C,cAAc,2BAAwB;AACtC,cAAc,+BAA4B;AAC1C,cAAc,0BAAuB;AACrC,cAAc,6BAA0B;AACxC,cAAc,aAAU;AACxB,cAAc,0BAAuB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["OctopusUIView"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,cAAc,iBAAc;AAC5B,cAAc,aAAU;AACxB,cAAc,cAAW;AACzB,cAAc,kBAAe;AAC7B,cAAc,qBAAkB;AAChC,cAAc,uBAAoB;AAClC,cAAc,4BAAyB;AACvC,cAAc,sCAAmC;AACjD,cAAc,8BAA2B;AACzC,cAAc,2BAAwB;AACtC,cAAc,kCAA+B;AAC7C,cAAc,2BAAwB;AACtC,cAAc,+BAA4B;AAC1C,cAAc,0BAAuB;AACrC,cAAc,2CAAwC;AACtD,cAAc,sCAAmC;AACjD,cAAc,0BAAuB;AACrC,cAAc,+BAA4B;AAC1C,cAAc,6BAA0B;AACxC,cAAc,sBAAmB;AACjC,cAAc,+BAA4B;AAC1C,cAAc,aAAU;AACxB,cAAc,0BAAuB;AACrC,SAASA,aAAa,QAAQ,oBAAiB","ignoreList":[]}
|
package/lib/module/initialize.js
CHANGED
|
@@ -33,6 +33,10 @@ import { parseFontConfig } from "./internals/fontParser.js";
|
|
|
33
33
|
* 2. Dual mode colors - separate color sets for light and dark modes
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* UI customization options for platform-specific layout adjustments.
|
|
38
|
+
*/
|
|
39
|
+
|
|
36
40
|
/**
|
|
37
41
|
* Configuration params for initializing the Octopus SDK.
|
|
38
42
|
*/
|
|
@@ -40,26 +44,23 @@ import { parseFontConfig } from "./internals/fontParser.js";
|
|
|
40
44
|
/**
|
|
41
45
|
* Initializes the Octopus SDK with the provided configuration.
|
|
42
46
|
*
|
|
43
|
-
* This function must be called before using any other Octopus SDK features.
|
|
44
|
-
*
|
|
47
|
+
* This function must be called before using any other Octopus SDK features. It sets up the SDK
|
|
48
|
+
* with your API key, connection mode (SSO or Octopus-managed authentication), and optional theme
|
|
49
|
+
* and UI options. For SSO, you also need to set up a token provider with `useUserTokenProvider` or
|
|
50
|
+
* `addUserTokenRequestListener` before calling `connectUser`.
|
|
51
|
+
*
|
|
52
|
+
* @param params - See {@link InitializeParams} (including `theme`, `ui`). For theming guide see the main README.
|
|
53
|
+
* @see {@link connectUser} – connect a user after initialization (SSO mode).
|
|
45
54
|
*
|
|
46
55
|
* @example
|
|
47
56
|
* ```typescript
|
|
48
|
-
* // Initialize with SSO mode
|
|
49
57
|
* await initialize({
|
|
50
58
|
* apiKey: 'your-api-key',
|
|
51
|
-
* connectionMode: {
|
|
52
|
-
* type: 'sso',
|
|
53
|
-
* appManagedFields: ['username', 'profilePicture']
|
|
54
|
-
* }
|
|
59
|
+
* connectionMode: { type: 'sso', appManagedFields: ['username', 'profilePicture'] }
|
|
55
60
|
* });
|
|
56
|
-
*
|
|
57
|
-
* // Initialize with Octopus authentication
|
|
58
61
|
* await initialize({
|
|
59
62
|
* apiKey: 'your-api-key',
|
|
60
|
-
* connectionMode: {
|
|
61
|
-
* type: 'octopus'
|
|
62
|
-
* }
|
|
63
|
+
* connectionMode: { type: 'octopus' }
|
|
63
64
|
* });
|
|
64
65
|
* ```
|
|
65
66
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["OctopusReactNativeSdk","Appearance","colorSchemeManager","parseFontConfig","initialize","params","colorScheme","getColorScheme","processedTheme","theme","fonts","parsedConfig","undefined","paramsWithColorScheme","setTheme","startListening"],"sourceRoot":"../../src","sources":["initialize.ts"],"mappings":";;AAAA,SAASA,qBAAqB,QAAQ,6BAA0B;AAGhE,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,kBAAkB,QAAQ,mCAAgC;AACnE,SAASC,eAAe,QAA+B,2BAAwB;;AAE/E;AACA;AACA;;AAYA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;;AAQA;AACA;AACA;;AA0BA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBA;AACA;AACA;;
|
|
1
|
+
{"version":3,"names":["OctopusReactNativeSdk","Appearance","colorSchemeManager","parseFontConfig","initialize","params","colorScheme","getColorScheme","processedTheme","theme","fonts","parsedConfig","undefined","paramsWithColorScheme","setTheme","startListening"],"sourceRoot":"../../src","sources":["initialize.ts"],"mappings":";;AAAA,SAASA,qBAAqB,QAAQ,6BAA0B;AAGhE,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,kBAAkB,QAAQ,mCAAgC;AACnE,SAASC,eAAe,QAA+B,2BAAwB;;AAE/E;AACA;AACA;;AAYA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;;AAQA;AACA;AACA;;AA0BA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBA;AACA;AACA;;AAUA;AACA;AACA;;AA0BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAACC,MAAwB,EAAiB;EAClE;EACA,MAAMC,WAAW,GAAGL,UAAU,CAACM,cAAc,CAAC,CAAC;;EAE/C;EACA,MAAMC,cAAc,GAAGH,MAAM,CAACI,KAAK,GAC/B;IACE,GAAGJ,MAAM,CAACI,KAAK;IACfC,KAAK,EAAEL,MAAM,CAACI,KAAK,CAACC,KAAK,GACrB;MACE,GAAGL,MAAM,CAACI,KAAK,CAACC,KAAK;MACrBC,YAAY,EAAER,eAAe,CAACE,MAAM,CAACI,KAAK,CAACC,KAAK;IAClD,CAAC,GACDE;EACN,CAAC,GACDA,SAAS;EAEb,MAAMC,qBAAqB,GAAG;IAC5B,GAAGR,MAAM;IACTI,KAAK,EAAED,cAAc;IACrBF,WAAW,EAAEA,WAAW,IAAIM;EAC9B,CAAC;;EAED;EACAV,kBAAkB,CAACY,QAAQ,CAACN,cAAc,IAAI,IAAI,CAAC;;EAEnD;EACAN,kBAAkB,CAACa,cAAc,CAAC,CAAC;EAEnC,OAAOf,qBAAqB,CAACI,UAAU,CAACS,qBAAqB,CAAC;AAChE","ignoreList":[]}
|
package/lib/module/openUI.js
CHANGED
|
@@ -2,10 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
import { OctopusReactNativeSdk } from "./internals/nativeModule.js";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Options for opening the Octopus UI.
|
|
7
|
+
*/
|
|
8
|
+
|
|
5
9
|
/**
|
|
6
10
|
* Opens the Octopus UI home screen.
|
|
11
|
+
*
|
|
12
|
+
* @param options - Optional configuration. Use `interceptUrls: true` to receive
|
|
13
|
+
* URL taps via `addNavigateToUrlListener` instead of having the SDK open them.
|
|
14
|
+
* @returns A promise that resolves when the UI has been opened.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Open UI with default behaviour (SDK opens links in system browser)
|
|
19
|
+
* await openUI();
|
|
20
|
+
*
|
|
21
|
+
* // Open UI with URL interception (app receives links via addNavigateToUrlListener)
|
|
22
|
+
* await openUI({ interceptUrls: true });
|
|
23
|
+
* ```
|
|
7
24
|
*/
|
|
8
|
-
export function openUI() {
|
|
9
|
-
|
|
25
|
+
export function openUI(options) {
|
|
26
|
+
const opts = options ?? {};
|
|
27
|
+
const interceptUrls = opts.interceptUrls === true;
|
|
28
|
+
return OctopusReactNativeSdk.openUI({
|
|
29
|
+
interceptUrls
|
|
30
|
+
});
|
|
10
31
|
}
|
|
11
32
|
//# sourceMappingURL=openUI.js.map
|
package/lib/module/openUI.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["OctopusReactNativeSdk","openUI"],"sourceRoot":"../../src","sources":["openUI.ts"],"mappings":";;AAAA,SAASA,qBAAqB,QAAQ,6BAA0B;;AAEhE;AACA;AACA;AACA,OAAO,SAASC,MAAMA,
|
|
1
|
+
{"version":3,"names":["OctopusReactNativeSdk","openUI","options","opts","interceptUrls"],"sourceRoot":"../../src","sources":["openUI.ts"],"mappings":";;AAAA,SAASA,qBAAqB,QAAQ,6BAA0B;;AAEhE;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,MAAMA,CAACC,OAAuB,EAAiB;EAC7D,MAAMC,IAAI,GAAGD,OAAO,IAAI,CAAC,CAAC;EAC1B,MAAME,aAAa,GAAGD,IAAI,CAACC,aAAa,KAAK,IAAI;EACjD,OAAOJ,qBAAqB,CAACC,MAAM,CAAC;IAAEG;EAAc,CAAC,CAAC;AACxD","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { OctopusReactNativeSdk } from "./internals/nativeModule.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Override the community access cohort for the current user.
|
|
7
|
+
*
|
|
8
|
+
* **When to use:** When the **Octopus SDK manages the A/B logic** — i.e. Octopus assigns
|
|
9
|
+
* the cohort and decides who has access to the community. In that case, the "Has access
|
|
10
|
+
* to community" state is the cohort value. Use this function to override that cohort
|
|
11
|
+
* (e.g. for testing or feature gating). The new state is reflected via `addHasAccessToCommunityListener`.
|
|
12
|
+
*
|
|
13
|
+
* **When not to use:** If **your app** decides who has access (e.g. your own feature flag or A/B logic),
|
|
14
|
+
* do not use `overrideCommunityAccess`. Use `trackCommunityAccess` instead to report the access
|
|
15
|
+
* value to Octopus for analytics only; that does not change the actual access state in the SDK.
|
|
16
|
+
*
|
|
17
|
+
* @param hasAccess - `true` to grant access, `false` to deny access.
|
|
18
|
+
* @returns A promise that resolves when the override has been applied.
|
|
19
|
+
* @throws An error if the SDK is not initialized or the call fails.
|
|
20
|
+
* @see {@link addHasAccessToCommunityListener} – subscribe to the Octopus-managed community access state.
|
|
21
|
+
* @see {@link trackCommunityAccess} – when your app manages access, report it for analytics only (no change to SDK state).
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const subscription = addHasAccessToCommunityListener((hasAccess) => {
|
|
26
|
+
* console.log(`Has access to community: ${hasAccess}`);
|
|
27
|
+
* });
|
|
28
|
+
* await overrideCommunityAccess(true);
|
|
29
|
+
* await overrideCommunityAccess(false);
|
|
30
|
+
* subscription.remove();
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function overrideCommunityAccess(hasAccess) {
|
|
34
|
+
return OctopusReactNativeSdk.overrideCommunityAccess(hasAccess);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=overrideCommunityAccess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["OctopusReactNativeSdk","overrideCommunityAccess","hasAccess"],"sourceRoot":"../../src","sources":["overrideCommunityAccess.ts"],"mappings":";;AAAA,SAASA,qBAAqB,QAAQ,6BAA0B;;AAEhE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAACC,SAAkB,EAAiB;EACzE,OAAOF,qBAAqB,CAACC,uBAAuB,CAACC,SAAS,CAAC;AACjE","ignoreList":[]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { OctopusReactNativeSdk } from "./internals/nativeModule.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Parameters for overriding the default locale used by the Octopus SDK UI.
|
|
7
|
+
* Uses ISO 639-1 language code and optional ISO 3166-1 alpha-2 country code.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** ISO 639-1: exactly 2 alphabetic characters (case-insensitive, normalized to lowercase). */
|
|
11
|
+
const LANGUAGE_CODE_REGEX = /^[a-zA-Z]{2}$/;
|
|
12
|
+
|
|
13
|
+
/** ISO 3166-1 alpha-2: exactly 2 alphabetic characters (case-insensitive, normalized to uppercase). */
|
|
14
|
+
const COUNTRY_CODE_REGEX = /^[a-zA-Z]{2}$/;
|
|
15
|
+
function validateAndNormalizeLocale(locale) {
|
|
16
|
+
const lang = locale.languageCode?.trim() ?? '';
|
|
17
|
+
if (!LANGUAGE_CODE_REGEX.test(lang)) {
|
|
18
|
+
throw new Error("overrideDefaultLocale: languageCode must be a 2-letter ISO 639-1 code (e.g. 'en', 'fr')");
|
|
19
|
+
}
|
|
20
|
+
const country = locale.countryCode?.trim();
|
|
21
|
+
if (country !== undefined && country !== '') {
|
|
22
|
+
if (!COUNTRY_CODE_REGEX.test(country)) {
|
|
23
|
+
throw new Error("overrideDefaultLocale: countryCode must be a 2-letter ISO 3166-1 alpha-2 code (e.g. 'US', 'FR')");
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
languageCode: lang.toLowerCase(),
|
|
27
|
+
countryCode: country.toUpperCase()
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
languageCode: lang.toLowerCase(),
|
|
32
|
+
countryCode: null
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Override the default locale used by the Octopus SDK for its UI.
|
|
38
|
+
*
|
|
39
|
+
* The change takes effect immediately for subsequently displayed SDK screens.
|
|
40
|
+
* Pass `null` to reset to the system default locale.
|
|
41
|
+
*
|
|
42
|
+
* @param locale - Object with `languageCode` and optional `countryCode`
|
|
43
|
+
* (e.g. `{ languageCode: 'fr' }` or `{ languageCode: 'en', countryCode: 'US' }`).
|
|
44
|
+
* Pass `null` to use the system default (no override).
|
|
45
|
+
* @returns A promise that resolves when the override has been applied.
|
|
46
|
+
* @throws An error if the SDK is not initialized or the call fails.
|
|
47
|
+
* @throws An error if locale is invalid (e.g. non-ISO language/country codes).
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* // Use French
|
|
52
|
+
* await overrideDefaultLocale({ languageCode: 'fr' });
|
|
53
|
+
*
|
|
54
|
+
* // Use English (US)
|
|
55
|
+
* await overrideDefaultLocale({ languageCode: 'en', countryCode: 'US' });
|
|
56
|
+
*
|
|
57
|
+
* // Reset to system default
|
|
58
|
+
* await overrideDefaultLocale(null);
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export function overrideDefaultLocale(locale) {
|
|
62
|
+
if (locale === null) {
|
|
63
|
+
return OctopusReactNativeSdk.overrideDefaultLocale(null, null);
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
const {
|
|
67
|
+
languageCode,
|
|
68
|
+
countryCode
|
|
69
|
+
} = validateAndNormalizeLocale(locale);
|
|
70
|
+
return OctopusReactNativeSdk.overrideDefaultLocale(languageCode, countryCode);
|
|
71
|
+
} catch (e) {
|
|
72
|
+
return Promise.reject(e);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=overrideDefaultLocale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["OctopusReactNativeSdk","LANGUAGE_CODE_REGEX","COUNTRY_CODE_REGEX","validateAndNormalizeLocale","locale","lang","languageCode","trim","test","Error","country","countryCode","undefined","toLowerCase","toUpperCase","overrideDefaultLocale","e","Promise","reject"],"sourceRoot":"../../src","sources":["overrideDefaultLocale.ts"],"mappings":";;AAAA,SAASA,qBAAqB,QAAQ,6BAA0B;;AAEhE;AACA;AACA;AACA;;AAQA;AACA,MAAMC,mBAAmB,GAAG,eAAe;;AAE3C;AACA,MAAMC,kBAAkB,GAAG,eAAe;AAE1C,SAASC,0BAA0BA,CAACC,MAA4B,EAG9D;EACA,MAAMC,IAAI,GAAGD,MAAM,CAACE,YAAY,EAAEC,IAAI,CAAC,CAAC,IAAI,EAAE;EAC9C,IAAI,CAACN,mBAAmB,CAACO,IAAI,CAACH,IAAI,CAAC,EAAE;IACnC,MAAM,IAAII,KAAK,CACb,yFACF,CAAC;EACH;EACA,MAAMC,OAAO,GAAGN,MAAM,CAACO,WAAW,EAAEJ,IAAI,CAAC,CAAC;EAC1C,IAAIG,OAAO,KAAKE,SAAS,IAAIF,OAAO,KAAK,EAAE,EAAE;IAC3C,IAAI,CAACR,kBAAkB,CAACM,IAAI,CAACE,OAAO,CAAC,EAAE;MACrC,MAAM,IAAID,KAAK,CACb,iGACF,CAAC;IACH;IACA,OAAO;MACLH,YAAY,EAAED,IAAI,CAACQ,WAAW,CAAC,CAAC;MAChCF,WAAW,EAAED,OAAO,CAACI,WAAW,CAAC;IACnC,CAAC;EACH;EACA,OAAO;IACLR,YAAY,EAAED,IAAI,CAACQ,WAAW,CAAC,CAAC;IAChCF,WAAW,EAAE;EACf,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,qBAAqBA,CACnCX,MAAmC,EACpB;EACf,IAAIA,MAAM,KAAK,IAAI,EAAE;IACnB,OAAOJ,qBAAqB,CAACe,qBAAqB,CAAC,IAAI,EAAE,IAAI,CAAC;EAChE;EACA,IAAI;IACF,MAAM;MAAET,YAAY;MAAEK;IAAY,CAAC,GAAGR,0BAA0B,CAACC,MAAM,CAAC;IACxE,OAAOJ,qBAAqB,CAACe,qBAAqB,CAChDT,YAAY,EACZK,WACF,CAAC;EACH,CAAC,CAAC,OAAOK,CAAC,EAAE;IACV,OAAOC,OAAO,CAACC,MAAM,CAACF,CAAC,CAAC;EAC1B;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { OctopusReactNativeSdk } from "./internals/nativeModule.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Track community access for analytics without changing the actual access.
|
|
7
|
+
*
|
|
8
|
+
* **When to use:** When **your app manages its own A/B logic** — i.e. your app decides who can see
|
|
9
|
+
* the community (e.g. via your own feature flag or experiment). Call this to report that decision
|
|
10
|
+
* to Octopus for analytics only. It does not grant or restrict access in the SDK; it only records
|
|
11
|
+
* the value for reporting.
|
|
12
|
+
*
|
|
13
|
+
* **When not to use:** If the **Octopus SDK manages the cohort** (Octopus assigns who has access),
|
|
14
|
+
* use `overrideCommunityAccess` to change the cohort and `addHasAccessToCommunityListener` to react
|
|
15
|
+
* to it. Use `trackCommunityAccess` only when the access decision is owned by your app and you just
|
|
16
|
+
* need to report it.
|
|
17
|
+
*
|
|
18
|
+
* @param hasAccess - The access value to report (e.g. the variant your app decided).
|
|
19
|
+
* @returns A promise that resolves when the tracking call has completed.
|
|
20
|
+
* @throws An error if the SDK is not initialized or the call fails.
|
|
21
|
+
* @see {@link overrideCommunityAccess} – when Octopus manages the cohort, override it (and use addHasAccessToCommunityListener to react).
|
|
22
|
+
* @see {@link addHasAccessToCommunityListener} – subscribe to the Octopus-managed access state (relevant when Octopus or override sets it).
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* await trackCommunityAccess(true);
|
|
27
|
+
* await trackCommunityAccess(false);
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export function trackCommunityAccess(hasAccess) {
|
|
31
|
+
return OctopusReactNativeSdk.trackCommunityAccess(hasAccess);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=trackCommunityAccess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["OctopusReactNativeSdk","trackCommunityAccess","hasAccess"],"sourceRoot":"../../src","sources":["trackCommunityAccess.ts"],"mappings":";;AAAA,SAASA,qBAAqB,QAAQ,6BAA0B;;AAEhE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAACC,SAAkB,EAAiB;EACtE,OAAOF,qBAAqB,CAACC,oBAAoB,CAACC,SAAS,CAAC;AAC9D","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { OctopusReactNativeSdk } from "./internals/nativeModule.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Track custom events that are merged into Octopus analytics reports.
|
|
7
|
+
*
|
|
8
|
+
* Use this to send app-specific business events (e.g. purchases, feature usage)
|
|
9
|
+
* so they appear alongside Octopus Community analytics.
|
|
10
|
+
*
|
|
11
|
+
* All property values must be strings. Non-string values should be stringified
|
|
12
|
+
* before calling (e.g. numbers as `"123"`, booleans as `"true"`).
|
|
13
|
+
*
|
|
14
|
+
* @param name - The name of the custom event (e.g. `"purchase"`, `"screen_view"`).
|
|
15
|
+
* @param properties - Optional map of string key-value pairs attached to the event.
|
|
16
|
+
* @returns A promise that resolves when the event has been tracked.
|
|
17
|
+
* @throws An error if the SDK is not initialized or tracking fails.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* await trackCustomEvent('purchase', {
|
|
22
|
+
* product_id: '123',
|
|
23
|
+
* price: '9.99',
|
|
24
|
+
* currency: 'EUR',
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* await trackCustomEvent('feature_used', {
|
|
28
|
+
* feature: 'community_search',
|
|
29
|
+
* source: 'home_screen',
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function trackCustomEvent(name, properties) {
|
|
34
|
+
return OctopusReactNativeSdk.trackCustomEvent(name, properties ?? {});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=trackCustomEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["OctopusReactNativeSdk","trackCustomEvent","name","properties"],"sourceRoot":"../../src","sources":["trackCustomEvent.ts"],"mappings":";;AAAA,SAASA,qBAAqB,QAAQ,6BAA0B;;AAEhE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAC9BC,IAAY,EACZC,UAAmC,EACpB;EACf,OAAOH,qBAAqB,CAACC,gBAAgB,CAACC,IAAI,EAAEC,UAAU,IAAI,CAAC,CAAC,CAAC;AACvE","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/sdkEvents.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Strategy for handling URLs tapped inside the Octopus Community UI.
|
|
5
|
+
*
|
|
6
|
+
* When URL interception is enabled via `openUI({ interceptUrls: true })`,
|
|
7
|
+
* the app receives each tapped URL via `addNavigateToUrlListener`. The callback
|
|
8
|
+
* returns one of these strategies to decide who handles the URL.
|
|
9
|
+
*/
|
|
10
|
+
export let UrlOpeningStrategy = /*#__PURE__*/function (UrlOpeningStrategy) {
|
|
11
|
+
/**
|
|
12
|
+
* The URL has been handled by the app. The SDK will not open it.
|
|
13
|
+
* Use this when you open the URL in an in-app web view or handle it yourself.
|
|
14
|
+
*/
|
|
15
|
+
UrlOpeningStrategy["handledByApp"] = "handledByApp";
|
|
16
|
+
/**
|
|
17
|
+
* The URL should be opened by the Octopus SDK (system browser).
|
|
18
|
+
* The native layer will open the URL in the default browser when this is returned.
|
|
19
|
+
*/
|
|
20
|
+
UrlOpeningStrategy["handledByOctopus"] = "handledByOctopus";
|
|
21
|
+
return UrlOpeningStrategy;
|
|
22
|
+
}({});
|
|
23
|
+
//# sourceMappingURL=urlOpeningStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["UrlOpeningStrategy"],"sourceRoot":"../../../src","sources":["types/urlOpeningStrategy.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAYA,kBAAkB,0BAAlBA,kBAAkB;EAC5B;AACF;AACA;AACA;EAJYA,kBAAkB;EAO5B;AACF;AACA;AACA;EAVYA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { OctopusReactNativeSdk } from "./internals/nativeModule.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Force refresh the unseen notification count from the server.
|
|
7
|
+
*
|
|
8
|
+
* This method triggers a manual update of the notification badge count.
|
|
9
|
+
* The updated count will be emitted via the notSeenNotificationsCountChanged event.
|
|
10
|
+
* Use `addNotSeenNotificationsCountListener` to listen for count changes.
|
|
11
|
+
*
|
|
12
|
+
* @returns A promise that resolves when the update is complete.
|
|
13
|
+
* @throws An error if the SDK is not initialized or if the update fails.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Listen to count changes
|
|
18
|
+
* const subscription = addNotSeenNotificationsCountListener((count) => {
|
|
19
|
+
* console.log(`Unseen notifications: ${count}`);
|
|
20
|
+
* // Update your badge UI
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Manually refresh the count
|
|
24
|
+
* await updateNotSeenNotificationsCount();
|
|
25
|
+
*
|
|
26
|
+
* // Later, unsubscribe
|
|
27
|
+
* subscription.remove();
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export function updateNotSeenNotificationsCount() {
|
|
31
|
+
return OctopusReactNativeSdk.updateNotSeenNotificationsCount();
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=updateNotSeenNotificationsCount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["OctopusReactNativeSdk","updateNotSeenNotificationsCount"],"sourceRoot":"../../src","sources":["updateNotSeenNotificationsCount.ts"],"mappings":";;AAAA,SAASA,qBAAqB,QAAQ,6BAA0B;;AAEhE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,+BAA+BA,CAAA,EAAkB;EAC/D,OAAOD,qBAAqB,CAACC,+BAA+B,CAAC,CAAC;AAChE","ignoreList":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
2
|
+
export interface OctopusUIViewProps {
|
|
3
|
+
/**
|
|
4
|
+
* When `true`, URLs tapped inside the community UI are not opened by the SDK.
|
|
5
|
+
* Instead, a `navigateToUrl` event is emitted. Subscribe with
|
|
6
|
+
* `addNavigateToUrlListener` to receive the URL.
|
|
7
|
+
*
|
|
8
|
+
* @default false
|
|
9
|
+
*/
|
|
10
|
+
interceptUrls?: boolean;
|
|
11
|
+
style?: StyleProp<ViewStyle>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Embeds the Octopus Community UI as a native view inside your screen.
|
|
15
|
+
* Use this when you want to keep your app navigation (e.g. bottom tab bar) visible
|
|
16
|
+
* instead of opening the SDK in fullscreen with `openUI()`.
|
|
17
|
+
*
|
|
18
|
+
* You must call `initialize()` before rendering this component.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* function CommunityTab() {
|
|
23
|
+
* return (
|
|
24
|
+
* <View style={{ flex: 1 }}>
|
|
25
|
+
* <OctopusUIView interceptUrls={true} style={StyleSheet.absoluteFill} />
|
|
26
|
+
* </View>
|
|
27
|
+
* );
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function OctopusUIView({ interceptUrls, style, }: OctopusUIViewProps): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
//# sourceMappingURL=OctopusUIView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OctopusUIView.d.ts","sourceRoot":"","sources":["../../../src/OctopusUIView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAKD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,EAC5B,aAAqB,EACrB,KAAK,GACN,EAAE,kBAAkB,2CAOpB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type HasAccessToCommunityListenerCallback = (hasAccess: boolean) => void;
|
|
2
|
+
/**
|
|
3
|
+
* Adds a listener for community access changes.
|
|
4
|
+
*
|
|
5
|
+
* This listener receives the **Octopus-managed** access state: the cohort value that determines
|
|
6
|
+
* whether the user has access to the community (when the SDK manages the A/B logic). It is triggered
|
|
7
|
+
* when that state changes — e.g. after you call `overrideCommunityAccess`, or when the cohort is
|
|
8
|
+
* updated by Octopus. Use it to show or hide community entry points in your UI. If your app manages
|
|
9
|
+
* access itself (and only reports it via `trackCommunityAccess`), this listener is less relevant,
|
|
10
|
+
* since the SDK is not the source of the access decision.
|
|
11
|
+
*
|
|
12
|
+
* @param callback - Function called when the access status changes
|
|
13
|
+
* @returns A subscription object with a `remove()` method to unsubscribe
|
|
14
|
+
* @see {@link overrideCommunityAccess} – set the cohort when Octopus manages A/B.
|
|
15
|
+
* @see {@link trackCommunityAccess} – report access for analytics when your app manages access.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const subscription = addHasAccessToCommunityListener((hasAccess) => {
|
|
20
|
+
* console.log(`Has access to community: ${hasAccess}`);
|
|
21
|
+
* // Show or hide community features based on access
|
|
22
|
+
* });
|
|
23
|
+
* subscription.remove();
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function addHasAccessToCommunityListener(callback: HasAccessToCommunityListenerCallback): import("react-native").EmitterSubscription;
|
|
27
|
+
//# sourceMappingURL=addHasAccessToCommunityListener.d.ts.map
|