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

swdc-tracker

Package Overview
Dependencies
Maintainers
5
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.19 to 1.0.20

41

dist/index.js

@@ -73,3 +73,7 @@ "use strict";

tracker_api_host = result.data.tracker_api;
e = emitter(tracker_api_host, 'https', null, 'post', 0);
e = emitter(tracker_api_host, "https", null, "post", 0, function (error, body, response) {
if (error) {
console.log("swdc-tracker collector stream error", error);
}
});
swdcTracker.spTracker = tracker([e], namespace, appId, false);

@@ -149,18 +153,25 @@ swdcTracker.spTracker.setPlatform('iot');

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()];
if (env_helper_1.isTestMode()) {
// test mode - console log the event
return [2 /*return*/, testEvent(event_payload, contexts)];
}
try {
/**
* trackUnstructEvent takes the following:
* properties => json of {schema, data} (required)
* context => list of event contexts (optional)
* tstamp => positive integer (optional)
*/
// The track logic is not async, no need to have an await,
// "track()" will perform a callback on the payload data but does not return
// a promise based on that.
// "function track(sb: PayloadData, context?: Array<SelfDescribingJson>, tstamp?: Timestamp): PayloadData {"
swdcTracker.spTracker.trackUnstructEvent(event_payload, contexts);
}
catch (e) {
// We may get IPIPE, or ECONNRESET. Log it.
console.log("swdc-tracker unstruct track event error", e);
}
return [2 /*return*/, response_1.success()];
});

@@ -167,0 +178,0 @@ });

@@ -66,2 +66,3 @@ "use strict";

// at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
console.log("swdc-tracker get request error", e);
return e;

@@ -85,2 +86,3 @@ })];

return [4 /*yield*/, axiosClient.post(endpoint, body).catch(function (e) {
console.log("swdc-tracker post request error", e);
return e;

@@ -87,0 +89,0 @@ })];

{
"name": "swdc-tracker",
"version": "1.0.19",
"version": "1.0.20",
"description": "swdc event tracker",

@@ -33,2 +33,2 @@ "main": "dist",

}
}
}

@@ -25,3 +25,8 @@ import { setBaseUrl, get } from "./utils/http";

// initialize snowplow tracker
const e = emitter(tracker_api_host, 'https', null, 'post', 0)
// endpoint, protocol, optional port, method, buffer events, request callback
const e = emitter(tracker_api_host, "https", null, "post", 0, function (error: any, body: any, response: any) {
if (error) {
console.log("swdc-tracker collector stream error", error);
}
});

@@ -32,3 +37,2 @@ swdcTracker.spTracker = tracker([e], namespace, appId, false)

if (isTestMode()) {

@@ -90,10 +94,20 @@ console.log('swdc-tracker test mode on. set env ENABLE_SWDC_TRACKER to "true" to send events');

// trackUnstrucEvent returns a PayloadData type:
// {add <func(key, val)>, addDict <func(dict)>, addJson <func(keyIfEncoded, keyIfNotEncoded, json)>, build <func()>}
const eventResult: any = await swdcTracker.spTracker.trackUnstructEvent(event_payload, contexts);
try {
/**
* trackUnstructEvent takes the following:
* properties => json of {schema, data} (required)
* context => list of event contexts (optional)
* tstamp => positive integer (optional)
*/
// The track logic is not async, no need to have an await,
// "track()" will perform a callback on the payload data but does not return
// a promise based on that.
// "function track(sb: PayloadData, context?: Array<SelfDescribingJson>, tstamp?: Timestamp): PayloadData {"
swdcTracker.spTracker.trackUnstructEvent(event_payload, contexts);
} catch (e) {
// We may get IPIPE, or ECONNRESET. Log it.
console.log("swdc-tracker unstruct track event error", e);
}
if (eventResult && eventResult.add) {
return success();
}
return error();
return success();
}

@@ -100,0 +114,0 @@

@@ -22,2 +22,3 @@ import axios from "axios";

// at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
console.log("swdc-tracker get request error", e);
return e;

@@ -31,2 +32,3 @@ });

const result = await axiosClient.post(endpoint, body).catch((e: any) => {
console.log("swdc-tracker post request error", e);
return e;

@@ -33,0 +35,0 @@ });

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