Skip to content

Commit 455739d

Browse files
authored
[STRATCONN] 2841 pinterest tag mapping event id as segment message id (#785)
* mapMessageIdToEventId settings added * Removed typo error * Changed in test case * added unit test case and mapped segment msgId as Pinterest event_id * Change in unit test case * added msgId as event_id * Removed test case of pinterest tag * Removed test case of pinterest tag * Test cases for pinterest tag api added
1 parent 2604384 commit 455739d

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

integrations/pinterest-tag/lib/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,15 @@ Pinterest.prototype.initialize = function() {
2525
if (!this.options.tid) return;
2626

2727
// Preparation for loading the Pinterest script.
28-
(function(e){if(!window.pintrk){window.pintrk=function(){window.pintrk.queue.push(Array.prototype.slice.call(arguments))};var n=window.pintrk;n.queue=[],n.version="3.0";}})(); // eslint-disable-line
28+
(function(e) {
29+
if (!window.pintrk) {
30+
window.pintrk = function() {
31+
window.pintrk.queue.push(Array.prototype.slice.call(arguments));
32+
};
33+
var n = window.pintrk;
34+
(n.queue = []), (n.version = '3.0');
35+
}
36+
})(); // eslint-disable-line
2937

3038
this.load(this.ready);
3139
var traits = this.analytics.user().traits();
@@ -153,6 +161,9 @@ Pinterest.prototype.generatePropertiesObject = function(track) {
153161
if (trackValue) pinterestProps[this.propertyMap[prop]] = trackValue;
154162
}
155163

164+
if (this.options.mapMessageIdToEventId) {
165+
pinterestProps['event_id'] = track.proxy('messageId');
166+
}
156167
// Determine if there's a 'products' Array, then add in the specific features on that decision.
157168
var products = track.proxy('properties.products');
158169
var lineItemsArray;

integrations/pinterest-tag/test/index.test.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,11 @@ describe('Pinterest', function() {
101101
});
102102

103103
it('should set Segment messageId as Pinterest Evnet Id', function() {
104-
analytics.track('Order Completed', {
105-
currency: 'SGD',
106-
value: 10.0,
107-
messageId: 'testing5671'
108-
});
109-
analytics.called(window.pintrk, 'track', 'Checkout', {
110-
value: 10.0,
111-
currency: 'SGD',
112-
event_id: 'testing5671'
113-
});
104+
analytics.track('Order Completed', {});
105+
analytics.called(window.pintrk, 'track', 'Checkout');
106+
if (!window.pintrk.args[0][2].event_id.startsWith('ajs-')) {
107+
throw new Error('Expected eventId on window.pintrk Not found.');
108+
}
114109
});
115110
});
116111
});

0 commit comments

Comments
 (0)