Socket
Socket
Sign inDemoInstall

@ninetailed/experience.js-shared

Package Overview
Dependencies
Maintainers
2
Versions
374
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ninetailed/experience.js-shared - npm Package Compare versions

Comparing version 4.3.0-beta.3 to 4.4.0-beta.1

lib/utils/experiences/isExperienceSticky.d.ts

5

index.d.ts
export * from './lib/types/Endpoints/CreateProfile';
export * from './lib/types/Endpoints/UpdateProfile';
export * from './lib/types/Endpoints/UpsertManyProfiles';
export * from './lib/types/Endpoints/RequestBodyOptions';
export * from './lib/types/Event/Event';

@@ -19,3 +18,2 @@ export * from './lib/types/Event/PageviewEvent';

export * from './lib/types/Event/NinetailedRequestContext';
export * from './lib/types/Event/SharedEventProperties';
export * from './lib/types/generic/Json';

@@ -32,3 +30,2 @@ export * from './lib/types/Localization/Locale';

export type { FetchImpl } from './lib/api/FetchImpl';
export { fetchTimeout } from './lib/api/fetch-timeout';
export { Logger, logger } from './lib/logger/Logger';

@@ -41,3 +38,2 @@ export { ConsoleLogSink } from './lib/logger/ConsoleLogSink';

export type { OnErrorHandler } from './lib/logger/OnErrorLogSink';
export * from './lib/event/build-event';
export * from './lib/event/build-query';

@@ -65,1 +61,2 @@ export * from './lib/event/build-campaign';

export * from './lib/utils/experiences/selectVariants';
export * from './lib/utils/experiences/isExperienceSticky';

48

index.js

@@ -19,3 +19,2 @@ import { z } from 'zod';

const SessionStatistics = z.object({
id: z.string(),
isReturningVisitor: z.boolean(),

@@ -51,3 +50,2 @@ landingPage: Page,

id: z.string(),
stableId: z.string(),
random: z.number(),

@@ -127,3 +125,2 @@ audiences: z.array(z.string()),

const Alias = 'alias';
const Component = 'component';

@@ -583,3 +580,3 @@ const LEGACY_ANONYMOUS_ID = '__anon_id';

name: 'Ninetailed React Analytics SDK',
version: "4.3.0-beta.3"
version: "4.4.0-beta.1"
},

@@ -597,3 +594,2 @@ userAgent: ctx.userAgent,

originalTimestamp: date,
timestamp: date,
sentAt: date,

@@ -709,5 +705,9 @@ type

};
const selectActiveExperiments = (experiments, profile) => {
const selectActiveExperimentIds = profile => {
const experimentTraits = pickExperimentTraits(profile);
const experimentTraitsIds = Object.keys(experimentTraits).map(id => id.replace(EXPERIENCE_TRAIT_PREFIX, ''));
return experimentTraitsIds;
};
const selectActiveExperiments = (experiments, profile) => {
const experimentTraitsIds = selectActiveExperimentIds(profile);
// a experiment is active when the use has it set as a true value on the traits and the experiment config is still active

@@ -751,2 +751,7 @@ const activeExperiments = experiments.filter(experiment => experimentTraitsIds.includes(experiment.id));

*/
/**
* @deprecated
*
* This function will get removed in SDK version 5 as a maximum limit of experiments will not be supported anymore.
*/
const selectEligibleExperiences = ({

@@ -764,7 +769,3 @@ experiences,

}) => {
const eligibleExperiences = selectEligibleExperiences({
experiences,
activeExperiments
});
const selectedExperience = eligibleExperiences.find(experience => isExperienceMatch({
const selectedExperience = experiences.find(experience => isExperienceMatch({
experience,

@@ -790,2 +791,9 @@ activeExperiments,

const isExperienceSticky = experience => {
if ('isSticky' in experience) {
return experience.isSticky;
}
return false;
};
const selectVariant = ({

@@ -800,2 +808,18 @@ baseline,

}
const activeExperimentVariantId = profile.traits[`${EXPERIENCE_TRAIT_PREFIX}${experience.id}`];
const isActiveExperiment = typeof activeExperimentVariantId === 'string';
if (isExperienceSticky(experience) && isActiveExperiment && activeExperimentVariantId === 'hidden') {
return {
id: 'hidden',
hidden: true
};
}
if (isExperienceSticky(experience) && isActiveExperiment) {
const activeVariant = variants.find(variant => variant.id === activeExperimentVariantId);
if (activeVariant) {
return activeVariant;
}
// if there is no active variant, e.g. the variant mapping changed - we can reassign a new variant.
}
const distribution = selectDistribution({

@@ -826,2 +850,2 @@ experience,

export { ANONYMOUS_ID, Alias, Alpha2Code, CONSENT, Campaign, Component, ConsoleLogSink, CreateProfileRequestBody, CreateProfileResponse, DEBUG_FLAG, EMPTY_MERGE_ID, EXPERIENCE_TRAIT_PREFIX, FEATURES, GeoLocation, Group, Identify, Json, JsonLiteral, JsonLiteralObject, JsonObject, LEGACY_ANONYMOUS_ID, Logger, NINETAILED_ANONYMOUS_ID_COOKIE, NinetailedApiClient, OnErrorLogSink, OnLogLogSink, PROFILE_CHANGE, PROFILE_FALLBACK_CACHE, PROFILE_RESET, Page, Pageview, PageviewProperties, Profile, JsonObject as Properties, Query, RequestBodyOptions, SET_ENABLED_FEATURES, Screen, SessionStatistics, Track, JsonObject as Traits, UpdateProfileRequestBody, UpdateProfileResponse, UpsertManyProfilesRequestBody, UpsertManyProfilesResponse, buildCampaign, buildEvent, buildIdentifyEvent, buildPage, buildPageEvent, buildQuery, buildTrackEvent, fetchTimeout, getDistributionRandom, getTrafficRandom, isBrowser, isExperienceMatch, logger, pickBy, pickExperimentTraits, pipe, selectActiveExperiments, selectBaselineWithVariants, selectDistribution, selectEligibleExperiences, selectExperience, selectHasVariants, selectVariant, selectVariants, template, unionBy };
export { ANONYMOUS_ID, Alias, Alpha2Code, CONSENT, Campaign, ConsoleLogSink, CreateProfileRequestBody, CreateProfileResponse, DEBUG_FLAG, EMPTY_MERGE_ID, EXPERIENCE_TRAIT_PREFIX, FEATURES, GeoLocation, Group, Identify, Json, JsonLiteral, JsonLiteralObject, JsonObject, LEGACY_ANONYMOUS_ID, Logger, NINETAILED_ANONYMOUS_ID_COOKIE, NinetailedApiClient, OnErrorLogSink, OnLogLogSink, PROFILE_CHANGE, PROFILE_FALLBACK_CACHE, PROFILE_RESET, Page, Pageview, PageviewProperties, Profile, JsonObject as Properties, Query, SET_ENABLED_FEATURES, Screen, SessionStatistics, Track, JsonObject as Traits, UpdateProfileRequestBody, UpdateProfileResponse, UpsertManyProfilesRequestBody, UpsertManyProfilesResponse, buildCampaign, buildIdentifyEvent, buildPage, buildPageEvent, buildQuery, buildTrackEvent, getDistributionRandom, getTrafficRandom, isBrowser, isExperienceMatch, isExperienceSticky, logger, pickBy, pickExperimentTraits, pipe, selectActiveExperimentIds, selectActiveExperiments, selectBaselineWithVariants, selectDistribution, selectEligibleExperiences, selectExperience, selectHasVariants, selectVariant, selectVariants, template, unionBy };

@@ -108,7 +108,5 @@ import type { Profile } from '../types/Profile/Profile';

id: string;
stableId: string;
random: number;
audiences: string[];
session: {
id: string;
isReturningVisitor: boolean;

@@ -163,7 +161,5 @@ landingPage: {

id: string;
stableId: string;
random: number;
audiences: string[];
session: {
id: string;
isReturningVisitor: boolean;

@@ -170,0 +166,0 @@ landingPage: {

@@ -28,3 +28,2 @@ import { z } from 'zod';

id: z.ZodString;
stableId: z.ZodString;
random: z.ZodNumber;

@@ -80,3 +79,2 @@ audiences: z.ZodArray<z.ZodString, "many">;

session: z.ZodObject<{
id: z.ZodString;
isReturningVisitor: z.ZodBoolean;

@@ -106,3 +104,2 @@ landingPage: z.ZodObject<{

}, "strip", z.ZodTypeAny, {
id: string;
isReturningVisitor: boolean;

@@ -120,3 +117,2 @@ landingPage: {

}, {
id: string;
isReturningVisitor: boolean;

@@ -136,3 +132,2 @@ landingPage: {

id: string;
stableId: string;
random: number;

@@ -156,3 +151,2 @@ audiences: string[];

session: {
id: string;
isReturningVisitor: boolean;

@@ -172,3 +166,2 @@ landingPage: {

id: string;
stableId: string;
random: number;

@@ -192,3 +185,2 @@ audiences: string[];

session: {
id: string;
isReturningVisitor: boolean;

@@ -210,3 +202,2 @@ landingPage: {

id: string;
stableId: string;
random: number;

@@ -230,3 +221,2 @@ audiences: string[];

session: {
id: string;
isReturningVisitor: boolean;

@@ -248,3 +238,2 @@ landingPage: {

id: string;
stableId: string;
random: number;

@@ -268,3 +257,2 @@ audiences: string[];

session: {
id: string;
isReturningVisitor: boolean;

@@ -290,3 +278,2 @@ landingPage: {

id: string;
stableId: string;
random: number;

@@ -310,3 +297,2 @@ audiences: string[];

session: {
id: string;
isReturningVisitor: boolean;

@@ -332,3 +318,2 @@ landingPage: {

id: string;
stableId: string;
random: number;

@@ -352,3 +337,2 @@ audiences: string[];

session: {
id: string;
isReturningVisitor: boolean;

@@ -355,0 +339,0 @@ landingPage: {

@@ -28,3 +28,2 @@ import { z } from 'zod';

id: z.ZodString;
stableId: z.ZodString;
random: z.ZodNumber;

@@ -80,3 +79,2 @@ audiences: z.ZodArray<z.ZodString, "many">;

session: z.ZodObject<{
id: z.ZodString;
isReturningVisitor: z.ZodBoolean;

@@ -106,3 +104,2 @@ landingPage: z.ZodObject<{

}, "strip", z.ZodTypeAny, {
id: string;
isReturningVisitor: boolean;

@@ -120,3 +117,2 @@ landingPage: {

}, {
id: string;
isReturningVisitor: boolean;

@@ -136,3 +132,2 @@ landingPage: {

id: string;
stableId: string;
random: number;

@@ -156,3 +151,2 @@ audiences: string[];

session: {
id: string;
isReturningVisitor: boolean;

@@ -172,3 +166,2 @@ landingPage: {

id: string;
stableId: string;
random: number;

@@ -192,3 +185,2 @@ audiences: string[];

session: {
id: string;
isReturningVisitor: boolean;

@@ -210,3 +202,2 @@ landingPage: {

id: string;
stableId: string;
random: number;

@@ -230,3 +221,2 @@ audiences: string[];

session: {
id: string;
isReturningVisitor: boolean;

@@ -248,3 +238,2 @@ landingPage: {

id: string;
stableId: string;
random: number;

@@ -268,3 +257,2 @@ audiences: string[];

session: {
id: string;
isReturningVisitor: boolean;

@@ -290,3 +278,2 @@ landingPage: {

id: string;
stableId: string;
random: number;

@@ -310,3 +297,2 @@ audiences: string[];

session: {
id: string;
isReturningVisitor: boolean;

@@ -332,3 +318,2 @@ landingPage: {

id: string;
stableId: string;
random: number;

@@ -352,3 +337,2 @@ audiences: string[];

session: {
id: string;
isReturningVisitor: boolean;

@@ -355,0 +339,0 @@ landingPage: {

@@ -28,3 +28,2 @@ import { z } from 'zod';

id: z.ZodString;
stableId: z.ZodString;
random: z.ZodNumber;

@@ -80,3 +79,2 @@ audiences: z.ZodArray<z.ZodString, "many">;

session: z.ZodObject<{
id: z.ZodString;
isReturningVisitor: z.ZodBoolean;

@@ -106,3 +104,2 @@ landingPage: z.ZodObject<{

}, "strip", z.ZodTypeAny, {
id: string;
isReturningVisitor: boolean;

@@ -120,3 +117,2 @@ landingPage: {

}, {
id: string;
isReturningVisitor: boolean;

@@ -136,3 +132,2 @@ landingPage: {

id: string;
stableId: string;
random: number;

@@ -156,3 +151,2 @@ audiences: string[];

session: {
id: string;
isReturningVisitor: boolean;

@@ -172,3 +166,2 @@ landingPage: {

id: string;
stableId: string;
random: number;

@@ -192,3 +185,2 @@ audiences: string[];

session: {
id: string;
isReturningVisitor: boolean;

@@ -210,3 +202,2 @@ landingPage: {

id: string;
stableId: string;
random: number;

@@ -230,3 +221,2 @@ audiences: string[];

session: {
id: string;
isReturningVisitor: boolean;

@@ -248,3 +238,2 @@ landingPage: {

id: string;
stableId: string;
random: number;

@@ -268,3 +257,2 @@ audiences: string[];

session: {
id: string;
isReturningVisitor: boolean;

@@ -290,3 +278,2 @@ landingPage: {

id: string;
stableId: string;
random: number;

@@ -310,3 +297,2 @@ audiences: string[];

session: {
id: string;
isReturningVisitor: boolean;

@@ -332,3 +318,2 @@ landingPage: {

id: string;
stableId: string;
random: number;

@@ -352,3 +337,2 @@ audiences: string[];

session: {
id: string;
isReturningVisitor: boolean;

@@ -355,0 +339,0 @@ landingPage: {

@@ -7,3 +7,2 @@ export declare const Pageview = "page";

export declare const Alias = "alias";
export declare const Component = "component";
export type Pageview = typeof Pageview;

@@ -15,3 +14,2 @@ export type Track = typeof Track;

export type Alias = typeof Alias;
export type Component = typeof Component;
export type EventType = Pageview | Track | Identify | Screen | Group | Alias | Component;
export type EventType = Pageview | Track | Identify | Screen | Group | Alias;

@@ -28,3 +28,2 @@ import type { GeoLocation } from '../Profile/GeoLocation';

originalTimestamp: string;
timestamp: string;
sentAt: string;

@@ -31,0 +30,0 @@ type: EventType;

@@ -17,3 +17,4 @@ import { BaselineWithVariants } from './BaselineWithVariants';

distribution: Distribution[];
isSticky?: boolean;
components: BaselineWithVariants<Variant>[];
};

@@ -5,3 +5,2 @@ import { z } from 'zod';

id: z.ZodString;
stableId: z.ZodString;
random: z.ZodNumber;

@@ -57,3 +56,2 @@ audiences: z.ZodArray<z.ZodString, "many">;

session: z.ZodObject<{
id: z.ZodString;
isReturningVisitor: z.ZodBoolean;

@@ -83,3 +81,2 @@ landingPage: z.ZodObject<{

}, "strip", z.ZodTypeAny, {
id: string;
isReturningVisitor: boolean;

@@ -97,3 +94,2 @@ landingPage: {

}, {
id: string;
isReturningVisitor: boolean;

@@ -113,3 +109,2 @@ landingPage: {

id: string;
stableId: string;
random: number;

@@ -133,3 +128,2 @@ audiences: string[];

session: {
id: string;
isReturningVisitor: boolean;

@@ -149,3 +143,2 @@ landingPage: {

id: string;
stableId: string;
random: number;

@@ -169,3 +162,2 @@ audiences: string[];

session: {
id: string;
isReturningVisitor: boolean;

@@ -172,0 +164,0 @@ landingPage: {

import { z } from 'zod';
export declare const SessionStatistics: z.ZodObject<{
id: z.ZodString;
isReturningVisitor: z.ZodBoolean;

@@ -28,3 +27,2 @@ landingPage: z.ZodObject<{

}, "strip", z.ZodTypeAny, {
id: string;
isReturningVisitor: boolean;

@@ -42,3 +40,2 @@ landingPage: {

}, {
id: string;
isReturningVisitor: boolean;

@@ -45,0 +42,0 @@ landingPage: {

import { Profile } from '../../types/Profile/Profile';
import { ExperienceConfiguration, Reference } from '../../types/ExperienceDefinition';
export declare const pickExperimentTraits: (profile: Profile) => Record<string, boolean>;
export declare const selectActiveExperimentIds: (profile: Profile) => string[];
export declare const selectActiveExperiments: <Variant extends Reference>(experiments: ExperienceConfiguration<Variant>[], profile: Profile) => ExperienceConfiguration<Variant>[];

@@ -11,3 +11,8 @@ import { ExperienceConfiguration, Reference } from '../../types/ExperienceDefinition';

*/
/**
* @deprecated
*
* This function will get removed in SDK version 5 as a maximum limit of experiments will not be supported anymore.
*/
export declare const selectEligibleExperiences: <Variant extends Reference>({ experiences, activeExperiments, }: SelectEligibleExperiencesArgs<Variant>) => ExperienceConfiguration<Variant>[];
export {};
{
"name": "@ninetailed/experience.js-shared",
"version": "4.3.0-beta.3",
"version": "4.4.0-beta.1",
"devDependencies": {

@@ -5,0 +5,0 @@ "@ninetailed/testing-utils": "*"

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