@ninetailed/experience.js-shared
Advanced tools
Comparing version 7.0.1-beta.0 to 7.1.0-beta.0
@@ -25,2 +25,4 @@ export * from './lib/types/Endpoints/CreateProfile'; | ||
export * from './lib/types/Profile/GeoLocation'; | ||
export * from './lib/types/SelectedVariantInfo/SelectedVariantInfo'; | ||
export * from './lib/types/SelectedVariantInfo/ProfileWithSelectedVariants'; | ||
export * from './lib/types/Session/SessionStatistics'; | ||
@@ -27,0 +29,0 @@ export * from './lib/types/ExperienceDefinition'; |
35
index.js
@@ -62,2 +62,8 @@ import { z } from 'zod'; | ||
const SelectedVariantInfo = z.object({ | ||
experienceId: z.string(), | ||
variantIndex: z.number(), | ||
variants: z.record(z.string()) | ||
}); | ||
const CreateProfileRequestBody = z.object({ | ||
@@ -71,3 +77,4 @@ // TODO | ||
data: z.object({ | ||
profile: Profile | ||
profile: Profile, | ||
experiences: z.array(SelectedVariantInfo) | ||
}), | ||
@@ -85,3 +92,4 @@ error: z.boolean().nullable() | ||
data: z.object({ | ||
profile: Profile | ||
profile: Profile, | ||
experiences: z.array(SelectedVariantInfo) | ||
}), | ||
@@ -134,2 +142,3 @@ error: z.boolean().nullable() | ||
const PROFILE_FALLBACK_CACHE = '__nt_profile__'; | ||
const EXPERIENCES_FALLBACK_CACHE = '__nt_experiences__'; | ||
const PROFILE_CHANGE = 'profile-change'; | ||
@@ -279,12 +288,10 @@ const PROFILE_RESET = 'profile-reset'; | ||
if (!profileId) { | ||
const profile = yield this.createProfile({ | ||
return this.createProfile({ | ||
events | ||
}, options); | ||
return profile; | ||
} else { | ||
const profile = yield this.updateProfile({ | ||
return this.updateProfile({ | ||
profileId: profileId, | ||
events | ||
}, options); | ||
return profile; | ||
} | ||
@@ -350,8 +357,6 @@ }); | ||
const { | ||
data: { | ||
profile | ||
} | ||
data | ||
} = CreateProfileResponse.parse(yield response.json()); | ||
logger.debug(`${requestName} request succesfully completed.`); | ||
return profile; | ||
return data; | ||
} catch (error) { | ||
@@ -384,8 +389,6 @@ this.logRequestError(error, { | ||
const { | ||
data: { | ||
profile | ||
} | ||
data | ||
} = UpdateProfileResponse.parse(yield response.json()); | ||
logger.debug(`${requestName} request successfully completed.`); | ||
return profile; | ||
return data; | ||
} catch (error) { | ||
@@ -587,3 +590,3 @@ this.logRequestError(error, { | ||
name: 'Ninetailed React Analytics SDK', | ||
version: "7.0.1-beta.0" | ||
version: "7.1.0-beta.0" | ||
}, | ||
@@ -813,2 +816,2 @@ userAgent: ctx.userAgent, | ||
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 }; | ||
export { ANONYMOUS_ID, Alias, Alpha2Code, CONSENT, Campaign, Component, ConsoleLogSink, CreateProfileRequestBody, CreateProfileResponse, DEBUG_FLAG, EMPTY_MERGE_ID, EXPERIENCES_FALLBACK_CACHE, 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, SelectedVariantInfo, 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 }; |
@@ -1,2 +0,2 @@ | ||
import type { Profile } from '../types/Profile/Profile'; | ||
import { ProfileWithSelectedVariants } from '../types/SelectedVariantInfo/ProfileWithSelectedVariants'; | ||
import type { Event } from '../types/Event/Event'; | ||
@@ -91,37 +91,3 @@ import { FetchImpl } from './FetchImpl'; | ||
private logRequestError; | ||
upsertProfile({ profileId, events }: UpsertProfileParams, options?: RequestOptions): Promise<{ | ||
location: { | ||
coordinates?: { | ||
latitude: number; | ||
longitude: number; | ||
} | undefined; | ||
city?: string | undefined; | ||
postalCode?: string | undefined; | ||
region?: string | undefined; | ||
regionCode?: string | undefined; | ||
country?: string | undefined; | ||
countryCode?: string | undefined; | ||
continent?: string | undefined; | ||
timezone?: string | undefined; | ||
}; | ||
traits: import("../..").Properties; | ||
id: string; | ||
stableId: string; | ||
random: number; | ||
audiences: string[]; | ||
session: { | ||
id: string; | ||
isReturningVisitor: boolean; | ||
landingPage: { | ||
url: string; | ||
path: string; | ||
query: Record<string, string>; | ||
referrer: string; | ||
search: string; | ||
}; | ||
count: number; | ||
activeSessionLength: number; | ||
averageSessionLength: number; | ||
}; | ||
}>; | ||
upsertProfile({ profileId, events }: UpsertProfileParams, options?: RequestOptions): Promise<ProfileWithSelectedVariants>; | ||
private makeRequest; | ||
@@ -133,3 +99,3 @@ /** | ||
*/ | ||
createProfile({ events }: CreateProfileParams, options?: RequestOptions): Promise<Profile>; | ||
createProfile({ events }: CreateProfileParams, options?: RequestOptions): Promise<ProfileWithSelectedVariants>; | ||
/** | ||
@@ -139,3 +105,3 @@ * Updates a profile with the given profileId. | ||
*/ | ||
updateProfile({ profileId, events }: UpdateProfileParams, options?: RequestOptions): Promise<Profile>; | ||
updateProfile({ profileId, events }: UpdateProfileParams, options?: RequestOptions): Promise<ProfileWithSelectedVariants>; | ||
/** | ||
@@ -142,0 +108,0 @@ * Sends multiple events to the Ninetailed API. |
@@ -5,2 +5,3 @@ export declare const LEGACY_ANONYMOUS_ID = "__anon_id"; | ||
export declare const PROFILE_FALLBACK_CACHE = "__nt_profile__"; | ||
export declare const EXPERIENCES_FALLBACK_CACHE = "__nt_experiences__"; | ||
export declare const PROFILE_CHANGE = "profile-change"; | ||
@@ -7,0 +8,0 @@ export declare const PROFILE_RESET = "profile-reset"; |
@@ -199,2 +199,15 @@ import { z } from 'zod'; | ||
}>; | ||
experiences: z.ZodArray<z.ZodObject<{ | ||
experienceId: z.ZodString; | ||
variantIndex: z.ZodNumber; | ||
variants: z.ZodRecord<z.ZodString, z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
experienceId: string; | ||
variantIndex: number; | ||
variants: Record<string, string>; | ||
}, { | ||
experienceId: string; | ||
variantIndex: number; | ||
variants: Record<string, string>; | ||
}>, "many">; | ||
}, "strip", z.ZodTypeAny, { | ||
@@ -236,2 +249,7 @@ profile: { | ||
}; | ||
experiences: { | ||
experienceId: string; | ||
variantIndex: number; | ||
variants: Record<string, string>; | ||
}[]; | ||
}, { | ||
@@ -273,2 +291,7 @@ profile: { | ||
}; | ||
experiences: { | ||
experienceId: string; | ||
variantIndex: number; | ||
variants: Record<string, string>; | ||
}[]; | ||
}>; | ||
@@ -314,2 +337,7 @@ error: z.ZodNullable<z.ZodBoolean>; | ||
}; | ||
experiences: { | ||
experienceId: string; | ||
variantIndex: number; | ||
variants: Record<string, string>; | ||
}[]; | ||
}; | ||
@@ -355,2 +383,7 @@ error: boolean | null; | ||
}; | ||
experiences: { | ||
experienceId: string; | ||
variantIndex: number; | ||
variants: Record<string, string>; | ||
}[]; | ||
}; | ||
@@ -357,0 +390,0 @@ error: boolean | null; |
@@ -199,2 +199,15 @@ import { z } from 'zod'; | ||
}>; | ||
experiences: z.ZodArray<z.ZodObject<{ | ||
experienceId: z.ZodString; | ||
variantIndex: z.ZodNumber; | ||
variants: z.ZodRecord<z.ZodString, z.ZodString>; | ||
}, "strip", z.ZodTypeAny, { | ||
experienceId: string; | ||
variantIndex: number; | ||
variants: Record<string, string>; | ||
}, { | ||
experienceId: string; | ||
variantIndex: number; | ||
variants: Record<string, string>; | ||
}>, "many">; | ||
}, "strip", z.ZodTypeAny, { | ||
@@ -236,2 +249,7 @@ profile: { | ||
}; | ||
experiences: { | ||
experienceId: string; | ||
variantIndex: number; | ||
variants: Record<string, string>; | ||
}[]; | ||
}, { | ||
@@ -273,2 +291,7 @@ profile: { | ||
}; | ||
experiences: { | ||
experienceId: string; | ||
variantIndex: number; | ||
variants: Record<string, string>; | ||
}[]; | ||
}>; | ||
@@ -314,2 +337,7 @@ error: z.ZodNullable<z.ZodBoolean>; | ||
}; | ||
experiences: { | ||
experienceId: string; | ||
variantIndex: number; | ||
variants: Record<string, string>; | ||
}[]; | ||
}; | ||
@@ -355,2 +383,7 @@ error: boolean | null; | ||
}; | ||
experiences: { | ||
experienceId: string; | ||
variantIndex: number; | ||
variants: Record<string, string>; | ||
}[]; | ||
}; | ||
@@ -357,0 +390,0 @@ error: boolean | null; |
{ | ||
"name": "@ninetailed/experience.js-shared", | ||
"version": "7.0.1-beta.0", | ||
"version": "7.1.0-beta.0", | ||
"devDependencies": { | ||
@@ -5,0 +5,0 @@ "@ninetailed/testing-utils": "*" |
Sorry, the diff of this file is not supported yet
131057
70
3680