1
1
( function ( ) {
2
2
3
+ /* global $, nacl, device */
4
+ /* TODO: track down device ... */
5
+
3
6
/*!
4
7
* Create export namespace.
5
8
*/
23
26
* - `permissionVal` {boolean} optIn value
24
27
*/
25
28
26
- window . phonegap . app . analytic . setPermission = function ( config , permissionVal ) {
29
+ window . phonegap . app . analytic . setPermission = function ( config , permissionVal ) {
27
30
config . optIn = permissionVal ;
28
- window . phonegap . app . config . save ( config , function ( ) { } ) ;
31
+ window . phonegap . app . config . save ( config , function ( ) { } ) ;
29
32
} ;
30
33
31
34
/**
32
35
* Get the text status of the permission
33
36
* - `config` {object} config object that holds the app's data
34
37
*/
35
38
36
- window . phonegap . app . analytic . getPermissionStatus = function ( config ) {
39
+ window . phonegap . app . analytic . getPermissionStatus = function ( config ) {
37
40
return config . optIn ;
38
41
} ;
39
42
45
48
*/
46
49
47
50
window . phonegap . app . analytic . logEvent = function ( config , gelfObject ) {
48
- if ( config . optIn ) {
51
+ if ( config . optIn ) {
49
52
var metricsURL = 'https://metrics.phonegap.com/gelf' ;
50
- $ . ajax ( { type : 'POST' , url : metricsURL , data : JSON . stringify ( gelfObject ) } ) ;
53
+ $ . ajax ( { type : 'POST' , url : metricsURL , data : JSON . stringify ( gelfObject ) } ) ;
51
54
}
52
55
} ;
53
56
54
57
/**
55
58
* Helper function to help construct analytic object
56
59
*/
57
60
58
- window . phonegap . app . analytic . basicGELF = function ( ) {
61
+ window . phonegap . app . analytic . basicGELF = function ( ) {
59
62
return {
60
- " version" : " 1.1" ,
61
- " host" : " dev app" ,
62
- " short_message" : "" ,
63
- " _userID" : nacl . util . encodeBase64 ( nacl . hash ( nacl . util . decodeUTF8 ( device . uuid ) ) ) ,
64
- " _platform" : device . platform ,
65
- " _appVersion" : getVersion ( ) ,
66
- " _env" : getDebugFlag ( ) ? 1 : 0
63
+ ' version' : ' 1.1' ,
64
+ ' host' : ' dev app' ,
65
+ ' short_message' : '' ,
66
+ ' _userID' : nacl . util . encodeBase64 ( nacl . hash ( nacl . util . decodeUTF8 ( device . uuid ) ) ) ,
67
+ ' _platform' : device . platform ,
68
+ ' _appVersion' : getVersion ( ) ,
69
+ ' _env' : getDebugFlag ( ) ? 1 : 0
67
70
} ;
68
71
} ;
69
72
70
73
/**
71
74
* Returns if the app is production or development
72
75
*/
73
76
74
- function getDebugFlag ( ) {
77
+ function getDebugFlag ( ) {
75
78
return / a d h o c / . test ( $ ( '#version' ) . html ( ) ) ;
76
79
}
77
80
78
81
/**
79
82
* Returns the version of the app
80
83
*/
81
84
82
- function getVersion ( ) {
85
+ function getVersion ( ) {
83
86
var versionStringSplit = $ ( '#version' ) . html ( ) . split ( ':' ) ;
84
- if ( versionStringSplit . length >= 1 ) {
85
- return '0.0.0'
87
+ if ( versionStringSplit . length >= 1 ) {
88
+ return '0.0.0' ;
86
89
} else {
87
90
return versionStringSplit [ 1 ] . trim ( ) . split ( '<' ) [ 0 ] ;
88
91
}
89
- } ;
90
- } ) ( ) ;
92
+ }
93
+ } ) ( ) ;
0 commit comments