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

@ninetailed/experience.js

Package Overview
Dependencies
Maintainers
2
Versions
363
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ninetailed/experience.js - npm Package Compare versions

Comparing version 7.6.0-beta.5 to 7.6.0-beta.6

src/lib/test-helpers/intersection-observer-test-helper.d.ts

56

index.cjs.js

@@ -123,2 +123,5 @@ 'use strict';

this.buildContext = buildClientNinetailedRequestContext;
this.getComponentViewTrackingThreshold = () => {
return 0;
};
this[_a] = ({

@@ -271,5 +274,2 @@ payload

}
getComponentViewTrackingThreshold() {
return 0;
}
onTrackExperience(properties) {

@@ -600,6 +600,2 @@ return __awaiter(this, void 0, void 0, function* () {

const hasComponentViewTrackingThreshold = arg => {
return typeof arg === 'object' && arg !== null && 'getComponentViewTrackingThreshold' in arg && typeof arg['getComponentViewTrackingThreshold'] === 'function';
};
const buildOverrideMiddleware = experienceSelectionMiddleware => _a => {

@@ -760,3 +756,5 @@ var {

return this.instance.dispatch(Object.assign(Object.assign({}, properties), {
type: experience_jsPluginAnalytics.HAS_SEEN_ELEMENT
type: experience_jsPluginAnalytics.HAS_SEEN_ELEMENT,
// TODO this is a temporary solution - to not make the user specify a delay
seenFor: this.componentViewTrackingThreshold
}));

@@ -775,5 +773,16 @@ };

} else {
this.observedElements.set(element, remaingPayload);
const existingPayloads = this.observedElements.get(element);
const delays = this.pluginsWithCustomComponentViewThreshold.map(plugin => plugin.getComponentViewTrackingThreshold());
const uniqueDelays = Array.from(new Set([...delays, (options === null || options === void 0 ? void 0 : options.delay) || this.componentViewTrackingThreshold]));
const uniqueDelays = Array.from(new Set([...delays, options === null || options === void 0 ? void 0 : options.delay]));
if (!existingPayloads) {
this.observedElements.set(element, [remaingPayload]);
} else {
const isPayloadAlreadyObserved = existingPayloads.some(payload => {
return JSON.stringify(payload) === JSON.stringify(remaingPayload);
});
if (isPayloadAlreadyObserved) {
return;
}
this.observedElements.set(element, [...existingPayloads, remaingPayload]);
}
uniqueDelays.forEach(delay => {

@@ -791,17 +800,11 @@ this.elementSeenObserver.observe(element, {

this.onElementSeen = (element, delay) => {
const payload = this.observedElements.get(element);
if (typeof payload !== 'undefined') {
const pluginNamesInterestedInSeenElementMessage = [...this.pluginsWithCustomComponentViewThreshold.filter(plugin => plugin.getComponentViewTrackingThreshold() === delay), ...this.plugins.filter(plugin => !hasComponentViewTrackingThreshold(plugin))].map(plugin => plugin.name);
if (pluginNamesInterestedInSeenElementMessage.length === 0) {
return;
const payloads = this.observedElements.get(element);
if (Array.isArray(payloads) && payloads.length > 0) {
for (const payload of payloads) {
this.instance.dispatch(Object.assign(Object.assign({}, payload), {
element,
type: experience_jsPluginAnalytics.HAS_SEEN_ELEMENT,
seenFor: delay
}));
}
this.instance.dispatch(Object.assign(Object.assign({}, payload), {
element,
type: experience_jsPluginAnalytics.HAS_SEEN_ELEMENT,
plugins: Object.assign({
all: false
}, pluginNamesInterestedInSeenElementMessage.reduce((acc, curr) => Object.assign(Object.assign({}, acc), {
[curr]: true
}), {}))
}));
}

@@ -1058,2 +1061,5 @@ };

}
if (experience_jsPluginAnalytics.hasComponentViewTrackingThreshold(plugin)) {
plugin.setComponentViewTrackingThreshold(componentViewTrackingThreshold);
}
});

@@ -1116,3 +1122,3 @@ this._profileState = {

get pluginsWithCustomComponentViewThreshold() {
return [this.ninetailedCorePlugin, ...this.plugins].filter(plugin => hasComponentViewTrackingThreshold(plugin));
return [this.ninetailedCorePlugin, ...this.plugins].filter(plugin => experience_jsPluginAnalytics.hasComponentViewTrackingThreshold(plugin));
}

@@ -1119,0 +1125,0 @@ get profileState() {

import { FEATURES, buildComponentViewEvent, logger, ConsoleLogSink, buildPageEvent, buildTrackEvent, buildIdentifyEvent, unionBy, pipe, PageviewProperties, Properties, Traits, isPageViewEvent, isTrackEvent, isIdentifyEvent, isComponentViewEvent, selectHasVariants, selectExperience, selectVariant as selectVariant$1, selectBaselineWithVariants, NinetailedApiClient, OnLogLogSink, OnErrorLogSink } from '@ninetailed/experience.js-shared';
export { EXPERIENCE_TRAIT_PREFIX, isExperienceMatch, selectActiveExperiments, selectDistribution, selectExperience, selectBaselineWithVariants as selectExperienceBaselineWithVariants, selectVariant as selectExperienceVariant, selectVariants as selectExperienceVariants, selectHasVariants as selectHasExperienceVariants } from '@ninetailed/experience.js-shared';
import { NinetailedAnalyticsPlugin, HAS_SEEN_COMPONENT, HAS_SEEN_ELEMENT } from '@ninetailed/experience.js-plugin-analytics';
import { NinetailedAnalyticsPlugin, HAS_SEEN_COMPONENT, HAS_SEEN_ELEMENT, hasComponentViewTrackingThreshold } from '@ninetailed/experience.js-plugin-analytics';
import Analytics from 'analytics';

@@ -85,2 +85,5 @@ import { v4 } from 'uuid';

this.ninetailed = void 0;
this.getComponentViewTrackingThreshold = () => {
return 0;
};
this[HAS_SEEN_STICKY_COMPONENT] = async function ({

@@ -226,5 +229,2 @@ payload

}
getComponentViewTrackingThreshold() {
return 0;
}
async onTrackExperience(properties) {

@@ -565,6 +565,2 @@ if (properties.experience.sticky) {

const hasComponentViewTrackingThreshold = arg => {
return typeof arg === 'object' && arg !== null && 'getComponentViewTrackingThreshold' in arg && typeof arg['getComponentViewTrackingThreshold'] === 'function';
};
const _excluded = ["experience", "variant", "variantIndex"],

@@ -741,3 +737,5 @@ _excluded2 = ["element"];

return this.instance.dispatch(Object.assign({}, properties, {
type: HAS_SEEN_ELEMENT
type: HAS_SEEN_ELEMENT,
// TODO this is a temporary solution - to not make the user specify a delay
seenFor: this.componentViewTrackingThreshold
}));

@@ -756,5 +754,16 @@ };

} else {
this.observedElements.set(element, remaingPayload);
const existingPayloads = this.observedElements.get(element);
const delays = this.pluginsWithCustomComponentViewThreshold.map(plugin => plugin.getComponentViewTrackingThreshold());
const uniqueDelays = Array.from(new Set([...delays, (options == null ? void 0 : options.delay) || this.componentViewTrackingThreshold]));
const uniqueDelays = Array.from(new Set([...delays, options == null ? void 0 : options.delay]));
if (!existingPayloads) {
this.observedElements.set(element, [remaingPayload]);
} else {
const isPayloadAlreadyObserved = existingPayloads.some(payload => {
return JSON.stringify(payload) === JSON.stringify(remaingPayload);
});
if (isPayloadAlreadyObserved) {
return;
}
this.observedElements.set(element, [...existingPayloads, remaingPayload]);
}
uniqueDelays.forEach(delay => {

@@ -772,17 +781,11 @@ this.elementSeenObserver.observe(element, {

this.onElementSeen = (element, delay) => {
const payload = this.observedElements.get(element);
if (typeof payload !== 'undefined') {
const pluginNamesInterestedInSeenElementMessage = [...this.pluginsWithCustomComponentViewThreshold.filter(plugin => plugin.getComponentViewTrackingThreshold() === delay), ...this.plugins.filter(plugin => !hasComponentViewTrackingThreshold(plugin))].map(plugin => plugin.name);
if (pluginNamesInterestedInSeenElementMessage.length === 0) {
return;
const payloads = this.observedElements.get(element);
if (Array.isArray(payloads) && payloads.length > 0) {
for (const payload of payloads) {
this.instance.dispatch(Object.assign({}, payload, {
element,
type: HAS_SEEN_ELEMENT,
seenFor: delay
}));
}
this.instance.dispatch(Object.assign({}, payload, {
element,
type: HAS_SEEN_ELEMENT,
plugins: Object.assign({
all: false
}, pluginNamesInterestedInSeenElementMessage.reduce((acc, curr) => Object.assign({}, acc, {
[curr]: true
}), {}))
}));
}

@@ -1040,2 +1043,5 @@ };

}
if (hasComponentViewTrackingThreshold(plugin)) {
plugin.setComponentViewTrackingThreshold(componentViewTrackingThreshold);
}
});

@@ -1042,0 +1048,0 @@ this._profileState = {

{
"name": "@ninetailed/experience.js",
"version": "7.6.0-beta.5",
"version": "7.6.0-beta.6",
"description": "Ninetailed SDK for javascript",

@@ -12,9 +12,12 @@ "license": "MIT",

"dependencies": {
"@ninetailed/experience.js-plugin-analytics": "7.6.0-beta.6",
"@ninetailed/experience.js-shared": "7.6.0-beta.6",
"analytics": "0.8.1",
"@ninetailed/experience.js-plugin-analytics": "7.6.0-beta.5",
"@ninetailed/experience.js-shared": "7.6.0-beta.5",
"uuid": "9.0.0"
},
"devDependencies": {
"@jest/globals": "29.7.0"
},
"module": "./index.esm.js",
"main": "./index.cjs.js"
}
import { AnalyticsInstance } from 'analytics';
import { Locale, NinetailedApiClient, NinetailedRequestContext } from '@ninetailed/experience.js-shared';
import { NinetailedAnalyticsPlugin, NinetailedPlugin, SanitizedElementSeenPayload } from '@ninetailed/experience.js-plugin-analytics';
import { NinetailedAnalyticsPlugin, SanitizedElementSeenPayload } from '@ninetailed/experience.js-plugin-analytics';
import { NinetailedInstance, FlushResult } from '../types';
import { HAS_SEEN_STICKY_COMPONENT } from '../constants';
import { HasComponentViewTrackingThreshold } from '../types/interfaces/HasComponentViewTrackingThreshold';
export type OnInitProfileId = (profileId?: string) => Promise<string | undefined> | string | undefined;

@@ -28,6 +27,6 @@ type AnalyticsPluginNinetailedConfig = {

};
export interface NinetailedCorePlugin extends NinetailedPlugin {
export interface NinetailedCorePlugin extends NinetailedAnalyticsPlugin {
flush: (args: void) => Promise<FlushResult>;
}
export declare class NinetailedCorePlugin extends NinetailedAnalyticsPlugin implements NinetailedCorePlugin, HasComponentViewTrackingThreshold {
export declare class NinetailedCorePlugin extends NinetailedAnalyticsPlugin implements NinetailedCorePlugin {
name: string;

@@ -52,3 +51,3 @@ private _instance?;

identify({ payload }: EventFn): Promise<void>;
getComponentViewTrackingThreshold(): number;
getComponentViewTrackingThreshold: () => number;
protected onTrackExperience(properties: SanitizedElementSeenPayload): Promise<void>;

@@ -55,0 +54,0 @@ protected onTrackComponent(): Promise<void>;

@@ -43,3 +43,3 @@ import { DetachListeners } from 'analytics';

export type TrackHasSeenComponent = (properties: TrackComponentProperties) => Promise<void>;
export type TrackComponentView = (properties: ElementSeenPayload) => Promise<void>;
export type TrackComponentView = (properties: Omit<ElementSeenPayload, 'seenFor'>) => Promise<void>;
export type Identify = (uid: string, traits?: Traits, options?: EventFunctionOptions) => Promise<FlushResult>;

@@ -46,0 +46,0 @@ export type Batch = (events: Event[]) => Promise<FlushResult>;

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