Skip to content

Commit

Permalink
chore: fix in-app site id (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrehan27 authored Oct 2, 2024
1 parent c82a7a4 commit 9f71af9
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 75 deletions.
5 changes: 3 additions & 2 deletions Apps/APN/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ export default function App() {
prepare();
const inAppEventListener = registerInAppEventListener();

// TODO: Add this when inapp feature is implemented
// inAppEventListener.remove();
return () => {
inAppEventListener.remove();
};
}, [
applyCustomerIoConfig,
handleCustomerIoConfigChanged,
Expand Down
46 changes: 0 additions & 46 deletions Apps/APN/android/app/google-services.json.example

This file was deleted.

4 changes: 2 additions & 2 deletions Apps/APN/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"clean-install-ios": "./scripts/clean-run-ios.sh",
"dev:update": "../../scripts/dev:update.sh",
"postinstall": "pod update --project-directory=ios",
"preinstall": "npm run dev:update --legacy-peer-deps",
"ci:install": "npm run preinstall && npm ci --legacy-peer-deps && npm run bundle:ios"
"preinstall": "npm run dev:update",
"ci:install": "npm run preinstall && npm ci"
},
"dependencies": {
"@react-native-async-storage/async-storage": "^1.19.1",
Expand Down
14 changes: 9 additions & 5 deletions Apps/APN/src/services/CustomerIOService.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { CustomerIO, CioLogLevel } from 'customerio-reactnative';
import {
CustomerIO,
CioLogLevel,
InAppMessageEventType,
} from 'customerio-reactnative';

export const initializeCustomerIoSDK = (sdkConfig) => {
const config = {
Expand All @@ -7,7 +11,7 @@ export const initializeCustomerIoSDK = (sdkConfig) => {
trackApplicationLifecycleEvents: sdkConfig.trackAppLifecycleEvents,
autoTrackDeviceAttributes: sdkConfig.autoTrackDeviceAttributes,
inApp: {
siteId: 'site_id',
siteId: sdkConfig.siteId,
},
};

Expand Down Expand Up @@ -65,7 +69,7 @@ export const requestPushNotificationsPermission = (options) => {

// TODO: Implement this method when inapp feature is added
export const registerInAppEventListener = () => {
/*const logInAppEvent = (name, params) => {
const logInAppEvent = (name, params) => {
console.log(`in-app message: ${name}, params: `, params);
};

Expand All @@ -88,7 +92,7 @@ export const registerInAppEventListener = () => {
CustomerIO.track('in-app message action', data);
};

const inAppMessaging = CustomerIO.inAppMessaging();
const inAppMessaging = CustomerIO.inAppMessaging;
return inAppMessaging.registerEventsListener((event) => {
switch (event.eventType) {
case InAppMessageEventType.messageShown:
Expand All @@ -114,5 +118,5 @@ export const registerInAppEventListener = () => {
default:
onInAppEventReceived('unsupported event', event);
}
});*/
});
};
3 changes: 1 addition & 2 deletions Apps/FCM/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ export default function App() {

// Remove listeners once unmounted
return () => {
// TODO: Add this when inapp feature is implemented
// inAppEventListener.remove();
inAppEventListener.remove();
};
}, [
applyCustomerIoConfig,
Expand Down
29 changes: 16 additions & 13 deletions Apps/FCM/src/services/CustomerIOService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {
CioLogLevel,
CustomerIO,
CioPushPermissionOptions
CioPushPermissionOptions,
InAppMessageEvent,
InAppMessageEventType,
} from 'customerio-reactnative';
import User from '../data/models/user';
import CustomerIoSDKConfig from '../data/sdk/CustomerIoSDKConfig';
Expand All @@ -13,22 +15,23 @@ export const initializeCustomerIoSDK = (sdkConfig: CustomerIoSDKConfig) => {
trackApplicationLifecycleEvents: sdkConfig.trackAppLifecycleEvents,
autoTrackDeviceAttributes: sdkConfig.trackDeviceAttributes,
inApp: {
siteId: 'site_id',
siteId: sdkConfig.siteId,
},
logLevel: CioLogLevel.None, // Add logLevel property
};
if (sdkConfig.debugMode) {
config.logLevel = CioLogLevel.Debug;
}
CustomerIO.initialize(config)
if (sdkConfig.debugMode) {
config.logLevel = CioLogLevel.Debug;
}
CustomerIO.initialize(config)
};

export const onUserLoggedIn = (user: User) => {
CustomerIO.identify({ id: user.email,
CustomerIO.identify({
id: user.email,
traits: {
first_name: user.name,
email: user.email,
}
first_name: user.name,
email: user.email,
}
});
};

Expand Down Expand Up @@ -71,7 +74,7 @@ export const requestPushNotificationsPermission = (


export const registerInAppEventListener = () => {
/*const logInAppEvent = (name: string, params: InAppMessageEvent) => {
const logInAppEvent = (name: string, params: InAppMessageEvent) => {
console.log(`in-app message: ${name}, params: `, params);
};

Expand All @@ -96,7 +99,7 @@ export const registerInAppEventListener = () => {
CustomerIO.track('in-app message action', data);
};

const inAppMessaging = CustomerIO.inAppMessaging();
const inAppMessaging = CustomerIO.inAppMessaging;
return inAppMessaging.registerEventsListener((event: InAppMessageEvent) => {
switch (event.eventType) {
case InAppMessageEventType.messageShown:
Expand All @@ -122,5 +125,5 @@ export const registerInAppEventListener = () => {
default:
onInAppEventReceived('unsupported event', event);
}
}); */
});
};
7 changes: 2 additions & 5 deletions src/customerio-cdp.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { NativeModules, Platform } from 'react-native';
import { CioLogLevel, type CioConfig } from './cio-config';
import { type IdentifyParams } from './cio-params';
// TODO: Import the CustomerIOInAppMessaging class from their respective files
// when they are implemented.
// import { CustomerIOInAppMessaging } from './customerio-inapp';
import { CustomerIOInAppMessaging } from './customerio-inapp';
import { CustomerIOPushMessaging } from './customerio-push';
import { NativeLoggerListener } from './native-logger-listener';

Expand Down Expand Up @@ -97,8 +95,7 @@ export class CustomerIO {

static readonly isInitialized = () => CustomerIO.initialized;

// TODO: Update when implemented.
// static readonly inAppMessaging = new CustomerIOInAppMessaging();
static readonly inAppMessaging = new CustomerIOInAppMessaging();
static readonly pushMessaging = new CustomerIOPushMessaging();

private static readonly assrtInitialized = () => {
Expand Down
File renamed without changes.

0 comments on commit 9f71af9

Please sign in to comment.