customerio-expo-plugin 3.1.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -2
- package/plugin/lib/commonjs/android/withCIOAndroid.js +13 -2
- package/plugin/lib/commonjs/android/withCIOAndroid.js.map +1 -1
- package/plugin/lib/commonjs/android/withLocationGradleProperties.js +37 -0
- package/plugin/lib/commonjs/android/withLocationGradleProperties.js.map +1 -0
- package/plugin/lib/commonjs/android/withMainApplicationModifications.js +21 -5
- package/plugin/lib/commonjs/android/withMainApplicationModifications.js.map +1 -1
- package/plugin/lib/commonjs/helpers/native-files/android/CustomerIOSDKInitializer.kt +2 -0
- package/plugin/lib/commonjs/helpers/native-files/ios/CustomerIOSDKInitializer.swift +2 -0
- package/plugin/lib/commonjs/helpers/native-files/ios/apn/CioSdkAppDelegateHandler.swift +1 -1
- package/plugin/lib/commonjs/helpers/native-files/ios/apn/NotificationService.swift +1 -1
- package/plugin/lib/commonjs/helpers/native-files/ios/apn/PushService.swift +1 -1
- package/plugin/lib/commonjs/helpers/native-files/ios/fcm/CioSdkAppDelegateHandler.swift +1 -1
- package/plugin/lib/commonjs/helpers/native-files/ios/fcm/NotificationService.swift +1 -1
- package/plugin/lib/commonjs/helpers/native-files/ios/fcm/PushService.swift +1 -1
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js +19 -2
- package/plugin/lib/commonjs/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/commonjs/helpers/utils/patchLocationCode.js +50 -0
- package/plugin/lib/commonjs/helpers/utils/patchLocationCode.js.map +1 -0
- package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js +3 -1
- package/plugin/lib/commonjs/helpers/utils/patchPluginNativeCode.js.map +1 -1
- package/plugin/lib/commonjs/index.js +2 -2
- package/plugin/lib/commonjs/index.js.map +1 -1
- package/plugin/lib/commonjs/ios/withCIOIos.js +46 -4
- package/plugin/lib/commonjs/ios/withCIOIos.js.map +1 -1
- package/plugin/lib/commonjs/ios/withCIOIosSwift.js +25 -12
- package/plugin/lib/commonjs/ios/withCIOIosSwift.js.map +1 -1
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js +45 -11
- package/plugin/lib/commonjs/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/commonjs/ios/withXcodeProject.js +4 -1
- package/plugin/lib/commonjs/ios/withXcodeProject.js.map +1 -1
- package/plugin/lib/commonjs/types/cio-types.js.map +1 -1
- package/plugin/lib/commonjs/utils/validation.js +13 -0
- package/plugin/lib/commonjs/utils/validation.js.map +1 -1
- package/plugin/lib/module/android/withCIOAndroid.js +13 -2
- package/plugin/lib/module/android/withCIOAndroid.js.map +1 -1
- package/plugin/lib/module/android/withLocationGradleProperties.js +30 -0
- package/plugin/lib/module/android/withLocationGradleProperties.js.map +1 -0
- package/plugin/lib/module/android/withMainApplicationModifications.js +20 -4
- package/plugin/lib/module/android/withMainApplicationModifications.js.map +1 -1
- package/plugin/lib/module/helpers/native-files/android/CustomerIOSDKInitializer.kt +2 -0
- package/plugin/lib/module/helpers/native-files/ios/CustomerIOSDKInitializer.swift +2 -0
- package/plugin/lib/module/helpers/native-files/ios/apn/CioSdkAppDelegateHandler.swift +1 -1
- package/plugin/lib/module/helpers/native-files/ios/apn/NotificationService.swift +1 -1
- package/plugin/lib/module/helpers/native-files/ios/apn/PushService.swift +1 -1
- package/plugin/lib/module/helpers/native-files/ios/fcm/CioSdkAppDelegateHandler.swift +1 -1
- package/plugin/lib/module/helpers/native-files/ios/fcm/NotificationService.swift +1 -1
- package/plugin/lib/module/helpers/native-files/ios/fcm/PushService.swift +1 -1
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js +18 -2
- package/plugin/lib/module/helpers/utils/injectCIOPodfileCode.js.map +1 -1
- package/plugin/lib/module/helpers/utils/patchLocationCode.js +44 -0
- package/plugin/lib/module/helpers/utils/patchLocationCode.js.map +1 -0
- package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js +3 -2
- package/plugin/lib/module/helpers/utils/patchPluginNativeCode.js.map +1 -1
- package/plugin/lib/module/index.js +2 -2
- package/plugin/lib/module/index.js.map +1 -1
- package/plugin/lib/module/ios/withCIOIos.js +46 -4
- package/plugin/lib/module/ios/withCIOIos.js.map +1 -1
- package/plugin/lib/module/ios/withCIOIosSwift.js +25 -12
- package/plugin/lib/module/ios/withCIOIosSwift.js.map +1 -1
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js +45 -11
- package/plugin/lib/module/ios/withNotificationsXcodeProject.js.map +1 -1
- package/plugin/lib/module/ios/withXcodeProject.js +5 -1
- package/plugin/lib/module/ios/withXcodeProject.js.map +1 -1
- package/plugin/lib/module/types/cio-types.js.map +1 -1
- package/plugin/lib/module/utils/validation.js +13 -1
- package/plugin/lib/module/utils/validation.js.map +1 -1
- package/plugin/lib/typescript/android/withCIOAndroid.d.ts +2 -2
- package/plugin/lib/typescript/android/withLocationGradleProperties.d.ts +9 -0
- package/plugin/lib/typescript/android/withMainApplicationModifications.d.ts +7 -2
- package/plugin/lib/typescript/helpers/utils/injectCIOPodfileCode.d.ts +9 -1
- package/plugin/lib/typescript/helpers/utils/patchLocationCode.d.ts +12 -0
- package/plugin/lib/typescript/helpers/utils/patchPluginNativeCode.d.ts +3 -1
- package/plugin/lib/typescript/index.d.ts +2 -1
- package/plugin/lib/typescript/ios/withCIOIos.d.ts +2 -2
- package/plugin/lib/typescript/ios/withCIOIosSwift.d.ts +2 -2
- package/plugin/lib/typescript/ios/withXcodeProject.d.ts +8 -1
- package/plugin/lib/typescript/types/cio-types.d.ts +35 -0
- package/plugin/lib/typescript/utils/validation.d.ts +3 -2
- package/plugin/src/android/withCIOAndroid.ts +13 -2
- package/plugin/src/android/withLocationGradleProperties.ts +41 -0
- package/plugin/src/android/withMainApplicationModifications.ts +26 -4
- package/plugin/src/helpers/native-files/android/CustomerIOSDKInitializer.kt +2 -0
- package/plugin/src/helpers/native-files/ios/CustomerIOSDKInitializer.swift +2 -0
- package/plugin/src/helpers/native-files/ios/apn/CioSdkAppDelegateHandler.swift +1 -1
- package/plugin/src/helpers/native-files/ios/apn/NotificationService.swift +1 -1
- package/plugin/src/helpers/native-files/ios/apn/PushService.swift +1 -1
- package/plugin/src/helpers/native-files/ios/fcm/CioSdkAppDelegateHandler.swift +1 -1
- package/plugin/src/helpers/native-files/ios/fcm/NotificationService.swift +1 -1
- package/plugin/src/helpers/native-files/ios/fcm/PushService.swift +1 -1
- package/plugin/src/helpers/utils/injectCIOPodfileCode.ts +35 -3
- package/plugin/src/helpers/utils/patchLocationCode.ts +80 -0
- package/plugin/src/helpers/utils/patchPluginNativeCode.ts +10 -1
- package/plugin/src/index.ts +9 -3
- package/plugin/src/ios/withCIOIos.ts +40 -3
- package/plugin/src/ios/withCIOIosSwift.ts +30 -4
- package/plugin/src/ios/withNotificationsXcodeProject.ts +56 -1
- package/plugin/src/ios/withXcodeProject.ts +20 -3
- package/plugin/src/types/cio-types.ts +38 -0
- package/plugin/src/utils/validation.ts +18 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "customerio-expo-plugin",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Expo config plugin for the Customer IO React Native SDK",
|
|
5
5
|
"main": "plugin/lib/commonjs/index",
|
|
6
6
|
"module": "plugin/lib/module/index",
|
|
@@ -55,9 +55,10 @@
|
|
|
55
55
|
"registry": "https://registry.npmjs.org/"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"customerio-reactnative": "6.
|
|
58
|
+
"customerio-reactnative": "6.4.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
+
"dotenv": "^16.4.5",
|
|
61
62
|
"@eslint/js": "^9.33.0",
|
|
62
63
|
"@expo/config-plugins": "^10.0.0",
|
|
63
64
|
"@expo/config-types": "^53.0.0",
|
|
@@ -7,12 +7,13 @@ exports.withCIOAndroid = withCIOAndroid;
|
|
|
7
7
|
var _withAndroidManifestUpdates = require("./withAndroidManifestUpdates");
|
|
8
8
|
var _withAppGoogleServices = require("./withAppGoogleServices");
|
|
9
9
|
var _withGoogleServicesJSON = require("./withGoogleServicesJSON");
|
|
10
|
+
var _withLocationGradleProperties = require("./withLocationGradleProperties");
|
|
10
11
|
var _withMainApplicationModifications = require("./withMainApplicationModifications");
|
|
11
12
|
var _withNotificationChannelMetadata = require("./withNotificationChannelMetadata");
|
|
12
13
|
var _withProjectBuildGradle = require("./withProjectBuildGradle");
|
|
13
14
|
var _withProjectGoogleServices = require("./withProjectGoogleServices");
|
|
14
15
|
var _withProjectStrings = require("./withProjectStrings");
|
|
15
|
-
function withCIOAndroid(config, sdkConfig, props) {
|
|
16
|
+
function withCIOAndroid(config, sdkConfig, props, location) {
|
|
16
17
|
// Only run notification setup if props are provided
|
|
17
18
|
if (props) {
|
|
18
19
|
var _props$pushNotificati;
|
|
@@ -29,7 +30,10 @@ function withCIOAndroid(config, sdkConfig, props) {
|
|
|
29
30
|
|
|
30
31
|
// Add auto initialization if sdkConfig is provided
|
|
31
32
|
if (sdkConfig) {
|
|
32
|
-
config = (0, _withMainApplicationModifications.withMainApplicationModifications)(config,
|
|
33
|
+
config = (0, _withMainApplicationModifications.withMainApplicationModifications)(config, {
|
|
34
|
+
sdkConfig,
|
|
35
|
+
location
|
|
36
|
+
});
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
// Update project strings for user agent metadata
|
|
@@ -38,6 +42,13 @@ function withCIOAndroid(config, sdkConfig, props) {
|
|
|
38
42
|
// Add dependency resolution strategy for Expo SDK 53 compatibility
|
|
39
43
|
// This prevents androidx versions that require API 36 from being pulled in
|
|
40
44
|
config = (0, _withProjectBuildGradle.withProjectBuildGradle)(config, props);
|
|
45
|
+
|
|
46
|
+
// Enable SDK location module when location.enabled is true
|
|
47
|
+
if ((location === null || location === void 0 ? void 0 : location.enabled) === true) {
|
|
48
|
+
config = (0, _withLocationGradleProperties.withLocationGradleProperties)(config, {
|
|
49
|
+
location
|
|
50
|
+
});
|
|
51
|
+
}
|
|
41
52
|
return config;
|
|
42
53
|
}
|
|
43
54
|
//# sourceMappingURL=withCIOAndroid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_withAndroidManifestUpdates","require","_withAppGoogleServices","_withGoogleServicesJSON","_withMainApplicationModifications","_withNotificationChannelMetadata","_withProjectBuildGradle","_withProjectGoogleServices","_withProjectStrings","withCIOAndroid","config","sdkConfig","props","_props$pushNotificati","withProjectGoogleServices","withAppGoogleServices","withGoogleServicesJSON","setHighPriorityPushHandler","undefined","withAndroidManifestUpdates","pushNotification","channel","withNotificationChannelMetadata","withMainApplicationModifications","withProjectStrings","withProjectBuildGradle"],"sources":["withCIOAndroid.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type {
|
|
1
|
+
{"version":3,"names":["_withAndroidManifestUpdates","require","_withAppGoogleServices","_withGoogleServicesJSON","_withLocationGradleProperties","_withMainApplicationModifications","_withNotificationChannelMetadata","_withProjectBuildGradle","_withProjectGoogleServices","_withProjectStrings","withCIOAndroid","config","sdkConfig","props","location","_props$pushNotificati","withProjectGoogleServices","withAppGoogleServices","withGoogleServicesJSON","setHighPriorityPushHandler","undefined","withAndroidManifestUpdates","pushNotification","channel","withNotificationChannelMetadata","withMainApplicationModifications","withProjectStrings","withProjectBuildGradle","enabled","withLocationGradleProperties"],"sources":["withCIOAndroid.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport type {\n CustomerIOPluginOptionsAndroid,\n CustomerIOPluginLocationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { withAndroidManifestUpdates } from './withAndroidManifestUpdates';\nimport { withAppGoogleServices } from './withAppGoogleServices';\nimport { withGoogleServicesJSON } from './withGoogleServicesJSON';\nimport { withLocationGradleProperties } from './withLocationGradleProperties';\nimport { withMainApplicationModifications } from './withMainApplicationModifications';\nimport { withNotificationChannelMetadata } from './withNotificationChannelMetadata';\nimport { withProjectBuildGradle } from './withProjectBuildGradle';\nimport { withProjectGoogleServices } from './withProjectGoogleServices';\nimport { withProjectStrings } from './withProjectStrings';\n\nexport function withCIOAndroid(\n config: ExpoConfig,\n sdkConfig?: NativeSDKConfig,\n props?: CustomerIOPluginOptionsAndroid,\n location?: CustomerIOPluginLocationOptions,\n): ExpoConfig {\n // Only run notification setup if props are provided\n if (props) {\n config = withProjectGoogleServices(config, props);\n config = withAppGoogleServices(config, props);\n config = withGoogleServicesJSON(config, props);\n if (props.setHighPriorityPushHandler !== undefined) {\n config = withAndroidManifestUpdates(config, props);\n }\n if (props.pushNotification?.channel) {\n config = withNotificationChannelMetadata(config, props);\n }\n }\n\n // Add auto initialization if sdkConfig is provided\n if (sdkConfig) {\n config = withMainApplicationModifications(config, { sdkConfig, location });\n }\n\n // Update project strings for user agent metadata\n config = withProjectStrings(config);\n\n // Add dependency resolution strategy for Expo SDK 53 compatibility\n // This prevents androidx versions that require API 36 from being pulled in\n config = withProjectBuildGradle(config, props);\n\n // Enable SDK location module when location.enabled is true\n if (location?.enabled === true) {\n config = withLocationGradleProperties(config, { location });\n }\n\n return config;\n}\n"],"mappings":";;;;;;AAOA,IAAAA,2BAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,uBAAA,GAAAF,OAAA;AACA,IAAAG,6BAAA,GAAAH,OAAA;AACA,IAAAI,iCAAA,GAAAJ,OAAA;AACA,IAAAK,gCAAA,GAAAL,OAAA;AACA,IAAAM,uBAAA,GAAAN,OAAA;AACA,IAAAO,0BAAA,GAAAP,OAAA;AACA,IAAAQ,mBAAA,GAAAR,OAAA;AAEO,SAASS,cAAcA,CAC5BC,MAAkB,EAClBC,SAA2B,EAC3BC,KAAsC,EACtCC,QAA0C,EAC9B;EACZ;EACA,IAAID,KAAK,EAAE;IAAA,IAAAE,qBAAA;IACTJ,MAAM,GAAG,IAAAK,oDAAyB,EAACL,MAAM,EAAEE,KAAK,CAAC;IACjDF,MAAM,GAAG,IAAAM,4CAAqB,EAACN,MAAM,EAAEE,KAAK,CAAC;IAC7CF,MAAM,GAAG,IAAAO,8CAAsB,EAACP,MAAM,EAAEE,KAAK,CAAC;IAC9C,IAAIA,KAAK,CAACM,0BAA0B,KAAKC,SAAS,EAAE;MAClDT,MAAM,GAAG,IAAAU,sDAA0B,EAACV,MAAM,EAAEE,KAAK,CAAC;IACpD;IACA,KAAAE,qBAAA,GAAIF,KAAK,CAACS,gBAAgB,cAAAP,qBAAA,eAAtBA,qBAAA,CAAwBQ,OAAO,EAAE;MACnCZ,MAAM,GAAG,IAAAa,gEAA+B,EAACb,MAAM,EAAEE,KAAK,CAAC;IACzD;EACF;;EAEA;EACA,IAAID,SAAS,EAAE;IACbD,MAAM,GAAG,IAAAc,kEAAgC,EAACd,MAAM,EAAE;MAAEC,SAAS;MAAEE;IAAS,CAAC,CAAC;EAC5E;;EAEA;EACAH,MAAM,GAAG,IAAAe,sCAAkB,EAACf,MAAM,CAAC;;EAEnC;EACA;EACAA,MAAM,GAAG,IAAAgB,8CAAsB,EAAChB,MAAM,EAAEE,KAAK,CAAC;;EAE9C;EACA,IAAI,CAAAC,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEc,OAAO,MAAK,IAAI,EAAE;IAC9BjB,MAAM,GAAG,IAAAkB,0DAA4B,EAAClB,MAAM,EAAE;MAAEG;IAAS,CAAC,CAAC;EAC7D;EAEA,OAAOH,MAAM;AACf","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.withLocationGradleProperties = void 0;
|
|
7
|
+
var _configPlugins = require("@expo/config-plugins");
|
|
8
|
+
const CUSTOMERIO_LOCATION_ENABLED_KEY = 'customerio_location_enabled';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Adds or updates customerio_location_enabled in android/gradle.properties when location.enabled is true.
|
|
12
|
+
* The Customer.io React Native SDK reads this to enable the location native module.
|
|
13
|
+
*/
|
|
14
|
+
const withLocationGradleProperties = (config, props) => {
|
|
15
|
+
var _props$location;
|
|
16
|
+
if ((props === null || props === void 0 || (_props$location = props.location) === null || _props$location === void 0 ? void 0 : _props$location.enabled) !== true) {
|
|
17
|
+
return config;
|
|
18
|
+
}
|
|
19
|
+
return (0, _configPlugins.withGradleProperties)(config, config => {
|
|
20
|
+
const items = config.modResults;
|
|
21
|
+
const existingIndex = items.findIndex(item => item.type === 'property' && item.key === CUSTOMERIO_LOCATION_ENABLED_KEY);
|
|
22
|
+
const newItem = {
|
|
23
|
+
type: 'property',
|
|
24
|
+
key: CUSTOMERIO_LOCATION_ENABLED_KEY,
|
|
25
|
+
value: 'true'
|
|
26
|
+
};
|
|
27
|
+
if (existingIndex >= 0) {
|
|
28
|
+
items[existingIndex] = newItem;
|
|
29
|
+
} else {
|
|
30
|
+
items.push(newItem);
|
|
31
|
+
}
|
|
32
|
+
config.modResults = items;
|
|
33
|
+
return config;
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
exports.withLocationGradleProperties = withLocationGradleProperties;
|
|
37
|
+
//# sourceMappingURL=withLocationGradleProperties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","CUSTOMERIO_LOCATION_ENABLED_KEY","withLocationGradleProperties","config","props","_props$location","location","enabled","withGradleProperties","items","modResults","existingIndex","findIndex","item","type","key","newItem","value","push","exports"],"sources":["withLocationGradleProperties.ts"],"sourcesContent":["import type { ConfigPlugin } from '@expo/config-plugins';\nimport { withGradleProperties } from '@expo/config-plugins';\nimport type { PropertiesItem } from '@expo/config-plugins/build/android/Properties';\n\nimport type { CustomerIOPluginLocationOptions } from '../types/cio-types';\n\nconst CUSTOMERIO_LOCATION_ENABLED_KEY = 'customerio_location_enabled';\n\n/**\n * Adds or updates customerio_location_enabled in android/gradle.properties when location.enabled is true.\n * The Customer.io React Native SDK reads this to enable the location native module.\n */\nexport const withLocationGradleProperties: ConfigPlugin<{\n location?: CustomerIOPluginLocationOptions;\n}> = (config, props) => {\n if (props?.location?.enabled !== true) {\n return config;\n }\n\n return withGradleProperties(config, (config) => {\n const items = config.modResults as PropertiesItem[];\n const existingIndex = items.findIndex(\n (item) => item.type === 'property' && item.key === CUSTOMERIO_LOCATION_ENABLED_KEY\n );\n\n const newItem: PropertiesItem = {\n type: 'property',\n key: CUSTOMERIO_LOCATION_ENABLED_KEY,\n value: 'true',\n };\n\n if (existingIndex >= 0) {\n items[existingIndex] = newItem;\n } else {\n items.push(newItem);\n }\n\n config.modResults = items;\n return config;\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAKA,MAAMC,+BAA+B,GAAG,6BAA6B;;AAErE;AACA;AACA;AACA;AACO,MAAMC,4BAEX,GAAGA,CAACC,MAAM,EAAEC,KAAK,KAAK;EAAA,IAAAC,eAAA;EACtB,IAAI,CAAAD,KAAK,aAALA,KAAK,gBAAAC,eAAA,GAALD,KAAK,CAAEE,QAAQ,cAAAD,eAAA,uBAAfA,eAAA,CAAiBE,OAAO,MAAK,IAAI,EAAE;IACrC,OAAOJ,MAAM;EACf;EAEA,OAAO,IAAAK,mCAAoB,EAACL,MAAM,EAAGA,MAAM,IAAK;IAC9C,MAAMM,KAAK,GAAGN,MAAM,CAACO,UAA8B;IACnD,MAAMC,aAAa,GAAGF,KAAK,CAACG,SAAS,CAClCC,IAAI,IAAKA,IAAI,CAACC,IAAI,KAAK,UAAU,IAAID,IAAI,CAACE,GAAG,KAAKd,+BACrD,CAAC;IAED,MAAMe,OAAuB,GAAG;MAC9BF,IAAI,EAAE,UAAU;MAChBC,GAAG,EAAEd,+BAA+B;MACpCgB,KAAK,EAAE;IACT,CAAC;IAED,IAAIN,aAAa,IAAI,CAAC,EAAE;MACtBF,KAAK,CAACE,aAAa,CAAC,GAAGK,OAAO;IAChC,CAAC,MAAM;MACLP,KAAK,CAACS,IAAI,CAACF,OAAO,CAAC;IACrB;IAEAb,MAAM,CAACO,UAAU,GAAGD,KAAK;IACzB,OAAON,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;AAACgB,OAAA,CAAAjB,4BAAA,GAAAA,4BAAA","ignoreList":[]}
|
|
@@ -10,27 +10,43 @@ var _common = require("../helpers/constants/common");
|
|
|
10
10
|
var _patchPluginNativeCode = require("../helpers/utils/patchPluginNativeCode");
|
|
11
11
|
var _android2 = require("../utils/android");
|
|
12
12
|
var _logger = require("../utils/logger");
|
|
13
|
-
const withMainApplicationModifications = (configOuter,
|
|
13
|
+
const withMainApplicationModifications = (configOuter, {
|
|
14
|
+
sdkConfig,
|
|
15
|
+
location
|
|
16
|
+
}) => {
|
|
14
17
|
return (0, _configPlugins.withMainApplication)(configOuter, async config => {
|
|
15
|
-
const content = setupCustomerIOSDKInitializer(config, sdkConfig);
|
|
18
|
+
const content = setupCustomerIOSDKInitializer(config, sdkConfig, location);
|
|
16
19
|
config.modResults.contents = content;
|
|
17
20
|
return config;
|
|
18
21
|
});
|
|
19
22
|
};
|
|
20
23
|
|
|
21
24
|
/**
|
|
22
|
-
*
|
|
25
|
+
* Build location options for native initializer from plugin config.
|
|
26
|
+
* trackingMode comes from config.location.trackingMode (only used when location.enabled is true).
|
|
23
27
|
*/
|
|
24
28
|
exports.withMainApplicationModifications = withMainApplicationModifications;
|
|
25
|
-
const
|
|
29
|
+
const getLocationInitOptions = (location, sdkConfig) => {
|
|
30
|
+
var _sdkConfig$location;
|
|
31
|
+
return {
|
|
32
|
+
enabled: (location === null || location === void 0 ? void 0 : location.enabled) === true,
|
|
33
|
+
trackingMode: sdkConfig === null || sdkConfig === void 0 || (_sdkConfig$location = sdkConfig.location) === null || _sdkConfig$location === void 0 ? void 0 : _sdkConfig$location.trackingMode
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Setup CustomerIOSDKInitializer for Android auto initialization
|
|
39
|
+
*/
|
|
40
|
+
const setupCustomerIOSDKInitializer = (config, sdkConfig, location) => {
|
|
26
41
|
const SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';
|
|
27
42
|
const SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';
|
|
28
43
|
const SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;
|
|
29
44
|
const SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;
|
|
45
|
+
const locationOptions = getLocationInitOptions(location, sdkConfig);
|
|
30
46
|
let content = config.modResults.contents;
|
|
31
47
|
try {
|
|
32
48
|
// Always regenerate the CustomerIOSDKInitializer file to reflect config changes
|
|
33
|
-
(0, _android2.copyTemplateFile)(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, content => (0, _patchPluginNativeCode.patchNativeSDKInitializer)(content, _common.PLATFORM.ANDROID, sdkConfig));
|
|
49
|
+
(0, _android2.copyTemplateFile)(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, content => (0, _patchPluginNativeCode.patchNativeSDKInitializer)(content, _common.PLATFORM.ANDROID, sdkConfig, locationOptions));
|
|
34
50
|
// Add import if not already present
|
|
35
51
|
content = (0, _android2.addImportToFile)(content, SDK_INITIALIZER_IMPORT);
|
|
36
52
|
// Add initialization code to onCreate if not already present
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_configPlugins","require","_android","_common","_patchPluginNativeCode","_android2","_logger","withMainApplicationModifications","configOuter","sdkConfig","withMainApplication","config","content","setupCustomerIOSDKInitializer","modResults","contents","exports","SDK_INITIALIZER_CLASS","SDK_INITIALIZER_PACKAGE","SDK_INITIALIZER_FILE","SDK_INITIALIZER_IMPORT","copyTemplateFile","patchNativeSDKInitializer","PLATFORM","ANDROID","addImportToFile","includes","CIO_NATIVE_SDK_INITIALIZE_CALL","addCodeToMethod","CIO_MAINAPPLICATION_ONCREATE_REGEX","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","error","logger","warn"],"sources":["withMainApplicationModifications.ts"],"sourcesContent":["import type { ConfigPlugin, ExportedConfigWithProps } from '@expo/config-plugins';\nimport { withMainApplication } from '@expo/config-plugins';\nimport type { ApplicationProjectFile } from '@expo/config-plugins/build/android/Paths';\nimport { CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_CALL, CIO_NATIVE_SDK_INITIALIZE_SNIPPET } from '../helpers/constants/android';\nimport { PLATFORM } from '../helpers/constants/common';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type {
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","_android","_common","_patchPluginNativeCode","_android2","_logger","withMainApplicationModifications","configOuter","sdkConfig","location","withMainApplication","config","content","setupCustomerIOSDKInitializer","modResults","contents","exports","getLocationInitOptions","_sdkConfig$location","enabled","trackingMode","SDK_INITIALIZER_CLASS","SDK_INITIALIZER_PACKAGE","SDK_INITIALIZER_FILE","SDK_INITIALIZER_IMPORT","locationOptions","copyTemplateFile","patchNativeSDKInitializer","PLATFORM","ANDROID","addImportToFile","includes","CIO_NATIVE_SDK_INITIALIZE_CALL","addCodeToMethod","CIO_MAINAPPLICATION_ONCREATE_REGEX","CIO_NATIVE_SDK_INITIALIZE_SNIPPET","error","logger","warn"],"sources":["withMainApplicationModifications.ts"],"sourcesContent":["import type { ConfigPlugin, ExportedConfigWithProps } from '@expo/config-plugins';\nimport { withMainApplication } from '@expo/config-plugins';\nimport type { ApplicationProjectFile } from '@expo/config-plugins/build/android/Paths';\nimport { CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_CALL, CIO_NATIVE_SDK_INITIALIZE_SNIPPET } from '../helpers/constants/android';\nimport { PLATFORM } from '../helpers/constants/common';\nimport { patchNativeSDKInitializer } from '../helpers/utils/patchPluginNativeCode';\nimport type {\n CustomerIOPluginLocationOptions,\n NativeSDKConfig,\n} from '../types/cio-types';\nimport { addCodeToMethod, addImportToFile, copyTemplateFile } from '../utils/android';\nimport { logger } from '../utils/logger';\n\ntype MainApplicationModParams = {\n sdkConfig: NativeSDKConfig;\n location?: CustomerIOPluginLocationOptions;\n};\n\nexport const withMainApplicationModifications: ConfigPlugin<MainApplicationModParams> = (configOuter, { sdkConfig, location }) => {\n return withMainApplication(configOuter, async (config) => {\n const content = setupCustomerIOSDKInitializer(config, sdkConfig, location);\n config.modResults.contents = content;\n return config;\n });\n};\n\n/**\n * Build location options for native initializer from plugin config.\n * trackingMode comes from config.location.trackingMode (only used when location.enabled is true).\n */\nconst getLocationInitOptions = (\n location?: CustomerIOPluginLocationOptions,\n sdkConfig?: NativeSDKConfig\n) => ({\n enabled: location?.enabled === true,\n trackingMode: sdkConfig?.location?.trackingMode,\n});\n\n/**\n * Setup CustomerIOSDKInitializer for Android auto initialization\n */\nconst setupCustomerIOSDKInitializer = (\n config: ExportedConfigWithProps<ApplicationProjectFile>,\n sdkConfig: NativeSDKConfig,\n location?: CustomerIOPluginLocationOptions,\n): string => {\n const SDK_INITIALIZER_CLASS = 'CustomerIOSDKInitializer';\n const SDK_INITIALIZER_PACKAGE = 'io.customer.sdk.expo';\n\n const SDK_INITIALIZER_FILE = `${SDK_INITIALIZER_CLASS}.kt`;\n const SDK_INITIALIZER_IMPORT = `import ${SDK_INITIALIZER_PACKAGE}.${SDK_INITIALIZER_CLASS}`;\n\n const locationOptions = getLocationInitOptions(location, sdkConfig);\n let content = config.modResults.contents;\n\n try {\n // Always regenerate the CustomerIOSDKInitializer file to reflect config changes\n copyTemplateFile(config, SDK_INITIALIZER_FILE, SDK_INITIALIZER_PACKAGE, (content) =>\n patchNativeSDKInitializer(content, PLATFORM.ANDROID, sdkConfig, locationOptions)\n );\n // Add import if not already present\n content = addImportToFile(content, SDK_INITIALIZER_IMPORT);\n // Add initialization code to onCreate if not already present\n if (!content.includes(CIO_NATIVE_SDK_INITIALIZE_CALL)) {\n content = addCodeToMethod(content, CIO_MAINAPPLICATION_ONCREATE_REGEX, CIO_NATIVE_SDK_INITIALIZE_SNIPPET);\n }\n } catch (error) {\n logger.warn(`Could not setup ${SDK_INITIALIZER_CLASS}:`, error);\n return config.modResults.contents;\n }\n\n return content;\n};\n"],"mappings":";;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AAKA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAOO,MAAMM,gCAAwE,GAAGA,CAACC,WAAW,EAAE;EAAEC,SAAS;EAAEC;AAAS,CAAC,KAAK;EAChI,OAAO,IAAAC,kCAAmB,EAACH,WAAW,EAAE,MAAOI,MAAM,IAAK;IACxD,MAAMC,OAAO,GAAGC,6BAA6B,CAACF,MAAM,EAAEH,SAAS,EAAEC,QAAQ,CAAC;IAC1EE,MAAM,CAACG,UAAU,CAACC,QAAQ,GAAGH,OAAO;IACpC,OAAOD,MAAM;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AAHAK,OAAA,CAAAV,gCAAA,GAAAA,gCAAA;AAIA,MAAMW,sBAAsB,GAAGA,CAC7BR,QAA0C,EAC1CD,SAA2B;EAAA,IAAAU,mBAAA;EAAA,OACvB;IACJC,OAAO,EAAE,CAAAV,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEU,OAAO,MAAK,IAAI;IACnCC,YAAY,EAAEZ,SAAS,aAATA,SAAS,gBAAAU,mBAAA,GAATV,SAAS,CAAEC,QAAQ,cAAAS,mBAAA,uBAAnBA,mBAAA,CAAqBE;EACrC,CAAC;AAAA,CAAC;;AAEF;AACA;AACA;AACA,MAAMP,6BAA6B,GAAGA,CACpCF,MAAuD,EACvDH,SAA0B,EAC1BC,QAA0C,KAC/B;EACX,MAAMY,qBAAqB,GAAG,0BAA0B;EACxD,MAAMC,uBAAuB,GAAG,sBAAsB;EAEtD,MAAMC,oBAAoB,GAAG,GAAGF,qBAAqB,KAAK;EAC1D,MAAMG,sBAAsB,GAAG,UAAUF,uBAAuB,IAAID,qBAAqB,EAAE;EAE3F,MAAMI,eAAe,GAAGR,sBAAsB,CAACR,QAAQ,EAAED,SAAS,CAAC;EACnE,IAAII,OAAO,GAAGD,MAAM,CAACG,UAAU,CAACC,QAAQ;EAExC,IAAI;IACF;IACA,IAAAW,0BAAgB,EAACf,MAAM,EAAEY,oBAAoB,EAAED,uBAAuB,EAAGV,OAAO,IAC9E,IAAAe,gDAAyB,EAACf,OAAO,EAAEgB,gBAAQ,CAACC,OAAO,EAAErB,SAAS,EAAEiB,eAAe,CACjF,CAAC;IACD;IACAb,OAAO,GAAG,IAAAkB,yBAAe,EAAClB,OAAO,EAAEY,sBAAsB,CAAC;IAC1D;IACA,IAAI,CAACZ,OAAO,CAACmB,QAAQ,CAACC,uCAA8B,CAAC,EAAE;MACrDpB,OAAO,GAAG,IAAAqB,yBAAe,EAACrB,OAAO,EAAEsB,2CAAkC,EAAEC,0CAAiC,CAAC;IAC3G;EACF,CAAC,CAAC,OAAOC,KAAK,EAAE;IACdC,cAAM,CAACC,IAAI,CAAC,mBAAmBjB,qBAAqB,GAAG,EAAEe,KAAK,CAAC;IAC/D,OAAOzB,MAAM,CAACG,UAAU,CAACC,QAAQ;EACnC;EAEA,OAAOH,OAAO;AAChB,CAAC","ignoreList":[]}
|
|
@@ -7,6 +7,7 @@ import io.customer.messaginginapp.ModuleMessagingInApp
|
|
|
7
7
|
import io.customer.messagingpush.MessagingPushModuleConfig
|
|
8
8
|
import io.customer.messagingpush.ModuleMessagingPushFCM
|
|
9
9
|
import io.customer.reactnative.sdk.messaginginapp.ReactInAppEventListener
|
|
10
|
+
{{LOCATION_MODULE_IMPORT}}
|
|
10
11
|
import io.customer.sdk.CustomerIOBuilder
|
|
11
12
|
import io.customer.sdk.core.util.CioLogLevel
|
|
12
13
|
import io.customer.sdk.data.model.Region
|
|
@@ -41,6 +42,7 @@ object CustomerIOSDKInitializer {
|
|
|
41
42
|
MessagingPushModuleConfig.Builder().build()
|
|
42
43
|
)
|
|
43
44
|
)
|
|
45
|
+
{{LOCATION_MODULE_INIT}}
|
|
44
46
|
|
|
45
47
|
build()
|
|
46
48
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import CioDataPipelines
|
|
2
2
|
import CioInternalCommon
|
|
3
3
|
import CioMessagingInApp
|
|
4
|
+
{{LOCATION_MODULE_IMPORT}}
|
|
4
5
|
|
|
5
6
|
class CustomerIOSDKInitializer {
|
|
6
7
|
static func initialize() {
|
|
@@ -23,6 +24,7 @@ class CustomerIOSDKInitializer {
|
|
|
23
24
|
setIfDefined(value: {{SCREEN_VIEW_USE}}, thenPassItTo: builder.screenViewUse) { ScreenView.getScreenView($0) }
|
|
24
25
|
setIfDefined(value: {{MIGRATION_SITE_ID}}, thenPassItTo: builder.migrationSiteId)
|
|
25
26
|
|
|
27
|
+
{{LOCATION_MODULE_INIT}}
|
|
26
28
|
CustomerIO.initialize(withConfig: builder.build())
|
|
27
29
|
|
|
28
30
|
if let siteId = siteId {
|
|
@@ -42,7 +42,7 @@ public class CioSdkAppDelegateHandler: NSObject {
|
|
|
42
42
|
MessagingPushAPN.initialize(
|
|
43
43
|
withConfig: MessagingPushConfigBuilder()
|
|
44
44
|
.autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
|
|
45
|
-
.showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
|
|
45
|
+
{{APP_GROUP_ID_BUILDER_LINE}} .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
|
|
46
46
|
.autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
|
|
47
47
|
.build()
|
|
48
48
|
)
|
|
@@ -12,7 +12,7 @@ public class NotificationServiceCioManager : NSObject {
|
|
|
12
12
|
MessagingPushAPN.initializeForExtension(
|
|
13
13
|
withConfig: MessagingPushConfigBuilder(cdpApiKey: Env.customerIOCdpApiKey)
|
|
14
14
|
.region(Env.customerIORegion)
|
|
15
|
-
.build()
|
|
15
|
+
{{APP_GROUP_ID_BUILDER_LINE}} .build()
|
|
16
16
|
)
|
|
17
17
|
|
|
18
18
|
MessagingPush.shared.didReceive(request, withContentHandler: contentHandler)
|
|
@@ -15,7 +15,7 @@ public class CIOAppPushNotificationsHandler : NSObject {
|
|
|
15
15
|
MessagingPushAPN.initialize(
|
|
16
16
|
withConfig: MessagingPushConfigBuilder()
|
|
17
17
|
.autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
|
|
18
|
-
.showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
|
|
18
|
+
{{APP_GROUP_ID_BUILDER_LINE}} .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
|
|
19
19
|
.autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
|
|
20
20
|
.build()
|
|
21
21
|
)
|
|
@@ -52,7 +52,7 @@ public class CioSdkAppDelegateHandler: NSObject {
|
|
|
52
52
|
MessagingPushFCM.initialize(
|
|
53
53
|
withConfig: MessagingPushConfigBuilder()
|
|
54
54
|
.autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
|
|
55
|
-
.showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
|
|
55
|
+
{{APP_GROUP_ID_BUILDER_LINE}} .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
|
|
56
56
|
.autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
|
|
57
57
|
.build()
|
|
58
58
|
)
|
|
@@ -12,7 +12,7 @@ public class NotificationServiceCioManager : NSObject {
|
|
|
12
12
|
MessagingPushFCM.initializeForExtension(
|
|
13
13
|
withConfig: MessagingPushConfigBuilder(cdpApiKey: Env.customerIOCdpApiKey)
|
|
14
14
|
.region(Env.customerIORegion)
|
|
15
|
-
.build()
|
|
15
|
+
{{APP_GROUP_ID_BUILDER_LINE}} .build()
|
|
16
16
|
)
|
|
17
17
|
|
|
18
18
|
MessagingPush.shared.didReceive(request, withContentHandler: contentHandler)
|
|
@@ -23,7 +23,7 @@ public class CIOAppPushNotificationsHandler : NSObject {
|
|
|
23
23
|
MessagingPushFCM.initialize(
|
|
24
24
|
withConfig: MessagingPushConfigBuilder()
|
|
25
25
|
.autoFetchDeviceToken({{AUTO_FETCH_DEVICE_TOKEN}})
|
|
26
|
-
.showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
|
|
26
|
+
{{APP_GROUP_ID_BUILDER_LINE}} .showPushAppInForeground({{SHOW_PUSH_APP_IN_FOREGROUND}})
|
|
27
27
|
.autoTrackPushEvents({{AUTO_TRACK_PUSH_EVENTS}})
|
|
28
28
|
.build()
|
|
29
29
|
)
|
|
@@ -3,13 +3,29 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.buildHostAppPodSnippet = buildHostAppPodSnippet;
|
|
6
7
|
exports.injectCIONotificationPodfileCode = injectCIONotificationPodfileCode;
|
|
7
8
|
exports.injectCIOPodfileCode = injectCIOPodfileCode;
|
|
8
9
|
var _logger = require("../../utils/logger");
|
|
9
10
|
var _ios = require("../constants/ios");
|
|
10
11
|
var _codeInjection = require("./codeInjection");
|
|
11
12
|
var _fileManagement = require("./fileManagement");
|
|
12
|
-
|
|
13
|
+
/** Builds the host app pod line for the Podfile (single subspec or :subspecs with location). Exported for tests. */
|
|
14
|
+
function buildHostAppPodSnippet(iosPath, isFcmPushProvider, options) {
|
|
15
|
+
const path = (0, _ios.getRelativePathToRNSDK)(iosPath);
|
|
16
|
+
const locationEnabled = (options === null || options === void 0 ? void 0 : options.locationEnabled) === true;
|
|
17
|
+
const hasPush = (options === null || options === void 0 ? void 0 : options.hasPush) !== false;
|
|
18
|
+
if (!locationEnabled) {
|
|
19
|
+
const subspec = isFcmPushProvider ? 'fcm' : 'apn';
|
|
20
|
+
return `pod 'customerio-reactnative/${subspec}', :path => '${path}'`;
|
|
21
|
+
}
|
|
22
|
+
if (!hasPush) {
|
|
23
|
+
return `pod 'customerio-reactnative', :subspecs => ['location'], :path => '${path}'`;
|
|
24
|
+
}
|
|
25
|
+
const pushSubspec = isFcmPushProvider ? 'fcm' : 'apn';
|
|
26
|
+
return `pod 'customerio-reactnative', :subspecs => ['${pushSubspec}', 'location'], :path => '${path}'`;
|
|
27
|
+
}
|
|
28
|
+
async function injectCIOPodfileCode(iosPath, isFcmPushProvider, options) {
|
|
13
29
|
const blockStart = '# --- CustomerIO Host App START ---';
|
|
14
30
|
const blockEnd = '# --- CustomerIO Host App END ---';
|
|
15
31
|
const filename = `${iosPath}/Podfile`;
|
|
@@ -20,9 +36,10 @@ async function injectCIOPodfileCode(iosPath, isFcmPushProvider) {
|
|
|
20
36
|
// The "post_install" line is always present in an Expo project Podfile so it's reliable.
|
|
21
37
|
// Find that line in the Podfile and then we will insert our code above that line.
|
|
22
38
|
const lineInPodfileToInjectSnippetBefore = /post_install do \|installer\|/;
|
|
39
|
+
const podLine = buildHostAppPodSnippet(iosPath, isFcmPushProvider, options);
|
|
23
40
|
const snippetToInjectInPodfile = `
|
|
24
41
|
${blockStart}
|
|
25
|
-
|
|
42
|
+
${podLine}
|
|
26
43
|
${blockEnd}
|
|
27
44
|
`.trim();
|
|
28
45
|
_fileManagement.FileManagement.write(filename, (0, _codeInjection.injectCodeByRegex)(podfile, lineInPodfileToInjectSnippetBefore, snippetToInjectInPodfile).join('\n'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_logger","require","_ios","_codeInjection","_fileManagement","
|
|
1
|
+
{"version":3,"names":["_logger","require","_ios","_codeInjection","_fileManagement","buildHostAppPodSnippet","iosPath","isFcmPushProvider","options","path","getRelativePathToRNSDK","locationEnabled","hasPush","subspec","pushSubspec","injectCIOPodfileCode","blockStart","blockEnd","filename","podfile","FileManagement","read","matches","match","RegExp","lineInPodfileToInjectSnippetBefore","podLine","snippetToInjectInPodfile","trim","write","injectCodeByRegex","join","logger","info","injectCIONotificationPodfileCode","useFrameworks","append"],"sources":["injectCIOPodfileCode.ts"],"sourcesContent":["import type { CustomerIOPluginOptionsIOS } from '../../types/cio-types';\nimport { logger } from '../../utils/logger';\nimport { getRelativePathToRNSDK } from '../constants/ios';\nimport { injectCodeByRegex } from './codeInjection';\nimport { FileManagement } from './fileManagement';\n\nexport type InjectCIOPodfileOptions = {\n /** When true, add the location subspec. When false/omit, use single push subspec only. */\n locationEnabled?: boolean;\n /** When false and locationEnabled, inject only :subspecs => ['location']. When true, use push + location. */\n hasPush?: boolean;\n};\n\n/** Builds the host app pod line for the Podfile (single subspec or :subspecs with location). Exported for tests. */\nexport function buildHostAppPodSnippet(\n iosPath: string,\n isFcmPushProvider: boolean,\n options?: InjectCIOPodfileOptions\n): string {\n const path = getRelativePathToRNSDK(iosPath);\n const locationEnabled = options?.locationEnabled === true;\n const hasPush = options?.hasPush !== false;\n\n if (!locationEnabled) {\n const subspec = isFcmPushProvider ? 'fcm' : 'apn';\n return `pod 'customerio-reactnative/${subspec}', :path => '${path}'`;\n }\n\n if (!hasPush) {\n return `pod 'customerio-reactnative', :subspecs => ['location'], :path => '${path}'`;\n }\n\n const pushSubspec = isFcmPushProvider ? 'fcm' : 'apn';\n return `pod 'customerio-reactnative', :subspecs => ['${pushSubspec}', 'location'], :path => '${path}'`;\n}\n\nexport async function injectCIOPodfileCode(\n iosPath: string,\n isFcmPushProvider: boolean,\n options?: InjectCIOPodfileOptions\n) {\n const blockStart = '# --- CustomerIO Host App START ---';\n const blockEnd = '# --- CustomerIO Host App END ---';\n\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n // We need to decide what line of code in the Podfile to insert our native code.\n // The \"post_install\" line is always present in an Expo project Podfile so it's reliable.\n // Find that line in the Podfile and then we will insert our code above that line.\n const lineInPodfileToInjectSnippetBefore = /post_install do \\|installer\\|/;\n\n const podLine = buildHostAppPodSnippet(iosPath, isFcmPushProvider, options);\n\n const snippetToInjectInPodfile = `\n${blockStart}\n ${podLine}\n${blockEnd}\n`.trim();\n\n FileManagement.write(\n filename,\n injectCodeByRegex(\n podfile,\n lineInPodfileToInjectSnippetBefore,\n snippetToInjectInPodfile\n ).join('\\n')\n );\n } else {\n logger.info('CustomerIO Podfile snippets already exists. Skipping...');\n }\n}\n\nexport async function injectCIONotificationPodfileCode(\n iosPath: string,\n useFrameworks: CustomerIOPluginOptionsIOS['useFrameworks'],\n isFcmPushProvider: boolean\n) {\n const filename = `${iosPath}/Podfile`;\n const podfile = await FileManagement.read(filename);\n\n const blockStart = '# --- CustomerIO Notification START ---';\n const blockEnd = '# --- CustomerIO Notification END ---';\n\n const matches = podfile.match(new RegExp(blockStart));\n\n if (!matches) {\n const snippetToInjectInPodfile = `\n${blockStart}\ntarget 'NotificationService' do\n ${useFrameworks === 'static' ? 'use_frameworks! :linkage => :static' : ''}\n pod 'customerio-reactnative-richpush/${isFcmPushProvider ? 'fcm' : 'apn'\n }', :path => '${getRelativePathToRNSDK(iosPath)}'\nend\n${blockEnd}\n`.trim();\n\n FileManagement.append(filename, snippetToInjectInPodfile);\n }\n}\n"],"mappings":";;;;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AASA;AACO,SAASI,sBAAsBA,CACpCC,OAAe,EACfC,iBAA0B,EAC1BC,OAAiC,EACzB;EACR,MAAMC,IAAI,GAAG,IAAAC,2BAAsB,EAACJ,OAAO,CAAC;EAC5C,MAAMK,eAAe,GAAG,CAAAH,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEG,eAAe,MAAK,IAAI;EACzD,MAAMC,OAAO,GAAG,CAAAJ,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEI,OAAO,MAAK,KAAK;EAE1C,IAAI,CAACD,eAAe,EAAE;IACpB,MAAME,OAAO,GAAGN,iBAAiB,GAAG,KAAK,GAAG,KAAK;IACjD,OAAO,+BAA+BM,OAAO,gBAAgBJ,IAAI,GAAG;EACtE;EAEA,IAAI,CAACG,OAAO,EAAE;IACZ,OAAO,sEAAsEH,IAAI,GAAG;EACtF;EAEA,MAAMK,WAAW,GAAGP,iBAAiB,GAAG,KAAK,GAAG,KAAK;EACrD,OAAO,gDAAgDO,WAAW,6BAA6BL,IAAI,GAAG;AACxG;AAEO,eAAeM,oBAAoBA,CACxCT,OAAe,EACfC,iBAA0B,EAC1BC,OAAiC,EACjC;EACA,MAAMQ,UAAU,GAAG,qCAAqC;EACxD,MAAMC,QAAQ,GAAG,mCAAmC;EAEpD,MAAMC,QAAQ,GAAG,GAAGZ,OAAO,UAAU;EACrC,MAAMa,OAAO,GAAG,MAAMC,8BAAc,CAACC,IAAI,CAACH,QAAQ,CAAC;EACnD,MAAMI,OAAO,GAAGH,OAAO,CAACI,KAAK,CAAC,IAAIC,MAAM,CAACR,UAAU,CAAC,CAAC;EAErD,IAAI,CAACM,OAAO,EAAE;IACZ;IACA;IACA;IACA,MAAMG,kCAAkC,GAAG,+BAA+B;IAE1E,MAAMC,OAAO,GAAGrB,sBAAsB,CAACC,OAAO,EAAEC,iBAAiB,EAAEC,OAAO,CAAC;IAE3E,MAAMmB,wBAAwB,GAAG;AACrC,EAAEX,UAAU;AACZ,IAAIU,OAAO;AACX,EAAET,QAAQ;AACV,CAAC,CAACW,IAAI,CAAC,CAAC;IAEJR,8BAAc,CAACS,KAAK,CAClBX,QAAQ,EACR,IAAAY,gCAAiB,EACfX,OAAO,EACPM,kCAAkC,EAClCE,wBACF,CAAC,CAACI,IAAI,CAAC,IAAI,CACb,CAAC;EACH,CAAC,MAAM;IACLC,cAAM,CAACC,IAAI,CAAC,yDAAyD,CAAC;EACxE;AACF;AAEO,eAAeC,gCAAgCA,CACpD5B,OAAe,EACf6B,aAA0D,EAC1D5B,iBAA0B,EAC1B;EACA,MAAMW,QAAQ,GAAG,GAAGZ,OAAO,UAAU;EACrC,MAAMa,OAAO,GAAG,MAAMC,8BAAc,CAACC,IAAI,CAACH,QAAQ,CAAC;EAEnD,MAAMF,UAAU,GAAG,yCAAyC;EAC5D,MAAMC,QAAQ,GAAG,uCAAuC;EAExD,MAAMK,OAAO,GAAGH,OAAO,CAACI,KAAK,CAAC,IAAIC,MAAM,CAACR,UAAU,CAAC,CAAC;EAErD,IAAI,CAACM,OAAO,EAAE;IACZ,MAAMK,wBAAwB,GAAG;AACrC,EAAEX,UAAU;AACZ;AACA,IAAImB,aAAa,KAAK,QAAQ,GAAG,qCAAqC,GAAG,EAAE;AAC3E,yCAAyC5B,iBAAiB,GAAG,KAAK,GAAG,KAAK,gBACpD,IAAAG,2BAAsB,EAACJ,OAAO,CAAC;AACrD;AACA,EAAEW,QAAQ;AACV,CAAC,CAACW,IAAI,CAAC,CAAC;IAEJR,8BAAc,CAACgB,MAAM,CAAClB,QAAQ,EAAES,wBAAwB,CAAC;EAC3D;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.patchLocationPlaceholders = patchLocationPlaceholders;
|
|
7
|
+
var _common = require("../constants/common");
|
|
8
|
+
const VALID_TRACKING_MODES = ['OFF', 'MANUAL', 'ON_APP_START'];
|
|
9
|
+
|
|
10
|
+
/** Options for location module in generated native initializer */
|
|
11
|
+
|
|
12
|
+
function normalizeTrackingMode(rawMode) {
|
|
13
|
+
const upper = rawMode === null || rawMode === void 0 ? void 0 : rawMode.toUpperCase();
|
|
14
|
+
return upper && VALID_TRACKING_MODES.includes(upper) ? upper : 'MANUAL';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Replaces {{LOCATION_MODULE_IMPORT}} and {{LOCATION_MODULE_INIT}} placeholders
|
|
19
|
+
* in SDK initializer template content for the given platform.
|
|
20
|
+
*/
|
|
21
|
+
function patchLocationPlaceholders(content, platform, locationOptions) {
|
|
22
|
+
const locationEnabled = (locationOptions === null || locationOptions === void 0 ? void 0 : locationOptions.enabled) === true;
|
|
23
|
+
const trackingMode = normalizeTrackingMode(locationOptions === null || locationOptions === void 0 ? void 0 : locationOptions.trackingMode);
|
|
24
|
+
if (platform === _common.PLATFORM.ANDROID) {
|
|
25
|
+
if (locationEnabled) {
|
|
26
|
+
return content.replace(/\{\{LOCATION_MODULE_IMPORT\}\}/g, `import io.customer.location.LocationModuleConfig
|
|
27
|
+
import io.customer.location.LocationTrackingMode
|
|
28
|
+
import io.customer.location.ModuleLocation
|
|
29
|
+
`).replace(/\{\{LOCATION_MODULE_INIT\}\}/g, `if (io.customer.reactnative.sdk.BuildConfig.CIO_LOCATION_ENABLED) {
|
|
30
|
+
addCustomerIOModule(
|
|
31
|
+
ModuleLocation(
|
|
32
|
+
LocationModuleConfig.Builder()
|
|
33
|
+
.setLocationTrackingMode(LocationTrackingMode.${trackingMode})
|
|
34
|
+
.build()
|
|
35
|
+
)
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
`);
|
|
39
|
+
}
|
|
40
|
+
return content.replace(/\n\{\{LOCATION_MODULE_IMPORT\}\}\n/g, '\n').replace(/\n\s*\{\{LOCATION_MODULE_INIT\}\}\n/g, '\n');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// iOS
|
|
44
|
+
if (locationEnabled) {
|
|
45
|
+
const modeSwift = trackingMode === 'OFF' ? '.off' : trackingMode === 'ON_APP_START' ? '.onAppStart' : '.manual';
|
|
46
|
+
return content.replace(/\{\{LOCATION_MODULE_IMPORT\}\}/g, 'import CioLocation\n').replace(/\{\{LOCATION_MODULE_INIT\}\}/g, `_ = builder.addModule(LocationModule(config: LocationConfig(mode: ${modeSwift})))`);
|
|
47
|
+
}
|
|
48
|
+
return content.replace(/\n\{\{LOCATION_MODULE_IMPORT\}\}\n/g, '\n').replace(/\n\s*\{\{LOCATION_MODULE_INIT\}\}\n/g, '\n\n');
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=patchLocationCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_common","require","VALID_TRACKING_MODES","normalizeTrackingMode","rawMode","upper","toUpperCase","includes","patchLocationPlaceholders","content","platform","locationOptions","locationEnabled","enabled","trackingMode","PLATFORM","ANDROID","replace","modeSwift"],"sources":["patchLocationCode.ts"],"sourcesContent":["import type { LocationTrackingMode } from '../../types/cio-types';\nimport { PLATFORM, type Platform } from '../constants/common';\n\nconst VALID_TRACKING_MODES: LocationTrackingMode[] = ['OFF', 'MANUAL', 'ON_APP_START'];\n\n/** Options for location module in generated native initializer */\nexport type LocationInitOptions = {\n enabled: boolean;\n trackingMode?: LocationTrackingMode;\n};\n\nfunction normalizeTrackingMode(\n rawMode: string | undefined\n): LocationTrackingMode {\n const upper = rawMode?.toUpperCase();\n return upper && VALID_TRACKING_MODES.includes(upper as LocationTrackingMode)\n ? (upper as LocationTrackingMode)\n : 'MANUAL';\n}\n\n/**\n * Replaces {{LOCATION_MODULE_IMPORT}} and {{LOCATION_MODULE_INIT}} placeholders\n * in SDK initializer template content for the given platform.\n */\nexport function patchLocationPlaceholders(\n content: string,\n platform: Platform,\n locationOptions?: LocationInitOptions\n): string {\n const locationEnabled = locationOptions?.enabled === true;\n const trackingMode = normalizeTrackingMode(locationOptions?.trackingMode);\n\n if (platform === PLATFORM.ANDROID) {\n if (locationEnabled) {\n return content\n .replace(\n /\\{\\{LOCATION_MODULE_IMPORT\\}\\}/g,\n `import io.customer.location.LocationModuleConfig\nimport io.customer.location.LocationTrackingMode\nimport io.customer.location.ModuleLocation\n`\n )\n .replace(\n /\\{\\{LOCATION_MODULE_INIT\\}\\}/g,\n `if (io.customer.reactnative.sdk.BuildConfig.CIO_LOCATION_ENABLED) {\n addCustomerIOModule(\n ModuleLocation(\n LocationModuleConfig.Builder()\n .setLocationTrackingMode(LocationTrackingMode.${trackingMode})\n .build()\n )\n )\n }\n `\n );\n }\n return content\n .replace(/\\n\\{\\{LOCATION_MODULE_IMPORT\\}\\}\\n/g, '\\n')\n .replace(/\\n\\s*\\{\\{LOCATION_MODULE_INIT\\}\\}\\n/g, '\\n');\n }\n\n // iOS\n if (locationEnabled) {\n const modeSwift =\n trackingMode === 'OFF'\n ? '.off'\n : trackingMode === 'ON_APP_START'\n ? '.onAppStart'\n : '.manual';\n return content\n .replace(/\\{\\{LOCATION_MODULE_IMPORT\\}\\}/g, 'import CioLocation\\n')\n .replace(\n /\\{\\{LOCATION_MODULE_INIT\\}\\}/g,\n `_ = builder.addModule(LocationModule(config: LocationConfig(mode: ${modeSwift})))`\n );\n }\n return content\n .replace(/\\n\\{\\{LOCATION_MODULE_IMPORT\\}\\}\\n/g, '\\n')\n .replace(/\\n\\s*\\{\\{LOCATION_MODULE_INIT\\}\\}\\n/g, '\\n\\n');\n}\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAEA,MAAMC,oBAA4C,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,CAAC;;AAEtF;;AAMA,SAASC,qBAAqBA,CAC5BC,OAA2B,EACL;EACtB,MAAMC,KAAK,GAAGD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,WAAW,CAAC,CAAC;EACpC,OAAOD,KAAK,IAAIH,oBAAoB,CAACK,QAAQ,CAACF,KAA6B,CAAC,GACvEA,KAAK,GACN,QAAQ;AACd;;AAEA;AACA;AACA;AACA;AACO,SAASG,yBAAyBA,CACvCC,OAAe,EACfC,QAAkB,EAClBC,eAAqC,EAC7B;EACR,MAAMC,eAAe,GAAG,CAAAD,eAAe,aAAfA,eAAe,uBAAfA,eAAe,CAAEE,OAAO,MAAK,IAAI;EACzD,MAAMC,YAAY,GAAGX,qBAAqB,CAACQ,eAAe,aAAfA,eAAe,uBAAfA,eAAe,CAAEG,YAAY,CAAC;EAEzE,IAAIJ,QAAQ,KAAKK,gBAAQ,CAACC,OAAO,EAAE;IACjC,IAAIJ,eAAe,EAAE;MACnB,OAAOH,OAAO,CACXQ,OAAO,CACN,iCAAiC,EACjC;AACV;AACA;AACA,CACQ,CAAC,CACAA,OAAO,CACN,+BAA+B,EAC/B;AACV;AACA;AACA;AACA,wEAAwEH,YAAY;AACpF;AACA;AACA;AACA;AACA,SACQ,CAAC;IACL;IACA,OAAOL,OAAO,CACXQ,OAAO,CAAC,qCAAqC,EAAE,IAAI,CAAC,CACpDA,OAAO,CAAC,sCAAsC,EAAE,IAAI,CAAC;EAC1D;;EAEA;EACA,IAAIL,eAAe,EAAE;IACnB,MAAMM,SAAS,GACbJ,YAAY,KAAK,KAAK,GAClB,MAAM,GACNA,YAAY,KAAK,cAAc,GAC7B,aAAa,GACb,SAAS;IACjB,OAAOL,OAAO,CACXQ,OAAO,CAAC,iCAAiC,EAAE,sBAAsB,CAAC,CAClEA,OAAO,CACN,+BAA+B,EAC/B,qEAAqEC,SAAS,KAChF,CAAC;EACL;EACA,OAAOT,OAAO,CACXQ,OAAO,CAAC,qCAAqC,EAAE,IAAI,CAAC,CACpDA,OAAO,CAAC,sCAAsC,EAAE,MAAM,CAAC;AAC5D","ignoreList":[]}
|
|
@@ -7,11 +7,12 @@ exports.patchNativeSDKInitializer = patchNativeSDKInitializer;
|
|
|
7
7
|
var _plugin = require("../../utils/plugin");
|
|
8
8
|
var _validation = require("../../utils/validation");
|
|
9
9
|
var _common = require("../constants/common");
|
|
10
|
+
var _patchLocationCode = require("./patchLocationCode");
|
|
10
11
|
/**
|
|
11
12
|
* Shared utility function to perform common SDK config replacements
|
|
12
13
|
* for both iOS and Android template files
|
|
13
14
|
*/
|
|
14
|
-
function patchNativeSDKInitializer(rawContent, platform, sdkConfig) {
|
|
15
|
+
function patchNativeSDKInitializer(rawContent, platform, sdkConfig, locationOptions) {
|
|
15
16
|
var _siteId, _migrationSiteId;
|
|
16
17
|
// Validate SDK configuration to ensure all fields are present and
|
|
17
18
|
// correct at the time of patching in prebuild
|
|
@@ -61,6 +62,7 @@ function patchNativeSDKInitializer(rawContent, platform, sdkConfig) {
|
|
|
61
62
|
// Replace siteId and migrationSiteId placeholders (trim whitespace and handle empty strings)
|
|
62
63
|
replaceValue(/\{\{SITE_ID\}\}/g, ((_siteId = siteId) === null || _siteId === void 0 ? void 0 : _siteId.trim()) || undefined, configValue => `"${configValue}"`);
|
|
63
64
|
replaceValue(/\{\{MIGRATION_SITE_ID\}\}/g, ((_migrationSiteId = migrationSiteId) === null || _migrationSiteId === void 0 ? void 0 : _migrationSiteId.trim()) || undefined, configValue => `"${configValue}"`);
|
|
65
|
+
content = (0, _patchLocationCode.patchLocationPlaceholders)(content, platform, locationOptions);
|
|
64
66
|
return content;
|
|
65
67
|
}
|
|
66
68
|
//# sourceMappingURL=patchPluginNativeCode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_plugin","require","_validation","_common","patchNativeSDKInitializer","rawContent","platform","sdkConfig","_siteId","_migrationSiteId","validateNativeSDKConfig","content","replaceValue","placeholder","value","transform","fallback","PLATFORM","ANDROID","undefined","replace","pluginVersion","getPluginVersion","cdpApiKey","region","configValue","logLevel","autoTrackDeviceAttributes","toString","trackApplicationLifecycleEvents","screenViewUse","siteId","migrationSiteId","trim"],"sources":["patchPluginNativeCode.ts"],"sourcesContent":["import type { NativeSDKConfig } from '../../types/cio-types';\nimport { getPluginVersion } from '../../utils/plugin';\nimport { validateNativeSDKConfig } from '../../utils/validation';\nimport { PLATFORM, type Platform } from '../constants/common';\n\n/**\n * Shared utility function to perform common SDK config replacements\n * for both iOS and Android template files\n */\nexport function patchNativeSDKInitializer(\n rawContent: string,\n platform: Platform,\n sdkConfig: NativeSDKConfig\n): string {\n // Validate SDK configuration to ensure all fields are present and \n // correct at the time of patching in prebuild\n validateNativeSDKConfig(sdkConfig);\n\n let content = rawContent;\n\n // Helper function to replace placeholders with platform-specific fallback values\n const replaceValue = <T>(\n placeholder: RegExp,\n value: T | undefined,\n transform: (configValue: T) => string,\n fallback: string = platform === PLATFORM.ANDROID ? 'null' : 'nil'\n ) => {\n if (value !== undefined && value !== null) {\n content = content.replace(placeholder, transform(value));\n } else {\n content = content.replace(placeholder, fallback);\n }\n };\n\n // Replace EXPO_PLUGIN_VERSION with actual plugin version\n const pluginVersion = getPluginVersion();\n content = content.replace(/\\{\\{EXPO_PLUGIN_VERSION\\}\\}/g, pluginVersion);\n\n // Replace CDP API Key (required field)\n content = content.replace(/\\{\\{CDP_API_KEY\\}\\}/g, sdkConfig.cdpApiKey);\n\n // Handle region - use empty string as fallback (nil not supported for region)\n replaceValue(\n /\\{\\{REGION\\}\\}/g,\n sdkConfig.region,\n (configValue) => `\"${configValue}\"`,\n '\"\"'\n );\n\n // Handle logLevel - use nil/null as fallback\n replaceValue(\n /\\{\\{LOG_LEVEL\\}\\}/g,\n sdkConfig.logLevel,\n (configValue) => `\"${configValue}\"`\n );\n\n // Handle optional boolean configurations\n replaceValue(\n /\\{\\{AUTO_TRACK_DEVICE_ATTRIBUTES\\}\\}/g,\n sdkConfig.autoTrackDeviceAttributes,\n (configValue) => configValue.toString()\n );\n\n replaceValue(\n /\\{\\{TRACK_APPLICATION_LIFECYCLE_EVENTS\\}\\}/g,\n sdkConfig.trackApplicationLifecycleEvents,\n (configValue) => configValue.toString()\n );\n\n // Handle screenViewUse - use nil/null as fallback\n replaceValue(\n /\\{\\{SCREEN_VIEW_USE\\}\\}/g,\n sdkConfig.screenViewUse,\n (configValue) => `\"${configValue}\"`\n );\n\n // Handle siteId/migrationSiteId business logic\n let siteId = sdkConfig.siteId;\n let migrationSiteId = sdkConfig.migrationSiteId;\n\n // Business rule: if only siteId provided, copy to migrationSiteId; if only migrationSiteId provided, set siteId to undefined\n if (siteId && !migrationSiteId) {\n migrationSiteId = siteId;\n } else if (migrationSiteId && !siteId) {\n siteId = undefined;\n }\n\n // Replace siteId and migrationSiteId placeholders (trim whitespace and handle empty strings)\n replaceValue(\n /\\{\\{SITE_ID\\}\\}/g,\n siteId?.trim() || undefined,\n (configValue) => `\"${configValue}\"`\n );\n\n replaceValue(\n /\\{\\{MIGRATION_SITE_ID\\}\\}/g,\n migrationSiteId?.trim() || undefined,\n (configValue) => `\"${configValue}\"`\n );\n\n return content;\n}\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;
|
|
1
|
+
{"version":3,"names":["_plugin","require","_validation","_common","_patchLocationCode","patchNativeSDKInitializer","rawContent","platform","sdkConfig","locationOptions","_siteId","_migrationSiteId","validateNativeSDKConfig","content","replaceValue","placeholder","value","transform","fallback","PLATFORM","ANDROID","undefined","replace","pluginVersion","getPluginVersion","cdpApiKey","region","configValue","logLevel","autoTrackDeviceAttributes","toString","trackApplicationLifecycleEvents","screenViewUse","siteId","migrationSiteId","trim","patchLocationPlaceholders"],"sources":["patchPluginNativeCode.ts"],"sourcesContent":["import type { NativeSDKConfig } from '../../types/cio-types';\nimport { getPluginVersion } from '../../utils/plugin';\nimport { validateNativeSDKConfig } from '../../utils/validation';\nimport { PLATFORM, type Platform } from '../constants/common';\nimport {\n type LocationInitOptions,\n patchLocationPlaceholders,\n} from './patchLocationCode';\n\nexport type { LocationInitOptions };\n\n/**\n * Shared utility function to perform common SDK config replacements\n * for both iOS and Android template files\n */\nexport function patchNativeSDKInitializer(\n rawContent: string,\n platform: Platform,\n sdkConfig: NativeSDKConfig,\n locationOptions?: LocationInitOptions\n): string {\n // Validate SDK configuration to ensure all fields are present and \n // correct at the time of patching in prebuild\n validateNativeSDKConfig(sdkConfig);\n\n let content = rawContent;\n\n // Helper function to replace placeholders with platform-specific fallback values\n const replaceValue = <T>(\n placeholder: RegExp,\n value: T | undefined,\n transform: (configValue: T) => string,\n fallback: string = platform === PLATFORM.ANDROID ? 'null' : 'nil'\n ) => {\n if (value !== undefined && value !== null) {\n content = content.replace(placeholder, transform(value));\n } else {\n content = content.replace(placeholder, fallback);\n }\n };\n\n // Replace EXPO_PLUGIN_VERSION with actual plugin version\n const pluginVersion = getPluginVersion();\n content = content.replace(/\\{\\{EXPO_PLUGIN_VERSION\\}\\}/g, pluginVersion);\n\n // Replace CDP API Key (required field)\n content = content.replace(/\\{\\{CDP_API_KEY\\}\\}/g, sdkConfig.cdpApiKey);\n\n // Handle region - use empty string as fallback (nil not supported for region)\n replaceValue(\n /\\{\\{REGION\\}\\}/g,\n sdkConfig.region,\n (configValue) => `\"${configValue}\"`,\n '\"\"'\n );\n\n // Handle logLevel - use nil/null as fallback\n replaceValue(\n /\\{\\{LOG_LEVEL\\}\\}/g,\n sdkConfig.logLevel,\n (configValue) => `\"${configValue}\"`\n );\n\n // Handle optional boolean configurations\n replaceValue(\n /\\{\\{AUTO_TRACK_DEVICE_ATTRIBUTES\\}\\}/g,\n sdkConfig.autoTrackDeviceAttributes,\n (configValue) => configValue.toString()\n );\n\n replaceValue(\n /\\{\\{TRACK_APPLICATION_LIFECYCLE_EVENTS\\}\\}/g,\n sdkConfig.trackApplicationLifecycleEvents,\n (configValue) => configValue.toString()\n );\n\n // Handle screenViewUse - use nil/null as fallback\n replaceValue(\n /\\{\\{SCREEN_VIEW_USE\\}\\}/g,\n sdkConfig.screenViewUse,\n (configValue) => `\"${configValue}\"`\n );\n\n // Handle siteId/migrationSiteId business logic\n let siteId = sdkConfig.siteId;\n let migrationSiteId = sdkConfig.migrationSiteId;\n\n // Business rule: if only siteId provided, copy to migrationSiteId; if only migrationSiteId provided, set siteId to undefined\n if (siteId && !migrationSiteId) {\n migrationSiteId = siteId;\n } else if (migrationSiteId && !siteId) {\n siteId = undefined;\n }\n\n // Replace siteId and migrationSiteId placeholders (trim whitespace and handle empty strings)\n replaceValue(\n /\\{\\{SITE_ID\\}\\}/g,\n siteId?.trim() || undefined,\n (configValue) => `\"${configValue}\"`\n );\n\n replaceValue(\n /\\{\\{MIGRATION_SITE_ID\\}\\}/g,\n migrationSiteId?.trim() || undefined,\n (configValue) => `\"${configValue}\"`\n );\n\n content = patchLocationPlaceholders(content, platform, locationOptions);\n\n return content;\n}\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AAOA;AACA;AACA;AACA;AACO,SAASI,yBAAyBA,CACvCC,UAAkB,EAClBC,QAAkB,EAClBC,SAA0B,EAC1BC,eAAqC,EAC7B;EAAA,IAAAC,OAAA,EAAAC,gBAAA;EACR;EACA;EACA,IAAAC,mCAAuB,EAACJ,SAAS,CAAC;EAElC,IAAIK,OAAO,GAAGP,UAAU;;EAExB;EACA,MAAMQ,YAAY,GAAGA,CACnBC,WAAmB,EACnBC,KAAoB,EACpBC,SAAqC,EACrCC,QAAgB,GAAGX,QAAQ,KAAKY,gBAAQ,CAACC,OAAO,GAAG,MAAM,GAAG,KAAK,KAC9D;IACH,IAAIJ,KAAK,KAAKK,SAAS,IAAIL,KAAK,KAAK,IAAI,EAAE;MACzCH,OAAO,GAAGA,OAAO,CAACS,OAAO,CAACP,WAAW,EAAEE,SAAS,CAACD,KAAK,CAAC,CAAC;IAC1D,CAAC,MAAM;MACLH,OAAO,GAAGA,OAAO,CAACS,OAAO,CAACP,WAAW,EAAEG,QAAQ,CAAC;IAClD;EACF,CAAC;;EAED;EACA,MAAMK,aAAa,GAAG,IAAAC,wBAAgB,EAAC,CAAC;EACxCX,OAAO,GAAGA,OAAO,CAACS,OAAO,CAAC,8BAA8B,EAAEC,aAAa,CAAC;;EAExE;EACAV,OAAO,GAAGA,OAAO,CAACS,OAAO,CAAC,sBAAsB,EAAEd,SAAS,CAACiB,SAAS,CAAC;;EAEtE;EACAX,YAAY,CACV,iBAAiB,EACjBN,SAAS,CAACkB,MAAM,EACfC,WAAW,IAAK,IAAIA,WAAW,GAAG,EACnC,IACF,CAAC;;EAED;EACAb,YAAY,CACV,oBAAoB,EACpBN,SAAS,CAACoB,QAAQ,EACjBD,WAAW,IAAK,IAAIA,WAAW,GAClC,CAAC;;EAED;EACAb,YAAY,CACV,uCAAuC,EACvCN,SAAS,CAACqB,yBAAyB,EAClCF,WAAW,IAAKA,WAAW,CAACG,QAAQ,CAAC,CACxC,CAAC;EAEDhB,YAAY,CACV,6CAA6C,EAC7CN,SAAS,CAACuB,+BAA+B,EACxCJ,WAAW,IAAKA,WAAW,CAACG,QAAQ,CAAC,CACxC,CAAC;;EAED;EACAhB,YAAY,CACV,0BAA0B,EAC1BN,SAAS,CAACwB,aAAa,EACtBL,WAAW,IAAK,IAAIA,WAAW,GAClC,CAAC;;EAED;EACA,IAAIM,MAAM,GAAGzB,SAAS,CAACyB,MAAM;EAC7B,IAAIC,eAAe,GAAG1B,SAAS,CAAC0B,eAAe;;EAE/C;EACA,IAAID,MAAM,IAAI,CAACC,eAAe,EAAE;IAC9BA,eAAe,GAAGD,MAAM;EAC1B,CAAC,MAAM,IAAIC,eAAe,IAAI,CAACD,MAAM,EAAE;IACrCA,MAAM,GAAGZ,SAAS;EACpB;;EAEA;EACAP,YAAY,CACV,kBAAkB,EAClB,EAAAJ,OAAA,GAAAuB,MAAM,cAAAvB,OAAA,uBAANA,OAAA,CAAQyB,IAAI,CAAC,CAAC,KAAId,SAAS,EAC1BM,WAAW,IAAK,IAAIA,WAAW,GAClC,CAAC;EAEDb,YAAY,CACV,4BAA4B,EAC5B,EAAAH,gBAAA,GAAAuB,eAAe,cAAAvB,gBAAA,uBAAfA,gBAAA,CAAiBwB,IAAI,CAAC,CAAC,KAAId,SAAS,EACnCM,WAAW,IAAK,IAAIA,WAAW,GAClC,CAAC;EAEDd,OAAO,GAAG,IAAAuB,4CAAyB,EAACvB,OAAO,EAAEN,QAAQ,EAAEE,eAAe,CAAC;EAEvE,OAAOI,OAAO;AAChB","ignoreList":[]}
|
|
@@ -15,8 +15,8 @@ function withCustomerIOPlugin(config, props) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
// Apply platform specific modifications
|
|
18
|
-
config = (0, _withCIOIos.withCIOIos)(config, props.config, props.ios);
|
|
19
|
-
config = (0, _withCIOAndroid.withCIOAndroid)(config, props.config, props.android);
|
|
18
|
+
config = (0, _withCIOIos.withCIOIos)(config, props.config, props.ios, props.location);
|
|
19
|
+
config = (0, _withCIOAndroid.withCIOAndroid)(config, props.config, props.android, props.location);
|
|
20
20
|
return config;
|
|
21
21
|
}
|
|
22
22
|
var _default = exports.default = withCustomerIOPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_withCIOAndroid","require","_utils","_withCIOIos","withCustomerIOPlugin","config","props","isExpoVersion53OrHigher","Error","withCIOIos","ios","withCIOAndroid","android","_default","exports","default"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withCIOAndroid } from './android/withCIOAndroid';\nimport { isExpoVersion53OrHigher } from './ios/utils';\nimport { withCIOIos } from './ios/withCIOIos';\nimport type {
|
|
1
|
+
{"version":3,"names":["_withCIOAndroid","require","_utils","_withCIOIos","withCustomerIOPlugin","config","props","isExpoVersion53OrHigher","Error","withCIOIos","ios","location","withCIOAndroid","android","_default","exports","default"],"sources":["index.ts"],"sourcesContent":["import type { ExpoConfig } from '@expo/config-types';\n\nimport { withCIOAndroid } from './android/withCIOAndroid';\nimport { isExpoVersion53OrHigher } from './ios/utils';\nimport { withCIOIos } from './ios/withCIOIos';\nimport type {\n CustomerIOPluginOptions,\n LocationTrackingMode,\n NativeSDKConfig,\n} from './types/cio-types';\n\nexport type { LocationTrackingMode, NativeSDKConfig };\n\n// Entry point for config plugin\nfunction withCustomerIOPlugin(\n config: ExpoConfig,\n props: CustomerIOPluginOptions\n) {\n // Check if config is being used with unsupported Expo version\n if (props.config && !isExpoVersion53OrHigher(config)) {\n throw new Error(\n 'CustomerIO auto initialization (config property) requires Expo SDK 53 or higher. ' +\n 'Please upgrade to Expo SDK 53+ or use manual initialization instead. ' +\n 'See documentation for manual setup instructions.'\n );\n }\n\n // Apply platform specific modifications\n config = withCIOIos(config, props.config, props.ios, props.location);\n config = withCIOAndroid(config, props.config, props.android, props.location);\n\n return config;\n}\n\nexport default withCustomerIOPlugin;\n"],"mappings":";;;;;;AAEA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AASA;AACA,SAASG,oBAAoBA,CAC3BC,MAAkB,EAClBC,KAA8B,EAC9B;EACA;EACA,IAAIA,KAAK,CAACD,MAAM,IAAI,CAAC,IAAAE,8BAAuB,EAACF,MAAM,CAAC,EAAE;IACpD,MAAM,IAAIG,KAAK,CACb,mFAAmF,GACnF,uEAAuE,GACvE,kDACF,CAAC;EACH;;EAEA;EACAH,MAAM,GAAG,IAAAI,sBAAU,EAACJ,MAAM,EAAEC,KAAK,CAACD,MAAM,EAAEC,KAAK,CAACI,GAAG,EAAEJ,KAAK,CAACK,QAAQ,CAAC;EACpEN,MAAM,GAAG,IAAAO,8BAAc,EAACP,MAAM,EAAEC,KAAK,CAACD,MAAM,EAAEC,KAAK,CAACO,OAAO,EAAEP,KAAK,CAACK,QAAQ,CAAC;EAE5E,OAAON,MAAM;AACf;AAAC,IAAAS,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcZ,oBAAoB","ignoreList":[]}
|
|
@@ -4,20 +4,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.withCIOIos = withCIOIos;
|
|
7
|
+
var _configPlugins = require("@expo/config-plugins");
|
|
7
8
|
var _config = require("../utils/config");
|
|
8
9
|
var _logger = require("../utils/logger");
|
|
10
|
+
var _validation = require("../utils/validation");
|
|
9
11
|
var _utils = require("./utils");
|
|
10
12
|
var _withAppDelegateModifications = require("./withAppDelegateModifications");
|
|
11
13
|
var _withCIOIosSwift = require("./withCIOIosSwift");
|
|
12
14
|
var _withGoogleServicesJsonFile = require("./withGoogleServicesJsonFile");
|
|
13
15
|
var _withNotificationsXcodeProject = require("./withNotificationsXcodeProject");
|
|
14
16
|
var _withXcodeProject = require("./withXcodeProject");
|
|
15
|
-
function withCIOIos(config, sdkConfig, props) {
|
|
17
|
+
function withCIOIos(config, sdkConfig, props, location) {
|
|
16
18
|
const isSwiftProject = (0, _utils.isExpoVersion53OrHigher)(config);
|
|
17
19
|
const platformConfig = mergeDeprecatedPropertiesAndLogWarnings(props);
|
|
20
|
+
const locationEnabled = (location === null || location === void 0 ? void 0 : location.enabled) === true;
|
|
18
21
|
if (platformConfig !== null && platformConfig !== void 0 && platformConfig.pushNotification) {
|
|
22
|
+
var _platformConfig$pushN;
|
|
23
|
+
(0, _validation.validatePushNotificationOptions)(platformConfig.pushNotification);
|
|
19
24
|
if (isSwiftProject) {
|
|
20
|
-
config = (0, _withCIOIosSwift.withCIOIosSwift)(config, sdkConfig, platformConfig);
|
|
25
|
+
config = (0, _withCIOIosSwift.withCIOIosSwift)(config, sdkConfig, platformConfig, location);
|
|
21
26
|
} else {
|
|
22
27
|
// Auto initialization is only supported in Swift projects (Expo SDK 53+)
|
|
23
28
|
// Legacy Objective-C projects only support push notifications
|
|
@@ -25,10 +30,47 @@ function withCIOIos(config, sdkConfig, props) {
|
|
|
25
30
|
}
|
|
26
31
|
platformConfig.pushNotification.env = platformConfig.pushNotification.env || (0, _config.mergeConfigWithEnvValues)(platformConfig, sdkConfig);
|
|
27
32
|
config = (0, _withNotificationsXcodeProject.withCioNotificationsXcodeProject)(config, platformConfig);
|
|
28
|
-
config = (0, _withXcodeProject.withCioXcodeProject)(config,
|
|
33
|
+
config = (0, _withXcodeProject.withCioXcodeProject)(config, {
|
|
34
|
+
...platformConfig,
|
|
35
|
+
podfileOptions: {
|
|
36
|
+
locationEnabled,
|
|
37
|
+
hasPush: true
|
|
38
|
+
}
|
|
39
|
+
});
|
|
29
40
|
config = (0, _withGoogleServicesJsonFile.withGoogleServicesJsonFile)(config, platformConfig);
|
|
41
|
+
|
|
42
|
+
// Merge App Group entitlements on host only when appGroupId is explicitly set
|
|
43
|
+
const appGroupId = (_platformConfig$pushN = platformConfig.pushNotification) === null || _platformConfig$pushN === void 0 ? void 0 : _platformConfig$pushN.appGroupId;
|
|
44
|
+
if (appGroupId) {
|
|
45
|
+
config = (0, _configPlugins.withEntitlementsPlist)(config, entitlementsConfig => {
|
|
46
|
+
const entitlements = entitlementsConfig.modResults;
|
|
47
|
+
const existing = entitlements['com.apple.security.application-groups'] ?? [];
|
|
48
|
+
if (!existing.includes(appGroupId)) {
|
|
49
|
+
entitlements['com.apple.security.application-groups'] = [...existing, appGroupId];
|
|
50
|
+
}
|
|
51
|
+
return entitlementsConfig;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
30
54
|
} else if (sdkConfig && isSwiftProject) {
|
|
31
|
-
config = (0, _withCIOIosSwift.withCIOIosSwift)(config, sdkConfig, platformConfig);
|
|
55
|
+
config = (0, _withCIOIosSwift.withCIOIosSwift)(config, sdkConfig, platformConfig, location);
|
|
56
|
+
if (locationEnabled) {
|
|
57
|
+
config = (0, _withXcodeProject.withCioXcodeProject)(config, {
|
|
58
|
+
...platformConfig,
|
|
59
|
+
podfileOptions: {
|
|
60
|
+
locationEnabled: true,
|
|
61
|
+
hasPush: false
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
} else if (locationEnabled) {
|
|
66
|
+
// Location-only: no push, no config. Still add Podfile location subspec so CIO_LOCATION_ENABLED is set and native location code is included.
|
|
67
|
+
config = (0, _withXcodeProject.withCioXcodeProject)(config, {
|
|
68
|
+
...platformConfig,
|
|
69
|
+
podfileOptions: {
|
|
70
|
+
locationEnabled: true,
|
|
71
|
+
hasPush: false
|
|
72
|
+
}
|
|
73
|
+
});
|
|
32
74
|
}
|
|
33
75
|
return config;
|
|
34
76
|
}
|