File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -87,5 +87,11 @@ function renderPage(page) {
8787function renderLoad ( settings ) {
8888 if ( ! settings . load ) return '' ;
8989
90+ if ( typeof settings . load !== 'boolean' ) {
91+ // eslint-disable-next-line no-restricted-globals
92+ var loadOptions = JSON . stringify ( settings . load ) ;
93+ return 'analytics.load("' + settings . apiKey + '", ' + loadOptions + ');' ;
94+ }
95+
9096 return 'analytics.load("' + settings . apiKey + '");' ;
9197}
Original file line number Diff line number Diff line change @@ -34,6 +34,12 @@ describe('snippet', function() {
3434 'analytics.load("key")' ) ;
3535 } ) ;
3636
37+ it ( 'should set the load options' , function ( ) {
38+ assertContains (
39+ snippet . max ( { apiKey : 'key' , load : { integrations : { All : false } } } ) ,
40+ 'analytics.load("key", {"integrations":{"All":false}})' ) ;
41+ } ) ;
42+
3743 it ( 'should set the _writekey' , function ( ) {
3844 assertContains (
3945 snippet . max ( { apiKey : 'foo' } ) ,
@@ -101,6 +107,12 @@ describe('snippet', function() {
101107 'analytics.load("key")' ) ;
102108 } ) ;
103109
110+ it ( 'should set the load options' , function ( ) {
111+ assertContains (
112+ snippet . max ( { apiKey : 'key' , load : { integrations : { All : false } } } ) ,
113+ 'analytics.load("key", {"integrations":{"All":false}})' ) ;
114+ } ) ;
115+
104116 it ( 'should set the _writekey' , function ( ) {
105117 assertContains (
106118 snippet . min ( { apiKey : 'foo' } ) ,
Original file line number Diff line number Diff line change @@ -7,6 +7,13 @@ declare module '@segment/snippet' {
77 }
88 }
99
10+ interface LoadOptions {
11+ integrations ?: {
12+ All ?: boolean
13+ [ key : string ] : boolean
14+ }
15+ }
16+
1017 interface Options {
1118 /** The domain name where the analytics.js script is hosted. */
1219 host ?: string
@@ -23,7 +30,7 @@ declare module '@segment/snippet' {
2330 * you want dynamically control the load process on the client-side for
2431 * things like GDPR.
2532 */
26- load ?: boolean
33+ load ?: boolean | LoadOptions
2734 }
2835
2936 /**
You can’t perform that action at this time.
0 commit comments