Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
JackCuthbert authored May 26, 2021
2 parents 82c6e8f + f8142ff commit 0917032
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@segment/snippet",
"author": "Segment.io <friends@segment.com>",
"version": "4.13.1",
"version": "4.13.2",
"repository": "git://github.com/segmentio/snippet.git",
"description": "Templating methods for rendering the analytics.js snippet.",
"main": "lib/index.js",
Expand Down
1 change: 1 addition & 0 deletions template/snippet.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
first.parentNode.insertBefore(script, first);
analytics._loadOptions = options;
};
analytics._writeKey = '<%= settings.apiKey %>'

// Add a version to keep track of what's in the wild.
analytics.SNIPPET_VERSION = '<%= settings.version %>';
Expand Down
13 changes: 13 additions & 0 deletions test/render.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ describe('snippet', function() {
'analytics.load("key")');
});

it('should set the _writekey', function() {
assertContains(
snippet.max({ apiKey: 'foo' }),
// eslint-disable-next-line
"analytics._writeKey = 'foo'");
});

it('should not include page if explicitly omitted', function() {
assertDoesNotContain(
snippet.max({ page: false }),
Expand Down Expand Up @@ -94,6 +101,12 @@ describe('snippet', function() {
'analytics.load("key")');
});

it('should set the _writekey', function() {
assertContains(
snippet.min({ apiKey: 'foo' }),
'analytics._writeKey="foo"');
});

it('should be shorter than max', function() {
var max = snippet.max().length;
var min = snippet.min().length;
Expand Down

0 comments on commit 0917032

Please sign in to comment.