Skip to content

Commit b1c4d08

Browse files
committed
Build snippet without script tag for segment integration
1 parent 3335e2e commit b1c4d08

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ BUILD_DIR = build
99
PROJECT = amplitude
1010
OUT = $(PROJECT).js
1111
SNIPPET_OUT = $(PROJECT)-snippet.min.js
12+
SEGMENT_SNIPPET_OUT = $(PROJECT)-segment-snippet.min.js
1213
MIN_OUT = $(PROJECT).min.js
1314
MOCHA = $(BINS)/mocha-phantomjs
1415

@@ -66,17 +67,21 @@ $(OUT): node_modules $(SRC) version
6667
@$(MINIFY) $(OUT) --output $(MIN_OUT)
6768

6869
#
69-
# Target for minified `amplitude-snippet.js` file. Update README.
70+
# Target for minified `amplitude-snippet.js` file.
7071
#
7172
$(SNIPPET_OUT): $(SRC) $(SNIPPET) version
7273
@$(JSHINT) --verbose $(SNIPPET)
73-
@$(MINIFY) $(SNIPPET) -m -b max-line-len=80,beautify=false --output $(SNIPPET_OUT)
74+
@$(MINIFY) $(SNIPPET) -m -b max-line-len=80,beautify=false | awk 'NF' > $(SNIPPET_OUT)
75+
76+
$(SEGMENT_SNIPPET_OUT): $(SRC) $(SNIPPET) version
77+
@grep -Ev "\ba?s\b" $(SNIPPET) | $(MINIFY) -m -b max-line-len=80,beautify=false - \
78+
| awk 'NF' > $(SEGMENT_SNIPPET_OUT)
7479

7580
#
7681
# Target for `tests-build.js` file.
7782
#
7883

79-
build: $(TESTS) $(OUT) $(SNIPPET_OUT) README.md
84+
build: $(TESTS) $(OUT) $(SNIPPET_OUT) $(SEGMENT_SNIPPET_OUT) README.md
8085
@-mkdir -p build
8186
@$(DUO) --development test/tests.js > build/tests.js
8287
@$(DUO) --development test/snippet-tests.js > build/snippet-tests.js

amplitude-segment-snippet.min.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(function(e,t){var n=e.amplitude||{};n._q=[];function o(e){n[e]=function(){n._q.push([e].concat(Array.prototype.slice.call(arguments,0)));
2+
}}var r=["init","logEvent","logRevenue","setUserId","setUserProperties","setOptOut","setVersionName","setDomain","setDeviceId","setGlobalUserProperties"];
3+
for(var s=0;s<r.length;s++){o(r[s])}e.amplitude=n})(window,document);

amplitude-snippet.min.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ n.async=true;n.src="https://d24n15hnbwhuhn.cloudfront.net/libs/amplitude-2.1.0-m
33
var s=t.getElementsByTagName("script")[0];s.parentNode.insertBefore(n,s);r._q=[];
44
function a(e){r[e]=function(){r._q.push([e].concat(Array.prototype.slice.call(arguments,0)));
55
}}var i=["init","logEvent","logRevenue","setUserId","setUserProperties","setOptOut","setVersionName","setDomain","setDeviceId","setGlobalUserProperties"];
6-
for(var o=0;o<i.length;o++){a(i[o])}e.amplitude=r})(window,document);
6+
for(var o=0;o<i.length;o++){a(i[o])}e.amplitude=r})(window,document);

0 commit comments

Comments
 (0)