mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-02 13:27:55 +08:00
feat(feedback): intercom for feedback
Summary: Caveat: If you submit feedback from one account, and then switch accounts and submit feedback again, the data from the old account still gets passed. It looks like that was true with the previous compose-a-draft-with-feedback action too. Maybe you know how to fix this? I couldn't figure it out. Test Plan: Try it out! Not sure how to usefully write specs. Reviewers: bengotow Reviewed By: bengotow Differential Revision: https://phab.nylas.com/D2106
This commit is contained in:
parent
fd7897b149
commit
01652ffb24
2 changed files with 82 additions and 35 deletions
|
@ -111,42 +111,27 @@ class DeveloperBarStore extends NylasStore
|
||||||
@triggerThrottled(@)
|
@triggerThrottled(@)
|
||||||
|
|
||||||
_onSendFeedback: ->
|
_onSendFeedback: ->
|
||||||
{AccountStore,
|
{AccountStore} = require 'nylas-exports'
|
||||||
Contact,
|
BrowserWindow = require('remote').require('browser-window')
|
||||||
Message,
|
path = require 'path'
|
||||||
DatabaseStore} = require 'nylas-exports'
|
|
||||||
|
|
||||||
user = AccountStore.current().name
|
account = AccountStore.current()
|
||||||
|
params = qs.stringify({
|
||||||
|
name: account.name
|
||||||
|
email: account.emailAddress
|
||||||
|
accountId: account.id
|
||||||
|
platform: process.platform
|
||||||
|
provider: account.displayProvider()
|
||||||
|
organizational_unit: account.organizationUnit
|
||||||
|
version: atom.getVersion()
|
||||||
|
})
|
||||||
|
w = new BrowserWindow
|
||||||
|
'node-integration': false,
|
||||||
|
'web-preferences': {'web-security':false},
|
||||||
|
'width': 450,
|
||||||
|
'height': 700
|
||||||
|
|
||||||
draft = new Message
|
url = path.join __dirname, '../static/feedback.html'
|
||||||
from: [AccountStore.current().me()]
|
w.loadUrl "file://#{url}?#{params}"
|
||||||
to: [
|
|
||||||
new Contact
|
|
||||||
name: "Nylas Team"
|
|
||||||
email: "feedback@nylas.com"
|
|
||||||
]
|
|
||||||
date: (new Date)
|
|
||||||
draft: true
|
|
||||||
subject: "Feedback"
|
|
||||||
accountId: AccountStore.current().id
|
|
||||||
body: """
|
|
||||||
Hi, Nylas team! I have some feedback for you.<br/>
|
|
||||||
<br/>
|
|
||||||
<b>What happened:</b><br/>
|
|
||||||
<br/>
|
|
||||||
<br/>
|
|
||||||
<b>Impact:</b><br/>
|
|
||||||
<br/>
|
|
||||||
<br/>
|
|
||||||
<b>Feedback:</b><br/>
|
|
||||||
<br/>
|
|
||||||
<br/>
|
|
||||||
<b>Environment:</b><br/>
|
|
||||||
I'm using N1 #{atom.getVersion()} and my platform is #{process.platform}-#{process.arch}.<br/>
|
|
||||||
--<br/>
|
|
||||||
#{user}<br/>
|
|
||||||
"""
|
|
||||||
DatabaseStore.persistModel(draft).then ->
|
|
||||||
Actions.composePopoutDraft(draft.clientId)
|
|
||||||
|
|
||||||
module.exports = new DeveloperBarStore()
|
module.exports = new DeveloperBarStore()
|
||||||
|
|
62
internal_packages/worker-ui/static/feedback.html
Normal file
62
internal_packages/worker-ui/static/feedback.html
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Feedback</title>
|
||||||
|
<script>
|
||||||
|
(function() {
|
||||||
|
var query = location.search.substr(1);
|
||||||
|
var queryParams = {};
|
||||||
|
query.split("&").forEach(function(part) {
|
||||||
|
if (!part) return;
|
||||||
|
var item = part.split("=");
|
||||||
|
var key = item[0];
|
||||||
|
var val = decodeURIComponent(item[1])
|
||||||
|
queryParams[key] = val;
|
||||||
|
});
|
||||||
|
console.log(queryParams);
|
||||||
|
|
||||||
|
// Load the intercom widget.
|
||||||
|
var w = window;
|
||||||
|
var ic = w.Intercom;
|
||||||
|
if (typeof ic==="function") {
|
||||||
|
ic('reattach_activator');
|
||||||
|
ic('update', intercomSettings);
|
||||||
|
} else {
|
||||||
|
var d = document;
|
||||||
|
var i = function() { i.c(arguments) };
|
||||||
|
i.q = [];
|
||||||
|
i.c = function(args){ i.q.push(args) };
|
||||||
|
w.Intercom = i;
|
||||||
|
}
|
||||||
|
function l() {
|
||||||
|
var s = d.createElement('script');
|
||||||
|
s.type = 'text/javascript';
|
||||||
|
s.async = true;
|
||||||
|
s.src = 'https://widget.intercom.io/widget/t7k2sjgy';
|
||||||
|
var x = d.getElementsByTagName('script')[0];
|
||||||
|
x.parentNode.insertBefore(s,x);
|
||||||
|
}
|
||||||
|
if (w.attachEvent) {
|
||||||
|
w.attachEvent('onload',l);
|
||||||
|
} else {
|
||||||
|
w.addEventListener('load', l, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show the intercom messaging window.
|
||||||
|
// Send along some extra info per
|
||||||
|
// http://docs.intercom.io/configuring-Intercom/send-custom-user-attributes-to-intercom
|
||||||
|
window.Intercom('boot', {
|
||||||
|
app_id: "t7k2sjgy",
|
||||||
|
email: queryParams.email,
|
||||||
|
name: queryParams.name,
|
||||||
|
"accountId": queryParams.accountId,
|
||||||
|
"platform": queryParams.platform,
|
||||||
|
"provider": queryParams.provider,
|
||||||
|
"organizational_unit": queryParams.organizational_unit,
|
||||||
|
"version": queryParams.version,
|
||||||
|
});
|
||||||
|
window.Intercom('show');
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body></body></html>
|
Loading…
Reference in a new issue