Skip to content
This repository was archived by the owner on Dec 11, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = function(config) {
'test/**/*.test.js'
],

browsers: ['PhantomJS'],
browsers: ['Chrome'],

frameworks: ['browserify', 'mocha'],

Expand Down
6 changes: 4 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ SatisMeter.prototype.identify = function(identify) {
writeKey: this.options.apiKey || this.options.token,
userId: identify.userId(),
traits: this.analytics.user().traits(),
type: 'identify'
type: 'identify',
source: 'analytics.js'
});
};

Expand All @@ -68,6 +69,7 @@ SatisMeter.prototype.page = function() {
window.satismeter({
writeKey: this.options.apiKey || this.options.token,
userId: this.analytics.user().id(),
type: 'page'
type: 'page',
source: 'analytics.js'
});
};
44 changes: 28 additions & 16 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,15 @@ describe('SatisMeter', function() {
analytics.stub(window, 'satismeter');
});

it('should send apiKey and user id', function() {
it('should send apiKey, user id and source', function() {
analytics.identify('id');
analytics.called(window.satismeter, {
writeKey: options.apiKey,
userId: 'id',
traits: {
},
type: 'identify'
type: 'identify',
source: 'analytics.js'
});
});

Expand All @@ -83,7 +84,8 @@ describe('SatisMeter', function() {
traits: {
email: 'email@example.com'
},
type: 'identify'
type: 'identify',
source: 'analytics.js'
});
});

Expand All @@ -95,7 +97,8 @@ describe('SatisMeter', function() {
traits: {
name: 'john doe'
},
type: 'identify'
type: 'identify',
source: 'analytics.js'
});
});

Expand All @@ -108,7 +111,8 @@ describe('SatisMeter', function() {
traits: {
createdAt: now
},
type: 'identify'
type: 'identify',
source: 'analytics.js'
});
});

Expand All @@ -128,7 +132,8 @@ describe('SatisMeter', function() {
},
language: 'en'
},
type: 'identify'
type: 'identify',
source: 'analytics.js'
});
});
});
Expand All @@ -138,13 +143,14 @@ describe('SatisMeter', function() {
analytics.stub(window, 'satismeter');
});

it('should send apiKey and user id', function() {
it('should send apiKey, user id and source', function() {
analytics.user().id('id');
analytics.page('Pricing');
analytics.called(window.satismeter, {
writeKey: options.apiKey,
userId: 'id',
type: 'page'
type: 'page',
source: 'analytics.js'
});
});
});
Expand Down Expand Up @@ -210,14 +216,15 @@ describe('SatisMeter - legacy setup', function() {
analytics.stub(window, 'satismeter');
});

it('should send token and user id', function() {
it('should send token, user id and source', function() {
analytics.identify('id');
analytics.called(window.satismeter, {
writeKey: options.token,
userId: 'id',
traits: {
},
type: 'identify'
type: 'identify',
source: 'analytics.js'
});
});

Expand All @@ -229,7 +236,8 @@ describe('SatisMeter - legacy setup', function() {
traits: {
email: 'email@example.com'
},
type: 'identify'
type: 'identify',
source: 'analytics.js'
});
});

Expand All @@ -241,7 +249,8 @@ describe('SatisMeter - legacy setup', function() {
traits: {
name: 'john doe'
},
type: 'identify'
type: 'identify',
source: 'analytics.js'
});
});

Expand All @@ -254,7 +263,8 @@ describe('SatisMeter - legacy setup', function() {
traits: {
createdAt: now
},
type: 'identify'
type: 'identify',
source: 'analytics.js'
});
});

Expand All @@ -274,7 +284,8 @@ describe('SatisMeter - legacy setup', function() {
},
language: 'en'
},
type: 'identify'
type: 'identify',
source: 'analytics.js'
});
});
});
Expand All @@ -284,13 +295,14 @@ describe('SatisMeter - legacy setup', function() {
analytics.stub(window, 'satismeter');
});

it('should send token and user id', function() {
it('should send token, user id and source', function() {
analytics.user().id('id');
analytics.page('Pricing');
analytics.called(window.satismeter, {
writeKey: options.token,
userId: 'id',
type: 'page'
type: 'page',
source: 'analytics.js'
});
});
});
Expand Down