Skip to content

Commit 881dbd3

Browse files
Merge pull request #173 from smallcase/prod
Prod
2 parents 4546331 + aec5c8f commit 881dbd3

10 files changed

Lines changed: 109 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
### [7.3.5](https://github.com/smallcase/react-native-smallcase-gateway/compare/v7.3.4...v7.3.5) (2026-03-29)
6+
7+
8+
### Features
9+
10+
* add IMR_SETUP transaction type and bump SCGateway pod to 7.1.6 ([d411416](https://github.com/smallcase/react-native-smallcase-gateway/commit/d41141669da49d79988d43b9e476ed0eb07ae00c))
11+
512
### [7.3.4](https://github.com/smallcase/react-native-smallcase-gateway/compare/v7.3.3...v7.3.4) (2026-03-23)
613

714
### [7.3.3](https://github.com/smallcase/react-native-smallcase-gateway/compare/v7.3.2...v7.3.3) (2026-03-23)

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
149149
dependencies {
150150
//noinspection GradleDynamicVersion
151151
implementation 'com.facebook.react:react-native:+' // From node_modules
152-
implementation 'com.smallcase.gateway:sdk:6.0.5'
152+
implementation 'com.smallcase.gateway:sdk:6.0.6'
153153
implementation 'com.smallcase.loans:sdk:5.1.1'
154154
implementation "androidx.core:core-ktx:1.3.1"
155155
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

ios/SmallcaseGateway.m

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,27 @@ @interface RCT_EXTERN_MODULE(SmallcaseGateway, NSObject)
290290
return;
291291
}
292292

293+
//MARK: intent - imr setup
294+
if([response isKindOfClass: [ObjcTransactionIntentIMRSetup class]]) {
295+
ObjcTransactionIntentIMRSetup *trxResponse = response;
296+
[responseDict setValue:@"IMR_SETUP" forKey:@"transaction"];
297+
298+
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
299+
[dict setValue: trxResponse.authToken forKey:@"smallcaseAuthToken"];
300+
[dict setValue: trxResponse.transactionId forKey:@"transactionId"];
301+
[dict setValue: trxResponse.imrAction forKey:@"imrAction"];
302+
[dict setValue: trxResponse.frequency forKey:@"frequency"];
303+
[dict setValue: trxResponse.iscid forKey:@"iscid"];
304+
[dict setValue: trxResponse.scheduledDate forKey:@"scheduledDate"];
305+
[dict setValue: trxResponse.triggerDate forKey:@"triggerDate"];
306+
[dict setValue: trxResponse.scid forKey:@"scid"];
307+
[dict setValue: trxResponse.signup forKey:@"signup"];
308+
[dict setValue: trxResponse.imrActive ? @"YES" : @"NO" forKey:@"imrActive"];
309+
310+
[responseDict setValue:dict forKey:@"data"];
311+
resolve(responseDict);
312+
return;
313+
}
293314

294315
//MARK: intent - authorize holdings
295316
if([response isKindOfClass: [ObjcTransactionIntentAuthoriseHoldings class]]) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-native-smallcase-gateway",
33
"title": "React Native Smallcase Gateway",
4-
"version": "7.3.4",
4+
"version": "7.3.5",
55
"description": "smallcase gateway bindings for react native",
66
"main": "src/index.js",
77
"files": [

react-native-smallcase-gateway.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ Pod::Spec.new do |s|
3434
s.dependency "ReactCommon/turbomodule/core"
3535
end
3636

37-
s.dependency 'SCGateway', '7.1.5'
37+
s.dependency 'SCGateway', '7.1.7'
3838
s.dependency 'SCLoans', '7.1.1'
3939
end

smart_investing_react_native/app/screens/SmtScreen.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import {Button, TextInput, View} from 'react-native';
33
import {launchSmallPlug} from '../apis/Functions';
4+
import {SCGatewayEventManager} from 'react-native-smallcase-gateway';
45

56
const SmtScreen = () => {
67
const [targetEndpoint, onChangeTargetEndpoint] = React.useState<
@@ -70,6 +71,12 @@ const SmtScreen = () => {
7071
backIconOpacity: bo,
7172
};
7273

74+
const smallplugSub = SCGatewayEventManager.subscribeToSmallplugEvents(
75+
event => {
76+
console.log('[SmallPlug Event]:', event);
77+
},
78+
);
79+
7380
try {
7481
const result = await launchSmallPlug(
7582
targetEndpoint,
@@ -79,16 +86,14 @@ const SmtScreen = () => {
7986
console.log('✅ Smallplug Success:', result);
8087
if (result?.data?.userInfo) {
8188
console.log(' User Info:', result.data.userInfo);
82-
// You can use the userInfo object here, for example, show an alert
83-
// alert(`Success! User phone: ${result.data.userInfo.phoneNumber}`);
8489
}
8590
} catch (error: any) {
8691
console.error(' Smallplug Error:', error);
8792
if (error?.data?.userInfo) {
8893
console.log(' User Info from error:', error.data.userInfo);
89-
// You can use the userInfo object here
90-
// alert(`Failure! User phone: ${error.data.userInfo.phoneNumber}`);
9194
}
95+
} finally {
96+
SCGatewayEventManager.unsubscribeFromSmallplugEvents(smallplugSub);
9297
}
9398
}}
9499
title={'SmallPlug'}

src/SCGatewayEventEmitter.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const SCGatewayEventTypes = {
1818
SUPER_PROPERTIES_UPDATED: 'scgateway_super_properties_updated',
1919
USER_RESET: 'scgateway_user_reset',
2020
USER_IDENTIFY: 'scgateway_user_identify',
21+
SMALLPLUG_ANALYTICS_EVENT: 'smallplug_analytics_event',
2122
};
2223

2324
const SCGatewayNotificationEvent = 'scg_notification';
@@ -104,6 +105,62 @@ class SCGatewayEvents {
104105
return subscription;
105106
}
106107

108+
/**
109+
* Subscribe to SmallPlug / DM analytics events streamed during a launchSmallplug session.
110+
* Events have shape: { eventName: string, data: object, timestamp: number }
111+
* @param {(event: {eventName: string, data: any, timestamp: number}) => void} callback
112+
* @returns {GatewayEventSubscription}
113+
*/
114+
subscribeToSmallplugEvents(callback) {
115+
if (!this.isInitialized) {
116+
console.warn('[SCGatewayEvents] Event emitter not initialized');
117+
return null;
118+
}
119+
120+
if (typeof callback !== 'function') {
121+
console.warn(
122+
'[SCGatewayEvents] Invalid callback provided for SmallPlug subscription'
123+
);
124+
return null;
125+
}
126+
127+
const subscription = this.eventEmitter.addListener(
128+
SCGatewayNotificationEvent,
129+
(jsonString) => {
130+
if (!jsonString) return;
131+
let parsed;
132+
try {
133+
parsed = JSON.parse(jsonString);
134+
} catch (e) {
135+
return;
136+
}
137+
if (parsed.type !== 'smallplug_analytics_event') return;
138+
const { eventName, data } = parsed.data ?? {};
139+
callback({
140+
eventName,
141+
data,
142+
timestamp: parsed.timestamp ?? Date.now(),
143+
});
144+
}
145+
);
146+
147+
this.subscriptions.push(subscription);
148+
return subscription;
149+
}
150+
151+
/**
152+
* Unsubscribe from SmallPlug analytics events
153+
* @param {GatewayEventSubscription} subscription - Subscription returned from subscribeToSmallplugEvents
154+
*/
155+
unsubscribeFromSmallplugEvents(subscription) {
156+
if (subscription && typeof subscription.remove === 'function') {
157+
subscription.remove();
158+
this.subscriptions = this.subscriptions.filter(
159+
(sub) => sub !== subscription
160+
);
161+
}
162+
}
163+
107164
/**
108165
* Unsubscribe from Gateway Events
109166
* @param {GatewayEventSubscription} subscription - Subscription returned from subscribeToGatewayEvents

src/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const ENV = {
77
export const TRANSACTION_TYPE = {
88
connect: 'CONNECT',
99
sipSetup: 'SIP_SETUP',
10+
imrSetup: 'IMR_SETUP',
1011
fetchFunds: 'FETCH_FUNDS',
1112
transaction: 'TRANSACTION',
1213
holdingsImport: 'HOLDINGS_IMPORT',

types/constants.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export namespace ENV {
66
export namespace TRANSACTION_TYPE {
77
const connect: string;
88
const sipSetup: string;
9+
const imrSetup: string;
910
const fetchFunds: string;
1011
const transaction: string;
1112
const holdingsImport: string;

types/index.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ export interface LoansEvent {
1212
timestamp: number;
1313
}
1414

15+
export interface SmallplugAnalyticsEvent {
16+
eventName: string;
17+
data: Record<string, any>;
18+
timestamp: number;
19+
}
20+
1521
export interface GatewayEventSubscription {
1622
remove(): void;
1723
}
@@ -22,6 +28,8 @@ export interface LoansEventSubscription {
2228

2329
interface SCGatewayEventManagerInterface {
2430
subscribeToGatewayEvents(callback: ((event: GatewayEvent) => void)): GatewayEventSubscription | null;
31+
subscribeToSmallplugEvents(callback: ((event: SmallplugAnalyticsEvent) => void)): GatewayEventSubscription | null;
32+
unsubscribeFromSmallplugEvents(subscription: GatewayEventSubscription): void;
2533
unsubscribeFromGatewayEvents(subscription: GatewayEventSubscription): void;
2634
}
2735

@@ -61,6 +69,7 @@ declare const _default: {
6169
TRANSACTION_TYPE: {
6270
connect: string;
6371
sipSetup: string;
72+
imrSetup: string;
6473
fetchFunds: string;
6574
transaction: string;
6675
holdingsImport: string;
@@ -86,6 +95,7 @@ declare const _default: {
8695
SCLoansEventManager: SCLoansEventManagerInterface;
8796
subscribeToGatewayEvents: (callback: (event: GatewayEvent) => void) => GatewayEventSubscription | null;
8897
unsubscribeFromGatewayEvents: (subscription: GatewayEventSubscription) => void;
98+
subscribeToSmallplugEvents: (callback: (event: SmallplugAnalyticsEvent) => void) => GatewayEventSubscription | null;
8999
subscribeToLoansEvent: (callback: (event: LoansEvent) => void) => LoansEventSubscription | null;
90100
unsubscribeFromLoansEvent: (subscription: LoansEventSubscription) => void;
91101
};

0 commit comments

Comments
 (0)