Skip to content
Open
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
9c53b71
fix: setup sdk function working now
aaditya-smallcase May 30, 2025
b30f6fa
feat: remove old example app and add new smart investing app
indrajit-roy-sc Jul 20, 2025
f4d0333
chore: android working state with 0.79.4
indrajit-roy-sc Jul 20, 2025
6acd2e4
chore: ios working state with 0.79.4
indrajit-roy-sc Jul 20, 2025
2f9c755
feat: implement core functionality for smart investing app
indrajit-roy-sc Jul 20, 2025
129e071
chore: revert back iOS min version and SCGateway dependency to match
indrajit-roy-sc Jul 24, 2025
24b1ca8
chore: update Podfile.lock
indrajit-roy-sc Jul 24, 2025
94a5d70
feat(analytics): Adding events capturing through new RCTBridgeModule
dporwal-shipit Jul 29, 2025
75bd9c3
feat(analytics): Adding events capturing through new RCTBridgeModule
dporwal-shipit Jul 29, 2025
0fc855d
feature(analytics): working state
dporwal-shipit Jul 30, 2025
145a91d
chore: update SCGateway dependency to version 4.1.5 in Podfile.lock
indrajit-roy-sc Aug 1, 2025
c70b0b1
chore: update iOS run script to list available devices
indrajit-roy-sc Aug 1, 2025
63378d4
revert: change impl. back to stable version
indrajit-roy-sc Aug 1, 2025
4eb3933
feature(analytics): updated code to capture events.
dporwal-shipit Aug 5, 2025
0e0091a
feature(analytics): updated code to capture events.
dporwal-shipit Aug 5, 2025
44ad07b
feat(analytics):- remove Mixpanel from SCLoans and substitute with ne…
dporwal-shipit Aug 8, 2025
2a2b64d
app building
dporwal-shipit Aug 11, 2025
f82d8c1
developing android event flow
dporwal-shipit Aug 12, 2025
2a319f7
feature(analytics): working state android and ios scgateway emitters
dporwal-shipit Aug 12, 2025
08de62a
feature(analytics): Working state android scloans events incoming
dporwal-shipit Aug 18, 2025
42eb202
feature(analytics): working state ios events emission-capturing
dporwal-shipit Aug 26, 2025
ca7ed39
feature(analytics): working state android events emission-capturing
dporwal-shipit Aug 26, 2025
8008365
refactor(analytics): restructure event bridging logic for improved ma…
dporwal-shipit Aug 30, 2025
767a0c2
refactor(analytics): restructure loans event bridging logic for impro…
dporwal-shipit Aug 31, 2025
46d9821
feature(analytics): making changes as requested in PR reviews
dporwal-shipit Sep 4, 2025
3691d60
feature(analytics): making changes as per PR request reviews
dporwal-shipit Sep 5, 2025
9ee02e7
feature(analytics): making changes as per PR request reviews
dporwal-shipit Sep 5, 2025
2b62d03
refactor(SCGatewayEvents): streamline initialization and subscription…
indrajit-roy-sc Sep 5, 2025
b55d7e3
refactor(analytics): refactoring the native files in bridge to forwar…
dporwal-shipit Sep 6, 2025
d29aba7
refactor(analytics): refactoring the code, shifted App.tsx from class…
dporwal-shipit Sep 6, 2025
9d19442
refactor(analytics): working state of android scgateway & scloans
dporwal-shipit Sep 7, 2025
2832b51
refactor(analytics): working state of ios scgateway & scloans
dporwal-shipit Sep 7, 2025
27eb4fb
refactor(analytics): making use of native sdk exposed properties dire…
dporwal-shipit Sep 7, 2025
1e7f2a0
refactor(analytics): standardize class structure with formatting and …
dporwal-shipit Sep 7, 2025
a17eac1
chore(analytics): Merge upgrade/react-native-0.79.4 into branch upgra…
dporwal-shipit Sep 7, 2025
8292030
refactor: improve event emitters and clean up codebase
dporwal-shipit Sep 8, 2025
4f1a28e
refactor: we no longer need try-catch in onCatalystInstanceDestroy
dporwal-shipit Sep 8, 2025
4fe94b8
refactor: we no longer need try-catch in onCatalystInstanceDestroy
dporwal-shipit Sep 8, 2025
4949c3e
refactor: renaming to ensure consistency across ios/android
dporwal-shipit Sep 8, 2025
3891eee
changed the PRODUCT_BUNDLE_IDENTIFIER and updated build.gradle with n…
dporwal-shipit Sep 8, 2025
b26c64b
making changes as per PR reviews
dporwal-shipit Sep 8, 2025
eff311e
making changes as per PR
dporwal-shipit Sep 9, 2025
8697b0b
Merge remote-tracking branch 'origin/development' into upgrade-react-…
dporwal-shipit Sep 9, 2025
09f4c52
2nd emitter got added while testing in XCode-VSCode, removed
dporwal-shipit Sep 9, 2025
25e9221
making changes as per PR reviews
dporwal-shipit Sep 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ buildscript {
}

dependencies {
//noinspection GradlePluginVersion
classpath 'com.android.tools.build:gradle:3.5.3'
// noinspection DifferentKotlinGradleVersion
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Expand Down Expand Up @@ -57,6 +58,12 @@ android {
}
}

// Ensure React Native Android sources are locatable when opening this library standalone
if (!rootProject.ext.has('reactNativeAndroidRoot')) {
// Absolute or relative path to the app's RN Android directory
rootProject.ext.reactNativeAndroidRoot = file('../../smart_investing_react_native/node_modules/react-native/android')
}

repositories {
mavenCentral()
google()
Expand All @@ -69,7 +76,7 @@ repositories {
password "reactNativeUser123"
}
}

maven {
url "https://artifactory.smallcase.com/artifactory/SCGateway-internal"
credentials {
Expand Down Expand Up @@ -149,8 +156,8 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+' // From node_modules
implementation 'com.smallcase.gateway:sdk:4.2.2'
implementation 'com.smallcase.loans:sdk:3.1.1'
implementation 'com.smallcase.gateway:sdk-sdk-extract-mixpanel-from-sdk:4.2.2-3183-release'
implementation 'com.smallcase.loans:sdk-sdk-extract-mixpanel-from-sdk:3.1.1-72-release'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the versions. This is probably local-device maven version numbers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we are testing internal builds right now, we would add the final version when it would get merged to main branch and a final android sdk would be released.

implementation "androidx.core:core-ktx:1.3.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
package com.reactnativesmallcasegateway

import android.util.Log
import com.facebook.react.bridge.*
import com.facebook.react.modules.core.DeviceEventManagerModule
import com.facebook.react.bridge.UiThreadUtil
import com.smallcase.gateway.data.listeners.NotificationCenter
import com.smallcase.gateway.data.listeners.Notification
import com.smallcase.gateway.portal.SmallcaseGatewaySdk
import com.smallcase.gateway.portal.ScgNotification

class SCGatewayBridgeEmitter(private val reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {

companion object {
const val TAG = "SCGatewayBridgeEmitter"
const val ANALYTICS_EVENT = ScgNotification.ANALYTICS_EVENT
const val SUPER_PROPERTIES_UPDATED = ScgNotification.SUPER_PROPS_UPDATED
const val USER_RESET = ScgNotification.USER_RESET
const val USER_IDENTIFY = ScgNotification.USER_IDENTIFY
}

private var notificationObserver: ((Notification) -> Unit)? = null

private val isListening: Boolean
get() = notificationObserver != null

override fun getName(): String = "SCGatewayBridgeEmitter"

override fun getConstants(): MutableMap<String, Any> {
return hashMapOf(
"ANALYTICS_EVENT" to ScgNotification.ANALYTICS_EVENT,
"SUPER_PROPERTIES_UPDATED" to ScgNotification.SUPER_PROPS_UPDATED,
"USER_RESET" to ScgNotification.USER_RESET,
"USER_IDENTIFY" to ScgNotification.USER_IDENTIFY
)
}

init {
UiThreadUtil.runOnUiThread {
startListening()
}
}

@ReactMethod
fun startListening(promise: Promise? = null) {
try {
Log.d(TAG, "startListening called")

if (isListening) {
Log.d(TAG, "Already listening to events")
promise?.resolve("Already listening")
return
}

UiThreadUtil.runOnUiThread {
try {
Log.d(TAG, "Starting listener on thread: ${Thread.currentThread().name}")

notificationObserver = { notification ->
Log.d(TAG, "Received notification: ${notification.name}")

try {
processScgNotification(notification)
} catch (e: Exception) {
Log.e(TAG, "Error processing notification: ${notification.name}", e)
}
}

notificationObserver?.let { observer ->
NotificationCenter.addObserver(observer)
Log.d(TAG, "Successfully started listening for notifications")
promise?.resolve("Started listening successfully")
} ?: run {
promise?.reject("START_LISTENING_ERROR", "Failed to create observer")
}

} catch (e: Exception) {
Log.e(TAG, "Error starting listener", e)
promise?.reject("START_LISTENING_ERROR", e.message ?: "Unknown error", e)
}
}
} catch (e: Exception) {
Log.e(TAG, "Error in startListening", e)
promise?.reject("START_LISTENING_ERROR", e.message ?: "Unknown error", e)
}
}

private fun processScgNotification(notification: Notification) {
try {
val jsonString = notification.userInfo?.get(ScgNotification.STRINGIFIED_PAYLOAD_KEY) as? String
if (jsonString == null) {
Log.e(TAG, "SCGatewayBridgeEmitter: Invalid notification object - expected JSON string")
return
}

sendEvent(SmallcaseGatewaySdk.SCG_NOTIFICATION_NAME, jsonString)

} catch (e: Exception) {
Log.e(TAG, "Error processing SCG notification", e)
}
}

private fun sendEvent(eventName: String, jsonString: String) {
try {
if (reactContext.hasActiveCatalystInstance()) {
reactContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
.emit(eventName, jsonString)
} else {
Log.w(TAG, "React context not active, cannot send event: $eventName")
}
} catch (e: Exception) {
Log.e(TAG, "Error sending event to React Native: $eventName", e)
}
}

@ReactMethod
fun stopListening(promise: Promise) {
try {
if (!isListening) {
promise.resolve("Not listening")
return
}

UiThreadUtil.runOnUiThread {
try {
notificationObserver?.let { observer ->
NotificationCenter.removeObserver(observer)
notificationObserver = null
promise.resolve("Stopped listening successfully")
} ?: run {
promise.resolve("No observer to remove")
}
} catch (e: Exception) {
Log.e(TAG, "Error stopping listener", e)
promise.reject("STOP_LISTENING_ERROR", e.message ?: "Unknown error", e)
}
}
} catch (e: Exception) {
Log.e(TAG, "Error in stopListening", e)
promise.reject("STOP_LISTENING_ERROR", e.message ?: "Unknown error", e)
}
}

override fun onCatalystInstanceDestroy() {
super.onCatalystInstanceDestroy()
try {
if (isListening) {
notificationObserver?.let { observer ->
NotificationCenter.removeObserver(observer)
}
notificationObserver = null
}
} catch (e: Exception) {
Log.e(TAG, "Error during cleanup", e)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
package com.reactnativesmallcasegateway

import android.util.Log
import com.facebook.react.bridge.*
import com.facebook.react.modules.core.DeviceEventManagerModule
import com.facebook.react.bridge.UiThreadUtil
import com.smallcase.loans.data.listeners.NotificationCenter
import com.smallcase.loans.data.listeners.Notification
import com.smallcase.loans.core.external.ScLoanNotification


class SCLoansBridgeEmitter(private val reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {

companion object {
const val TAG = "SCLoansBridgeEmitter"

const val ANALYTICS_EVENT = ScLoanNotification.ANALYTICS_EVENT
const val SUPER_PROPERTIES_UPDATED = ScLoanNotification.SUPER_PROPS_UPDATED
}

private var notificationObserver: ((Notification) -> Unit)? = null

private val isListening: Boolean
get() = notificationObserver != null

override fun getName(): String = "SCLoansBridgeEmitter"

override fun getConstants(): MutableMap<String, Any> {
return hashMapOf(
"ANALYTICS_EVENT" to ScLoanNotification.ANALYTICS_EVENT,
"SUPER_PROPERTIES_UPDATED" to ScLoanNotification.SUPER_PROPS_UPDATED,
)
}

init {
UiThreadUtil.runOnUiThread {
startListening()
}
}

@ReactMethod
fun startListening(promise: Promise? = null) {
try {
Log.d(TAG, "startListening called")

if (isListening) {
Log.d(TAG, "Already listening to events")
promise?.resolve("Already listening")
return
}

UiThreadUtil.runOnUiThread {
try {
Log.d(TAG, "Starting listener on thread: ${Thread.currentThread().name}")

notificationObserver = { notification ->
Log.d(TAG, "Received notification: ${notification.name}")

try {
processScLoansNotification(notification)
} catch (e: Exception) {
Log.e(TAG, "Error processing notification: ${notification.name}", e)
}
}

notificationObserver?.let { observer ->
NotificationCenter.addObserver(observer)
Log.d(TAG, "Successfully started listening for notifications")
promise?.resolve("Started listening successfully")
} ?: run {
promise?.reject("START_LISTENING_ERROR", "Failed to create observer")
}

} catch (e: Exception) {
Log.e(TAG, "Error starting listener", e)
promise?.reject("START_LISTENING_ERROR", e.message ?: "Unknown error", e)
}
}
} catch (e: Exception) {
Log.e(TAG, "Error in startListening", e)
promise?.reject("START_LISTENING_ERROR", e.message ?: "Unknown error", e)
}
}

@ReactMethod
fun stopListening(promise: Promise) {
try {
if (!isListening) {
promise.resolve("Not listening")
return
}

UiThreadUtil.runOnUiThread {
try {
notificationObserver?.let { observer ->
NotificationCenter.removeObserver(observer)
notificationObserver = null
promise.resolve("Stopped listening successfully")
} ?: run {
promise.resolve("No observer to remove")
}
} catch (e: Exception) {
Log.e(TAG, "Error stopping listener on UI thread", e)
promise.reject("STOP_LISTENING_ERROR", e.message, e)
}
}
} catch (e: Exception) {
Log.e(TAG, "Error scheduling stopListening on UI thread", e)
promise.reject("STOP_LISTENING_ERROR", e.message, e)
}
}

@ReactMethod
fun getListeningStatus(promise: Promise) {
try {
val status = Arguments.createMap().apply {
putBoolean("isListening", isListening)
putBoolean("hasNotificationObserver", notificationObserver != null)
}
promise.resolve(status)
} catch (e: Exception) {
promise.reject("STATUS_ERROR", e.message, e)
}
}

private fun processScLoansNotification(notification: Notification) {
try {
val jsonString = notification.userInfo?.get(ScLoanNotification.STRINGIFIED_PAYLOAD_KEY) as? String
if (jsonString == null) {
Log.e(TAG, "SCLoansBridgeEmitter: Invalid notification object - expected JSON string")
return
}

sendEvent("scloans_notification", jsonString)

} catch (e: Exception) {
Log.e(TAG, "Error processing SCLoans notification", e)
}
}

private fun sendEvent(eventName: String, jsonString: String) {
try {
if (reactContext.hasActiveCatalystInstance()) {
reactContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
.emit(eventName, jsonString)
} else {
Log.w(TAG, "React context not active, cannot send event: $eventName")
}
} catch (e: Exception) {
Log.e(TAG, "Error sending event to React Native: $eventName", e)
}
}

override fun onCatalystInstanceDestroy() {
super.onCatalystInstanceDestroy()
try {
if (isListening) {
notificationObserver?.let { observer ->
NotificationCenter.removeObserver(observer)
}
notificationObserver = null
}
} catch (e: Exception) {
Log.e(TAG, "Error during cleanup", e)
}
}
}
Loading