Skip to content

Commit 2d89b35

Browse files
committed
Delete stuff b/c we hate stuff
1 parent 646d759 commit 2d89b35

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

component.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"segmentio/top-domain": "1.0.0",
1818
"segmentio/utm-params": "1.0.2",
1919
"yields/send-json": "1.1.1",
20-
"yields/store": "1.0.2"
20+
"yields/store": "1.0.2",
21+
"component/has-cors": "*"
2122
},
2223
"development": {
2324
"component/assert": "0.5.0",

lib/index.js

+9-12
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var send = require('yields/send-json');
1414
var topDomain = require('top-domain');
1515
var uuid = require('uuid');
1616
var encode = require('ForbesLindesay/base64-encode');
17+
var cors = require('has-cors');
1718

1819
/**
1920
* Cookie options
@@ -169,26 +170,22 @@ Attribution.prototype.normalize = function(msg) {
169170
Attribution.prototype.send = function(path, msg, fn) {
170171
var url = scheme() + '//track.attributionapp.com' + path;
171172

172-
var username = this.options.project || window.Attribution.projectId;
173-
var password = "";
174-
var basicAuth = 'Basic ' + encode(username + ":" + password);
173+
var projectId = this.options.project || window.Attribution.projectId;
175174

176-
var headers = {
177-
'Content-Type': 'text/plain',
178-
'Authorization': basicAuth
179-
};
175+
// If we're POSTing, let's send the project_id in the params
176+
// only on POST though, or else we'll get two question marks
177+
if(cors)
178+
url += "?project_id=" + projectId;
180179

181-
// No headers on JSONP so put the project_id in the msg
182-
msg.project_id = username;
180+
// If we're JSONPing, let's send it in the encoded params
181+
msg.project_id = projectId;
183182

184183
fn = fn || noop;
185184
var self = this;
186185

187-
// msg
188186
msg = this.normalize(msg);
189187

190-
// send
191-
send(url, msg, headers, function(err, res) {
188+
send(url, msg, function(err, res) {
192189
self.debug('sent %O, received %O', msg, arguments);
193190
if (err) return fn(err);
194191
res.url = url;

0 commit comments

Comments
 (0)