Skip to content

Commit af28eb7

Browse files
authored
Merge pull request #113 from amplitude/webpack-and-karma-with-headless-chrome
Drop component for webpack. Drop phantom for headless chrome and karma
2 parents c99198b + 98ca3f3 commit af28eb7

28 files changed

+17906
-9502
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ components
33
npm-debug.log
44
build
55
dist
6-
.DS_Store
6+
.DS_Store

Makefile

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ SNIPPET = src/amplitude-snippet.js
33
TESTS = $(wildcard test/*.js)
44
BINS = node_modules/.bin
55
DUO = $(BINS)/duo
6+
WEBPACK = $(BINS)/webpack
67
MINIFY = $(BINS)/uglifyjs
78
JSDOC = $(BINS)/jsdoc
89
JSHINT = $(BINS)/jshint
@@ -25,7 +26,6 @@ default: test
2526
#
2627

2728
clean:
28-
@-rm -rf components
2929
@-rm -f amplitude.js amplitude.min.js
3030
@-rm -rf node_modules npm-debug.log
3131

@@ -34,9 +34,11 @@ clean:
3434
# Test.
3535
#
3636

37-
test: build test/browser/index.html
38-
@$(MOCHA) test/browser/index.html
39-
@$(MOCHA) test/browser/snippet.html
37+
test: build
38+
@./node_modules/.bin/karma start karma.conf.js
39+
40+
test-sauce: build
41+
@./node_modules/.bin/karma start karma.conf.js --browsers sauce_chrome_windows
4042

4143

4244
#
@@ -49,7 +51,7 @@ node_modules: package.json
4951
#
5052
# Target for updating version.
5153

52-
version: component.json package.json src/version.js
54+
version: package.json src/version.js
5355
node scripts/version
5456

5557
#
@@ -64,8 +66,8 @@ README.md: $(SNIPPET_OUT) version
6466

6567
$(OUT): node_modules $(SRC) version
6668
@$(JSHINT) --verbose $(SRC)
67-
@$(DUO) --standalone amplitude src/index.js > $(OUT)
68-
@$(MINIFY) $(OUT) --output $(MIN_OUT)
69+
@$(WEBPACK) --config webpack.build.js
70+
@NODE_ENV=production $(WEBPACK) --config webpack.build.js
6971

7072
#
7173
# Target for minified `amplitude-snippet.js` file.
@@ -83,8 +85,7 @@ $(SEGMENT_SNIPPET_OUT): $(SRC) $(SNIPPET) version
8385
#
8486

8587
build: $(TESTS) $(OUT) $(SNIPPET_OUT) $(SEGMENT_SNIPPET_OUT) README.md
86-
@-mkdir -p build
87-
@$(DUO) --development test/tests.js > build/tests.js
88+
@$(WEBPACK) --config webpack.test.js
8889
@$(DUO) --development test/snippet-tests.js > build/snippet-tests.js
8990

9091
docs:

amplitude-segment-snippet.min.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
(function(e,t){var n=e.amplitude||{_q:[],_iq:{}};function r(e,t){e.prototype[t]=function(){
2-
this._q.push([t].concat(Array.prototype.slice.call(arguments,0)));return this}}var i=function(){
3-
this._q=[];return this};var s=["add","append","clearAll","prepend","set","setOnce","unset"];
4-
for(var o=0;o<s.length;o++){r(i,s[o])}n.Identify=i;var a=function(){this._q=[];return this;
5-
};var u=["setProductId","setQuantity","setPrice","setRevenueType","setEventProperties"];
6-
for(var c=0;c<u.length;c++){r(a,u[c])}n.Revenue=a;var l=["init","logEvent","logRevenue","setUserId","setUserProperties","setOptOut","setVersionName","setDomain","setDeviceId","setGlobalUserProperties","identify","clearUserProperties","setGroup","logRevenueV2","regenerateDeviceId","logEventWithTimestamp","logEventWithGroups",];
7-
function p(e){function t(t){e[t]=function(){e._q.push([t].concat(Array.prototype.slice.call(arguments,0)));
8-
}}for(var n=0;n<l.length;n++){t(l[n])}}p(n);n.getInstance=function(e){e=(!e||e.length===0?"$default_instance":e).toLowerCase();
9-
if(!n._iq.hasOwnProperty(e)){n._iq[e]={_q:[]};p(n._iq[e])}return n._iq[e]};e.amplitude=n;
10-
})(window,document);
1+
(function(e,t){var n=e.amplitude||{_q:[],_iq:{}};function r(e,t){
2+
e.prototype[t]=function(){
3+
this._q.push([t].concat(Array.prototype.slice.call(arguments,0)));return this}}
4+
var i=function(){this._q=[];return this}
5+
;var s=["add","append","clearAll","prepend","set","setOnce","unset"]
6+
;for(var o=0;o<s.length;o++){r(i,s[o])}n.Identify=i;var a=function(){this._q=[]
7+
;return this}
8+
;var u=["setProductId","setQuantity","setPrice","setRevenueType","setEventProperties"]
9+
;for(var c=0;c<u.length;c++){r(a,u[c])}n.Revenue=a
10+
;var l=["init","logEvent","logRevenue","setUserId","setUserProperties","setOptOut","setVersionName","setDomain","setDeviceId","setGlobalUserProperties","identify","clearUserProperties","setGroup","logRevenueV2","regenerateDeviceId","logEventWithTimestamp","logEventWithGroups"]
11+
;function p(e){function t(t){e[t]=function(){
12+
e._q.push([t].concat(Array.prototype.slice.call(arguments,0)))}}
13+
for(var n=0;n<l.length;n++){t(l[n])}}p(n);n.getInstance=function(e){
14+
e=(!e||e.length===0?"$default_instance":e).toLowerCase()
15+
;if(!n._iq.hasOwnProperty(e)){n._iq[e]={_q:[]};p(n._iq[e])}return n._iq[e]}
16+
;e.amplitude=n})(window,document);

amplitude-snippet.min.js

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1-
(function(e,t){var n=e.amplitude||{_q:[],_iq:{}};var r=t.createElement("script");r.type="text/javascript";
2-
r.async=true;r.src="https://d24n15hnbwhuhn.cloudfront.net/libs/amplitude-3.4.1-min.gz.js";
3-
r.onload=function(){if(e.amplitude.runQueuedFunctions){e.amplitude.runQueuedFunctions();
4-
}else{console.log("[Amplitude] Error: could not load SDK")}};var i=t.getElementsByTagName("script")[0];
5-
i.parentNode.insertBefore(r,i);function s(e,t){e.prototype[t]=function(){this._q.push([t].concat(Array.prototype.slice.call(arguments,0)));
6-
return this}}var o=function(){this._q=[];return this};var a=["add","append","clearAll","prepend","set","setOnce","unset"];
7-
for(var u=0;u<a.length;u++){s(o,a[u])}n.Identify=o;var c=function(){this._q=[];return this;
8-
};var l=["setProductId","setQuantity","setPrice","setRevenueType","setEventProperties"];
9-
for(var p=0;p<l.length;p++){s(c,l[p])}n.Revenue=c;var d=["init","logEvent","logRevenue","setUserId","setUserProperties","setOptOut","setVersionName","setDomain","setDeviceId","setGlobalUserProperties","identify","clearUserProperties","setGroup","logRevenueV2","regenerateDeviceId","logEventWithTimestamp","logEventWithGroups"];
10-
function v(e){function t(t){e[t]=function(){e._q.push([t].concat(Array.prototype.slice.call(arguments,0)));
11-
}}for(var n=0;n<d.length;n++){t(d[n])}}v(n);n.getInstance=function(e){e=(!e||e.length===0?"$default_instance":e).toLowerCase();
12-
if(!n._iq.hasOwnProperty(e)){n._iq[e]={_q:[]};v(n._iq[e])}return n._iq[e]};e.amplitude=n;
13-
})(window,document);
1+
(function(e,t){var n=e.amplitude||{_q:[],_iq:{}};var r=t.createElement("script")
2+
;r.type="text/javascript";r.async=true
3+
;r.src="https://d24n15hnbwhuhn.cloudfront.net/libs/amplitude-3.4.1-min.gz.js"
4+
;r.onload=function(){if(e.amplitude.runQueuedFunctions){
5+
e.amplitude.runQueuedFunctions()}else{
6+
console.log("[Amplitude] Error: could not load SDK")}}
7+
;var i=t.getElementsByTagName("script")[0];i.parentNode.insertBefore(r,i)
8+
;function o(e,t){e.prototype[t]=function(){
9+
this._q.push([t].concat(Array.prototype.slice.call(arguments,0)));return this}}
10+
var s=function(){this._q=[];return this}
11+
;var a=["add","append","clearAll","prepend","set","setOnce","unset"]
12+
;for(var u=0;u<a.length;u++){o(s,a[u])}n.Identify=s;var c=function(){this._q=[]
13+
;return this}
14+
;var l=["setProductId","setQuantity","setPrice","setRevenueType","setEventProperties"]
15+
;for(var p=0;p<l.length;p++){o(c,l[p])}n.Revenue=c
16+
;var d=["init","logEvent","logRevenue","setUserId","setUserProperties","setOptOut","setVersionName","setDomain","setDeviceId","setGlobalUserProperties","identify","clearUserProperties","setGroup","logRevenueV2","regenerateDeviceId","logEventWithTimestamp","logEventWithGroups"]
17+
;function v(e){function t(t){e[t]=function(){
18+
e._q.push([t].concat(Array.prototype.slice.call(arguments,0)))}}
19+
for(var n=0;n<d.length;n++){t(d[n])}}v(n);n.getInstance=function(e){
20+
e=(!e||e.length===0?"$default_instance":e).toLowerCase()
21+
;if(!n._iq.hasOwnProperty(e)){n._iq[e]={_q:[]};v(n._iq[e])}return n._iq[e]}
22+
;e.amplitude=n})(window,document);

0 commit comments

Comments
 (0)