@ninetailed/experience.js-shared
Advanced tools
Comparing version 6.2.1 to 6.3.0-beta.0
@@ -57,3 +57,2 @@ export * from './lib/types/Endpoints/CreateProfile'; | ||
export * from './lib/utils/experiences/selectDistribution'; | ||
export * from './lib/utils/experiences/selectEligibleExperiences'; | ||
export * from './lib/utils/experiences/selectExperience'; | ||
@@ -60,0 +59,0 @@ export * from './lib/utils/experiences/selectHasVariants'; |
33
index.js
@@ -580,3 +580,3 @@ import { z } from 'zod'; | ||
name: 'Ninetailed React Analytics SDK', | ||
version: "6.2.1" | ||
version: "6.3.0-beta.0" | ||
}, | ||
@@ -680,3 +680,2 @@ userAgent: ctx.userAgent, | ||
experience, | ||
activeExperiments, | ||
profile | ||
@@ -688,9 +687,5 @@ }) => { | ||
const matchesAudience = !experience.audience || profile.audiences.includes(experience.audience.id); | ||
const hasActiveExperiment = activeExperiments.some(activeExperiement => activeExperiement.id === experience.id); | ||
logger.info(`Is the profile in traffic allocation range? ${isInTrafficRange ? 'yes' : 'no'}.\n | ||
Does the profile match the audience of the experience? ${matchesAudience ? 'yes' : 'no'}.\n | ||
Is there an active experiment for this profile? ${hasActiveExperiment ? 'yes' : 'no'}.`); | ||
return isInTrafficRange && (matchesAudience || | ||
// if the expriment is active already then it's selectible without further contraints to be fullfilled | ||
hasActiveExperiment); | ||
Does the profile match the audience of the experience? ${matchesAudience ? 'yes' : 'no'}.\n`); | ||
return isInTrafficRange && matchesAudience; | ||
}; | ||
@@ -743,26 +738,8 @@ | ||
/** | ||
* We can use any personalization as eligible experience | ||
* When going for an experiment we can only select a active experiment when 1 or more experiments are active | ||
* If the profile is not in any active experiments, we can select any expermiment | ||
*/ | ||
const selectEligibleExperiences = ({ | ||
experiences, | ||
activeExperiments | ||
}) => { | ||
return experiences.filter(experience => experience.type === 'nt_personalization' || activeExperiments.length === 0 || activeExperiments.some(activeExperiment => activeExperiment.id === experience.id)); | ||
}; | ||
const selectExperience = ({ | ||
experiences, | ||
activeExperiments, | ||
profile | ||
}) => { | ||
const eligibleExperiences = selectEligibleExperiences({ | ||
experiences, | ||
activeExperiments | ||
}); | ||
const selectedExperience = eligibleExperiences.find(experience => isExperienceMatch({ | ||
const selectedExperience = experiences.find(experience => isExperienceMatch({ | ||
experience, | ||
activeExperiments, | ||
profile | ||
@@ -832,2 +809,2 @@ })); | ||
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, 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, selectExperience, selectHasVariants, selectVariant, selectVariants, template, unionBy }; |
@@ -5,6 +5,5 @@ import type { Profile } from '../../types/Profile/Profile'; | ||
experience: ExperienceConfiguration<any>; | ||
activeExperiments: ExperienceConfiguration<any>[]; | ||
profile: Profile; | ||
}; | ||
export declare const isExperienceMatch: ({ experience, activeExperiments, profile, }: IsExperienceMatchArgs) => boolean; | ||
export declare const isExperienceMatch: ({ experience, profile, }: IsExperienceMatchArgs) => boolean; | ||
export {}; |
@@ -5,6 +5,5 @@ import { ExperienceConfiguration, Reference } from '../../types/ExperienceDefinition'; | ||
experiences: ExperienceConfiguration<Variant>[]; | ||
activeExperiments: ExperienceConfiguration<Variant>[]; | ||
profile: Profile; | ||
}; | ||
export declare const selectExperience: <Variant extends Reference>({ experiences, activeExperiments, profile, }: SelectExprienceArgs<Variant>) => ExperienceConfiguration<Variant> | null; | ||
export declare const selectExperience: <Variant extends Reference>({ experiences, profile, }: SelectExprienceArgs<Variant>) => ExperienceConfiguration<Variant> | null; | ||
export {}; |
{ | ||
"name": "@ninetailed/experience.js-shared", | ||
"version": "6.2.1", | ||
"version": "6.3.0-beta.0", | ||
"devDependencies": { | ||
@@ -5,0 +5,0 @@ "@ninetailed/testing-utils": "*" |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
128419
68
3618
2