@mparticle/web-twitter-kit 2.0.2 → 3.2.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 -123
- package/package.json +38 -25
|
@@ -14,148 +14,156 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
14
14
|
// See the License for the specific language governing permissions and
|
|
15
15
|
// limitations under the License.
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
isInitialized = true;
|
|
68
|
-
|
|
69
|
-
return 'Successfully initialized: ' + name;
|
|
70
|
-
|
|
71
|
-
} catch (e) {
|
|
72
|
-
return 'Can\'t initialize forwarder: '+ name +':' + e;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function processEvent(event) {
|
|
77
|
-
var reportEvent = false;
|
|
78
|
-
|
|
79
|
-
if(!isInitialized) {
|
|
80
|
-
return 'Can\'t send forwarder '+ name + ', not initialized';
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if(!window.twttr) {
|
|
84
|
-
eventQueue.push(event);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
try {
|
|
89
|
-
if (event.EventDataType === MessageType.PageView || event.EventDataType === MessageType.PageEvent) {
|
|
90
|
-
reportEvent = true;
|
|
91
|
-
logEvent(event);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if(reportEvent && reportingService) {
|
|
95
|
-
reportingService(self, event);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return 'Successfully sent to forwarder ' + name;
|
|
99
|
-
} catch (error) {
|
|
100
|
-
return 'Can\'t send to forwarder: ' + name + ' ' + e;
|
|
17
|
+
var name = 'Twitter',
|
|
18
|
+
moduleId = 43,
|
|
19
|
+
MessageType = {
|
|
20
|
+
PageView: 3,
|
|
21
|
+
PageEvent: 4,
|
|
22
|
+
};
|
|
23
|
+
|
|
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
|
+
})();
|
|
101
65
|
}
|
|
66
|
+
|
|
67
|
+
isInitialized = true;
|
|
68
|
+
|
|
69
|
+
return 'Successfully initialized: ' + name;
|
|
70
|
+
} catch (e) {
|
|
71
|
+
return "Can't initialize forwarder: " + name + ':' + e;
|
|
102
72
|
}
|
|
103
|
-
|
|
104
|
-
function logEvent(event) {
|
|
105
|
-
twttr.conversion.trackPid(forwarderSettings.pixelId);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
this.init = initForwarder;
|
|
109
|
-
this.process = processEvent;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
function getId() {
|
|
113
|
-
return moduleId;
|
|
114
73
|
}
|
|
115
74
|
|
|
116
|
-
function
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
75
|
+
function processEvent(event) {
|
|
76
|
+
var reportEvent = false;
|
|
77
|
+
|
|
78
|
+
if (!isInitialized) {
|
|
79
|
+
return "Can't send forwarder " + name + ', not initialized';
|
|
120
80
|
}
|
|
121
81
|
|
|
122
|
-
if (!
|
|
123
|
-
|
|
82
|
+
if (!window.twttr) {
|
|
83
|
+
eventQueue.push(event);
|
|
124
84
|
return;
|
|
125
85
|
}
|
|
126
86
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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;
|
|
136
103
|
}
|
|
137
|
-
window.console.log('Successfully registered ' + name + ' to your mParticle configuration');
|
|
138
104
|
}
|
|
139
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') {
|
|
140
149
|
if (window && window.mParticle && window.mParticle.addForwarder) {
|
|
141
150
|
window.mParticle.addForwarder({
|
|
142
151
|
name: name,
|
|
143
152
|
constructor: constructor,
|
|
144
|
-
getId: getId
|
|
153
|
+
getId: getId,
|
|
145
154
|
});
|
|
146
155
|
}
|
|
156
|
+
}
|
|
147
157
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
register: register
|
|
158
|
-
};
|
|
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
|
+
};
|
|
159
167
|
var TwitterEventForwarder_1 = TwitterEventForwarder.register;
|
|
160
168
|
|
|
161
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.2.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
|
}
|