Skip to content

Commit

Permalink
Merge pull request #26 from SparkPost/issue-25
Browse files Browse the repository at this point in the history
removed defaulting open/click tracking to true to allow usage of the template level engagement tracking options
  • Loading branch information
Jessica Martin committed Apr 16, 2015
2 parents e5ee8a9 + 1a28ad6 commit 54e9830
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ sparkpost.transmission.send(trans, function(err, res) {
| campaign | no | Field for assigning a given transmission to a specific campaign, which is a logical container for similar transmissions | String |
| metadata | no | Field for adding arbitrary key/value pairs which will be included in open/click tracking | Object (Simple) |
| substitutionData | no | Field for adding transmission level substitution data, which can be used in a variety of fields and in content | Object (Complex) |
| trackOpens | no | Field for enabling/disabling transmission level open tracking (default: true) | Boolean |
| trackClicks | no | Field for enabling/disabling transmission level click tracking (default: true) | Boolean |
| trackOpens | no | Field for enabling/disabling transmission level open tracking, if not set will use settings from Template | Boolean |
| trackClicks | no | Field for enabling/disabling transmission level click tracking, if not set will use settings from Template | Boolean |
| useSandbox | no | Field for enabling/disabling using sandbox domain to send transmission(You are limited to 50 messages ever with sandbox) | Boolean |
| useDraftTemplate | no | Field for allowing the sending of a transmission using a draft of a stored template (default: false) | Boolean |
| replyTo | no | Field for specifying the email address that should be used when a recipient hits the reply button | String |
Expand Down
4 changes: 3 additions & 1 deletion examples/transmission/mime_parts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ var trans = {
recipients: [{ address: { email: 'john.doe@example.com' } }],
subject: 'Example Email for MIME Parts',
html: '<html><body><p>Hello World!</p></body></html>',
text: 'Hello World!'
text: 'Hello World!',
trackOpens: true,
trackClicks: true
};

sparkpost.transmission.send(trans, function(err, res) {
Expand Down
4 changes: 2 additions & 2 deletions examples/transmission/send_transmission_all_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ var trans = {
customHeaders: {
'X-Custom-Header': 'Sample Custom Header'
},
trackOpens: false,
trackClicks: false,
trackOpens: true,
trackClicks: true,
useSandbox: true,
useDraftTemplate: true,
from: 'From Envelope <from@example.com>',
Expand Down
4 changes: 2 additions & 2 deletions lib/transmission.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ var toApiFormat = function(input) {
model.metadata = input.metadata;
model.substitution_data = input.substitutionData;

model.options.open_tracking = input.trackOpens === false ? false : true;
model.options.click_tracking = input.trackClicks === false ? false : true;
model.options.open_tracking = input.trackOpens;
model.options.click_tracking = input.trackClicks;
model.options.sandbox = input.useSandbox;

model.content.use_draft_template = input.useDraftTemplate || false;
Expand Down
8 changes: 4 additions & 4 deletions test/spec/transmissions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ describe('Transmissions Library', function() {
});
});

it('should default open and click tracking', function() {
it('should default open and click tracking to be undefined', function() {
transmission.send({}, function(err, res) {
expect(sendSpy.args[0][0].json.options.open_tracking).to.be.true;
expect(sendSpy.args[0][0].json.options.click_tracking).to.be.true;
expect(sendSpy.args[0][0].json.options.open_tracking).to.be.undefined;
expect(sendSpy.args[0][0].json.options.click_tracking).to.be.undefined;
});
});

it('should allow a user to override open and click tracking', function() {
it('should allow a user to set open/click tracking', function() {
transmission.send({trackOpens: false, trackClicks: false}, function(err, res) {
expect(sendSpy.args[0][0].json.options.open_tracking).to.be.false;
expect(sendSpy.args[0][0].json.options.click_tracking).to.be.false;
Expand Down

0 comments on commit 54e9830

Please sign in to comment.