Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ask-sdk-core/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export { CustomSkillBuilder } from './skill/factory/CustomSkillBuilder';
export { CustomSkillFactory } from './skill/factory/CustomSkillFactory';
export { SkillBuilders } from './skill/SkillBuilders';
export { CustomSkillConfiguration as SkillConfiguration } from './skill/CustomSkillConfiguration';
export { Logger, MetricsType } from './util/Logger';
export {
getViewportDpiGroup,
getViewportOrientation,
Expand Down
3 changes: 2 additions & 1 deletion ask-sdk-core/lib/skill/CustomSkill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { PersistenceAdapter } from '../attributes/persistence/PersistenceAdapter
import { HandlerInput } from '../dispatcher/request/handler/HandlerInput';
import { ResponseFactory } from '../response/ResponseFactory';
import { CustomSkillConfiguration } from './CustomSkillConfiguration';
import { Logger } from '../util/Logger';
import ServiceClientFactory = services.ServiceClientFactory;
import ApiClient = services.ApiClient;

Expand Down Expand Up @@ -99,7 +100,7 @@ export class CustomSkill implements Skill<RequestEnvelope, ResponseEnvelope> {
return {
version : '1.0',
response,
userAgent : UserAgentManager.getUserAgent(),
userAgent : UserAgentManager.getUserAgent() + Logger.getFeatures(),
sessionAttributes : requestEnvelope.session ? input.attributesManager.getSessionAttributes() : undefined,
};
}
Expand Down
67 changes: 67 additions & 0 deletions ask-sdk-core/lib/util/Logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* Logger to log SDK interfaces and functions used by a skill
*/

export enum MetricsType{
InSDK = 1,
Component = 2
}

export abstract class Logger{
private constructor(){}

/**
* Set of features used by the skill from SDK
*/
private static inSDKfeatures: Set<string> = new Set<string>();


/**
* Set of components used by a skill
*/
private static componentList: Set<string> = new Set<string>();

/**
* Method to log the feature
*/
public static log(featureName: string, type: MetricsType){
if(type==1){
Logger.inSDKfeatures.add(featureName);
}
else if(type==2){
Logger.componentList.add(featureName);
}
}

/**
* Method to get the components used by the skill
*/
private static getComponentList(): string{
const componentList = Array.from(Logger.componentList).toString();
if(!componentList.length){
return '';
}
const log = ' components:['+componentList+']';
return log;
}

/**
* Method to get the SDK features used by the skill
*/
private static getInSDKfeatures(): string{
const inSDKfeatures = Array.from(Logger.inSDKfeatures).toString();
if(!inSDKfeatures.length){
return '';
}
const log = ' sdk-dependencies:['+inSDKfeatures+']';
return log;
}

/**
* Method to get all the features used by the skill
*/
public static getFeatures(): string{
const log = Logger.getInSDKfeatures() + Logger.getComponentList();
return log;
}
}