根據工作階段範本建立工作階段,並傳回工作階段的唯一識別碼。
語法
Microsoft.Apm.createSession(SessionInput);
參數
| 名稱 | 類型 | 為必填項目 | Description |
|---|---|---|---|
| 工作階段輸入 | 繩子 | Yes | 要建立之工作階段的 JSON 輸入屬性。 |
JSON SessionInput 參數的結構如下:
{
/**
* Returns the name of the template used in the session
*/
templateName: string;
/**
* additional information for session creation
*/
sessionContext: Map<string, string>;
/**
* will focus after session is created
*/
isFocused?: boolean;
}
返回值
會話識別碼為字串。
範例
這些範例會使用方法 createSession 來建立新的階段作業,將實體記錄識別碼和階段作業範本傳遞為參數。
建立基本工作階段
建立新的工作階段,將事件傳遞為實體名稱、事件識別碼為 entityId,以及工作階段範本的唯一名稱為 templateName。
備註
叫用這些方法的使用者必須指派給包含工作階段範本的應用程式設定檔。
x=new Map();
x.set("parametersStr", '[["entityName", "incident"], ["entityId", "11bb11bb-cc22-dd33-ee44-55ff55ff55ff"]]');
Microsoft.Apm.createSession({templateName: "case_entity_session_default_template", sessionContext: x});
建立未聚焦的工作階段
x=new Map();
x.set("parametersStr", '[["entityName", "incident"], ["entityId", "22cc22cc-dd33-ee44-ff55-66aa66aa66aa"]]');
Microsoft.Apm.createSession({templateName: "case_entity_session_default_template", sessionContext: x, isFocused: false});