Socket
Socket
Sign inDemoInstall

kepler-companion

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kepler-companion - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

12

index.d.ts

@@ -14,2 +14,10 @@ export declare type KeplerCompanionConfiguration = {

export declare type KeplerCompanionMode = 'browser' | 'node';
export declare type TrackingOpts = {
action: string;
product: string;
version: string;
tags?: {
[key: string]: string;
};
};
export default class KeplerCompanion {

@@ -21,6 +29,4 @@ config: KeplerCompanionConfiguration;

turnOff(): void;
track(action: string, product: string, version: string, tags?: {
[key: string]: string;
}): Promise<void>;
track(opts: TrackingOpts, timeout?: number): Promise<unknown>;
private _track;
}

@@ -64,11 +64,20 @@ "use strict";

}
track(action, product, version, tags = {}) {
track(opts, timeout = 1000) {
if (!this.config.analytics.enabled) {
return;
}
return this._track(action, product, version, tags);
const innerTrack = this._track.bind(this);
return Promise.race([
new Promise(() => {
try {
return innerTrack(opts);
}
catch (_) { /* Analytics should not interfer with user process */ }
}),
new Promise((resolve) => setTimeout(resolve, timeout))
]);
}
async _track(action, product, version, tags = {}) {
async _track(opts) {
const user = this.forgeUserID();
const url = `${this.server_url}?a=${action}&p=${product}&v=${version}&u=${user}`;
const url = `${this.server_url}?a=${opts.action}&p=${opts.product}&v=${opts.version}&u=${user}`;
const response = await (0, node_fetch_1.default)(url, {

@@ -79,3 +88,3 @@ method: 'POST',

},
body: JSON.stringify(tags),
body: JSON.stringify(opts.tags || {}),
});

@@ -88,2 +97,8 @@ if (!response.ok) {

exports.default = KeplerCompanion;
const a = new KeplerCompanion();
a.track({
action: 'test',
product: 'test',
version: 'test',
}).then();
//# sourceMappingURL=index.js.map
{
"name": "kepler-companion",
"version": "1.0.0",
"version": "1.0.1",
"description": "Kepler analytics toolkit for client side",

@@ -5,0 +5,0 @@ "main": "index.js",

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