in extensions/applicationinsights-clickanalytics-js/src/events/PageAction.ts [63:119]
public capturePageAction(element: Element, overrideValues?: IPageActionOverrideValues, customProperties?: { [name: string]: string | number | boolean | string[] | number[] | boolean[] | object }, isRightClick?: boolean): void {
overrideValues = !isValueAssigned(overrideValues) ? {} : overrideValues;
let pageActionEvent: IPageActionTelemetry = { name : ""};
let pageActionProperties: ICustomProperties = isValueAssigned(customProperties) ? customProperties : {};
this.setCommonProperties(pageActionEvent, overrideValues);
pageActionEvent.behavior = this._getBehavior(overrideValues);
// element in scope is needed for below properties. We cannot pass element into the plugin call chain.
// process them here.
let elementContent: any = {};
if (isRightClick) {
// Default behavior for righ click
pageActionEvent.behavior = this._config.defaultRightClickBhvr;
}
// Fill PartB
if (element) {
pageActionEvent.targetUri = DataCollector.getClickTarget(element);
elementContent = this._contentHandler.getElementContent(element); // collect id,cn tags
// if the element has a data-*-bhvr attrib defined, use it.
if (elementContent.bhvr && !isValueAssigned(overrideValues.behavior)) {
let currentBehavior: string = extractFieldFromObject(elementContent, "bhvr");
pageActionEvent.behavior = this._getValidBehavior(currentBehavior);
}
// Validate to ensure the minimum required field 'contentName' or 'id' is present. However,
// requiring these fields would result in majority of adopter's content from being collected.
// Just throw a warning and continue collection.
if (!isValueAssigned(elementContent.id) && !isValueAssigned(elementContent.contentName)) {
this._traceLogger.throwInternal(
LoggingSeverity.WARNING,
_ExtendedInternalMessageId.InvalidContentBlob, "Missing attributes id or contentName in click event. Click event information will still be collected!"
);
}
}
pageActionEvent.name = elementContent.id || elementContent.contentName || strNotSpecified;
pageActionEvent.parentId = elementContent.parentid || elementContent.parentName || strNotSpecified;
if (isValueAssigned(overrideValues.actionType)) {
pageActionEvent.actionType = overrideValues.actionType;
}
if (isValueAssigned(overrideValues.clickCoordinateX) && isValueAssigned(overrideValues.clickCoordinateY)) {
pageActionEvent.clickCoordinates = overrideValues.clickCoordinateX + "X" + overrideValues.clickCoordinateY;
}
this._sanitizePageActionEventContent(elementContent);
pageActionEvent.content = bracketIt(JSON.stringify(extend(
elementContent,
overrideValues && overrideValues.contentTags ? overrideValues.contentTags : {})));
pageActionEvent.timeToAction = this._getTimeToClick();
pageActionEvent.refUri = isValueAssigned(overrideValues.refUri) ? overrideValues.refUri : this._config.coreData.referrerUri;
if(this._isUndefinedEvent(pageActionEvent)) return;
this.trackPageAction(pageActionEvent, pageActionProperties);
}