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

@molassesapp/molasses-server

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@molassesapp/molasses-server - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

352

__tests__/index.test.ts

@@ -18,42 +18,44 @@ import { MolassesClient } from "../src"

const response: {
data: Feature[]
data: { features: Feature[] }
} = {
data: [
{
active: true,
description: "foo",
key: "FOO_TEST",
segments: [],
},
{
active: false,
description: "foo",
key: "FOO_FALSE_TEST",
segments: [],
},
{
active: true,
description: "foo",
key: "FOO_50_PERCENT_TEST",
segments: [
{
segmentType: SegmentType.everyoneElse,
percentage: 50,
userConstraints: [],
},
],
},
{
active: true,
description: "foo",
key: "FOO_0_PERCENT_TEST",
segments: [
{
segmentType: SegmentType.everyoneElse,
percentage: 0,
userConstraints: [],
},
],
},
],
data: {
features: [
{
active: true,
description: "foo",
key: "FOO_TEST",
segments: [],
},
{
active: false,
description: "foo",
key: "FOO_FALSE_TEST",
segments: [],
},
{
active: true,
description: "foo",
key: "FOO_50_PERCENT_TEST",
segments: [
{
segmentType: SegmentType.everyoneElse,
percentage: 50,
userConstraints: [],
},
],
},
{
active: true,
description: "foo",
key: "FOO_0_PERCENT_TEST",
segments: [
{
segmentType: SegmentType.everyoneElse,
percentage: 0,
userConstraints: [],
},
],
},
],
},
}

@@ -80,3 +82,3 @@

})
expect(mockAxios.get).toBeCalledWith("/v1/sdk/features", {
expect(mockAxios.get).toBeCalledWith("/get-features", {
headers: { Authorization: "Bearer testapikey" },

@@ -98,40 +100,42 @@ })

const response: {
data: Feature[]
data: { features: Feature[] }
} = {
data: [
{
active: true,
description: "foo",
key: "FOO_TEST",
segments: [
{
percentage: 100,
segmentType: SegmentType.alwaysControl,
userConstraints: [
{
userParam: "isScaredUser",
operator: Operator.in,
values: "true,maybe",
},
],
},
{
percentage: 100,
segmentType: SegmentType.alwaysExperiment,
userConstraints: [
{
userParam: "isBetaUser",
operator: Operator.equals,
values: "true",
},
],
},
{
percentage: 100,
segmentType: SegmentType.everyoneElse,
userConstraints: [],
},
],
},
],
data: {
features: [
{
active: true,
description: "foo",
key: "FOO_TEST",
segments: [
{
percentage: 100,
segmentType: SegmentType.alwaysControl,
userConstraints: [
{
userParam: "isScaredUser",
operator: Operator.in,
values: "true,maybe",
},
],
},
{
percentage: 100,
segmentType: SegmentType.alwaysExperiment,
userConstraints: [
{
userParam: "isBetaUser",
operator: Operator.equals,
values: "true",
},
],
},
{
percentage: 100,
segmentType: SegmentType.everyoneElse,
userConstraints: [],
},
],
},
],
},
}

@@ -182,3 +186,3 @@

})
expect(mockAxios.get).toBeCalledWith("/v1/sdk/features", {
expect(mockAxios.get).toBeCalledWith("/get-features", {
headers: { Authorization: "Bearer testapikey" },

@@ -191,40 +195,42 @@ })

const response: {
data: Feature[]
data: { features: Feature[] }
} = {
data: [
{
active: true,
description: "foo",
key: "FOO_TEST",
segments: [
{
percentage: 100,
segmentType: SegmentType.alwaysControl,
userConstraints: [
{
userParam: "isScaredUser",
operator: Operator.nin,
values: "false,maybe",
},
],
},
{
percentage: 100,
segmentType: SegmentType.alwaysExperiment,
userConstraints: [
{
userParam: "isBetaUser",
operator: Operator.doesNotEqual,
values: "false",
},
],
},
{
percentage: 100,
segmentType: SegmentType.everyoneElse,
userConstraints: [],
},
],
},
],
data: {
features: [
{
active: true,
description: "foo",
key: "FOO_TEST",
segments: [
{
percentage: 100,
segmentType: SegmentType.alwaysControl,
userConstraints: [
{
userParam: "isScaredUser",
operator: Operator.nin,
values: "false,maybe",
},
],
},
{
percentage: 100,
segmentType: SegmentType.alwaysExperiment,
userConstraints: [
{
userParam: "isBetaUser",
operator: Operator.doesNotEqual,
values: "false",
},
],
},
{
percentage: 100,
segmentType: SegmentType.everyoneElse,
userConstraints: [],
},
],
},
],
},
}

@@ -275,3 +281,3 @@

})
expect(mockAxios.get).toBeCalledWith("/v1/sdk/features", {
expect(mockAxios.get).toBeCalledWith("/get-features", {
headers: { Authorization: "Bearer testapikey" },

@@ -284,40 +290,59 @@ })

const response: {
data: Feature[]
data: { features: Feature[] }
} = {
data: [
{
active: true,
description: "foo",
key: "FOO_TEST",
segments: [
{
percentage: 100,
segmentType: SegmentType.alwaysControl,
userConstraints: [
{
userParam: "isScaredUser",
operator: Operator.contains,
values: "scared",
},
],
},
{
percentage: 100,
segmentType: SegmentType.alwaysExperiment,
userConstraints: [
{
userParam: "isBetaUser",
operator: Operator.doesNotContain,
values: "fal",
},
],
},
{
percentage: 100,
segmentType: SegmentType.everyoneElse,
userConstraints: [],
},
],
},
],
data: {
features: [
{
active: true,
description: "foo",
key: "FOO_TEST",
segments: [
{
percentage: 100,
segmentType: SegmentType.alwaysControl,
constraint: Operator.all,
userConstraints: [
{
userParam: "isScaredUser",
operator: Operator.contains,
values: "scared",
},
{
userParam: "isDefinitelyScaredUser",
operator: Operator.contains,
values: "scared",
},
{
userParam: "isMostDefinitelyScaredUser",
operator: Operator.contains,
values: "scared",
},
],
},
{
percentage: 100,
segmentType: SegmentType.alwaysExperiment,
constraint: Operator.any,
userConstraints: [
{
userParam: "isBetaUser",
operator: Operator.doesNotContain,
values: "fal",
},
{
userParam: "isDefinitelyBetaUser",
operator: Operator.doesNotContain,
values: "fal",
},
],
},
{
percentage: 100,
segmentType: SegmentType.everyoneElse,
userConstraints: [],
},
],
},
],
},
}

@@ -353,2 +378,21 @@

}),
).toBeTruthy()
expect(
client.isActive("FOO_TEST", {
id: "123",
params: {
isScaredUser: "i am very scared man",
isDefinitelyScaredUser: "i am very scared man",
},
}),
).toBeTruthy()
expect(
client.isActive("FOO_TEST", {
id: "123",
params: {
isScaredUser: "i am very scared man",
isDefinitelyScaredUser: "i am very scared man",
isMostDefinitelyScaredUser: "i am very scared man",
},
}),
).toBeFalsy()

@@ -369,3 +413,3 @@

})
expect(mockAxios.get).toBeCalledWith("/v1/sdk/features", {
expect(mockAxios.get).toBeCalledWith("/get-features", {
headers: { Authorization: "Bearer testapikey" },

@@ -372,0 +416,0 @@ })

@@ -6,2 +6,13 @@ # Change Log

## [0.3.1](https://github.com/molassesapp/molasses-node/compare/v0.3.0...v0.3.1) (2020-07-25)
### Bug Fixes
* use api.molasses.app/v1 for base route ([d246dc3](https://github.com/molassesapp/molasses-node/commit/d246dc36be3fd8e3e4e60ec1c3ea9f22ebb21e2b))
# [0.3.0](https://github.com/molassesapp/molasses-node/compare/v0.2.7...v0.3.0) (2020-07-25)

@@ -8,0 +19,0 @@

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

APIKey: "",
URL: "https://www.molasses.app",
URL: "https://api.molasses.app/v1",
debug: false,

@@ -102,3 +102,3 @@ sendEvents: true,

var data = __assign(__assign({}, eventOptions), { tags: JSON.stringify(eventOptions.tags) });
axios_1.default.post("https://us-central1-molasses-36bff.cloudfunctions.net/analytics", data, {
this.axios.post("/analytics", data, {
headers: headers,

@@ -114,3 +114,3 @@ });

return this.axios
.get("/v1/sdk/features", {
.get("/get-features", {
headers: headers,

@@ -123,4 +123,4 @@ })

}
if (response.data && response.data.data) {
var jsonData = response.data.data;
if (response.data && response.data.data && response.data.data.features) {
var jsonData = response.data.data.features;
_this.featuresCache = jsonData.reduce(function (acc, value) {

@@ -127,0 +127,0 @@ acc[value.key] = value;

{
"name": "@molassesapp/molasses-server",
"version": "0.3.0",
"version": "0.3.1",
"description": "A Node (with TypeScript support) SDK for Molasses. It allows you to evaluate user's status for a feature. It also helps simplify logging events for A/B testing.",

@@ -25,3 +25,3 @@ "main": "dist/index.js",

},
"gitHead": "1ed9670de84fd070f6049e644a29e73fae0e14ad"
"gitHead": "3afc06bc8ba1719b93c3b1c793bbe4b9b70e8451"
}

@@ -28,3 +28,3 @@ import axios, { AxiosInstance, AxiosResponse } from "axios"

APIKey: "",
URL: "https://www.molasses.app",
URL: "https://api.molasses.app/v1",
debug: false,

@@ -129,3 +129,3 @@ sendEvents: true,

}
axios.post("https://us-central1-molasses-36bff.cloudfunctions.net/analytics", data, {
this.axios.post("/analytics", data, {
headers,

@@ -141,3 +141,3 @@ })

return this.axios
.get("/v1/sdk/features", {
.get("/get-features", {
headers,

@@ -151,4 +151,4 @@ })

if (response.data && response.data.data) {
const jsonData: Feature[] = response.data.data
if (response.data && response.data.data && response.data.data.features) {
const jsonData: Feature[] = response.data.data.features
this.featuresCache = jsonData.reduce<{ [key: string]: Feature }>(

@@ -155,0 +155,0 @@ (acc, value: Feature) => {

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