swdc-tracker
Advanced tools
Comparing version 1.0.10 to 1.0.11
@@ -55,3 +55,3 @@ "use strict"; | ||
return [2 /*return*/, { | ||
schema: "iglu:com.software/ui_element/jsonschema/1-0-0", | ||
schema: "iglu:com.software/ui_element/jsonschema/1-0-1", | ||
data: { | ||
@@ -58,0 +58,0 @@ element_name: this.element_name, |
declare const swdcTracker: any; | ||
export default swdcTracker; | ||
export * from "./events/codetime"; | ||
export * from "./events/editor_action"; | ||
export * from "./events/ui_interaction"; | ||
export * from "./entities/auth"; | ||
export * from "./entities/file"; | ||
export * from "./entities/plugin"; | ||
export * from "./entities/project"; | ||
export * from "./entities/repo"; | ||
export * from "./entities/ui_element"; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -167,1 +177,10 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
exports.default = swdcTracker; | ||
__exportStar(require("./events/codetime"), exports); | ||
__exportStar(require("./events/editor_action"), exports); | ||
__exportStar(require("./events/ui_interaction"), exports); | ||
__exportStar(require("./entities/auth"), exports); | ||
__exportStar(require("./entities/file"), exports); | ||
__exportStar(require("./entities/plugin"), exports); | ||
__exportStar(require("./entities/project"), exports); | ||
__exportStar(require("./entities/repo"), exports); | ||
__exportStar(require("./entities/ui_element"), exports); |
{ | ||
"name": "swdc-tracker", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "swdc event tracker", | ||
@@ -5,0 +5,0 @@ "main": "dist", |
@@ -31,3 +31,3 @@ // The ui_element interface | ||
return { | ||
schema: "iglu:com.software/ui_element/jsonschema/1-0-0", | ||
schema: "iglu:com.software/ui_element/jsonschema/1-0-1", | ||
data: { | ||
@@ -42,2 +42,2 @@ element_name: this.element_name, | ||
} | ||
} | ||
} |
@@ -19,3 +19,3 @@ import { get } from "./utils/http"; | ||
try { | ||
// fetch tracker_api from plugin config | ||
// fetch tracker_api from plugin config | ||
const result = await get(swdcApiHost, "/plugins/config") | ||
@@ -43,3 +43,3 @@ const tracker_api_host = result.data.tracker_api | ||
* @param jwt - the authorization token | ||
* @param codetimeEvent - the CodeTime event extends Repo, Project, File | ||
* @param codetimeEvent - the CodeTime event extends Repo, Project, File | ||
*/ | ||
@@ -112,2 +112,11 @@ swdcTracker.trackCodeTimeEvent = async (params: CodeTimeParams): Promise<any> => { | ||
export default swdcTracker; | ||
export default swdcTracker; | ||
export * from "./events/codetime"; | ||
export * from "./events/editor_action"; | ||
export * from "./events/ui_interaction"; | ||
export * from "./entities/auth"; | ||
export * from "./entities/file"; | ||
export * from "./entities/plugin"; | ||
export * from "./entities/project"; | ||
export * from "./entities/repo"; | ||
export * from "./entities/ui_element"; |
import swdcTracker from "../../src/index"; | ||
import { TrackerResponse } from "../../src/utils/response"; | ||
import { FileInterface, File } from "../../src/entities/file"; | ||
import { CodeTime } from "../../src/events/codetime"; | ||
@@ -10,3 +9,3 @@ | ||
describe("Test ui interaction event functions", function () { | ||
describe("UI Interaction Event", function () { | ||
@@ -30,9 +29,11 @@ const sandbox = sinon.createSandbox(); | ||
}); | ||
it("Validate creating a UI interaction payload", async function () { | ||
context('when creating a ui_interaction event', async function() { | ||
const eventData = { | ||
jwt: "JWT 123", | ||
interaction_type: "execute_command", | ||
element_name: "tree_view_summary_button", | ||
element_location: "tree", | ||
interaction_type: "click", | ||
element_name: "ct_summary_btn", | ||
element_location: "ct_menu_tree", | ||
color: "purple", | ||
icon_name: "guage", | ||
cta_text: "View Summary", | ||
tz_offset_minutes: 420, | ||
@@ -44,22 +45,39 @@ plugin_id: 2, | ||
const response: TrackerResponse = await swdcTracker.trackUIInteraction(eventData); | ||
it("returns a 200 status", async function () { | ||
const response: TrackerResponse = await swdcTracker.trackUIInteraction(eventData); | ||
expect(response.status).to.equal(200); | ||
}); | ||
expect(response.status).to.equal(200); | ||
it("creates an event with the ui_interaction schema", async function () { | ||
await swdcTracker.trackUIInteraction(eventData); | ||
const props = swdcTracker.getLastProcessedTestEvent().properties; | ||
const lastProcessedTestEvent = swdcTracker.getLastProcessedTestEvent(); | ||
expect(props.schema).to.include("ui_interaction"); | ||
}); | ||
// get the data | ||
const props = lastProcessedTestEvent.properties; | ||
const contexts = lastProcessedTestEvent.contexts; | ||
it("creates an event with the supplied interaction_type", async function () { | ||
await swdcTracker.trackUIInteraction(eventData); | ||
const props = swdcTracker.getLastProcessedTestEvent().properties; | ||
// SCHEMA validation "ui_interaction" | ||
expect(props.schema).to.include("ui_interaction"); | ||
expect(props.data.interaction_type).to.equal("execute_command"); | ||
expect(props.data.interaction_type).to.equal(eventData.interaction_type); | ||
}); | ||
// get the plugin context | ||
const pluginContext: any = contexts.find((n: any) => n.schema.includes("plugin")); | ||
expect(pluginContext.data.plugin_id).to.equal(2); | ||
it("creates a plugin context with the supplied plugin attributes", async function () { | ||
await swdcTracker.trackUIInteraction(eventData); | ||
const contexts = swdcTracker.getLastProcessedTestEvent().contexts; | ||
const pluginContext: any = contexts.find((n: any) => n.schema.includes("plugin")); | ||
expect(eventData).to.include(pluginContext.data); | ||
}); | ||
it("creates a ui_element context with the supplied ui_element attributes", async function () { | ||
await swdcTracker.trackUIInteraction(eventData); | ||
const contexts = swdcTracker.getLastProcessedTestEvent().contexts; | ||
const ui_elementContext: any = contexts.find((n: any) => n.schema.includes("ui_element")); | ||
expect(eventData).to.include(ui_elementContext.data); | ||
}); | ||
}); | ||
it("Validate not creating a codetime payload for the ui interaction payload", async function () { | ||
it("does not create a codetime payload", async function () { | ||
const eventData: any = { | ||
@@ -78,4 +96,3 @@ jwt: "JWT 123", | ||
expect(CodeTime.hasData(eventData)).to.be.undefined; | ||
}); | ||
}); | ||
}); |
109397
2296