88 < title > Branch Metrics Web SDK Example App</ title >
99 < link rel ="stylesheet " href ="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css ">
1010 < style type ="text/css ">
11- .btn {
12- margin-top : 5px ;
13- }
14-
1511 body {
1612 font-family : Arial, sans-serif;
1713 background-color : # f4f4f9 ;
163159 } ) ;
164160 }
165161
162+ function copySessionInfo ( ) {
163+ const pre = document . getElementById ( 'session-info' ) ;
164+ const text = pre . textContent ;
165+ navigator . clipboard . writeText ( text ) . then ( ( ) => {
166+ console . log ( 'Copied' ) ;
167+ } ) . catch ( err => {
168+ console . error ( 'Failed to copy text: ' , err ) ;
169+ } ) ;
170+ }
166171 </ script >
167172</ head >
168173
@@ -173,12 +178,14 @@ <h2>Branch Metrics Web SDK Example</h2>
173178 </ div >
174179 < section >
175180 < div class ="row col-lg-8 col-lg-offset-2 ">
176- < h4 > Session Info</ h4 >
181+ < h4 > Session Info
182+ < button class ="btn btn-info " onclick ="copySessionInfo() " style ="margin-left: 10px; font-size: 12px; padding: 2px 8px; cursor: pointer; ">
183+ Copy
184+ </ button >
185+ </ h4 >
177186 < pre id ="session-info "> Reading session from .init()...</ pre >
178- < br >
179187 < h4 > Request</ h4 >
180188 < pre id ="request "> Click a button!</ pre >
181- < br >
182189 < h4 > Response</ h4 >
183190 < pre id ="response "> Click a button!</ pre >
184191 </ div >
@@ -252,7 +259,7 @@ <h3>Api Settings</h3>
252259 // Take the Branch key from a meta tag
253260 branch . init ( getBranchKey ( ) , function ( err , data ) {
254261 // Avoid XSS by HTML escaping the data for display
255- $ ( '#session-info' ) . text ( JSON . stringify ( data ) ) ;
262+ $ ( '#session-info' ) . text ( JSON . stringify ( data , null , 2 ) ) ;
256263 if ( err ) {
257264 let alertMessage = err . message ;
258265 if ( getApiUrlLocal ( ) . includes ( 'stage' ) ) {
0 commit comments