Last active
June 21, 2023 09:30
-
-
Save AndreasFurster/c4286b472c0d932a8c81b44044bd2317 to your computer and use it in GitHub Desktop.
Export & import Firebase or Google Analytics custom dimensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var result = Array.from(document.querySelectorAll('definition-table mat-row')).map(function(row) { | |
let cells = Array.from(row.querySelectorAll('mat-cell')) | |
return { | |
'name': cells[0].innerText, | |
'description': cells[1].innerText, | |
'scope': cells[2].innerText, | |
'property': cells[3].innerText, | |
}; | |
}) | |
console.log(JSON.stringify(result)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// const input = EXPORTED_DATA_HERE; | |
const input = [ | |
{"name":"Test 1","description":"Dit is test 1","scope":"User","property":"test_dimension"}, | |
{"name":"Test 2","description":"Dit is test 2","scope":"Event","property":"test_dimension2"} | |
] | |
const sleep = ms => new Promise(r => setTimeout(r, ms)); | |
(async function() { | |
document.querySelector('.create-definition-button').click() | |
input.map(function(dimension) { | |
document.getElementById('mat-input-3').value = dimension.name | |
document.getElementById('mat-input-4').value = dimension.description | |
document.getElementById('mat-input-5').value = dimension.property | |
// Scope | |
document.getElementById('mat-select-6').click() | |
Array.from(document.getElementById('mat-select-6-panel').querySelectorAll('mat-option')) | |
.filter(option => option.innerText == dimension.scope)[0] | |
.click() | |
// Scope | |
document.getElementById('mat-select-6').click() | |
Array.from(document.getElementById('mat-select-6-panel').querySelectorAll('mat-option')) | |
.filter(option => option.innerText == dimension.scope)[0] | |
.click() | |
document.querySelector('.definition-builder-button').click() | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment