From 950108c7c0e4e489c33bc5f9e823e71860a0728e Mon Sep 17 00:00:00 2001 From: Enrico Zannini Date: Wed, 27 Mar 2024 11:22:38 +0100 Subject: [PATCH] [MT-1497] Version 2.4.0 (#66) * 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 --- .gitignore | 2 + .../TealiumFirebase/build-extras.gradle | 2 +- RemoteCommands/TealiumFirebase/package.json | 4 +- RemoteCommands/TealiumFirebase/plugin.xml | 10 +- .../src/android/tealium.gradle | 4 +- Tealium/build-extras.gradle | 2 +- Tealium/package.json | 2 +- Tealium/plugin.xml | 17 ++-- Tealium/src/android/tealium.gradle | 12 +-- Tealium/www/tealium.js | 2 +- TealiumCordovaSample/build-extras.gradle | 8 ++ TealiumCordovaSample/config.xml | 22 ++++- .../hooks/copy-gradle-extras.js | 18 ++++ .../hooks/disable-kotlin-extensions.js | 47 +++++++++ TealiumCordovaSample/package.json | 6 +- TealiumCordovaSample/resources/firebase.json | 97 +++++++++++++++++++ TealiumCordovaSample/www/js/index.js | 6 +- 17 files changed, 227 insertions(+), 34 deletions(-) create mode 100644 TealiumCordovaSample/build-extras.gradle create mode 100644 TealiumCordovaSample/hooks/copy-gradle-extras.js create mode 100644 TealiumCordovaSample/hooks/disable-kotlin-extensions.js create mode 100644 TealiumCordovaSample/resources/firebase.json diff --git a/.gitignore b/.gitignore index 52ee62f..8db15df 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ plugins/ platforms/ .DS_STORE package-lock.json +*GoogleService-Info.plist +*google-services.json \ No newline at end of file diff --git a/RemoteCommands/TealiumFirebase/build-extras.gradle b/RemoteCommands/TealiumFirebase/build-extras.gradle index 6c9e145..6efd0a4 100644 --- a/RemoteCommands/TealiumFirebase/build-extras.gradle +++ b/RemoteCommands/TealiumFirebase/build-extras.gradle @@ -1,7 +1,7 @@ android { defaultConfig { minSdkVersion 21 - targetSdkVersion 29 + targetSdkVersion 34 } packagingOptions { diff --git a/RemoteCommands/TealiumFirebase/package.json b/RemoteCommands/TealiumFirebase/package.json index 788d0ec..19ca691 100644 --- a/RemoteCommands/TealiumFirebase/package.json +++ b/RemoteCommands/TealiumFirebase/package.json @@ -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", @@ -30,7 +30,7 @@ } ], "dependencies": { - "tealium-cordova-plugin" : ">=2.1.0" + "tealium-cordova-plugin": ">=2.1.0" }, "variables": { "GRADLEPLUGINKOTLINENABLED": true diff --git a/RemoteCommands/TealiumFirebase/plugin.xml b/RemoteCommands/TealiumFirebase/plugin.xml index 06c516f..7905a89 100755 --- a/RemoteCommands/TealiumFirebase/plugin.xml +++ b/RemoteCommands/TealiumFirebase/plugin.xml @@ -1,7 +1,7 @@ + id="tealium-cordova-firebase-plugin" version="1.1.0" name="tealium-cordova-firebase-plugin"> TealiumFirebaseCordova Tealium Tag Management and UDH @@ -16,7 +16,7 @@ - + @@ -39,9 +39,9 @@ - - - + + + diff --git a/RemoteCommands/TealiumFirebase/src/android/tealium.gradle b/RemoteCommands/TealiumFirebase/src/android/tealium.gradle index 51846c6..56f095d 100644 --- a/RemoteCommands/TealiumFirebase/src/android/tealium.gradle +++ b/RemoteCommands/TealiumFirebase/src/android/tealium.gradle @@ -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 { diff --git a/Tealium/build-extras.gradle b/Tealium/build-extras.gradle index 6c9e145..6efd0a4 100644 --- a/Tealium/build-extras.gradle +++ b/Tealium/build-extras.gradle @@ -1,7 +1,7 @@ android { defaultConfig { minSdkVersion 21 - targetSdkVersion 29 + targetSdkVersion 34 } packagingOptions { diff --git a/Tealium/package.json b/Tealium/package.json index 4269c6f..13d66bc 100644 --- a/Tealium/package.json +++ b/Tealium/package.json @@ -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", diff --git a/Tealium/plugin.xml b/Tealium/plugin.xml index 68b70e6..07df86b 100755 --- a/Tealium/plugin.xml +++ b/Tealium/plugin.xml @@ -1,7 +1,7 @@ TealiumCordova @@ -17,7 +17,7 @@ name="tealium-cordova-plugin"> - + @@ -26,6 +26,7 @@ name="tealium-cordova-plugin"> + @@ -45,12 +46,12 @@ name="tealium-cordova-plugin"> - - - - - - + + + + + + diff --git a/Tealium/src/android/tealium.gradle b/Tealium/src/android/tealium.gradle index 5502d49..68854c6 100644 --- a/Tealium/src/android/tealium.gradle +++ b/Tealium/src/android/tealium.gradle @@ -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 { diff --git a/Tealium/www/tealium.js b/Tealium/www/tealium.js index 28c9bc9..90b1b0b 100755 --- a/Tealium/www/tealium.js +++ b/Tealium/www/tealium.js @@ -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) diff --git a/TealiumCordovaSample/build-extras.gradle b/TealiumCordovaSample/build-extras.gradle new file mode 100644 index 0000000..30bc493 --- /dev/null +++ b/TealiumCordovaSample/build-extras.gradle @@ -0,0 +1,8 @@ +// Manually set the Kotlin version +if(cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) { + android { + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8 + } + } +} \ No newline at end of file diff --git a/TealiumCordovaSample/config.xml b/TealiumCordovaSample/config.xml index 8a1f02a..0bb62c3 100644 --- a/TealiumCordovaSample/config.xml +++ b/TealiumCordovaSample/config.xml @@ -18,16 +18,32 @@ - - - + + + + + + + + + + + + + + + + + + diff --git a/TealiumCordovaSample/hooks/copy-gradle-extras.js b/TealiumCordovaSample/hooks/copy-gradle-extras.js new file mode 100644 index 0000000..0e58ca6 --- /dev/null +++ b/TealiumCordovaSample/hooks/copy-gradle-extras.js @@ -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.'); + }); + } +}; \ No newline at end of file diff --git a/TealiumCordovaSample/hooks/disable-kotlin-extensions.js b/TealiumCordovaSample/hooks/disable-kotlin-extensions.js new file mode 100644 index 0000000..523107a --- /dev/null +++ b/TealiumCordovaSample/hooks/disable-kotlin-extensions.js @@ -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'); +} \ No newline at end of file diff --git a/TealiumCordovaSample/package.json b/TealiumCordovaSample/package.json index c51646f..aceaf1c 100644 --- a/TealiumCordovaSample/package.json +++ b/TealiumCordovaSample/package.json @@ -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": [ diff --git a/TealiumCordovaSample/resources/firebase.json b/TealiumCordovaSample/resources/firebase.json new file mode 100644 index 0000000..e69732c --- /dev/null +++ b/TealiumCordovaSample/resources/firebase.json @@ -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" + } +} \ No newline at end of file diff --git a/TealiumCordovaSample/www/js/index.js b/TealiumCordovaSample/www/js/index.js index fb7355b..42545de 100644 --- a/TealiumCordovaSample/www/js/index.js +++ b/TealiumCordovaSample/www/js/index.js @@ -162,9 +162,13 @@ function createRemoteCommands() { var remoteCommands = window.tealium && window.tealium.remotecommands; if (remoteCommands) { + let path = 'firebase' + if (window.cordova.platformId == 'android') { + path += ".json" + } var firebase = remoteCommands.firebase && remoteCommands.firebase.create() - .setPath("firebase.json"); + .setPath(path); firebase && commands.push(firebase); }