Skip to content

Commit

Permalink
[MT-1497] Version 2.4.0 (#66)
Browse files Browse the repository at this point in the history
* Update Versions and install firebase on sample app

* Add firebase JSON resource

* Android Sample updates

* build-extras.gradle copy hook

* change clobbers to merges to fix ordering issue

* Add firebase google services to sample app

Leave them commented for now
ignored the actual files

WIP: android seems not to be working

* Add (commented) google play services to sample app for testing firebase

Uncomment them to test after adding the google-services.json

* Make local firebase work for both platforms

* TealiumFirebase package.json spacing

* Just leave the direct dependency to tealiumfirebase in tealium.gradle

---------

Co-authored-by: jameskeith <[email protected]>
  • Loading branch information
Enricoza and jameskeith authored Mar 27, 2024
1 parent aeb352a commit 950108c
Show file tree
Hide file tree
Showing 17 changed files with 227 additions and 34 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ plugins/
platforms/
.DS_STORE
package-lock.json
*GoogleService-Info.plist
*google-services.json
2 changes: 1 addition & 1 deletion RemoteCommands/TealiumFirebase/build-extras.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 34
}

packagingOptions {
Expand Down
4 changes: 2 additions & 2 deletions RemoteCommands/TealiumFirebase/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tealium-cordova-firebase-plugin",
"version": "1.0.0",
"version": "1.1.0",
"description": "Tealium Customer Data Hub",
"cordova": {
"id": "tealium-cordova-firebase-plugin",
Expand Down Expand Up @@ -30,7 +30,7 @@
}
],
"dependencies": {
"tealium-cordova-plugin" : ">=2.1.0"
"tealium-cordova-plugin": ">=2.1.0"
},
"variables": {
"GRADLEPLUGINKOTLINENABLED": true
Expand Down
10 changes: 5 additions & 5 deletions RemoteCommands/TealiumFirebase/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="tealium-cordova-firebase-plugin" version="1.0.0" name="tealium-cordova-firebase-plugin">
id="tealium-cordova-firebase-plugin" version="1.1.0" name="tealium-cordova-firebase-plugin">

<name>TealiumFirebaseCordova</name>
<description>Tealium Tag Management and UDH</description>
Expand All @@ -16,7 +16,7 @@
</engines>

<js-module src="www/tealium-firebase.js" name="tealium-firebase">
<clobbers target="tealium.remotecommands.firebase" />
<merges target="tealium.remotecommands.firebase" />
</js-module>

<!-- ios -->
Expand All @@ -39,9 +39,9 @@
<source url="https://github.com/CocoaPods/Specs.git"/>
</config>
<pods use-frameworks="true">
<pod name="TealiumFirebase" spec="~> 2.0.2"/>
<pod name="Firebase" spec="~> 8.0"/>
<pod name="FirebaseAnalytics" spec="~> 8.0"/>
<pod name="TealiumFirebase" spec="~> 3.2"/>
<pod name="Firebase" spec="~> 10.7"/>
<pod name="FirebaseAnalytics" spec="~> 10.7"/>
</pods>
</podspec>
</platform>
Expand Down
4 changes: 1 addition & 3 deletions RemoteCommands/TealiumFirebase/src/android/tealium.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ repositories{
}

dependencies {
implementation 'com.tealium:remotecommands:1.0.0'
implementation 'com.tealium.remotecommands:firebase:1.2.1'
implementation 'com.google.firebase:firebase-analytics:17.6.0'
implementation 'com.tealium.remotecommands:firebase:1.5.0'
}

android {
Expand Down
2 changes: 1 addition & 1 deletion Tealium/build-extras.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 34
}

packagingOptions {
Expand Down
2 changes: 1 addition & 1 deletion Tealium/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tealium-cordova-plugin",
"version": "2.3.1",
"version": "2.4.0",
"description": "Tealium Customer Data Hub",
"cordova": {
"id": "tealium-cordova-plugin",
Expand Down
17 changes: 9 additions & 8 deletions Tealium/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="tealium-cordova-plugin" version="2.3.1"
id="tealium-cordova-plugin" version="2.4.0"
name="tealium-cordova-plugin">

<name>TealiumCordova</name>
Expand All @@ -17,7 +17,7 @@ name="tealium-cordova-plugin">
</engines>

<js-module src="www/tealium.js" name="tealium">
<clobbers target="tealium" />
<merges target="tealium" />
</js-module>

<!-- ios -->
Expand All @@ -26,6 +26,7 @@ name="tealium-cordova-plugin">
<plugins-plist key="TealiumCordova" string="TealiumCordova" />
<!-- Cordova >= 2.3 -->
<config-file target="config.xml" parent="/*">
<preference name="deployment-target" value="12.0" />
<plugin name="TealiumCordova" value="TealiumCordova"/>
<feature name="TealiumCordova">
<param name="ios-package" value="TealiumCordova" />
Expand All @@ -45,12 +46,12 @@ name="tealium-cordova-plugin">
<source url="https://github.com/CocoaPods/Specs.git"/>
</config>
<pods use-frameworks="true">
<pod name="tealium-swift/Core" spec="~> 2.8"/>
<pod name="tealium-swift/TagManagement" spec="~> 2.8"/>
<pod name="tealium-swift/Collect" spec="~> 2.8"/>
<pod name="tealium-swift/Lifecycle" spec="~> 2.8"/>
<pod name="tealium-swift/RemoteCommands" spec="~> 2.8"/>
<pod name="tealium-swift/VisitorService" spec="~> 2.8"/>
<pod name="tealium-swift/Core" spec="~> 2.12"/>
<pod name="tealium-swift/TagManagement" spec="~> 2.12"/>
<pod name="tealium-swift/Collect" spec="~> 2.12"/>
<pod name="tealium-swift/Lifecycle" spec="~> 2.12"/>
<pod name="tealium-swift/RemoteCommands" spec="~> 2.12"/>
<pod name="tealium-swift/VisitorService" spec="~> 2.12"/>
</pods>
</podspec>
</platform>
Expand Down
12 changes: 6 additions & 6 deletions Tealium/src/android/tealium.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ repositories {
}

dependencies {
implementation 'com.tealium:kotlin-core:1.5.1'
implementation 'com.tealium:kotlin-collect-dispatcher:1.1.0'
implementation 'com.tealium:kotlin-tagmanagement-dispatcher:1.2.0'
implementation 'com.tealium:kotlin-remotecommand-dispatcher:1.2.1'
implementation 'com.tealium:kotlin-lifecycle:1.1.1'
implementation 'com.tealium:kotlin-visitor-service:1.1.1'
implementation 'com.tealium:kotlin-core:1.5.5'
implementation 'com.tealium:kotlin-collect-dispatcher:1.1.1'
implementation 'com.tealium:kotlin-tagmanagement-dispatcher:1.2.1'
implementation 'com.tealium:kotlin-remotecommand-dispatcher:1.3.1'
implementation 'com.tealium:kotlin-lifecycle:1.2.0'
implementation 'com.tealium:kotlin-visitor-service:1.2.0'
}

android {
Expand Down
2 changes: 1 addition & 1 deletion Tealium/www/tealium.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ let TealiumPlugin = {
initialize(config, callback) {
let self = this;
cordova.exec(function(e) {
self.addData({'plugin_name': 'Tealium-Cordova', 'plugin_version': '2.3.1'}, Expiry.forever);
self.addData({'plugin_name': 'Tealium-Cordova', 'plugin_version': '2.4.0'}, Expiry.forever);
if (config.remoteCommands) {
config.remoteCommands.forEach((remoteCommand) => {
self.addRemoteCommand(remoteCommand.id, remoteCommand.callback, remoteCommand.path, remoteCommand.url)
Expand Down
8 changes: 8 additions & 0 deletions TealiumCordovaSample/build-extras.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Manually set the Kotlin version
if(cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) {
android {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
}
}
22 changes: 19 additions & 3 deletions TealiumCordovaSample/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,32 @@
<platform name="android">
<allow-intent href="market:*" />
<preference name="AndroidXEnabled" value="true" />
<preference name="android-targetSdkVersion" value="31" />
<preference name="android-compileSdkVersion" value="31" />
<preference name="android-buildToolsVersion" value="30.0.3" />
<preference name="android-targetSdkVersion" value="34" />
<preference name="android-compileSdkVersion" value="34" />
<preference name="android-buildToolsVersion" value="33.0.2" />
<preference name="GradlePluginKotlinVersion" value="1.9.20"/>
<!-- uncomment the following to test Firebase after adding the google-services.json under the resources directory -->
<!-- <preference name="GradlePluginGoogleServicesEnabled" value="true"/>
<preference name="GradlePluginGoogleServicesVersion" value="4.3.15"/> -->
<config-file parent="/manifest/application" target="AndroidManifest.xml">
<!-- TODO: Replace with your real AdMob app ID -->
<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-################~##########" />
</config-file>
<resource-file src="resources/firebase.json" target="app/src/main/assets/firebase.json" />
<!-- uncomment the following to test Firebase after adding the google-services.json under the resources directory -->
<!-- <resource-file src="resources/google-services.json" target="app/google-services.json" /> -->
<hook type="before_build" src="hooks/copy-gradle-extras.js"/>
<hook type="after_platform_add" src="hooks/disable-kotlin-extensions.js"/>
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
<config-file parent="/*" target="config.xml">
<preference name="deployment-target" value="12.0" />
<preference name="target-device" value="universal" />
</config-file>
<resource-file src="resources/firebase.json" />
<!-- uncomment the following to test Firebase after adding the GoogleService-Info.plist under the resources directory -->
<!-- <resource-file src="resources/GoogleService-Info.plist" /> -->
</platform>
</widget>
18 changes: 18 additions & 0 deletions TealiumCordovaSample/hooks/copy-gradle-extras.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env node
'use strict';

const fs = require('fs');
const path = require('path');


module.exports = function () {
const sourceFile = path.join('build-extras.gradle');
const destinationFile = path.join('platforms', 'android', 'app', 'build-extras.gradle');

if (fs.existsSync(sourceFile)) {
fs.copyFile(sourceFile, destinationFile, (err) => {
if (err) throw err;
console.log('build-extras.gradle was copied.');
});
}
};
47 changes: 47 additions & 0 deletions TealiumCordovaSample/hooks/disable-kotlin-extensions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env node
'use strict';

const fs = require('fs');
const path = require('path');

const plugins = ['kotlin-android-extensions'];

module.exports = function () {
const file = path.join('platforms', 'android', 'app', 'build.gradle');

if (fs.existsSync(file)) {
let newFile = fs.readFileSync(file).toString();

console.log('Removing lines from build.gradle... ');

newFile = removeRegExp(newFile, plugins, applyPluginRegExp);

fs.writeFileSync(file, newFile);
} else {
throw `Couldn't find file: ${file}`;
}
};

function removeRegExp(file, items, regExp) {
const lines = [];

for (const item of items) {
lines.push(...Array.from(file.matchAll(regExp(item))));
}

if (lines.length > 0) {
lines.sort((a, b) => b.index - a.index);

for (const line of lines) {
console.log(`Removing line from build.gradle: ${line[0].trim()}`);

file = file.slice(0, line.index) + file.slice(line.index + line[0].length);
}
}

return file;
}

function applyPluginRegExp(plugin) {
return new RegExp("\\s*?apply plugin: '" + plugin + "'.*?", 'gm');
}
6 changes: 4 additions & 2 deletions TealiumCordovaSample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
"author": "Apache Cordova Team",
"license": "Apache-2.0",
"devDependencies": {
"cordova-android": "^10.1.2",
"cordova-ios": "^6.2.0",
"cordova-android": "^12.0.1",
"cordova-ios": "^7.0.1",
"cordova-plugin-whitelist": "^1.3.4",
"tealium-cordova-firebase-plugin": "file:../RemoteCommands/TealiumFirebase",
"tealium-cordova-plugin": "file:../Tealium"
},
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"tealium-cordova-firebase-plugin": {},
"tealium-cordova-plugin": {}
},
"platforms": [
Expand Down
97 changes: 97 additions & 0 deletions TealiumCordovaSample/resources/firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"config": {
"firebase_analytics_enabled": "true",
"firebase_session_timeout_seconds": "30",
"firebase_log_level": "max",
"firebase_session_minimum_seconds": "100"
},
"mappings": {
"achievement_id": "event.param_achievement_id",
"ad_network_click_id": "event.param_ad_network_click_id",
"affiliation": "event.param_affiliation",
"campaign_keywords": "event.param_cp1",
"campaign": "event.param_campaign",
"game_character": "event.param_character",
"checkout_option": "event.param_checkout_option",
"checkout_step": "event.param_checkout_step",
"content": "event.param_content",
"content_type": "event.param_content_type",
"coupon": "event.param_coupon",
"creative_name": "event.param_creative_name",
"creative_slot": "event.param_creative_slot",
"currency_code": "event.param_currency",
"travel_destination": "event.param_destination",
"end_date": "event.param_end_date",
"flight_number": "event.param_flight_number",
"group_id": "event.param_group_id",
"current_index": "param_index",
"product_brand": "items.param_item_brand",
"product_category": "items.param_item_category",
"product_id": "items.param_item_id",
"product_unit_price": "items.param_price",
"product_quantity": "items.param_quantity",
"product_list": "items.param_item_list",
"product_location_id": "items.param_item_location_id",
"product_name": "items.param_item_name",
"product_variant": "items.param_item_variant",
"current_level": "event.param_level",
"most_recent_location": "event.param_location",
"campaign_medium": "event.param_medium",
"number_nights": "event.param_number_nights",
"number_pax": "event.param_number_pax",
"number_rooms": "event.param_number_rooms",
"travel_origin": "event.param_origin",
"score": "event.param_score",
"search_keyword": "event.param_search_term",
"order_shipping_amount": "event.param_shipping",
"signup_method": "event.param_signup_method",
"campaign_source": "event.param_source",
"start_date": "event.param_start_date",
"order_tax_amount": "event.param_tax",
"product_term": "event.param_term",
"order_id": "event.param_transaction_id",
"travel_class": "event.param_travel_class",
"order_total": "event.param_value",
"currency_type": "event.param_virtual_currency_name",
"user_signup_method": "event.param_user_signup_method",
"tealium_event": "firebase_event_name",
"screen_name": "firebase_screen_name",
"screen_class": "firebase_screen_class",
"customer_property": "firebase_property_name",
"customer_value": "firebase_property_value",
"customer_id": "firebase_user_id",
"customparam1": "event.custom_param_1_mapped",
"customparam2": "event.custom_param_2_mapped",
"character": "event.character",
"consent_ad_storage": "firebase_consent_settings.ad_storage",
"consent_analytics_storage": "firebase_consent_settings.analytics_storage",
"consent_ad_user_data": "firebase_consent_settings.ad_user_data",
"consent_ad_personalization": "firebase_consent_settings.ad_personalization"
},
"commands": {
"launch": "config",
"user_login": "logevent",
"user_register": "logevent,setuserproperty",
"share": "logevent",
"show_offers": "logevent",
"join_group": "logevent",
"travel_order": "logevent",
"earn_currency": "logevent",
"spend_currency": "logevent",
"unlock_achievement": "logevent",
"level_up": "logevent",
"start_tutorial": "logevent",
"stop_tutorial": "logevent",
"record_score": "logevent",
"category": "logevent,setscreenname",
"product": "logevent,setscreenname",
"cart_add": "logevent",
"wishlist_add": "logevent",
"checkout": "logevent,setscreenname",
"checkout_progress": "logevent",
"email_signup": "logevent",
"order": "logevent,setscreenname",
"setconsent": "setconsent",
"TestEvent": "logevent"
}
}
Loading

0 comments on commit 950108c

Please sign in to comment.