New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

analytics-client

Package Overview
Dependencies
Maintainers
1
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

analytics-client - npm Package Compare versions

Comparing version 0.6.2 to 0.7.0-roman-web-e2089b3a99c072bae104dea6543ba889293fa4e9

5

CHANGELOG.md

@@ -7,2 +7,7 @@ # Change Log

# v0.7.0
## (2020-05-27)
* Add user ID and properties interface [Roman Mazur]
# v0.6.2

@@ -9,0 +14,0 @@ ## (2020-05-26)

2

dist/package.json
{
"name": "analytics-client",
"version": "0.6.2",
"version": "0.7.0-roman-web-e2089b3a99c072bae104dea6543ba889293fa4e9",
"description": "Convenient builders to compose analytics tools",

@@ -5,0 +5,0 @@ "repository": {

@@ -6,2 +6,6 @@ import amplitude = require('amplitude-js');

}
export interface UserProperties {
set?: Properties;
setOnce?: Properties;
}
export interface Client {

@@ -12,2 +16,4 @@ amplitude(): amplitude.AmplitudeClient;

track(eventType: string, props?: Properties): void;
setUserId(userId: string): void;
setUserProperties(props: UserProperties): void;
}

@@ -14,0 +20,0 @@ export interface Config {

@@ -60,3 +60,3 @@ "use strict";

var originalDeviceId = this.deviceId();
this.amplitudeInstance.setUserId(userId);
this.setUserId(userId);
var identifyData = identifyObject();

@@ -74,2 +74,19 @@ this.amplitudeInstance.identify(identifyData);

};
DefaultClient.prototype.setUserId = function (userId) {
this.amplitudeInstance.setUserId(userId);
};
DefaultClient.prototype.setUserProperties = function (props) {
var identify = new amplitude.Identify();
for (var key in props.set) {
if (props.set.hasOwnProperty(key)) {
identify.set(key, props.set[key]);
}
}
for (var key in props.setOnce) {
if (props.setOnce.hasOwnProperty(key)) {
identify.setOnce(key, props.setOnce[key]);
}
}
this.amplitudeInstance.identify(identify);
};
return DefaultClient;

@@ -76,0 +93,0 @@ }());

@@ -18,7 +18,12 @@ "use strict";

var identifyCallsCount = 0;
var setUserIdCallsCount = 0;
client.amplitude().identify = function () {
identifyCallsCount++;
};
client.amplitude().setUserId = function () {
setUserIdCallsCount++;
};
client.linkDevices('test-user', ['d1', 'd2']);
expect(identifyCallsCount).toBe(3);
expect(setUserIdCallsCount).toBe(1);
});

@@ -33,2 +38,22 @@ test('amplitude config', function () {

});
test('user properties', function () {
var client = client_1.createClient({
projectName: 'balena-test',
endpoint: "some.host",
componentName: 'test',
});
var callCount = 0;
client.amplitude().identify = function (obj) {
callCount++;
expect(obj.userPropertiesOperations).toStrictEqual({
$set: { p1: 'v1', p2: 'v2' },
$setOnce: { p3: 'v3', p4: 'v4' },
});
};
client.setUserProperties({
set: { p1: 'v1', p2: 'v2' },
setOnce: { p3: 'v3', p4: 'v4' },
});
expect(callCount).toBe(1);
});
//# sourceMappingURL=client.test.js.map
{
"name": "analytics-client",
"version": "0.6.2",
"version": "0.7.0-roman-web-e2089b3a99c072bae104dea6543ba889293fa4e9",
"description": "Convenient builders to compose analytics tools",

@@ -5,0 +5,0 @@ "repository": {

@@ -16,2 +16,7 @@ import amplitude = require('amplitude-js');

export interface UserProperties {
set?: Properties;
setOnce?: Properties;
}
/**

@@ -32,2 +37,7 @@ * Client defines an interface for interaction wih balena analytics backend.

track(eventType: string, props?: Properties): void;
/** Set current user ID. */
setUserId(userId: string): void;
setUserProperties(props: UserProperties): void;
}

@@ -125,3 +135,3 @@

const originalDeviceId = this.deviceId();
this.amplitudeInstance.setUserId(userId);
this.setUserId(userId);

@@ -145,2 +155,22 @@ const identifyData = identifyObject();

}
setUserId(userId: string) {
this.amplitudeInstance.setUserId(userId);
}
setUserProperties(props: UserProperties) {
const identify = new amplitude.Identify();
for (const key in props.set) {
if (props.set.hasOwnProperty(key)) {
identify.set(key, props.set[key]);
}
}
for (const key in props.setOnce) {
if (props.setOnce.hasOwnProperty(key)) {
identify.setOnce(key, props.setOnce[key]);
}
}
this.amplitudeInstance.identify(identify);
}
}

@@ -147,0 +177,0 @@

@@ -19,8 +19,13 @@ import { createClient } from '../src/client';

let identifyCallsCount = 0;
let setUserIdCallsCount = 0;
client.amplitude().identify = () => {
identifyCallsCount++;
};
client.amplitude().setUserId = () => {
setUserIdCallsCount++;
};
client.linkDevices('test-user', ['d1', 'd2']);
expect(identifyCallsCount).toBe(3); // Number of devices + original device ID.
expect(setUserIdCallsCount).toBe(1);
});

@@ -36,1 +41,22 @@

});
test('user properties', () => {
const client = createClient({
projectName: 'balena-test',
endpoint: `some.host`,
componentName: 'test',
});
let callCount = 0;
client.amplitude().identify = obj => {
callCount++;
expect((obj as any).userPropertiesOperations).toStrictEqual({
$set: { p1: 'v1', p2: 'v2' },
$setOnce: { p3: 'v3', p4: 'v4' },
});
};
client.setUserProperties({
set: { p1: 'v1', p2: 'v2' },
setOnce: { p3: 'v3', p4: 'v4' },
});
expect(callCount).toBe(1);
});

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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