Skip to content

Commit 65e74ff

Browse files
authored
Merge branch 'master' into inbox-updates-1.3.2
2 parents 434e54c + 72a8ae8 commit 65e74ff

17 files changed

Lines changed: 932 additions & 591 deletions

Iterable-React-Native-SDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ Pod::Spec.new do |s|
2424

2525
s.swift_version = '5.3'
2626

27-
s.dependency 'Iterable-iOS-SDK', '~> 6.4.2'
27+
s.dependency 'Iterable-iOS-SDK', '~> 6.4.3'
2828
s.dependency 'React-Core'
2929
end

SampleApp/javascript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"lint": "eslint ."
1111
},
1212
"dependencies": {
13-
"@iterable/react-native-sdk": "^1.3.0",
13+
"@iterable/react-native-sdk": "^1.3.2",
1414
"@react-native-community/masked-view": "^0.1.10",
1515
"@react-native-community/toolbar-android": "^0.1.0-rc.2",
1616
"@react-navigation/bottom-tabs": "^5.4.5",

SampleApp/javascript/yarn.lock

Lines changed: 150 additions & 29 deletions
Large diffs are not rendered by default.

SampleApp/typescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"lint": "eslint ."
1111
},
1212
"dependencies": {
13-
"@iterable/react-native-sdk": "^1.3.0",
13+
"@iterable/react-native-sdk": "^1.3.2",
1414
"@react-native-community/masked-view": "^0.1.10",
1515
"@react-native-community/toolbar-android": "^0.1.0-rc.2",
1616
"@react-navigation/bottom-tabs": "^5.4.5",

SampleApp/typescript/yarn.lock

Lines changed: 150 additions & 29 deletions
Large diffs are not rendered by default.

integration-testing/ts/Login.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
Image,
1111
} from 'react-native'
1212
import { TextInput } from 'react-native-gesture-handler'
13-
import { Iterable } from '@iterable/react-native-sdk'
13+
import { Iterable } from '@iterable/react-native-sdk/js/Iterable'
1414

1515
interface Props { }
1616
interface State {

integration-testing/yarn.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@
707707
version "1.3.2"
708708
resolved "https://registry.yarnpkg.com/@iterable/react-native-sdk/-/react-native-sdk-1.3.2.tgz#03aff1b440b7b4f58b982ebc292d4500830569f6"
709709
integrity sha512-s+TTXQUOvcjAyp4lB9g42moAOPjiN7Gd4zWCvicO+zNcF170oZ8zSw/CJoUxvZIaFqKYIJXREeECBuDpA/p3Nw==
710+
710711
dependencies:
711712
"@react-native-community/hooks" "^2.6.0"
712713
"@react-navigation/native" "^6.0.6"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@iterable/react-native-sdk",
3-
"version": "1.3.0",
3+
"version": "1.3.2",
44
"description": "Iterable SDK for React Native.",
55
"main": "./js/index.js",
66
"types": "./js/index.d.ts",

ts/Iterable.ts

Lines changed: 56 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
import IterableInAppManager from './IterableInAppManager'
1717
import IterableInAppMessage from './IterableInAppMessage'
1818
import IterableConfig from './IterableConfig'
19+
import { IterableLogger } from './IterableLogger'
1920

2021
const RNIterableAPI = NativeModules.RNIterableAPI
2122
const RNEventEmitter = new NativeEventEmitter(RNIterableAPI)
@@ -121,15 +122,10 @@ enum EventName {
121122
}
122123

123124
class Iterable {
124-
/**
125-
* inAppManager instance
126-
*/
127125
static inAppManager = new IterableInAppManager()
128126

127+
static logger: IterableLogger
129128

130-
/**
131-
* savedConfig instance.
132-
*/
133129
static savedConfig: IterableConfig
134130

135131
/**
@@ -138,9 +134,12 @@ class Iterable {
138134
* @param {IterableConfig} config
139135
*/
140136
static initialize(apiKey: string, config: IterableConfig = new IterableConfig()): Promise<boolean> {
141-
console.log("initialize: " + apiKey);
142-
143137
Iterable.savedConfig = config
138+
139+
Iterable.logger = new IterableLogger(Iterable.savedConfig)
140+
141+
Iterable.logger.log("initialize: " + apiKey)
142+
144143
this.setupEventHandlers()
145144
const version = this.getVersionFromPackageJson()
146145

@@ -152,9 +151,12 @@ class Iterable {
152151
* This method is used internally to connect to staging environment.
153152
*/
154153
static initialize2(apiKey: string, config: IterableConfig = new IterableConfig(), apiEndPoint: string): Promise<boolean> {
155-
console.log("initialize2: " + apiKey);
156-
157154
Iterable.savedConfig = config
155+
156+
Iterable.logger = new IterableLogger(Iterable.savedConfig)
157+
158+
Iterable.logger.log("initialize2: " + apiKey);
159+
158160
this.setupEventHandlers()
159161
const version = this.getVersionFromPackageJson()
160162

@@ -166,15 +168,17 @@ class Iterable {
166168
* @param {string | undefined} email the email address of the user
167169
*/
168170
static setEmail(email: string | undefined) {
169-
console.log("setEmail: " + email)
171+
Iterable.logger.log("setEmail: " + email)
172+
170173
RNIterableAPI.setEmail(email)
171174
}
172175

173176
/**
174177
* Get the email of the current user
175178
*/
176179
static getEmail(): Promise<string | undefined> {
177-
console.log("getEmail")
180+
Iterable.logger.log("getEmail")
181+
178182
return RNIterableAPI.getEmail()
179183
}
180184

@@ -183,39 +187,44 @@ class Iterable {
183187
* @param {string | undefined} userId the ID of the user
184188
*/
185189
static setUserId(userId: string | undefined) {
186-
console.log("setUserId: " + userId)
190+
Iterable.logger.log("setUserId: " + userId)
191+
187192
RNIterableAPI.setUserId(userId)
188193
}
189194

190195
/**
191196
* Get the user ID of the current user
192197
*/
193198
static getUserId(): Promise<string | undefined> {
194-
console.log("getUserId")
199+
Iterable.logger.log("getUserId")
200+
195201
return RNIterableAPI.getUserId()
196202
}
197203

198204
/**
199205
*
200206
*/
201207
static disableDeviceForCurrentUser() {
202-
console.log("disableDeviceForCurrentUser")
208+
Iterable.logger.log("disableDeviceForCurrentUser")
209+
203210
RNIterableAPI.disableDeviceForCurrentUser()
204211
}
205212

206213
/**
207214
*
208215
*/
209216
static getLastPushPayload(): Promise<any | undefined> {
210-
console.log("getLastPushPayload")
217+
Iterable.logger.log("getLastPushPayload")
218+
211219
return RNIterableAPI.getLastPushPayload()
212220
}
213221

214222
/**
215223
*
216224
*/
217225
static getAttributionInfo(): Promise<IterableAttributionInfo | undefined> {
218-
console.log("getAttributionInfo")
226+
Iterable.logger.log("getAttributionInfo")
227+
219228
return RNIterableAPI.getAttributionInfo().then((dict: any | undefined) => {
220229
if (dict) {
221230
return new IterableAttributionInfo(dict["campaignId"] as number, dict["templateId"] as number, dict["messageId"] as string)
@@ -231,7 +240,8 @@ class Iterable {
231240
* @param {attributionInfo} IterableAttributionInfo
232241
*/
233242
static setAttributionInfo(attributionInfo?: IterableAttributionInfo) {
234-
console.log("setAttributionInfo")
243+
Iterable.logger.log("setAttributionInfo")
244+
235245
RNIterableAPI.setAttributionInfo(attributionInfo)
236246
}
237247

@@ -244,7 +254,8 @@ class Iterable {
244254
* @param {any | undefined} dataFields
245255
*/
246256
static trackPushOpenWithCampaignId(campaignId: number, templateId: number, messageId: string | undefined, appAlreadyRunning: boolean, dataFields: any | undefined) {
247-
console.log("trackPushOpenWithCampaignId")
257+
Iterable.logger.log("trackPushOpenWithCampaignId")
258+
248259
RNIterableAPI.trackPushOpenWithCampaignId(campaignId, templateId, messageId, appAlreadyRunning, dataFields)
249260
}
250261

@@ -253,13 +264,15 @@ class Iterable {
253264
* @param {Array<IterableCommerceItem>} items
254265
*/
255266
static updateCart(items: Array<IterableCommerceItem>) {
256-
console.log("updateCart")
267+
Iterable.logger.log("updateCart")
268+
257269
RNIterableAPI.updateCart(items)
258270
}
259271

260272
static wakeApp() {
261273
if (Platform.OS === "android") {
262-
console.log('Attempting to wake the app')
274+
Iterable.logger.log("Attempting to wake the app")
275+
263276
RNIterableAPI.wakeApp();
264277
}
265278
}
@@ -271,7 +284,8 @@ class Iterable {
271284
* @param {any | undefined} dataFields
272285
*/
273286
static trackPurchase(total: number, items: Array<IterableCommerceItem>, dataFields: any | undefined) {
274-
console.log("trackPurchase")
287+
Iterable.logger.log("trackPurchase")
288+
275289
RNIterableAPI.trackPurchase(total, items, dataFields)
276290
}
277291

@@ -281,7 +295,8 @@ class Iterable {
281295
* @param {IterableInAppLocation} location
282296
*/
283297
static trackInAppOpen(message: IterableInAppMessage, location: IterableInAppLocation) {
284-
console.log("trackInAppOpen")
298+
Iterable.logger.log("trackInAppOpen")
299+
285300
RNIterableAPI.trackInAppOpen(message.messageId, location)
286301
}
287302

@@ -292,7 +307,8 @@ class Iterable {
292307
* @param {string} clickedUrl
293308
*/
294309
static trackInAppClick(message: IterableInAppMessage, location: IterableInAppLocation, clickedUrl: string) {
295-
console.log("trackInAppClick")
310+
Iterable.logger.log("trackInAppClick")
311+
296312
RNIterableAPI.trackInAppClick(message.messageId, location, clickedUrl)
297313
}
298314

@@ -304,7 +320,8 @@ class Iterable {
304320
* @param {string} clickedUrl
305321
*/
306322
static trackInAppClose(message: IterableInAppMessage, location: IterableInAppLocation, source: IterableInAppCloseSource, clickedUrl?: string | undefined) {
307-
console.log("trackInAppClose")
323+
Iterable.logger.log("trackInAppClose")
324+
308325
RNIterableAPI.trackInAppClose(message.messageId, location, source, clickedUrl)
309326
}
310327

@@ -315,7 +332,8 @@ class Iterable {
315332
* @param {IterableInAppDeleteSource} source
316333
*/
317334
static inAppConsume(message: IterableInAppMessage, location: IterableInAppLocation, source: IterableInAppDeleteSource) {
318-
console.log("inAppConsume")
335+
Iterable.logger.log("inAppConsume")
336+
319337
RNIterableAPI.inAppConsume(message.messageId, location, source)
320338
}
321339

@@ -325,7 +343,8 @@ class Iterable {
325343
* @param {any | undefined} dataFields
326344
*/
327345
static trackEvent(name: string, dataFields: any | undefined) {
328-
console.log("trackEvent")
346+
Iterable.logger.log("trackEvent")
347+
329348
RNIterableAPI.trackEvent(name, dataFields)
330349
}
331350

@@ -335,7 +354,8 @@ class Iterable {
335354
* @param {boolean} mergeNestedObjects Whether to merge top level objects instead of overwriting
336355
*/
337356
static updateUser(dataFields: any, mergeNestedObjects: boolean) {
338-
console.log("updateUser")
357+
Iterable.logger.log("updateUser")
358+
339359
RNIterableAPI.updateUser(dataFields, mergeNestedObjects)
340360
}
341361

@@ -344,7 +364,8 @@ class Iterable {
344364
* @param email the new email to set
345365
*/
346366
static updateEmail(email: string) {
347-
console.log("updateEmail")
367+
Iterable.logger.log("updateEmail")
368+
348369
RNIterableAPI.updateEmail(email)
349370
}
350371

@@ -353,7 +374,8 @@ class Iterable {
353374
* @param {string} link URL in string form to be either opened as an app link or as a normal one
354375
*/
355376
static handleAppLink(link: string): Promise<boolean> {
356-
console.log("handleAppLink")
377+
Iterable.logger.log("handleAppLink")
378+
357379
return RNIterableAPI.handleAppLink(link)
358380
}
359381

@@ -372,7 +394,8 @@ class Iterable {
372394
subscribedMessageTypeIds: Array<number> | undefined,
373395
campaignId: number,
374396
templateId: number) {
375-
console.log("updateSubscriptions")
397+
Iterable.logger.log("updateSubscriptions")
398+
376399
RNIterableAPI.updateSubscriptions(emailListIds, unsubscribedChannelIds, unsubscribedMessageTypeIds, subscribedMessageTypeIds, campaignId, templateId)
377400
}
378401

@@ -391,6 +414,7 @@ class Iterable {
391414
const url = dict["url"]
392415
const context = IterableActionContext.fromDict(dict["context"])
393416
Iterable.wakeApp()
417+
394418
if (Platform.OS === "android") {
395419
//Give enough time for Activity to wake up.
396420
setTimeout(() => {
@@ -443,7 +467,7 @@ class Iterable {
443467
.then(canOpen => {
444468
if (canOpen) { Linking.openURL(url) }
445469
})
446-
.catch(reason => { console.log("could not open url: " + reason) })
470+
.catch(reason => { Iterable.logger.log("could not open url: " + reason) })
447471
}
448472
}
449473
}

ts/IterableConfig.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ class IterableConfig {
6565
*/
6666
logLevel: IterableLogLevel = IterableLogLevel.info
6767

68+
/**
69+
* Set whether the React Native SDK should print function calls to console
70+
* This is for calls within the React Native layer, and is separate from `logLevel`
71+
* which affects the Android and iOS native SDKs
72+
*/
73+
logReactNativeSdkCalls: boolean = true
74+
6875
/**
6976
* Set the amount of time (in seconds) before the current auth token expires to make a call to retrieve a new one
7077
*/

0 commit comments

Comments
 (0)