Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
const admin = require('firebase-admin');
admin.initializeApp();

// [START validate_template]
function validateTemplate(template) {
admin.remoteConfig().validateTemplate(template)
.then(function (validatedTemplate) {
// The template is valid and safe to use.
console.log('Template was valid and safe to use');
})
.catch(function (err) {
console.error('Template is invalid and cannot be published');
console.error(err);
});
}
// [END validate_template]

// [START add_new_condition]
function addNewCondition(template) {
template.conditions.push({
name: 'android_en',
expression: 'device.os == \'android\' && device.country in [\'us\', \'uk\']',
Copy link
Contributor

@samtstern samtstern May 7, 2020

Choose a reason for hiding this comment

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

If you use " for the string you won't have to escape the ':

"device.os == 'android' && device.country in ['us', 'uk']"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ESLint is yelling at me, should I ignore it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe using ` instead of " will make it stop yelling?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is still angry 22:17 error Strings must use singlequote quotes

Copy link
Contributor

Choose a reason for hiding this comment

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

Eh ok not worth fighting more, but thats strange

tagColor: 'BLUE',
});
}
// [END add_new_condition]

// [START set_modify_parameter]
function setOrModifyParameter(template) {
// Set header_text parameter.
template.parameters['header_text'] = {
defaultValue: {
value: 'A Gryffindor must be brave, talented and helpful.'
},
conditionalValues: {
android_en: {
value: 'A Droid must be brave, talented and helpful.'
},
},
};
}
// [END set_modify_parameter]

// [START set_modify_parameter_group]
function setOrModifyParameterGroup(template) {
// Set new_menu parameter group
template.parameterGroups['new_menu'] = {
description: 'Description of the group.',
parameters: {
pumpkin_spice_season: {
defaultValue: {
value: 'A Gryffindor must love a pumpkin spice latte.'
},
conditionalValues: {
android_en: {
value: 'A Droid must love a pumpkin spice latte.'
},
},
description: 'Description of the parameter.',
},
},
};
}
// [END set_modify_parameter_group]

// [START add_parameter_to_group]
function addParameterToGroup(template) {
template.parameterGroups['new_menu'].parameters['spring_season'] = {
defaultValue: {
useInAppDefault: true
},
description: 'spring season menu visibility.',
};
}
// [END add_parameter_to_group]
Loading