@dapperlabs/react-analytics
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -73,2 +73,4 @@ 'use strict'; | ||
* @param {String} SEGMENT_WRITE_TOKEN | ||
* | ||
* WARNING: Replacing this snippet will remove code that accommodates injection without existing script tag. See Line 81. | ||
*/ | ||
@@ -121,5 +123,12 @@ function injectAnalyticsJs(SEGMENT_WRITE_TOKEN) { | ||
script.src = 'https://cdn.segment.com/analytics.js/v1/' + key + '/analytics.min.js'; // Insert our script next to the first script element. | ||
// In cases where there isn't a script element (ex: Dapper's Auth0 pages), | ||
// insert the script next to the body instead. | ||
var first = document.getElementsByTagName('script')[0]; | ||
first.parentNode.insertBefore(script, first); | ||
var element = document.getElementsByTagName('script')[0]; | ||
if (!element) { | ||
element = document.getElementsByTagName('body')[0]; | ||
} | ||
element.parentNode.insertBefore(script, element); | ||
analytics._loadOptions = options; | ||
@@ -126,0 +135,0 @@ }; // Add a version to keep track of what's in the wild. |
{ | ||
"name": "@dapperlabs/react-analytics", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "A utility to connect react projects to segment", | ||
@@ -5,0 +5,0 @@ "repository": "github:dapperlabs/react-analytics", |
@@ -5,3 +5,6 @@ /** | ||
* @param {String} SEGMENT_WRITE_TOKEN | ||
* | ||
* WARNING: Replacing this snippet will remove code that accommodates injection without existing script tag. See Line 81. | ||
*/ | ||
export default function injectAnalyticsJs(SEGMENT_WRITE_TOKEN) { | ||
@@ -76,4 +79,9 @@ // Create a queue, but don't obliterate an existing one! | ||
// Insert our script next to the first script element. | ||
var first = document.getElementsByTagName('script')[0]; | ||
first.parentNode.insertBefore(script, first); | ||
// In cases where there isn't a script element (ex: Dapper's Auth0 pages), | ||
// insert the script next to the body instead. | ||
var element = document.getElementsByTagName('script')[0]; | ||
if (!element) { | ||
element = document.getElementsByTagName('body')[0]; | ||
} | ||
element.parentNode.insertBefore(script, element); | ||
analytics._loadOptions = options; | ||
@@ -80,0 +88,0 @@ }; |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
40410
763
0