Getting Leanplum app ID and key from outside the repo.

This commit is contained in:
Brendon Duncan 2018-09-13 12:02:25 +12:00
commit ff01933151
4 changed files with 58 additions and 6 deletions

1
.gitignore vendored
View file

@ -107,3 +107,4 @@ www/img/app
## Firebase
/GoogleService-Info.plist
/google-services.json
src/js/generated

View file

@ -175,6 +175,7 @@ module.exports = function(grunt) {
js: {
src: [
'src/js/app.js',
'src/js/generated/constants/*.js',
'src/js/routes.js',
'src/js/decorators/*.js',
@ -242,6 +243,26 @@ module.exports = function(grunt) {
},
},
copy: {
gen_constant_leanplum: {
src: 'src/js/templates/constants/leanplum-config.constant.js',
dest: 'src/js/generated/constants/leanplum-config.constant.js',
options: {
process: function (content, srcpath) {
var leanplumConfig = {};
try {
leanplumConfig = grunt.file.readJSON('../leanplum-config.json');
} catch (e) {
// Without this, there is no clue on the console about what happened.
console.error('Error reading JSON', e);
throw e;
}
var newContent = '// Generated\n' + content
.replace("appId: ''","appId: '" + leanplumConfig.dev.appId + "'")
.replace("key: ''", "key: '" + leanplumConfig.dev.key + "'");
return newContent;
},
},
},
ionic_fonts: {
expand: true,
flatten: true,
@ -345,8 +366,8 @@ module.exports = function(grunt) {
}
}
});
grunt.registerTask('default', ['nggettext_compile', 'exec:appConfig', 'exec:externalServices', 'browserify', 'sass', 'concat', 'copy:ionic_fonts', 'copy:ionic_js']);
grunt.registerTask('default', ['nggettext_compile', 'exec:appConfig', 'exec:externalServices', 'browserify', 'sass', 'copy:gen_constant_leanplum', 'concat', 'copy:ionic_fonts', 'copy:ionic_js']);
grunt.registerTask('prod', ['default', 'uglify']);
grunt.registerTask('translate', ['nggettext_extract']);
grunt.registerTask('chrome', ['default','exec:chrome']);

View file

@ -1207,7 +1207,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
}
});
})
.run(function($rootScope, $state, $location, $log, $timeout, startupService, ionicToast, fingerprintService, $ionicHistory, $ionicPlatform, $window, appConfigService, lodash, platformInfo, profileService, uxLanguage, gettextCatalog, openURLService, storageService, scannerService, configService, emailService, /* plugins START HERE => */ buydotbitcoindotcomService, pushNotificationsService, glideraService, amazonService, bitpayCardService, applicationService, mercadoLibreService, rateService) {
.run(function(leanplumConfig, $rootScope, $state, $location, $log, $timeout, startupService, ionicToast, fingerprintService, $ionicHistory, $ionicPlatform, $window, appConfigService, lodash, platformInfo, profileService, uxLanguage, gettextCatalog, openURLService, storageService, scannerService, configService, emailService, /* plugins START HERE => */ buydotbitcoindotcomService, pushNotificationsService, glideraService, amazonService, bitpayCardService, applicationService, mercadoLibreService, rateService) {
$ionicPlatform.ready(function() {
@ -1228,7 +1228,8 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
"wallet_created": "nd3dg5",
"wallet_opened": "4n39l7"
}
}
},
leanplum: leanplumConfig
});
configService.whenAvailable(function(config) {
@ -1273,14 +1274,14 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
name: 'tab_open',
class: 'track_tab_open',
params: ['href', 'title', 'icon-off'],
channels: [channel]
channels: [channel, 'leanplum']
});
window.BitAnalytics.ActionHandlers.trackAction(actionTabOpen);
var actionShapeShiftStart = new window.BitAnalytics.ActionFactory.createAction('click', {
name: 'shapeshift_start_click',
class: 'track_shapeshift_start_click',
channels: [channel]
channels: [channel, 'leanplum']
});
window.BitAnalytics.ActionHandlers.trackAction(actionShapeShiftStart);

View file

@ -0,0 +1,29 @@
'use strict';
/*
Template is at:
src/js/templates/constants
Requires a file above the project root: leanplum-config.json, containing:
{
"dev": {
"appId": "YOUR_DEV_APP_ID",
"key": "YOUR_DEV_KEY"
},
"prod": {
"appId": "YOUR_PROD_APP_ID",
"key": "YOUR_PROD_KEY"
}
}
*/
(function(){
angular
.module('bitcoincom.services')
.constant('leanplumConfig', {
appId: '',
key: ''
});
})();