Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4150840
SamplingController.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
SamplingController.js
View Options
const
isValidSample
=
require
(
'./StreamConfigUtils.js'
).
isValidSample
;
const
UINT32_MAX
=
4294967295
;
// (2^32) - 1
/**
* Evaluate events for presence in sample based on the stream configuration.
*
* @param {Integration} integration
* @constructor
*/
function
SamplingController
(
integration
)
{
this
.
integration
=
integration
;
}
/**
* Determine whether a stream is in or out of sample.
*
* @param {?StreamConfig} streamConfig stream configuration
* @return {boolean} true if in-sample, false if out-sample.
*/
SamplingController
.
prototype
.
isStreamInSample
=
function
(
streamConfig
)
{
if
(
!
streamConfig
)
{
// If a stream is not defined, it is not in sample.
return
false
;
}
if
(
!
streamConfig
.
sample
)
{
// If the stream does not specify sampling, it is in-sample.
return
true
;
}
if
(
!
isValidSample
(
streamConfig
.
sample
)
)
{
return
false
;
}
let
id
;
switch
(
streamConfig
.
sample
.
unit
)
{
case
'pageview'
:
id
=
this
.
integration
.
getPageviewId
();
break
;
case
'session'
:
id
=
this
.
integration
.
getSessionId
();
break
;
default
:
return
false
;
}
return
parseInt
(
id
.
slice
(
0
,
8
),
16
)
/
UINT32_MAX
<
streamConfig
.
sample
.
rate
;
};
module
.
exports
=
SamplingController
;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Aug 19 2026, 19:45 (6 w, 6 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
45/b2/b096773ac351fe1068a91a82705c
Default Alt Text
SamplingController.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment