Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
persona
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hexang 息壤平台
persona
Commits
e3097966
Commit
e3097966
authored
12 years ago
by
Shane Tomlinson
Browse files
Options
Downloads
Patches
Plain Diff
fixing interaction data
parent
f3875465
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
resources/static/shared/modules/interaction_data.js
+43
-35
43 additions, 35 deletions
resources/static/shared/modules/interaction_data.js
with
43 additions
and
35 deletions
resources/static/shared/modules/interaction_data.js
+
43
−
35
View file @
e3097966
...
@@ -31,6 +31,7 @@ BrowserID.Modules.InteractionData = (function() {
...
@@ -31,6 +31,7 @@ BrowserID.Modules.InteractionData = (function() {
sc
;
sc
;
function
onSessionContext
(
msg
,
result
)
{
function
onSessionContext
(
msg
,
result
)
{
console
.
log
(
"
session context
"
);
var
self
=
this
;
var
self
=
this
;
// defend against onSessionContext being called multiple times
// defend against onSessionContext being called multiple times
...
@@ -41,48 +42,51 @@ BrowserID.Modules.InteractionData = (function() {
...
@@ -41,48 +42,51 @@ BrowserID.Modules.InteractionData = (function() {
// session data must be published independently of whether the current
// session data must be published independently of whether the current
// dialog session is allowed to sample data. This is because the original
// dialog session is allowed to sample data. This is because the original
// dialog session has already decided whether to collect data.
// dialog session has already decided whether to collect data.
publishStored
();
// set the sample rate as defined by the server. It's a value
// Continuation after publishing MUST be done
// between 0..1, integer or float, and it specifies the percentage
publishStored
(
function
()
{
// of the time that we should capture
// set the sample rate as defined by the server. It's a value
var
sampleRate
=
result
.
data_sample_rate
||
0
;
// between 0..1, integer or float, and it specifies the percentage
// of the time that we should capture
if
(
typeof
self
.
samplingEnabled
===
"
undefined
"
)
{
var
sampleRate
=
result
.
data_sample_rate
||
0
;
// now that we've got sample rate, let's smash it into a boolean
// probalistically
if
(
typeof
self
.
samplingEnabled
===
"
undefined
"
)
{
self
.
samplingEnabled
=
Math
.
random
()
<=
sampleRate
;
// now that we've got sample rate, let's smash it into a boolean
}
// probalistically
self
.
samplingEnabled
=
Math
.
random
()
<=
sampleRate
;
}
// if we're not going to sample, kick out early.
// if we're not going to sample, kick out early.
if
(
!
self
.
samplingEnabled
)
{
if
(
!
self
.
samplingEnabled
)
{
return
;
return
;
}
}
var
currentData
=
{
var
currentData
=
{
event_stream
:
self
.
initialEventStream
,
event_stream
:
self
.
initialEventStream
,
sample_rate
:
sampleRate
,
sample_rate
:
sampleRate
,
timestamp
:
result
.
server_time
,
timestamp
:
result
.
server_time
,
local_timestamp
:
self
.
startTime
.
toString
(),
local_timestamp
:
self
.
startTime
.
toString
(),
lang
:
dom
.
getAttr
(
'
html
'
,
'
lang
'
)
||
null
,
lang
:
dom
.
getAttr
(
'
html
'
,
'
lang
'
)
||
null
,
};
if
(
window
.
screen
)
{
currentData
.
screen_size
=
{
width
:
window
.
screen
.
width
,
height
:
window
.
screen
.
height
};
};
}
// cool. now let's persist the initial data. This data will be published
if
(
window
.
screen
)
{
// as soon as the first session_context completes for the next dialog
currentData
.
screen_size
=
{
// session. Use a push because old data *may not* have been correctly
width
:
window
.
screen
.
width
,
// published to a down server or erroring web service.
height
:
window
.
screen
.
height
storage
.
push
(
currentData
);
};
}
// cool. now let's persist the initial data. This data will be published
// as soon as the first session_context completes for the next dialog
// session. Use a push because old data *may not* have been correctly
// published to a down server or erroring web service.
console
.
log
(
"
pushing currentData
"
);
storage
.
push
(
currentData
);
self
.
initialEventStream
=
null
;
self
.
initialEventStream
=
null
;
self
.
samplesBeingStored
=
true
;
self
.
samplesBeingStored
=
true
;
});
}
}
// At every load, after session_context returns, we'll try to publish
// At every load, after session_context returns, we'll try to publish
...
@@ -98,8 +102,10 @@ BrowserID.Modules.InteractionData = (function() {
...
@@ -98,8 +102,10 @@ BrowserID.Modules.InteractionData = (function() {
// XXX: should we even try to post data if it's larger than some reasonable
// XXX: should we even try to post data if it's larger than some reasonable
// threshold?
// threshold?
console
.
log
(
data
);
if
(
data
&&
data
.
length
!==
0
)
{
if
(
data
&&
data
.
length
!==
0
)
{
network
.
sendInteractionData
(
data
,
function
()
{
network
.
sendInteractionData
(
data
,
function
()
{
console
.
log
(
"
clear
"
);
storage
.
clear
();
storage
.
clear
();
complete
(
oncomplete
,
true
);
complete
(
oncomplete
,
true
);
},
function
(
status
)
{
},
function
(
status
)
{
...
@@ -126,11 +132,13 @@ BrowserID.Modules.InteractionData = (function() {
...
@@ -126,11 +132,13 @@ BrowserID.Modules.InteractionData = (function() {
var
eventData
=
[
eventName
,
new
Date
()
-
self
.
startTime
];
var
eventData
=
[
eventName
,
new
Date
()
-
self
.
startTime
];
if
(
self
.
samplesBeingStored
)
{
if
(
self
.
samplesBeingStored
)
{
console
.
log
(
"
add stored event:
"
+
eventName
);
var
d
=
storage
.
current
()
||
{};
var
d
=
storage
.
current
()
||
{};
if
(
!
d
.
event_stream
)
d
.
event_stream
=
[];
if
(
!
d
.
event_stream
)
d
.
event_stream
=
[];
d
.
event_stream
.
push
(
eventData
);
d
.
event_stream
.
push
(
eventData
);
storage
.
setCurrent
(
d
);
storage
.
setCurrent
(
d
);
}
else
{
}
else
{
console
.
log
(
"
add initial event:
"
+
eventName
);
self
.
initialEventStream
.
push
(
eventData
);
self
.
initialEventStream
.
push
(
eventData
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment