Changing the Canister safety limits
Canister safety limits are managed through Canister Safety Limits [BB]
,
a Experience Analytics Standard Event that accesses three Experience Analytics
session attributes.
Through Advanced Mode in the Event Manager, you can edit the JavaScript™ definition of the Canister Safety Limits event. Below is the default definition.
// Canister Safety Limits [BB]
function PALI$E_SAFETY_LIMITS()
{
//Default: 2048 Hits
if ($S.NumberOfHits > 2048)
TLCloseSession.CloseForSafetyHits();
//Default: 5242880 Bytes (5MB)
if (($S.TotalREQBytes + $S.TotalRSPBytes) > 5242880)
TLCloseSession.CloseForSafetySize();
//Default: 3600 Seconds (60 minutes)
if ($S.TotalTime> 3600)
TLCloseSession.CloseForSafetyTime();
}
Costly Session - Too Long
Costly Session - Too Many Hits
Costly Session - Too Big
After you modify the Canister Safety Limit
event, the above events continue
to fire and cannot be disabled, which may cause confusion. You can clear the Display in
Portal
option for these events to limit user interaction with them. You might also consider
changing the description to include NOT_USED
, as well as adding them to a special
event label.
- Edit the event for the canister safety limits. Note: You should verify the other settings in the event before switching to Advanced Mode. After you switch to Advanced Mode, returning to Basic Mode removes all JavaScript changes you made during the current edit.
- When you finish editing the basic properties of the event, click Advanced Mode.
- In the following table, you can review the canister safety limits, which are session
attribute variables that are maintained by the Canister. If any of these values are exceeded, then
the active session is automatically closed by the Canister and written to disk. Subsequent hits that
are collected by the Canister for the same visitor session are assigned to a new session identifier.
Table 1. Example - Changing the Canister safety limits JavaScript Variable Default Value Description $S.Number OfHits
2048
Maximum number of hits that are allowed in a single session. $S.Number OfHits
+$S.Total RSPBytes
5242880
Total number of bytes allowed in all requests and responses of a single session. Default value is 5 MB. Note: If DOM capture is enabled (EnbableDomCapture=1
), you might need to increase the byte size from the default value. DOM Capture can incur additional processing and network transmission cost - increasing the byte size accommodates the additional costs and can prevent the session from splitting too early. Contact Professional services to determine if your DOM Capture solution requires you to increase the byte size.$S.Total Time
3600
Maximum time in seconds allowed in a single session. Default value is 1 hour. - To change the values, enter a new value where you see the default value in the JavaScript.
- After you change all values as needed, click Save
Draft.The JavaScript is validated.
- After you save your session, you should test it in the Event Tester, where you can load a session that exceeds one of your defined limits.
- After you test the event, save it to the server.The new canister safety limits are applied to all subsequent sessions.
Rounding event values to a fixed number of digits
In some cases, you might need to round off the digits after a decimal point to a fixed number of digits. For example, values that are submitted as U.S currency may require rounding to two decimal places for display purposes.
By default, the Event Engine is configured to record data under the assumption that the decimal
point is identified by the period (109.02
). However, in some locales, the decimal
point is identified by a comma (109,02
).
The Event Engine in the Canister attempts to identify the proper decimal point to use for
recording purposes that are based on a configuration setting. However, for some values, it may be
ambiguous. For example, values between 1,000
or 999,999
could
represent decimal values or not. However, some report data may contain many of ambiguous numeric
strings.
When the comma decimal point (,
) is configured for numeric value extraction, the
conversion of calculated fact value may not be correct. For example, the Activity reports generate
many ambiguous strings.
If incorrect values are encountered, the event that records the value can be corrected to convert the number to make an unambiguous value by rounding it off to four digits.
- Open the event in the Event Manager.
- Edit the JavaScript for the event to change
the number to a decimal precision of less than or greater than three digits.
In the following example, the Page Generation event (
TL$PageGen()
) is modified to generate four digits of data after the decimal:- Original version:
function TL$PageGen() { var pageGen = $H.GenTime/1000; var f = $F.getFact("TL.PageGenFact"); if (f != null) pageGen += f.NumericValue; $F.setFact("TL.PageGenFact", pageGen); }
- Modified version:
function TL$PageGen() { var pageGen = $H.GenTime/1000; var f = $F.getFact("TL.PageGenFact"); if (f != null) pageGen += f.NumericValue; $F.setFact("TL.PageGenFact", pageGen.toFixed(4)); }
- Original version:
- Save the event.
- If you have access to a session containing values detected by the event, you can test the event in the Event Tester.
- Commit your changes to the server.
The JavaScript number converts to a period decimal
string format only. For a calculated number like 1.000
, the Event Engine treats the
period as a grouping separator and converts it to the value 1000
. By making the
decimal precision to four digits, 1.0000
, the event engine can resolve that the
period is actually a decimal point.
The pageGen.toFixed(4)
includes the number of decimal places to which the value
is rounded.
Setting Report Groups
In this example, the value of the event is the fact count for the session.
Even though only one fact was specified, you are setting two facts. The first fact is the default No Dimension Report Group fact. The second fact is the added report group. By default, the Event Manager sets the value of all facts to be the value that is set in the Value step. However, it is possible to set different values for different facts.
To make a new fact in Advanced mode, click New Current Event Fact in the left column. The Fact Editor is opened.
The Value Type
, Tracked Occurrence
, Search
,
and Report
settings are shared across all facts. If you change one of these values
in a fact, it is automatically changed in all facts for this event.
Creating regular expression patterns
In this example, we are trying to create a regular expression pattern in JavaScript to look for the last value in the response, matching on the fourth match group.
Here is one implementation:
// the pattern used to extract the amount (found in match group 4 ($4)
var pattern = "COMP\\x3B(.*?)\\x3A(.*?)\\x3B(.*?)\\x3B(.*?)($|\\)"
// The weba.s.products hit attribute is the pattern found in the response.
// We want the last one in the response.
// the amount is found in the fourth match group of the last match.
// var $amt = /$pattern/.exec
// ($P["APP.P__H_WEBA_S_PRODUCTS__HA__634261087410339197"].lastValue()).$4;
In the above example, two methods are called in a single line: .exec()
and
lastValue()
. However, if the exec()
method cannot find a match, it
returns a null value, which generates a runtime error. Determining the source of this error is not
straightforward.
To simplify debugging issues, break up the above JavaScript into multiple variable assignments, as in the following example:
//Define the regular expression
var pattern = "COMP\\x3B(.*?)\\x3A(.*?)\\x3B(.*?)\\x3B(.*?)($|\\)";
//Define the search buffer
var $search_buffer =
$P["APP.P__H_WEBA_S_PRODUCTS__HA__634261087410339197"].lastValue();
//Construct the RegEx object (If the pattern is invalid, this statement fails)
var $regex = new RegExp(pattern);
//Returns [FullMatch, Group1, Group2, Group3, Group4]
var $match = $regex.exec($search_buffer);
//Check to see if the match was successful and ensure that the match group is
//available
if($match && $match.length > 4) {
var $amt = $match[4];
}
The above code separates the regular expression checks into simpler declarations, which isolate the regex definition, pattern definition, regex compilation, and regex execution. Using simpler declarations:
- Simplifies automated and manual JavaScript validation.
- Simplifies debugging issues.
The performance impacts of writing looser JavaScript are minimal.