Merge pull request #3236 from betagouv/fix-3235-sendinblue-automation

Fix #3235 sendinblue automation
This commit is contained in:
Pierre de La Morinerie 2019-01-07 10:32:33 +01:00 committed by GitHub
commit 0137a41523
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View file

@ -0,0 +1,26 @@
:javascript
(function() {
window.sib = { equeue: [], client_key: "pcxtf4lpkka986pf4l1kt" };
/* OPTIONAL: email for identify request*/
window.sib.email_id = '#{current_administrateur.email}';
window.sendinblue = {}; for (var j = ['track', 'identify', 'trackLink', 'page'], i = 0; i < j.length; i++) { (function(k) { window.sendinblue[k] = function() { var arg = Array.prototype.slice.call(arguments); (window.sib[k] || function() { var t = {}; t[k] = arg; window.sib.equeue.push(t);})(arg[0], arg[1], arg[2]);};})(j[i]);}var n = document.createElement("script"),i = document.getElementsByTagName("script")[0]; n.type = "text/javascript", n.id = "sendinblue-js", n.async = !0, n.src = "https://sibautomation.com/sa.js?key=" + window.sib.client_key, i.parentNode.insertBefore(n, i), window.sendinblue.page();
})();
sendinblue.identify('#{current_administrateur.email}', {
'nb_demarches_brouillons': '#{current_administrateur.procedures.brouillons.count}',
'nb_demarches_actives': '#{current_administrateur.procedures.publiees.count}',
'nb_demarches_archivees': '#{current_administrateur.procedures.archivees.count}',
'sign_in_count' : '#{current_administrateur.sign_in_count}',
'created_at' : '#{current_administrateur.created_at}',
'active' : '#{current_administrateur.active}'
// Dans l'ideal :
// 'nom' : //pour personnaliser les emails
// 'prenom' : //pour personnaliser les emails
// 'nb_demarches_prod' : // Avec plus de 20 dossiers
// 'nb_demarches_test' : // Avec entre 1 et 20 dossiers
// 'nb_services' : //combien de service ?
// 'nb_instructeurs' : //combien d'instructeur en tout ?
// 'nb_dossiers' : //combien de dossier en tout ?
});

View file

@ -17,6 +17,7 @@
= csrf_meta_tags = csrf_meta_tags
= render partial: "layouts/matomo" = render partial: "layouts/matomo"
= render partial: "layouts/sendinblue"
:javascript :javascript
DATA = [{ DATA = [{