Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix in-app site id #341

Merged
merged 4 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 @@
prepare();
const inAppEventListener = registerInAppEventListener();

// TODO: Add this when inapp feature is implemented
// inAppEventListener.remove();
return () => {
inAppEventListener.remove();
};
}, [
applyCustomerIoConfig,
handleCustomerIoConfigChanged,
Expand Down Expand Up @@ -103,7 +104,7 @@
}

return (
<GestureHandlerRootView style={{ flex: 1 }}>

Check warning on line 107 in Apps/APN/App.js

View workflow job for this annotation

GitHub Actions / eslint results

Apps/APN/App.js#L107

[react-native/no-inline-styles] Inline style: { flex: 1 }
<CustomerIoSdkContext.Provider value={customerIoSdkState}>
<UserStateContext.Provider value={userState}>
<SafeAreaView style={styles.container}>
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"
Comment on lines +14 to +15
Copy link
Contributor

Choose a reason for hiding this comment

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

think they are not needed due to the react native version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, we now user newer versions so longer need to install legacy dependencies

},
"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.
Loading