Skip to content

Conversation

dporwal-shipit
Copy link
Collaborator

No description provided.

@dporwal-shipit dporwal-shipit self-assigned this Jul 30, 2025
@dporwal-shipit dporwal-shipit changed the title Upgrade react native 0.79.4 dhruv events Upgrade react native 0.79.4 + Removed Mixpanel from Native Android/IOS SDKs Aug 26, 2025
@dporwal-shipit dporwal-shipit marked this pull request as draft August 26, 2025 09:50
@dporwal-shipit
Copy link
Collaborator Author

dporwal-shipit commented Aug 26, 2025

React-Native Bridge for Android successfully propagating events from Native Android SDK(Producer) to Smart Investing Appln (Consumer):

For SCGateway:
image

For SCLoans:
image

React-Native Bridge for IOS successfully propagating events from Native Android IOS(Producer) to Smart Investing Appln (Consumer):

For SCGateway:
image

For SCLoans:
image

…intainability

- Simplified event flow between native and JS layers
- Improved code readability and reduced complexity
- Easier to extend with new analytics events in future
…ved maintainability

- Simplified event flow between native and JS layers
- Improved code readability and reduced complexity
- Easier to extend with new analytics events in future
@dporwal-shipit dporwal-shipit marked this pull request as ready for review August 31, 2025 10:32
Copy link
Member

Choose a reason for hiding this comment

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

install the "prettier" vscode extention for formatting js files. make sure that it matches the older style

(here the diff should only show changes that you've already made)

Copy link
Collaborator Author

@dporwal-shipit dporwal-shipit Sep 5, 2025

Choose a reason for hiding this comment

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

Error: Cannot find module 'prettier' from '/Users/dhruvporwal/smallcase/react-native-smallcase-gateway'
at e.exports [as sync] (/Users/dhruvporwal/.vscode/extensions/esbenp.prettier-vscode-11.0.0/dist/extension.js:1:38498)

Unable to do for .js files. Would i have to add prettier to project? Because i have added prettier as default formatter in settings.json already:

{

"security.workspace.trust.untrustedFiles": "open",
"dart.flutterSdkPath": "/Users/dhruvporwal/fvm/versions/stable",
"git.enableSmartCommit": true,
"files.autoSave": "afterDelay",
"diffEditor.ignoreTrimWhitespace": true,
"gitlens.ai.model": "gitkraken",
"gitlens.ai.gitkraken.model": "gemini:gemini-2.0-flash",
"dart.debugExternalPackageLibraries": true,
"dart.debugSdkLibraries": true,
"editor.formatOnSave": true,
"prettier.resolveGlobalModules": true,
"editor.formatOnPaste": true,
"editor.formatOnType": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"notebook.defaultFormatter": "esbenp.prettier-vscode"
}

return SmallcaseGatewayNative.archiveSmallcase(safeIscid);
};

/**
* Returns the native android/ios and react-native sdk version
* (internal-tracking)
* @returns {Promise}
Copy link
Member

Choose a reason for hiding this comment

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

why did we remove these return and param types?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They have been added back.


/**
* 🔕 Unsubscribe from Gateway Event
* @param {object} subscription - Subscription returned from startGatewayEventListening
Copy link
Member

Choose a reason for hiding this comment

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

these param and return types can be better. make it closer to the actual types, instead of generic types

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

this.isInitialized = true;
console.log('[SCLoansEvents] Initialized for', Platform.OS);
} else {
console.warn('[SCLoansEvents] Native module not found for', Platform.OS);
Copy link
Member

Choose a reason for hiding this comment

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

this probably should be thrown as an error. shouldn't silently fail

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

}

try {
const subscription = this.eventEmitter.addListener('scloans_notification', (eventData) => {
Copy link
Member

Choose a reason for hiding this comment

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

keep all these strings ("scloans_notification") as constants. don't use them directly

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment on lines 55 to 58
type: eventData.eventType || eventData.type || 'unknown_event',
eventType: eventData.eventType || eventData.type || 'unknown_event',
data: eventData.data || eventData,
timestamp: eventData.timestamp || Date.now(),
Copy link
Member

Choose a reason for hiding this comment

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

do these fallbacks make sense?

please check with the analytics team on what should be the correct fallback values such that invalid values don't make it into real analysis

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done


this.subscriptions.push(subscription);

console.log('SCLoansEvents Subscribed to gateway events');
Copy link
Member

Choose a reason for hiding this comment

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

remove all these console logs from the SDK

Copy link
Collaborator Author

@dporwal-shipit dporwal-shipit Sep 5, 2025

Choose a reason for hiding this comment

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

Done.

Comment on lines 81 to 84
const index = this.subscriptions.indexOf(subscription);
if (index > -1) {
this.subscriptions.splice(index, 1);
}
Copy link
Member

Choose a reason for hiding this comment

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

better to use array.filter()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

USER_IDENTIFY: 'scgateway_user_identify',
};

export class SCGatewayEvents {
Copy link
Member

Choose a reason for hiding this comment

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

here again, a lot of the event emitter code is duplicated.

structure it in a way where things can be shared as much as possible

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually we are treating both the sdks as separate and isolated. So, created separate files to support this. Same is true in android implementation as well for Notification Center.

Comment on lines 76 to 79
// Add debug observer for all notifications
NotificationCenter.addObserver { notification ->
Log.d("DEBUG_ALL_EVENTS", "All notifications: ${notification.name}")
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove

const val USER_IDENTIFY = ScLoanNotification.USER_RESET
}

private var isListening = false
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this just be derived?

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


try {
// Only process scloans_notification - single way to subscribe
if (notification.name == "scloans_notification") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use constant from the native SDK.

Comment on lines +147 to +148
putBoolean("isListening", isListening)
putBoolean("hasNotificationObserver", notificationObserver != null)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can just keep isListening

Comment on lines 157 to 174
fun emitTestEvent(eventType: String, testData: ReadableMap?, promise: Promise) {
try {
Log.d(TAG, "Emitting test event: $eventType")

val payload = Arguments.createMap().apply {
putString("type", eventType)
putBoolean("isTest", true)
testData?.let { putMap("data", it) }
}

sendEvent("scloans_notification", payload)
promise.resolve("Test event emitted successfully")

} catch (e: Exception) {
Log.e(TAG, "Error emitting test event", e)
promise.reject("TEST_EVENT_ERROR", e.message, e)
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not needed right?

Comment on lines +159 to +160
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'

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants