@@ -242,7 +242,7 @@ module Exceptionless {
242242 }
243243
244244 if ( ! plugin . name ) {
245- plugin . name = Random . guid ( ) ;
245+ plugin . name = Utils . guid ( ) ;
246246 }
247247
248248 if ( ! plugin . priority ) {
@@ -341,7 +341,7 @@ module Exceptionless {
341341 return ;
342342 }
343343
344- var key = this . queuePath ( ) + '-' + new Date ( ) . toJSON ( ) + '-' + Random . number ( ) ;
344+ var key = this . queuePath ( ) + '-' + new Date ( ) . toJSON ( ) + '-' + Utils . randomNumber ( ) ;
345345 this . _config . log . info ( 'Enqueuing event: ' + key ) ;
346346 return this . _config . storage . save ( key , event ) ;
347347 }
@@ -1015,7 +1015,7 @@ module Exceptionless {
10151015
10161016 run ( context :Exceptionless . EventPluginContext ) : Promise < any > {
10171017 if ( ( ! context . event . reference_id || context . event . reference_id . length === 0 ) && context . event . type === 'error' ) {
1018- context . event . reference_id = Random . guid ( ) . replace ( '-' , '' ) . substring ( 0 , 10 ) ;
1018+ context . event . reference_id = Utils . guid ( ) . replace ( '-' , '' ) . substring ( 0 , 10 ) ;
10191019 }
10201020
10211021 return Promise . resolve ( ) ;
@@ -1080,7 +1080,7 @@ module Exceptionless {
10801080 }
10811081 }
10821082
1083- export class ModuleInfoPlugin implements IEventPlugin {
1083+ class ModuleInfoPlugin implements IEventPlugin {
10841084 public priority :number = 40 ;
10851085 public name :string = 'ModuleInfoPlugin' ;
10861086
@@ -1096,9 +1096,9 @@ module Exceptionless {
10961096 if ( scripts && scripts . length > 0 ) {
10971097 for ( var index = 0 ; index < scripts . length ; index ++ ) {
10981098 if ( scripts [ index ] . src ) {
1099- modules . push ( { module_id : index , name : scripts [ index ] . src , version : this . getVersion ( scripts [ index ] . src ) } ) ;
1099+ modules . push ( { module_id : index , name : scripts [ index ] . src , version : Utils . parseVersion ( scripts [ index ] . src ) } ) ;
11001100 } else if ( ! ! scripts [ index ] . innerHTML ) {
1101- modules . push ( { module_id : index , name : 'Script Tag' , version : this . getHashCode ( scripts [ index ] . innerHTML ) } ) ;
1101+ modules . push ( { module_id : index , name : 'Script Tag' , version : Utils . getHashCode ( scripts [ index ] . innerHTML ) } ) ;
11021102 }
11031103 }
11041104
@@ -1110,37 +1110,6 @@ module Exceptionless {
11101110
11111111 return Promise . resolve ( ) ;
11121112 }
1113-
1114- public getVersion ( source :string ) : string {
1115- if ( ! source ) {
1116- return null ;
1117- }
1118-
1119- var versionRegex = / ( v ? ( ( \d + ) \. ( \d + ) ( \. ( \d + ) ) ? ) (?: - ( [ \d A - Z a - z \- ] + (?: \. [ \d A - Z a - z \- ] + ) * ) ) ? (?: \+ ( [ \d A - Z a - z \- ] + (?: \. [ \d A - Z a - z \- ] + ) * ) ) ? ) / ;
1120- var matches = versionRegex . exec ( source ) ;
1121- if ( matches && matches . length > 0 ) {
1122- return matches [ 0 ] ;
1123- }
1124-
1125- return null ;
1126- }
1127-
1128- public getHashCode ( source :string ) : string {
1129- if ( ! source || source . length === 0 ) {
1130- return null ;
1131- }
1132-
1133- var hash :number = 0 ;
1134- for ( var index = 0 ; index < source . length ; index ++ ) {
1135- var character = source . charCodeAt ( index ) ;
1136- hash = ( ( hash << 5 ) - hash ) + character ;
1137- hash |= 0 ;
1138- }
1139-
1140- return hash . toString ( ) ;
1141- }
1142-
1143- private get
11441113 }
11451114
11461115 class DuplicateCheckerPlugin implements IEventPlugin {
@@ -1174,7 +1143,7 @@ module Exceptionless {
11741143 path : location . pathname ,
11751144 //client_ip_address: 'TODO',
11761145 cookies : this . getCookies ( ) ,
1177- query_string : this . getQueryString ( ) ,
1146+ query_string : Utils . parseQueryString ( location . search . substring ( 1 ) ) ,
11781147 } ;
11791148
11801149 if ( document . referrer && document . referrer !== '' ) {
@@ -1200,22 +1169,6 @@ module Exceptionless {
12001169
12011170 return result ;
12021171 }
1203-
1204- private getQueryString ( ) : any {
1205- var query :string = location . search . substring ( 1 ) ;
1206- var pairs = query . split ( '&' ) ;
1207- if ( pairs . length === 0 ) {
1208- return null ;
1209- }
1210-
1211- var result = { } ;
1212- for ( var index = 0 ; index < pairs . length ; index ++ ) {
1213- var pair = pairs [ index ] . split ( '=' ) ;
1214- result [ decodeURIComponent ( pair [ 0 ] ) ] = decodeURIComponent ( pair [ 1 ] ) ;
1215- }
1216-
1217- return result ;
1218- }
12191172 }
12201173
12211174 class SubmissionMethodPlugin implements IEventPlugin {
@@ -1309,7 +1262,22 @@ module Exceptionless {
13091262 data ?:any ;
13101263 }
13111264
1312- class Random {
1265+ export class Utils {
1266+ public static getHashCode ( source :string ) : string {
1267+ if ( ! source || source . length === 0 ) {
1268+ return null ;
1269+ }
1270+
1271+ var hash :number = 0 ;
1272+ for ( var index = 0 ; index < source . length ; index ++ ) {
1273+ var character = source . charCodeAt ( index ) ;
1274+ hash = ( ( hash << 5 ) - hash ) + character ;
1275+ hash |= 0 ;
1276+ }
1277+
1278+ return hash . toString ( ) ;
1279+ }
1280+
13131281 public static guid ( ) : string {
13141282 function s4 ( ) {
13151283 return Math . floor ( ( 1 + Math . random ( ) ) * 0x10000 ) . toString ( 16 ) . substring ( 1 ) ;
@@ -1318,7 +1286,40 @@ module Exceptionless {
13181286 return s4 ( ) + s4 ( ) + '-' + s4 ( ) + '-' + s4 ( ) + '-' + s4 ( ) + '-' + s4 ( ) + s4 ( ) + s4 ( ) ;
13191287 }
13201288
1321- public static number ( ) : number {
1289+ public static parseVersion ( source :string ) : string {
1290+ if ( ! source ) {
1291+ return null ;
1292+ }
1293+
1294+ var versionRegex = / ( v ? ( ( \d + ) \. ( \d + ) ( \. ( \d + ) ) ? ) (?: - ( [ \d A - Z a - z \- ] + (?: \. [ \d A - Z a - z \- ] + ) * ) ) ? (?: \+ ( [ \d A - Z a - z \- ] + (?: \. [ \d A - Z a - z \- ] + ) * ) ) ? ) / ;
1295+ var matches = versionRegex . exec ( source ) ;
1296+ if ( matches && matches . length > 0 ) {
1297+ return matches [ 0 ] ;
1298+ }
1299+
1300+ return null ;
1301+ }
1302+
1303+ public static parseQueryString ( query :string ) {
1304+ if ( ! query || query . length === 0 ) {
1305+ return null ;
1306+ }
1307+
1308+ var pairs = query . split ( '&' ) ;
1309+ if ( pairs . length === 0 ) {
1310+ return null ;
1311+ }
1312+
1313+ var result = { } ;
1314+ for ( var index = 0 ; index < pairs . length ; index ++ ) {
1315+ var pair = pairs [ index ] . split ( '=' ) ;
1316+ result [ decodeURIComponent ( pair [ 0 ] ) ] = decodeURIComponent ( pair [ 1 ] ) ;
1317+ }
1318+
1319+ return result ;
1320+ }
1321+
1322+ public static randomNumber ( ) : number {
13221323 return Math . floor ( Math . random ( ) * 9007199254740992 ) ;
13231324 }
13241325 }
0 commit comments