Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

swdc-tracker

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swdc-tracker - npm Package Compare versions

Comparing version 1.0.9 to 1.0.10

dist/entities/ui_element.d.ts

1

dist/entities/file.d.ts

@@ -15,2 +15,3 @@ export interface FileInterface {

constructor(data: FileInterface);
static hasData(data: FileInterface): string;
buildPayload(): Promise<{

@@ -17,0 +18,0 @@ schema: string;

@@ -49,2 +49,5 @@ "use strict";

}
File.hasData = function (data) {
return data.file_name && data.file_path;
};
File.prototype.buildPayload = function () {

@@ -51,0 +54,0 @@ return __awaiter(this, void 0, void 0, function () {

@@ -11,2 +11,3 @@ export interface PluginInterface {

constructor(data: PluginInterface);
static hasData(data: PluginInterface): string | 0;
buildPayload(): {

@@ -13,0 +14,0 @@ schema: string;

@@ -10,2 +10,5 @@ "use strict";

}
Plugin.hasData = function (data) {
return data.plugin_id && data.plugin_version;
};
Plugin.prototype.buildPayload = function () {

@@ -12,0 +15,0 @@ return {

@@ -9,2 +9,3 @@ export interface ProjectInterface {

constructor(data: ProjectInterface);
static hasData(data: ProjectInterface): string;
buildPayload(): Promise<{

@@ -11,0 +12,0 @@ schema: string;

@@ -46,2 +46,5 @@ "use strict";

}
Project.hasData = function (data) {
return data.project_name && data.project_directory;
};
Project.prototype.buildPayload = function () {

@@ -48,0 +51,0 @@ return __awaiter(this, void 0, void 0, function () {

@@ -15,2 +15,3 @@ export interface RepoInterface {

constructor(data: RepoInterface);
static hasData(data: RepoInterface): string;
buildPayload(): Promise<{

@@ -17,0 +18,0 @@ schema: string;

@@ -49,2 +49,5 @@ "use strict";

}
Repo.hasData = function (data) {
return data.repo_identifier;
};
Repo.prototype.buildPayload = function () {

@@ -51,0 +54,0 @@ return __awaiter(this, void 0, void 0, function () {

5

dist/events/codetime.d.ts

@@ -5,2 +5,3 @@ import { RepoInterface } from "../entities/repo";

import { PluginInterface } from "../entities/plugin";
import { AuthInterface } from "../entities/auth";
export interface CodeTimeInterface {

@@ -30,2 +31,3 @@ keystrokes: number;

constructor(data: CodeTimeInterface);
static hasData(data: CodeTimeInterface): number;
buildPayload(): {

@@ -47,4 +49,3 @@ schema: string;

}
export interface CodeTimeParams extends PluginInterface, RepoInterface, ProjectInterface, FileInterface, CodeTimeInterface {
jwt: string;
export interface CodeTimeParams extends AuthInterface, PluginInterface, RepoInterface, ProjectInterface, FileInterface, CodeTimeInterface {
}

@@ -17,2 +17,5 @@ "use strict";

}
CodeTime.hasData = function (data) {
return data.start_time && data.start_time;
};
CodeTime.prototype.buildPayload = function () {

@@ -19,0 +22,0 @@ return {

import { PluginInterface } from "../entities/plugin";
import { FileInterface } from "../entities/file";
import { ProjectInterface } from "../entities/project";
import { AuthInterface } from "../entities/auth";
export interface EditorActionInterface {

@@ -14,2 +15,3 @@ entity: string;

constructor(data: EditorActionInterface);
static hasData(data: EditorActionInterface): string;
buildPayload(): {

@@ -24,4 +26,3 @@ schema: string;

}
export interface EditorActionParams extends PluginInterface, FileInterface, ProjectInterface, EditorActionInterface {
jwt: string;
export interface EditorActionParams extends AuthInterface, PluginInterface, FileInterface, ProjectInterface, EditorActionInterface {
}

@@ -10,2 +10,5 @@ "use strict";

}
EditorAction.hasData = function (data) {
return data.entity;
};
EditorAction.prototype.buildPayload = function () {

@@ -12,0 +15,0 @@ return {

@@ -42,9 +42,6 @@ "use strict";

var editor_action_1 = require("./events/editor_action");
var auth_1 = require("./entities/auth");
var project_1 = require("./entities/project");
var repo_1 = require("./entities/repo");
var file_1 = require("./entities/file");
var plugin_1 = require("./entities/plugin");
var response_1 = require("./utils/response");
var env_helper_1 = require("./utils/env_helper");
var ui_interaction_1 = require("./events/ui_interaction");
var context_helper_1 = require("./utils/context_helper");
var snowplow = require("snowplow-tracker");

@@ -86,48 +83,13 @@ var emitter = snowplow.emitter;

swdcTracker.trackCodeTimeEvent = function (params) { return __awaiter(void 0, void 0, void 0, function () {
var codetime, project, repo, file, plugin, auth, _codetimePayload, _projecPayload, _repoPayload, _filePayload, _pluginPayload, _authPayload, contexts;
var _codetimePayload, contexts;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
codetime = new codetime_1.CodeTime(params);
project = new project_1.Project(params);
repo = new repo_1.Repo(params);
file = new file_1.File(params);
plugin = new plugin_1.Plugin(params);
auth = new auth_1.Auth(params);
return [4 /*yield*/, codetime.buildPayload()];
case 0: return [4 /*yield*/, new codetime_1.CodeTime(params).buildPayload()];
case 1:
_codetimePayload = _a.sent();
return [4 /*yield*/, project.buildPayload()];
return [4 /*yield*/, context_helper_1.buildContexts(params)];
case 2:
_projecPayload = _a.sent();
return [4 /*yield*/, repo.buildPayload()];
case 3:
_repoPayload = _a.sent();
return [4 /*yield*/, file.buildPayload()];
case 4:
_filePayload = _a.sent();
return [4 /*yield*/, plugin.buildPayload()];
case 5:
_pluginPayload = _a.sent();
return [4 /*yield*/, auth.buildPayload()];
case 6:
_authPayload = _a.sent();
contexts = [
_authPayload,
_codetimePayload,
_projecPayload,
_repoPayload,
_filePayload,
_pluginPayload
];
if (env_helper_1.isTestMode()) {
// test mode - console log the event
return [2 /*return*/, testEvent(_codetimePayload, contexts)];
}
return [4 /*yield*/, swdcTracker.spTracker.trackUnstructEvent(_codetimePayload, contexts)];
case 7:
// track the event.
// trackUnstrucEvent returns...
// {add <func(key, val)>, addDict <func(dict)>, addJson <func(keyIfEncoded, keyIfNotEncoded, json)>, build <func()>}
return [2 /*return*/, _a.sent()];
contexts = _a.sent();
return [4 /*yield*/, sendEvent(_codetimePayload, contexts)];
case 3: return [2 /*return*/, _a.sent()];
}

@@ -141,46 +103,56 @@ });

swdcTracker.trackEditorAction = function (params) { return __awaiter(void 0, void 0, void 0, function () {
var editorAction, plugin, file, project, auth, _editorActionPayload, _projecPayload, _filePayload, _pluginPayload, _authPayload, contexts;
var _editorActionPayload, contexts;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
editorAction = new editor_action_1.EditorAction(params);
plugin = new plugin_1.Plugin(params);
file = new file_1.File(params);
project = new project_1.Project(params);
auth = new auth_1.Auth(params);
return [4 /*yield*/, editorAction.buildPayload()];
case 0: return [4 /*yield*/, new editor_action_1.EditorAction(params).buildPayload()];
case 1:
_editorActionPayload = _a.sent();
return [4 /*yield*/, project.buildPayload()];
return [4 /*yield*/, context_helper_1.buildContexts(params)];
case 2:
_projecPayload = _a.sent();
return [4 /*yield*/, file.buildPayload()];
case 3:
_filePayload = _a.sent();
return [4 /*yield*/, plugin.buildPayload()];
case 4:
_pluginPayload = _a.sent();
return [4 /*yield*/, auth.buildPayload()];
case 5:
_authPayload = _a.sent();
contexts = [
_authPayload,
_editorActionPayload,
_pluginPayload,
_filePayload,
_projecPayload
];
if (env_helper_1.isTestMode()) {
// test mode - console log the event
return [2 /*return*/, testEvent(_editorActionPayload, contexts)];
}
return [4 /*yield*/, swdcTracker.spTracker.trackUnstructEvent(_editorActionPayload, contexts)];
case 6:
// track the event.
// trackUnstrucEvent returns...
// {add <func(key, val)>, addDict <func(dict)>, addJson <func(keyIfEncoded, keyIfNotEncoded, json)>, build <func()>}
return [2 /*return*/, _a.sent()];
contexts = _a.sent();
return [4 /*yield*/, sendEvent(_editorActionPayload, contexts)];
case 3: return [2 /*return*/, _a.sent()];
}
});
}); };
/**
* @param jwt - the authorization token
* @param params - the UI Interaction params
*/
swdcTracker.trackUIInteraction = function (params) { return __awaiter(void 0, void 0, void 0, function () {
var _uiInteractionPayload, contexts;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, new ui_interaction_1.UIInteraction(params).buildPayload()];
case 1:
_uiInteractionPayload = _a.sent();
return [4 /*yield*/, context_helper_1.buildContexts(params)];
case 2:
contexts = _a.sent();
return [4 /*yield*/, sendEvent(_uiInteractionPayload, contexts)];
case 3: return [2 /*return*/, _a.sent()];
}
});
}); };
function sendEvent(event_payload, contexts) {
return __awaiter(this, void 0, void 0, function () {
var eventResult;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (env_helper_1.isTestMode()) {
// test mode - console log the event
return [2 /*return*/, testEvent(event_payload, contexts)];
}
return [4 /*yield*/, swdcTracker.spTracker.trackUnstructEvent(event_payload, contexts)];
case 1:
eventResult = _a.sent();
if (eventResult && eventResult.add) {
return [2 /*return*/, response_1.success()];
}
return [2 /*return*/, response_1.error()];
}
});
});
}
function testEvent(properties, contexts) {

@@ -187,0 +159,0 @@ var event = {

{
"name": "swdc-tracker",
"version": "1.0.9",
"version": "1.0.10",
"description": "swdc event tracker",

@@ -5,0 +5,0 @@ "main": "dist",

@@ -27,2 +27,6 @@ import { hashValue } from "../utils/hash";

static hasData(data: FileInterface) {
return data.file_name && data.file_path;
}
async buildPayload() {

@@ -29,0 +33,0 @@

@@ -19,2 +19,6 @@ // The plugin entity

static hasData(data: PluginInterface) {
return data.plugin_id && data.plugin_version;
}
buildPayload() {

@@ -21,0 +25,0 @@ return {

@@ -18,2 +18,6 @@ import { hashValue } from "../utils/hash";

static hasData(data: ProjectInterface) {
return data.project_name && data.project_directory;
}
async buildPayload() {

@@ -20,0 +24,0 @@

@@ -27,2 +27,6 @@ import { hashValue } from "../utils/hash";

static hasData(data: RepoInterface) {
return data.repo_identifier;
}
async buildPayload() {

@@ -29,0 +33,0 @@

@@ -5,2 +5,3 @@ import { RepoInterface } from "../entities/repo";

import { PluginInterface } from "../entities/plugin";
import { AuthInterface } from "../entities/auth";

@@ -46,2 +47,6 @@ // The CodeTime event

static hasData(data: CodeTimeInterface) {
return data.start_time && data.start_time;
}
buildPayload() {

@@ -67,4 +72,3 @@

export interface CodeTimeParams extends PluginInterface, RepoInterface, ProjectInterface, FileInterface, CodeTimeInterface {
jwt: string
}
export interface CodeTimeParams extends
AuthInterface, PluginInterface, RepoInterface, ProjectInterface, FileInterface, CodeTimeInterface { }
import { PluginInterface } from "../entities/plugin";
import { FileInterface } from "../entities/file";
import { ProjectInterface } from "../entities/project";
import { AuthInterface } from "../entities/auth";

@@ -23,2 +24,6 @@ // The EditorAction event

static hasData(data: EditorActionInterface) {
return data.entity;
}
buildPayload() {

@@ -36,4 +41,3 @@ return {

export interface EditorActionParams extends PluginInterface, FileInterface, ProjectInterface, EditorActionInterface {
jwt: string
}
export interface EditorActionParams extends
AuthInterface, PluginInterface, FileInterface, ProjectInterface, EditorActionInterface { }
import { get } from "./utils/http";
import { CodeTimeParams, CodeTime } from "./events/codetime";
import { EditorActionParams, EditorAction } from "./events/editor_action";
import { Auth } from "./entities/auth";
import { Project } from "./entities/project";
import { Repo } from "./entities/repo";
import { File } from "./entities/file";
import { Plugin } from "./entities/plugin";
import { success, error, TrackerResponse } from "./utils/response";
import { isTestMode } from "./utils/env_helper";
import { UIInteractionParams, UIInteraction } from "./events/ui_interaction";
import { buildContexts } from "./utils/context_helper";

@@ -49,43 +46,20 @@ const snowplow = require("snowplow-tracker");

// build the strict types
// code time
const codetime: CodeTime = new CodeTime(params);
// project
const project: Project = new Project(params);
// repo
const repo: Repo = new Repo(params);
// file
const file: File = new File(params);
// plugin
const plugin: Plugin = new Plugin(params);
// auth
const auth: Auth = new Auth(params);
// build the contexts and event payload
const _codetimePayload: any = await new CodeTime(params).buildPayload();
const contexts: any = await buildContexts(params);
// create the payloads
const _codetimePayload = await codetime.buildPayload();
const _projecPayload = await project.buildPayload();
const _repoPayload = await repo.buildPayload();
const _filePayload = await file.buildPayload();
const _pluginPayload = await plugin.buildPayload();
const _authPayload = await auth.buildPayload();
return await sendEvent(_codetimePayload, contexts);
}
// crate the context with the authorization info
const contexts = [
_authPayload,
_codetimePayload,
_projecPayload,
_repoPayload,
_filePayload,
_pluginPayload
];
/**
* @param jwt - the authorization token
* @param editorActionEvent - the DomEvent properties (extends plugin, event_meta, and time_info)
*/
swdcTracker.trackEditorAction = async (params: EditorActionParams): Promise<any> => {
if (isTestMode()) {
// test mode - console log the event
return testEvent(_codetimePayload, contexts);
}
// build the contexts and event payload
const _editorActionPayload: any = await new EditorAction(params).buildPayload();
const contexts: any = await buildContexts(params);
// track the event.
// trackUnstrucEvent returns...
// {add <func(key, val)>, addDict <func(dict)>, addJson <func(keyIfEncoded, keyIfNotEncoded, json)>, build <func()>}
return await swdcTracker.spTracker.trackUnstructEvent(_codetimePayload, contexts);
return await sendEvent(_editorActionPayload, contexts);
}

@@ -95,42 +69,27 @@

* @param jwt - the authorization token
* @param editorActionEvent - the DomEvent properties (extends plugin, event_meta, and time_info)
* @param params - the UI Interaction params
*/
swdcTracker.trackEditorAction = async (params: EditorActionParams): Promise<any> => {
swdcTracker.trackUIInteraction = async (params: UIInteractionParams): Promise<any> => {
// build the strict types
const editorAction: EditorAction = new EditorAction(params);
// plugin
const plugin: Plugin = new Plugin(params);
// file
const file: File = new File(params);
// project
const project: Project = new Project(params);
// auth
const auth: Auth = new Auth(params);
// build the contexts and event payload
const _uiInteractionPayload: any = await new UIInteraction(params).buildPayload();
const contexts: any = await buildContexts(params);
// create the payload
const _editorActionPayload = await editorAction.buildPayload();
const _projecPayload = await project.buildPayload();
const _filePayload = await file.buildPayload();
const _pluginPayload = await plugin.buildPayload();
const _authPayload = await auth.buildPayload();
return await sendEvent(_uiInteractionPayload, contexts);
}
// crate the context with the authorization info
const contexts = [
_authPayload,
_editorActionPayload,
_pluginPayload,
_filePayload,
_projecPayload
];
async function sendEvent(event_payload: any, contexts: any): Promise<TrackerResponse> {
if (isTestMode()) {
// test mode - console log the event
return testEvent(_editorActionPayload, contexts);
return testEvent(event_payload, contexts);
}
// track the event.
// trackUnstrucEvent returns...
// trackUnstrucEvent returns a PayloadData type:
// {add <func(key, val)>, addDict <func(dict)>, addJson <func(keyIfEncoded, keyIfNotEncoded, json)>, build <func()>}
return await swdcTracker.spTracker.trackUnstructEvent(_editorActionPayload, contexts);
const eventResult: any = await swdcTracker.spTracker.trackUnstructEvent(event_payload, contexts);
if (eventResult && eventResult.add) {
return success();
}
return error();
}

@@ -137,0 +96,0 @@

@@ -55,2 +55,4 @@ import swdcTracker from "../../src/index";

const contexts = lastProcessedTestEvent.contexts;
// SCHEMA validation "codetime"
expect(props.schema).to.include("codetime");

@@ -57,0 +59,0 @@ expect(props.data.keystrokes).to.equal(20);

@@ -49,2 +49,4 @@ import swdcTracker from "../../src/index";

const contexts = lastProcessedTestEvent.contexts;
// SCHEMA validation "editor_action"
expect(props.schema).to.include("editor_action");

@@ -51,0 +53,0 @@ expect(props.data.type).to.equal("mouse");

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc