@mparticle/web-twitter-kit 2.0.0-rc.2 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/TwitterEventForwarder.common.js +131 -137
- package/package.json +38 -25
|
@@ -1,26 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
|
|
3
|
-
/*!
|
|
4
|
-
* isobject <https://github.com/jonschlinkert/isobject>
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
7
|
-
* Released under the MIT License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
function isObject(val) {
|
|
11
|
-
return val != null && typeof val === 'object' && Array.isArray(val) === false;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
var isobject = /*#__PURE__*/Object.freeze({
|
|
15
|
-
'default': isObject
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
function getCjsExportFromNamespace (n) {
|
|
19
|
-
return n && n['default'] || n;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
var isobject$1 = getCjsExportFromNamespace(isobject);
|
|
23
|
-
|
|
24
3
|
// Copyright 2015 mParticle, Inc.
|
|
25
4
|
//
|
|
26
5
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -35,141 +14,156 @@ var isobject$1 = getCjsExportFromNamespace(isobject);
|
|
|
35
14
|
// See the License for the specific language governing permissions and
|
|
36
15
|
// limitations under the License.
|
|
37
16
|
|
|
38
|
-
|
|
17
|
+
var name = 'Twitter',
|
|
18
|
+
moduleId = 43,
|
|
19
|
+
MessageType = {
|
|
20
|
+
PageView: 3,
|
|
21
|
+
PageEvent: 4,
|
|
22
|
+
};
|
|
39
23
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
e = d.getElementsByTagName('script')[0];
|
|
83
|
-
|
|
84
|
-
e.parentNode.insertBefore(s, e);
|
|
85
|
-
}
|
|
86
|
-
})();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
isInitialized = true;
|
|
90
|
-
|
|
91
|
-
return 'Successfully initialized: ' + name;
|
|
92
|
-
|
|
93
|
-
} catch (e) {
|
|
94
|
-
return 'Can\'t initialize forwarder: '+ name +':' + e;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function processEvent(event) {
|
|
99
|
-
var reportEvent = false;
|
|
100
|
-
|
|
101
|
-
if(!isInitialized) {
|
|
102
|
-
return 'Can\'t send forwarder '+ name + ', not initialized';
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if(!window.twttr) {
|
|
106
|
-
eventQueue.push(event);
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
try {
|
|
111
|
-
if(event.EventDataType == MessageType.PageView) {
|
|
112
|
-
reportEvent = true;
|
|
113
|
-
logEvent(event);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if(reportEvent && reportingService) {
|
|
117
|
-
reportingService(self, event);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return 'Successfully sent to forwarder ' + name;
|
|
121
|
-
} catch (error) {
|
|
122
|
-
return 'Can\'t send to forwarder: ' + name + ' ' + e;
|
|
24
|
+
var constructor = function() {
|
|
25
|
+
var self = this,
|
|
26
|
+
isInitialized = false,
|
|
27
|
+
forwarderSettings = null,
|
|
28
|
+
reportingService = null,
|
|
29
|
+
eventQueue = [];
|
|
30
|
+
|
|
31
|
+
self.name = name;
|
|
32
|
+
|
|
33
|
+
function initForwarder(settings, service, testMode) {
|
|
34
|
+
forwarderSettings = settings;
|
|
35
|
+
reportingService = service;
|
|
36
|
+
d = document;
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
if (!testMode) {
|
|
40
|
+
(function() {
|
|
41
|
+
var w, d, s, e;
|
|
42
|
+
|
|
43
|
+
w = window;
|
|
44
|
+
|
|
45
|
+
if (!w.twttr) {
|
|
46
|
+
d = document;
|
|
47
|
+
s = document.createElement('script');
|
|
48
|
+
s.type = 'text/javascript';
|
|
49
|
+
s.src = '//platform.twitter.com/oct.js';
|
|
50
|
+
s.onload = function() {
|
|
51
|
+
if (twttr && eventQueue.length > 0) {
|
|
52
|
+
for (var i = 0; i < eventQueue.length; i++) {
|
|
53
|
+
processEvent(eventQueue[i]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
eventQueue = [];
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
e = d.getElementsByTagName('script')[0];
|
|
61
|
+
|
|
62
|
+
e.parentNode.insertBefore(s, e);
|
|
63
|
+
}
|
|
64
|
+
})();
|
|
123
65
|
}
|
|
66
|
+
|
|
67
|
+
isInitialized = true;
|
|
68
|
+
|
|
69
|
+
return 'Successfully initialized: ' + name;
|
|
70
|
+
} catch (e) {
|
|
71
|
+
return "Can't initialize forwarder: " + name + ':' + e;
|
|
124
72
|
}
|
|
125
|
-
|
|
126
|
-
function logEvent(event) {
|
|
127
|
-
twttr.conversion.trackPid(forwarderSettings.pixelId);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
this.init = initForwarder;
|
|
131
|
-
this.process = processEvent;
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
function getId() {
|
|
135
|
-
return moduleId;
|
|
136
73
|
}
|
|
137
74
|
|
|
138
|
-
function
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
75
|
+
function processEvent(event) {
|
|
76
|
+
var reportEvent = false;
|
|
77
|
+
|
|
78
|
+
if (!isInitialized) {
|
|
79
|
+
return "Can't send forwarder " + name + ', not initialized';
|
|
142
80
|
}
|
|
143
81
|
|
|
144
|
-
if (!
|
|
145
|
-
|
|
82
|
+
if (!window.twttr) {
|
|
83
|
+
eventQueue.push(event);
|
|
146
84
|
return;
|
|
147
85
|
}
|
|
148
86
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
87
|
+
try {
|
|
88
|
+
if (
|
|
89
|
+
event.EventDataType === MessageType.PageView ||
|
|
90
|
+
event.EventDataType === MessageType.PageEvent
|
|
91
|
+
) {
|
|
92
|
+
reportEvent = true;
|
|
93
|
+
logEvent(event);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (reportEvent && reportingService) {
|
|
97
|
+
reportingService(self, event);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return 'Successfully sent to forwarder ' + name;
|
|
101
|
+
} catch (error) {
|
|
102
|
+
return "Can't send to forwarder: " + name + ' ' + e;
|
|
158
103
|
}
|
|
159
|
-
window.console.log('Successfully registered ' + name + ' to your mParticle configuration');
|
|
160
104
|
}
|
|
161
105
|
|
|
106
|
+
function logEvent(event) {
|
|
107
|
+
twttr.conversion.trackPid(forwarderSettings.pixelId);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
this.init = initForwarder;
|
|
111
|
+
this.process = processEvent;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
function getId() {
|
|
115
|
+
return moduleId;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function register(config) {
|
|
119
|
+
if (!config) {
|
|
120
|
+
window.console.log(
|
|
121
|
+
'You must pass a config object to register the kit ' + name
|
|
122
|
+
);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (!isObject(config)) {
|
|
127
|
+
window.console.log(
|
|
128
|
+
"'config' must be an object. You passed in a " + typeof config
|
|
129
|
+
);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (isObject(config.kits)) {
|
|
134
|
+
config.kits[name] = {
|
|
135
|
+
constructor: constructor,
|
|
136
|
+
};
|
|
137
|
+
} else {
|
|
138
|
+
config.kits = {};
|
|
139
|
+
config.kits[name] = {
|
|
140
|
+
constructor: constructor,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
window.console.log(
|
|
144
|
+
'Successfully registered ' + name + ' to your mParticle configuration'
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (typeof window !== 'undefined') {
|
|
162
149
|
if (window && window.mParticle && window.mParticle.addForwarder) {
|
|
163
150
|
window.mParticle.addForwarder({
|
|
164
151
|
name: name,
|
|
165
152
|
constructor: constructor,
|
|
166
|
-
getId: getId
|
|
153
|
+
getId: getId,
|
|
167
154
|
});
|
|
168
155
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function isObject(val) {
|
|
159
|
+
return (
|
|
160
|
+
val != null && typeof val === 'object' && Array.isArray(val) === false
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
var TwitterEventForwarder = {
|
|
165
|
+
register: register,
|
|
166
|
+
};
|
|
173
167
|
var TwitterEventForwarder_1 = TwitterEventForwarder.register;
|
|
174
168
|
|
|
175
169
|
exports.default = TwitterEventForwarder;
|
package/package.json
CHANGED
|
@@ -1,27 +1,40 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
2
|
+
"name": "@mparticle/web-twitter-kit",
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"author": "mParticle Developers <developers@mparticle.com> (https://www.mparticle.com)",
|
|
5
|
+
"description": "mParticle integration sdk for Twitter",
|
|
6
|
+
"browser": "dist/TwitterEventForwarder.common.js",
|
|
7
|
+
"main": "dist/TwitterEventForwarder.common.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist/TwitterEventForwarder.common.js"
|
|
10
|
+
],
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/mParticle/mparticle-web-sdk",
|
|
14
|
+
"directory": "kits/twitter"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "rollup --config rollup.config.js",
|
|
18
|
+
"watch": "rollup --config rollup.config.js -w",
|
|
19
|
+
"test": "node test/boilerplate/test-karma.js"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"chai": "^4.2.0",
|
|
23
|
+
"karma": "^5.1.0",
|
|
24
|
+
"karma-chai": "^0.1.0",
|
|
25
|
+
"karma-chrome-launcher": "^3.1.0",
|
|
26
|
+
"karma-firefox-launcher": "^1.3.0",
|
|
27
|
+
"karma-mocha": "^2.0.1",
|
|
28
|
+
"mocha": "^2.5.3",
|
|
29
|
+
"rollup": "^1.13.1",
|
|
30
|
+
"rollup-plugin-commonjs": "^10.0.0",
|
|
31
|
+
"rollup-plugin-node-resolve": "^5.0.1",
|
|
32
|
+
"shelljs": "^0.8.4",
|
|
33
|
+
"should": "^7.1.0",
|
|
34
|
+
"watchify": "^3.11.1"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@mparticle/web-sdk": "^3.0.0"
|
|
38
|
+
},
|
|
39
|
+
"license": "Apache-2.0"
|
|
27
40
|
}
|