Skip to main content
Mit dem Kameleoon JavaScript SDK können Sie Experiments ausführen und feature flags aktivieren. Die Integration unseres SDK in Ihre Webanwendung ist einfach und sein Footprint (Speicher- und Netzwerknutzung) ist gering. Erste Schritte: Hilfe für den Einstieg finden Sie im developer guide. Changelog: Details zur neuesten Version des JavaScript / TypeScript SDK finden Sie im changelog. SDK Methoden: Die vollständige Referenzdokumentation des JavaScript SDK, see the reference section.

Developer guide

Dieser Abschnitt hilft Ihnen beim Einstieg und stellt Ihnen einige fortgeschrittenere Konzepte vor.

Erste Schritte

Installation

Das Kameleoon SDK Installation-Tool ist die beste Methode, um das SDK schnell zu installieren. Der SDK Installer hilft Ihnen bei der Installation des SDK Ihrer Wahl, beim Generieren eines einfachen Codebeispiels und beim Konfigurieren von externe Abhängigkeiten falls erforderlich. Um das SDK Installation-Tool zu verwenden, installieren und führen Sie es global aus:
Oder führen Sie es direkt mit npx:
Sie können das JavaScript SDK auch als einzelne Datei mit dem <script> -Tag in Ihre App einbinden. Sie können dann alle SDK-Methoden über das globale Objekt KameleoonSDK.Beispiel:
index.html
app.js
To always verwenden Sie neueste Version of a Hauptrelease, verwenden die folgende Skript, wo 4 ist die aktuell major Version:
To always stay on a spezifisch Version, angeben the vollständig Version Zahl stattdessen. Zum Beispiel for Version 4.24.0, das ist die earliest Version verfügbar as a static Skript, verwenden die folgende:
Versions kann referenced on the Release Seite.
Standardmäßig the static Skript verwendet optimized SDK Bundle, wo INFO and DEBUG Log-Nachrichten are removed to reduce Bundle-Größe.Wenn Sie verwenden KameleoonLogger.setLogLevel(LogLevel.DEBUG) or KameleoonLogger.setLogLevel(LogLevel.INFO), verwenden Sie full static Skript stattdessen.

Initialisieren the Kameleoon-Client

Hier ist a Schritt-für-Schritt guide for configuring the JavaScript SDK for your Anwendung.
Um zu starten, developers need to erstellen an Einstiegspunkt for the JavaScript SDK by creating a neu Instanz of Kameleoon-Client. Verwenden KameleoonClient to run feature Experiments and abrufen der Status of feature flags and their variations. KameleoonClient initialization is durchgeführt asynchron to ensure that the Kameleoon API call was erfolgreich. For initialization, verwenden die Methode initialize(). Verwenden async/await, Promise.then() or beliebige andere Methode to handle asynchron client initialization.
Arguments
Konfiguration Parameters
Option 1 (Empfohlen): Verwenden JSON.stringify()
Option 2: Raw JSON Zeichenfolge (escape special characters)
Do not verwenden several client Instanzen in one Anwendung, as es ist not fully unterstützt noch. Several client Instanzen may lead to local storage Konfiguration being overwritten and cause bugs.

Activating a feature flag

Assigning a eindeutig ID to einen Benutzer
To assign a eindeutig ID to einen Benutzer, Sie können verwenden Sie getVisitorCode() Methode. Wenn ein Besucher code doesn’t exist (from die Anfrage headers Cookie), die Methode generates a random eindeutig ID or verwendet a defaultVisitorCode that you would have generated. The ID is then set in a Antwort headers Cookie. Wenn Sie are using Kameleoon in Hybrid Modus, calling the getVisitorCode() Methode ensures that the eindeutig ID (Besucher code) is shared zwischen die Anwendung Datei engine.js (previously named, kameleoon.js) and das SDK.
Retrieving a flag Konfiguration
To implement a feature flag in your code, Sie müssen first erstellen the feature flag in your Kameleoon account. To bestimmen der Status or variation of a feature flag for a spezifisch Benutzer, Sie sollten verwenden Sie getVariation() or isFeatureFlagActive() Methode to abrufen die Konfiguration based on the featureKey. The getVariation() Methode handles both simple feature flags mit ON/OFF states and more complex flags mit mehrere variations. Die Methode retrieves the appropriate variation for den Benutzer by checking the feature Regeln, assigning the variation, and returning it based on the featureKey and visitorCode. The isFeatureFlagActive() Methode kann verwendet wenn Sie möchten abrufen die Konfiguration of a simple feature flag that has only an ON or OFF state, as opposed to more complex feature flags mit mehrere variations or Targeting options. If your feature flag has zugeordnet variables (wie zum Beispiel spezifisch behaviors tied to jedes variation) getVariation() also ermöglicht es Ihnen, access the Variation Objekt, das bietet details about the assigned variation and its zugeordnet Experiment. Diese Methode checks whether den Benutzer is targeted, finds den Besucher’s assigned variation, and saves it to storage. Wenn track=true, das SDK will senden the exposure Event to the angegeben Experiment on the next Tracking Anfrage, das is automatically triggered based on das SDK’s tracking_interval_millisecond. Standardmäßig this Intervall gesetzt ist to 1000 Millisekunden (1 second). The getVariation() Methode ermöglicht es Ihnen, control whether Tracking is done. If track=false, no exposure Events wird sent by das SDK. Dies ist useful if you prefer not to tracken data durch das SDK and stattdessen rely on clientseitig Tracking managed by the Kameleoon engine, for Beispiel. Zusätzlich setting track=false is helpful wenn using the getVariations() Methode, wo you might only need the variations for alle flags ohne triggering beliebige Tracking Events. Wenn Sie möchten know more about how Tracking works, view this article
Adding data points to target einen Benutzer or filter / breakdown visits in reports
To target einen Benutzer, ensure you’ve added relevant data points to their profile vor retrieving the feature variation or checking if the flag ist aktiv. Verwenden Sie addData() Methode to add these data points to den Benutzer’s profile. Um abzurufen data points collected on andere devices or to access past Benutzer data (collected clientseitig wenn using Kameleoon in Hybrid Modus), verwenden Sie getRemoteVisitorData() Methode. Diese Methode asynchron ruft ab data from the servers. Es ist important to call getRemoteVisitorData() vor retrieving the variation or checking if the feature flag ist aktiv, as this data might be erforderlich to assign einen Benutzer to a given variation. Um mehr zu erfahren about verfügbar Targeting conditions, see the detailed article on the subject. Zusätzlich die Daten points you add to den Besucher profile wird verfügbar wenn analyzing your Experiments, allowing you to filter and break down your Ergebnisse by factors like device and browser. Kameleoon Hybrid Modus automatically collects a variety of data points on the clientseitig, making it easy to break down your Ergebnisse based on these pre-collected data points. See the complete Liste here. If Sie müssen tracken additional data points beyond what’s automatically collected, Sie können verwenden Kameleoon’s Benutzerdefiniert Daten feature. Benutzerdefiniert Daten ermöglicht es Ihnen, capture and analyze spezifisch information relevant to your Experiments. Don’t forget to call the flush() Methode to senden the collected data to Kameleoon-Servern for analysis.
To ensure your Ergebnisse are accurate, it’s empfohlen to filter out bots by using the UserAgent data Typ.
Tracking Ziel Konversionen
Wenn einen Benutzer completes a desired Aktion (wie zum Beispiel making a purchase), es ist recorded as a Konversion. Um zu tracken Konversionen, verwenden Sie trackConversion() Methode and provide the erforderlich visitorCode and goalId Parameter. The Konversion Tracking Anfrage wird sent along mit the next scheduled Tracking Anfrage, das das SDK sends at regular Intervalle (defined by tracking_interval_millisecond). Wenn Sie prefer to senden die Anfrage immediately, verwenden Sie flush() Methode mit der Parameter instant=true.
Sending Events to analytics solutions
Um zu tracken Konversionen and senden exposure Events to your customer analytics solution, Sie müssen first implement Kameleoon in Hybrid Modus. Then, verwenden Sie getEngineTrackingCode() Methode. The getEngineTrackingCode() Methode retrieves the eindeutig Tracking code erforderlich to senden exposure Events to your analytics solution. Using diese Methode ermöglicht es Ihnen, record Events and senden them to your desired analytics platform.

Using a benutzerdefiniert bucketing Schlüssel

Standardmäßig Kameleoon verwendet a eindeutig, anonymous Besucher ID (visitorCode) to assign Benutzer to feature flag variations. This ID is typically generated and stored on den Benutzer’s device (in a browser Cookie for clientseitig and serverseitig SDKs—in persistent storage for mobile SDKs). Allerdings in certain scenarios Sie können need to ensure alle Benutzer of die gleiche organization see die gleiche variant of a feature flag. The Benutzerdefiniert Bucketing Schlüssel option ermöglicht es Ihnen, override this Standard behavior by providing your own benutzerdefiniert identifier for bucketing. This override ensures that Kameleoon’s assignment logic verwendet your angegeben Schlüssel anstelle von the Standard visitorCode.

Verwenden cases

Using a benutzerdefiniert bucketing Schlüssel is essential for maintaining consistency and accuracy in your feature flag assignments, particularly in these situations:
  • Account-level or organizational Experiments: For B2B products or scenarios wo you want to assign alle Benutzer from die gleiche organization to die gleiche variation, Sie können verwenden an identifier like an accountId. Benutzerdefiniert bucketing Schlüssel are crucial for A/B testing features that impact an entire team or company.
By implementing a benutzerdefiniert bucketing Schlüssel, you ensure greater consistency and accuracy in your Experiments, leading to more reliable Ergebnisse and a better Benutzer experience.

Technical details

Wenn you konfigurieren a benutzerdefiniert bucketing Schlüssel for a feature flag, you provide Kameleoon mit a spezifisch identifier from your Anwendung’s data:
  • Providing the benutzerdefiniert Schlüssel: You provide your benutzerdefiniert identifier to the Kameleoon SDK using the addData() Methode. In diese Methode, Sie werden pass your chosen benutzerdefiniert bucketing Schlüssel as a CustomData Objekt. Here, newVisitorCode refers to the identifier you wish to verwenden for your bucketing (zum Beispiel the neu userId or accountId).
For the benutzerdefiniert bucketing Schlüssel to Funktion correctly, it must also be defined and configured for the feature flag während the flag creation or editing process. Ohne this corresponding Konfiguration, das SDK’s bucketing will not apply your benutzerdefiniert Schlüssel. For detailed instructions on how to set this up in Kameleoon, refer to this article.
  • Bucketing logic: Einmal a benutzerdefiniert bucketing Schlüssel is provided durch the addData() Methode, alle hash calculations for assigning Benutzer to variations will verwenden this newVisitorCode (your benutzerdefiniert Schlüssel) anstelle von the Standard visitorCode. Using the newVisitorCode means that the bucketing decision is tied to your benutzerdefiniert identifier, ensuring consistent assignments across various contexts wo that identifier is present.
  • Daten Tracking and analytics: It’s crucial to beachten Sie, dass while the newVisitorCode (your benutzerdefiniert Schlüssel) is verwendet for bucketing decisions, alle subsequent data (Tracking Events and Konversionen, for Beispiel) is sent and zugeordnet zu the original visitorCode. This separation ensures that your analytics accurately reflect individual Benutzer journeys and interactions innerhalb your Experiment’s broader context, even wenn bucketing is durchgeführt at a higher level (like an account) or across mehrere devices/Sitzungen. Your original Besucher data remains intact for comprehensive reporting.

Technical requirementes

To effectively verwenden a benutzerdefiniert bucketing Schlüssel:
  • The Schlüssel muss a string.
  • It muss eindeutig for the entity you intend to bucket (zum Beispiel if using a userId, jedes Benutzer’s ID sollte eindeutig).
  • The Schlüssel muss verfügbar to das SDK at the exact moment the feature flag decision is ausgewertet for that Benutzer or Anfrage.

Targeting conditions

The Kameleoon SDKs support a variety of predefined Targeting conditions that Sie können verwenden to target Benutzer in your campaigns. For die Liste of conditions unterstützt by dieses SDK, see verwenden visit history to target Benutzer. Sie können auch verwenden your own extern data to target Benutzer.

Logging

Das SDK generates logs to reflect various internal processes and issues.

Log levels

Das SDK unterstützt configuring limiting logging by a log level.

Benutzerdefiniert handling of logs

Das SDK writes its logs to the console output standardmäßig. This behaviour kann overridden.
Logging limiting by a log level is durchgeführt apart from the log handling logic.

Domain information

You provide a Domain as the domain in the KameleoonClient Konfiguration, das is verwendet for storing Kameleoon Besucher code in Cookies. Domains are important wenn working mit the getVisitorCode and setLegalConsent Methoden. The Domain you provide is stored in the Cookie as the Domain= Schlüssel.

Setting die Domain

The Domain you provide zeigt an if die URL address can verwenden Sie Cookie. Zum Beispiel if your Domain is www.example.com. the Cookie is only verfügbar from a www.example.com URL. This means Seiten mit the app.example.com Domain can’t verwenden Sie Cookie. For more fllexibility mit subdomains, Sie können angeben die Domain mit a period (.). Zum Beispiel die Domain .example.com ermöglicht the Cookie to Funktion on both app.example.com and login.example.com.
Sie können’t verwenden regular expressions, special symbols, protocol, or port Zahlen in the domain. Zusätzlich a spezifisch Liste of subdomains can’t be verwendet mit the prefix ..
Here’s a small Domain cheat sheet:

Developing on localhost

localhost is always considered a bad Domain, making testing die Domain wenn developing on localhost difficult. Es gibt two ways to avoid this issue:
  • Don’t angeben the domain Feld in das SDK client while testing.
  • Erstellen a local Domain for localhost. Zum Beispiel:
    • Navigate to /etc/hosts on Linux or to c:\Windows\System32\Drivers\etc\hosts on Windows.
    • Open hosts mit Datei super Benutzer or administrator rights.
    • Add a Domain to the localhost port, for Beispiel: 127.0.0.1 app.com
    • Now Sie können run your app locally on app.com:{my_port} and angeben .app.com as your Domain

Externe Abhängigkeiten

SDK externe Abhängigkeiten verwenden Sie dependency injection pattern to give you the ability to provide your own implementations for certain parts of ein SDK.
In the JavaScript SDK, alle externe Abhängigkeiten have Standard implementations, das verwenden a native browser API so there’s no need to provide them unless ein anderes API ist erforderlich for spezifisch verwenden cases.
Here’s die Liste of verfügbar externe Abhängigkeiten: Die folgende Beispiel implements externe Abhängigkeiten. To import an interface from ein SDK, erstellen a class that implements the interface and pass the instantiated class to das SDK.

Storage

EventSource

VisitorCodeManager

Requester

Fehler Handling

Almost every KameleoonClient Methode may throw ein Fehler occassionaly. These Fehler are deliberately predefined KameleoonErrors that extend the native JavaScript Error class, providing useful Nachrichten and special type Felder mit a Typ KameleoonException. KameleoonException ist ein enum containing alle possible Fehler Typen. To know exactly what Typ of KameleoonException die Methode may throw, prüfen the Throws section in die Methode Beschreibung on this Seite, or hover over die Methode in your IDE to see the jsdocs Beschreibung. Handling Fehler makes your Anwendung more stable and avoids technical issues.

Cross-device experimentation

To support Besucher der access an app from mehrere devices, Kameleoon ermöglicht the synchronization of previously collected Besucher data across jedes of den Besucher’s devices and reconciliation of their visit history across devices durch cross-device experimentation. Case studies and detailed information on how Kameleoon handles data across devices sind verfügbar in the article on cross-device experimentation.

Synchronizing benutzerdefiniert data across devices

Although benutzerdefiniert mapping synchronization is verwendet to align Besucher data across devices, es ist not always necessary. Below are two scenarios wo benutzerdefiniert mapping sync is not erforderlich: Same Benutzer ID across devices If die gleiche Benutzer ID is verwendet consistently across alle devices, synchronization is handled automatically ohne a benutzerdefiniert mapping sync. Es ist enough to call the getRemoteVisitorData() Methode wenn you want to sync die Daten collected zwischen mehrere devices. Multi-server Instanzen mit consistent IDs In complex setups involving mehrere servers (zum Beispiel distributed server Instanzen), wo die gleiche Benutzer ID ist verfügbar across servers, synchronization zwischen servers (mit getRemoteVisitorData()) is sufficient ohne additional benutzerdefiniert mapping sync. Customers der need additional data can refer to the getRemoteVisitorData() Methode Beschreibung for further guidance. In the below code, es ist assumed that die gleiche eindeutig identifier (in this case, the visitorCode, das can also be referred to as userId) is verwendet consistently zwischen the two devices for accurate data retrieval.
Wenn Sie möchten sync collected data in Echtzeit, Sie müssen choose the scope Besucher for your benutzerdefiniert data.
Device One
Device Two

Using benutzerdefiniert data for Sitzung merging

Cross-device experimentation ermöglicht for combining einen Besucher’s history across jedes of their devices (history reconciliation). History reconciliation allow merging different Besucher Sitzungen into one. To reconcile visit history, verwenden CustomData to provide a eindeutig identifier for den Besucher. Weitere Informationen, see the dedicated documentation.Nach cross-device reconciliation ist aktiviert, calling getRemoteVisitorData() mit der Parameter userId retrieves alle known data for a given Benutzer.Sitzungen mit die gleiche identifier will always be shown die gleiche variation in an Experiment. In the Besucher view of your Experiment’s Ergebnisse Seiten, these Sitzungen will appear as ein einzelnes Besucher.Das SDK Konfiguration ensures that zugeordnet Sitzungen always see die gleiche variation of the Experiment. Allerdings es gibt einige limitations regarding cross-device variation allocation. These limitations are outlined here.Follow the activating cross-device history reconciliation guide to einrichten your benutzerdefiniert data on the Kameleoon platform.Afterwards, Sie können verwenden das SDK normally. Die folgende Methoden that may be helpful in the context of Sitzung merging:
  • getRemoteVisitorData() mit added UniqueIdentifier(true) - to abrufen data for alle linked Besucher.
  • trackConversion() or flush() mit added UniqueIdentifier(true) data - to tracken einige data for spezifisch Besucher that is zugeordnet zu ein anderes Besucher.
As the benutzerdefiniert data you verwenden as the identifier muss gesetzt auf Besucher scope, Sie müssen verwenden cross-device benutzerdefiniert data synchronization to abrufen the identifier mit the getRemoteVisitorData() Methode on jedes device.
Here’s an Beispiel of how to verwenden benutzerdefiniert data for Sitzung merging.
Login Page
Application Page

Utilities

Das SDK has a set of utility Methoden that Sie können verwenden to simplify your development process. Alle Methoden are represented as static members of KameleoonUtils class.

simulateSuccessRequest

Verwenden Sie simulateSuccessRequest Methode to simulate a erfolgreich Anfrage to the Kameleoon server. It kann useful for benutzerdefiniert Requester implementations, wenn a developer needs to simulate a erfolgreich Anfrage (zum Beispiel disabling Tracking).
Arguments
Daten Typ SimulateRequestDataType ist definiert as follows:
  • RequestType.Tracking - null
  • RequestType.ClientConfiguration - ClientConfigurationDataType
  • RequestType.RemoteData - JSONType
Zurückgeben Wert

getCookieValue

Verwenden Sie getCookieValue Methode to parse a common Cookie Zeichenfolge (key_1=value_1; key_2=value_2; ...) and get der Wert of a spezifisch Cookie Schlüssel. Diese Methode is useful wenn working mit a benutzerdefiniert implementation of VisitorCodeManager.
Arguments
Zurückgeben Wert

Referenz

Dies ist the vollständig reference documentation for the Kameleoon JavaScript SDK.

Initialization

initialisieren()

An asynchron Methode for KameleoonClient initialization by fetching Kameleoon SDK related data from server or by retrieving data from local source if data is up-to-date or aktualisieren Intervall has not been reached.
  • If das SDK Konfiguration could not be retrieved but es gibt an older Konfiguration verfügbar in SDK storage, das SDK verwendet older Konfiguration as a fallback and the initialize does not throw ein Fehler.
  • SDK unterstützt an offline mode.
In offline mode if Tracking Anfragen from beliebige of die folgende Methoden fail due to internet connectivity issues, das SDK automatically resends die Anfrage as soon as it detects that the internet connection wurde re-established:
Zurückgeben Wert
Exceptions thrown

Feature flags and variations

getVariation()

  • 📨 Sends Tracking Daten to Kameleoon (depending on the track Parameter)
Retrieves the Variation assigned to a given Besucher for a spezifisch feature flag. Diese Methode benötigt featureKey as a obligatorisch argument and track as an optional argument. The track argument ist optional and defaults to true. It gibt zurück assigned Variation for den Besucher. If den Besucher is not zugeordnet zu beliebige feature flag Regeln, die Methode gibt zurück Standard Variation for the given feature flag. Ensure that proper Fehler handling is implemented in your code to manage potential Ausnahmen.
The Standard variation refers to the variation assigned to einen Besucher wenn they do not match beliebige predefined delivery Regeln for a feature flag. In andere words, it ist die fallback variation applied to alle Benutzer der are not targeted by spezifisch Regeln. It’s represented as the variation in the “Then, for everyone else…” section in a management interface.
Arguments
An Objekt of Typ GetVariationParamsType mit die folgende Eigenschaften:
Zurückgeben Wert
Exceptions thrown

getVariations()

  • 📨 Sends Tracking Daten to Kameleoon (depending on the track Parameter)
  • 🎯 Events: EventType.Evaluation
Retrieves a map of Variation Objekte assigned to a given Besucher across alle feature flags. Diese Methode iterates over alle verfügbar feature flags and gibt zurück assigned Variation for jedes flag zugeordnet zu the angegeben Besucher. It benötigt visitorCode as a obligatorisch argument, while onlyActive and track sind optional.
  • If onlyActive gesetzt ist to true, die Methode getVariations() will zurückgeben feature flags variations provided den Benutzer is not bucketed mit the off variation.
  • The track Parameter controls whether or not die Methode will tracken the variation assignments. Standardmäßig it gesetzt ist to true. Wenn gesetzt to false, the Tracking wird deaktiviert.
The returned map consists of feature flag Schlüssel as Schlüssel and their corresponding Variation as Werte. Wenn kein variation is assigned for a feature flag, die Methode gibt zurück Standard Variation for that flag. Proper Fehler handling sollte implemented to manage potential Ausnahmen.
The Standard variation refers to the variation assigned to einen Besucher wenn they do not match beliebige predefined delivery Regeln for a feature flag. In andere words, it ist die fallback variation applied to alle Benutzer der are not targeted by spezifisch Regeln. It’s represented as the variation in the “Then, for everyone else…” section in a management interface.
Arguments
An Objekt of Typ GetVariationParamsType mit die folgende Eigenschaften:
Zurückgeben Wert
Exceptions thrown

isFeatureFlagActive()

  • 📨 Sends Tracking Daten to Kameleoon (depending on the track Parameter)
  • 🎯 Events: EventType.Evaluation
Die Methode isFeatureFlagActive() gibt einen boolescher Wert Wert indicating whether den Besucher identified by visitorCode has the angegeben featureKey aktiv. Diese Methode checks for Targeting, bestimmt the variation for den Besucher, and saves this information to storage. Zusätzlich it sends a Tracking Anfrage. Es gibt also an overload of diese Methode that ermöglicht es Ihnen, pass a track Parameter, das Sie können verwenden to deaktivieren Tracking of the feature evaluation.
Only Besucher mit an aktiv feature flag muss targetted.
Kameleoon verwendet Tracking to count Sitzungen and Besucher wenn you call certain Methoden, wie zum Beispiel isFeatureFlagActive(), getVariation() or getVariations().Verwenden Sie Standard true Wert for the track Parameter wenn you expose Besucher to a variation and need to count them. Set the track Parameter to false only if you call these Methoden vor you expose Besucher.Zum Beispiel if you call getVariations() to abrufen alle variations vor you expose Besucher, set the track Parameter to false. This setting prevents Kameleoon from prematurely counting a Sitzung. Sie können then trigger Tracking later wenn you explicitly expose den Besucher.Kameleoon sends Tracking data every second standardmäßig. Sie können konfigurieren this Intervall up to five Sekunden using the Tracking Intervall Konfiguration option. Kameleoon groups Tracking Events into ein einzelnes Sitzung as long as das Intervall zwischen Events is less than 30 Minuten. If more than 30 Minuten elapse zwischen Tracking Events, Kameleoon counts the Events as separate Sitzungen. A visit appears in your reports 30 Minuten nach the last recorded Event in the Sitzung.
The isFeatureFlagActive() Methode evaluates the served variant, not the master flag state. Wenn Sie exclude Regeln, die Methode verwendet Then, for everyone else serve Standard state. Wenn Sie select Off for this Standard state, die Methode always returns false even wenn the master feature flag is On.
Arguments
Es gibt two overloads verfügbar for diese Methode:
  1. Two Parameter overload:
This overload is veraltet and wird removed in the next major aktualisieren. Please verwenden Sie neu overload mit an Objekt Parameter.
  1. Objekt Parameter overload of Typ IsFeatureFlagActiveParamsType:
Zurückgeben Wert
Exceptions thrown

setForcedVariation()

Die Methode ermöglicht es Ihnen, programmatically assign a spezifisch Variation to einen Benutzer, bypassing the standard evaluation process. Dies ist especially valuable for controlled Experiments wo the usual evaluation logic is not erforderlich or muss skipped. It can also be helpful in scenarios like debugging or benutzerdefiniert testing. Wenn a forced variation gesetzt ist, it overrides Kameleoon’s Echtzeit evaluation logic. Processes like segmentation, Targeting conditions, and algorithmic calculations are skipped. To preserve segmentation and Targeting conditions während an Experiment, set forceTargeting=false stattdessen.
Simulated variations always nehmen precedence in the execution order. Wenn ein simulated variation calculation is triggered, it wird fully processed and completed first.
A forced variation is treated die gleiche as an ausgewertet variation. Es ist getrackt in analytics and stored in den Benutzer context like beliebige standard ausgewertet variation, ensuring consistency in reporting. Die Methode may throw Ausnahmen under certain conditions (e.g., ungültig Parameter, Benutzer context, or internal issues). Proper Ausnahme handling is essential to ensure that your Anwendung remains stable and resilient.
It’s important to distinguish forced variations from simulated variations:
  • Forced variations: Are spezifisch to an individual Experiment.
  • Simulated variations: Affect the overall feature flag Ergebnis.
Arguments
An Objekt of Typ SetForcedVariationParametersType mit die folgende Eigenschaften:
Exceptions thrown
In most cases, only the basic Fehler, KameleoonException, needs to be handled, as demonstrated in das Beispiel. Allerdings if different Typen of Fehler require a Antwort, handle jedes one separately based on spezifisch requirements. Zusätzlich for enhanced reliability, general language Fehler kann handled by including Error.

evaluateAudiences()

  • 📨 Sends Tracking Daten to Kameleoon
Diese Methode evaluates Besucher against alle verfügbar Audiences Explorer Segmente and tracks those der match. evaluateAudiences() sollte aufgerufen nach alle relevant Besucher data wurde set or updated, and just vor getting a feature variation or checking a feature flag. This approach ensures that den Besucher is ausgewertet against the most aktuell data verfügbar, allowing for accurate audience assignment based on alle criteria. Nach calling diese Methode, Sie können durchführen a detailed analysis of Segment performance in Audiences Explorer.
Arguments
Exceptions thrown
In most cases, only the basic Fehler, KameleoonException, needs to be handled, as demonstrated in das Beispiel. Allerdings if different Typen of Fehler require a Antwort, handle jedes one separately based on spezifisch requirements. Zusätzlich for enhanced reliability, general language Fehler kann handled by including Error.

getDataFile()

To auswerten alle feature flags, verwenden getVariations(). Diese Methode is more efficient than calling DataFile and iterating durch flags mit getVariation().
Gibt zurück aktuell SDK Konfiguration as a DataFile Objekt.
Zurückgeben Wert

Besucher data

getVisitorCode()

The getVisitorCode() Methode obtains einen Besucher code from der Browser Cookie. If den Besucher code doesn’t exist, die Methode generates a random Besucher code (or verwendet defaultVisitorCode Wert if you provided one) and sets the neu Besucher code in a Cookie.
The getVisitorCode() Methode ermöglicht es Ihnen, set simulated variations for einen Besucher. Wenn Cookies (from a Anfrage or document) contain der Schlüssel kameleoonSimulationFFData, the standard evaluation process is bypassed. Stattdessen, die Methode directly gibt einen Variation based on the provided data.Sie können apply simulations in two ways:
  • Automatically (empfohlen): If using Kameleoon Web Experimentation or das SDK in Hybrid Modus, the Cookie is erstellt automatically wenn simulating a variant’s display using the Simulation Panel.
  • Manually: Set the kameleoonSimulationFFData Cookie manually.
It’s important to distinguish simulated variations from forced variations:
  • Simulated variations: Affect the overall feature flag Ergebnis.
  • Forced variations: Are spezifisch to an individual Experiment.
⚙️ Manual setupPlease ensure the kameleoonSimulationFFData Cookie follows this Format:
  • kameleoonSimulationFFData={"featureKey":{"expId":10,"varId":20}}: Simulates the variation mit varId of Experiment expId for the given featureKey.
  • kameleoonSimulationFFData={"featureKey":{"expId":0}}: Simulates the Standard variation (defined in the Then, for everyone else in Production, serve section) for the given featureKey.
⚠️ To ensure proper functionality, the Cookie Wert muss encoded as a URI component using a Methode wie zum Beispiel encodeURIComponent.
Arguments
Wenn Sie don’t provide a defaultVisitorCode and es gibt no Besucher code stored in a Cookie, den Besucher code wird randomly generated.
Zurückgeben Wert
Exceptions thrown

addData()

The addData() Methode adds Targeting-Daten to storage so andere Methoden can verwenden die Daten to decide whether to target the aktuell Besucher. The addData() Methode does not zurückgeben beliebige Wert and does not interact mit Kameleoon back-end servers on its own. Stattdessen, alle the declared data is saved for future transmission using the flush Methode. This approach reduces die Zahl of server Aufrufe made, as die Daten is typically grouped into ein einzelnes server call. Beachten Sie, dass the trackConversion Methode also sends out beliebige previously zugeordnete Daten, just like the flush Methode. The same is true for the getFeatureFlagVariationKey and getFeatureFlagVariable Methoden, if an experimentation Regel is triggered.
Jedes Besucher can only have one Instanz of zugeordnete Daten for most data Typen. Allerdings CustomData ist ein Ausnahme. Visitors can have one Instanz of zugeordnet CustomData pro customDataIndex.
  • userAgent data will not be stored in storage like andere data, and it wird sent mit every Tracking Anfrage for bot filtration.
  • For die Daten Typen Sie können verwenden for Targeting, see the unterstützt Targeting conditions.
Arguments
  • kameleoonData ist ein variadic argument. It kann passed as one or several arguments (see das Beispiel).
  • The index or ID of the benutzerdefiniert data kann found in your Kameleoon account. Beachten Sie, dass this index starts at 0, das means that the first benutzerdefiniert data you erstellen for a given site wird assigned 0 as its ID, not 1.
Exceptions thrown
Prüfen the Daten Types reference weitere Details on how to manage different data Typen.

flush()

flush() benötigt the Kameleoon data zugeordnet zu einen Besucher and schedules die Daten to be sent in the next Tracking Anfrage. The time of the next Tracking Anfrage ist definiert by das SDK Konfiguration trackingInterval Parameter. Besucher data kann added using the addData and getRemoteVisitorData Methoden.Wenn Sie don’t angeben a visitorCode, das SDK flushes alle of its stored data to the remote Kameleoon-Servern. If beliebige previously failed Tracking Anfragen were stored locally in offline Modus, das SDK attempts to senden the stored Anfragen vor executing die neueste Anfrage.
If Sie müssen senden Tracking Anfragen immediately, verwenden flushInstant() — the asynchron Version of flush that returns Promise<void>. Sie können await it wenn you need delivery guarantees (zum Beispiel vor Seite navigation/unload), or call it ohne await as a fire-and-forget Anfrage:
  • await client.flushInstant(visitorCode) sends Tracking Anfragen immediately for a spezifisch Besucher and waits for completion
  • await client.flushInstant() sends Tracking Anfragen immediately for alle Besucher and waits for completion
Arguments
Or an Objekt mit der Typ FlushParamsType, containing:
Exceptions thrown

getRemoteData()

The getRemoteData() Methode returns data that is stored for a angegeben site code in a remote Kameleoon server. Sie können verwenden diese Methode to abrufen Benutzer preferences, historical data, or beliebige andere data relevant to your Anwendung’s logic. By storing this data on our highly scalable servers using our Daten API, Sie können efficiently manage massive amounts of data and abrufen it for jedes of your Besucher or Benutzer.
Arguments
Zurückgeben Wert
Exceptions thrown

getRemoteVisitorData()

getRemoteVisitorData() ist ein asynchron Methode for retrieving Kameleoon Visits Daten for the visitorCode from the Kameleoon Daten API. Die Methode adds data to storage for andere Methoden to verwenden wenn making Targeting decisions.Daten obtained using dies ist important wenn you want to:
  • verwenden data collected from andere devices.
  • access einen Benutzer’s history, wie zum Beispiel previously visited Seiten während past visits.
  • verwenden data that is only accessible on the clientseitig, like datalayer variables and Ziele that only convert on the front-end.
Lesen this article for a better understanding of possible verwenden cases.
Standardmäßig getRemoteVisitorData() automatically retrieves die neueste stored benutzerdefiniert data mit scope=Visitor and attaches them to den Besucher ohne the need to call die Methode addData(). Es ist particularly useful for synchronizing benutzerdefiniert data zwischen mehrere devices.
Arguments
An Objekt mit der Typ RemoteVisitorDataParamsType containing:
Zurückgeben Wert
Exceptions thrown
Using Parameter in getRemoteVisitorData()
The getRemoteVisitorData() Methode offers flexibility, allowing you to define various Parameter wenn retrieving data on Besucher. Whether you’re Targeting based on Ziele, Experiments, or variations, die gleiche approach applies across alle data Typen.Zum Beispiel wenn Sie möchten abrufen data on Besucher der completed a Ziel “Order transaction”, Sie können angeben Parameter innerhalb the getRemoteVisitorData() Methode to refine your Targeting. For Instanz, wenn Sie möchten target only Benutzer der converted on the Ziel in their last five visits, die Sie festlegen können the previousVisitAmount Parameter to 5 and conversions to true.The flexibility shown in this Beispiel is not limited to Ziel data. Sie können verwenden Parameter innerhalb the getRemoteVisitorData() Methode to abrufen data on a variety of Besucher behaviors.
Hier ist die Liste of verfügbar VisitorDataFiltersType filters:

getVisitorWarehouseAudience()

getVisitorWarehouseAudience ist ein asynchron Methode that retrieves alle audience data zugeordnet zu den Besucher in your data warehouse using the angegeben visitorCode and warehouseKey. The warehouseKey is typically your internal Benutzer ID. The customDataIndex Parameter corresponds to the Kameleoon benutzerdefiniert data that Kameleoon verwendet to target your Besucher. Refer to the warehouse Targeting documentation for additional details.
Arguments
Parameters Objekt consisting of:
Zurückgeben Wert
Exceptions thrown

setLegalConsent()

Consent information is synchronized zwischen the Kameleoon Engine (Anwendung Datei engine.js) and the JS SDK. This synchronization means that einmal consent gesetzt ist on either the Engine or das SDK, it’s automatically set for both. This feature eliminates the need for manual consent handling and ensures that SDKs operate in compliance mit Benutzer preferences.Wenn Sie verwenden Kameleoon in Hybrid Modus, we recommend reading the consent section in our Hybrid experimentation article
Wenn handling legal consent, it’s important to verwenden Sie getVisitorCode Methode from KameleoonClient, not the veraltet Methode from KameleoonUtils. Zusätzlich diese Methode does not accept domain as an argument. Stattdessen, pass it to the KameleoonClient constructor. Refer to the above Beispiel. The setLegalConsent Methode gibt an whether den Besucher has given legal consent to verwenden personal data. Setting the legalConsent Parameter to false limits the Typen of data that Sie können include in Tracking Anfragen. Diese Methode hilft Ihnen, adhere to legal and regulatory requirements while responsibly managing Besucher data. Sie können find weitere Informationen on personal data in the consent management policy.
Arguments
Exceptions thrown
Consent revocation behavior
Wenn you call setLegalConsent() mit consent=false, das SDK does not delete the kameleoonVisitorCode Cookie. Stattdessen, it stops extending the Cookie’s expiration date, allowing the Cookie to persist until it naturally expires. If your compliance requirements demand the immediate removal of the Cookie Datei upon opt-out, Sie müssen delete it manually using your framework’s native Cookie management Methoden. Das SDK will not entfernen die Datei automatically.

Ziele and Drittanbieter- analytics

trackConversion()

  • 📨 Sends Tracking Daten to Kameleoon
Verwenden diese Methode to tracken a Konversion for a spezifisch Ziel and Benutzer. Diese Methode erfordert visitorCode and goalId. Zusätzlich diese Methode also accepts an optional revenue, negative and metadata arguments. The visitorCode is usually identical to the one that was verwendet wenn triggering the Experiment.The trackConversion() Methode doesn’t zurückgeben beliebige Wert. Diese Methode is non-blocking as der Server call is made asynchron.
Arguments
Parameters Objekt consisting of:
metadata Werte are accessible durch raw data exports and the Ergebnisse Seite.Wenn das metadata Parameter is provided, Kameleoon will verwenden these angegeben Werte for the aktuell Konversion anstelle von what was previously collected using the addData() Methode. If der Parameter is omitted, Kameleoon will verwenden Sie last getrackt Werte for those CustomData prior to the Konversion and innerhalb die gleiche visit.Kameleoon will only consider the metadata Werte that are explicitly passed as Parameter to the trackConversion() Methode.In das Beispiel below, Kameleoon will associate the Konversion only mit the benutzerdefiniert data Wert explicitly provided as a Parameter (here: index 5 mit der Wert ‘Amex Credit Card’).
Exceptions thrown

getEngineTrackingCode()

Kameleoon integrates mit several analytics solutions, including Mixpanel, Google Analytics 4, and Segment. Um zu tracken serverseitig Experiments correctly, call the getEngineTrackingCode() Methode nach den Besucher triggers an Experiment. Das SDK returns JavaScript queue commands for the Experiments that den Besucher triggered während the vorherig five Sekunden. Wenn you insert this code into die Seite, Engine.js processes the commands and sends the exposure Events durch die aktiven analytics integration. Refer to hybrid experimentation weitere Informationen on implementing diese Methode.
  • To verwenden this feature, implement both the JavaScript SDK and Kameleoon Engine.js. Weil Engine.js is verwendet only for Tracking in this flow, Sie können install the asynchron tag vor the closing </body> tag.
  • Sie können insert the returned Tracking code directly into an HTML <script> tag.
In this Beispiel, 123456 and 234567 are Experiment IDs, and 7890 and 8901 are variation IDs. In your implementation, das SDK generates these Werte in the returned Tracking code.
Arguments
Zurückgeben Wert
Exceptions thrown

Events

onEvent()

Methode onEvent() fires a Callback wenn a spezifisch Event is triggered. The Callback Funktion can access die Daten zugeordnet zu das Event. Das SDK Methoden in this documentation note das Event Typen they trigger, if beliebige.
Sie können only assign one Callback to jedes EventType.
Events
Events sind definiert in the EventType enum. Depending on das Event Typ, the eventData Parameter will have a different Typ.
Arguments
Exceptions thrown

Sending exposure Events to extern tools
Kameleoon offers built-in integrations mit various analytics and CDP solutions, wie zum Beispiel Mixpanel, Google Analytics 4, Segment…. To ensure that Sie können tracken and analyze your serverseitig Experiments, Kameleoon bietet a Methode, getEngineTrackingCode(), that gibt zurück JavasScript code to be inserted in your Seite. The code automatically sends the exposure Events to your analytics solution. Das SDK builds a Tracking code for your aktiv analytics solution based on the Experiments that den Besucher has triggered in the last five Sekunden. Weitere Informationen about hybrid experimentation, please refer to this article.The getEngineTrackingCode() Methode gibt zurück Kameleoon Tracking code for the aktuell Besucher. The Tracking code is based on the Experiments that were triggered während the last five Sekunden.
To benefit from this feature, Sie werden need to implement both the JavaScript SDK and our Kameleoon JavaScript tag. We recommend you implement the Kameleoon asynchron tag, das Sie können install vor closing the <body> tag in your HTML Seite, as it will only be verwendet for Tracking purposes.

Daten Typen

Kameleoon Daten Typen are helper classes verwendet to store data in storage in predefined forms. Während the flush execution, das SDK collects alle data and sends it mit the Tracking Anfrage. Daten verfügbar in das SDK is not verfügbar for Targeting and reporting in the Kameleoon app until you add die Daten (zum Beispiel by using the addData() methodt). See verwenden visit history to target Benutzer weitere Informationen.
Wenn Sie are using hybrid Modus, call getRemoteVisitorData() to automatically fill alle data that Kameleoon has previously collected.

Browser

Since JavaScript SDK 4.10.0, Browser is automatically detected based on the User-Agent Zeichenfolge. Allerdings Sie können still manually override it falls erforderlich.
Browser enthält browser information.
Jedes Besucher can only have one Browser. Adding second a Browser overwrites the first one.

UniqueIdentifier

UniqueIdentifier data is verwendet as marker for eindeutig Besucher identification. Wenn Sie add UniqueIdentifier for einen Besucher, visitorCode is verwendet as the eindeutig Besucher identifier, das is useful for Cross-device experimentation. Associating a UniqueIdentifier mit einen Besucher notifies das SDK that den Besucher is linked to ein anderes Besucher. The isUniqueIdentifier kann helpful in eindeutig situations; zum Beispiel if you cannot access the anonymous visitorCode given to einen Besucher, but Sie können verwenden an internal ID linked to that Besucher durch Sitzung merging.
Jedes Besucher can only have one UniqueIdentifier. Adding ein anderes UniqueIdentifier overwrites the first one.

Konversion

The Conversion data set stored here kann verwendet to filter Experiment and personalization reports by beliebige Ziel zugeordnet zu it.
  • Jedes Besucher can have mehrere Conversion Objekte.
  • Sie können find the goalId in the Kameleoon app.
ConversionParametersType conversionParameters - an Objekt mit Konversion Parameter described below
Cookie enthält information about the Cookie stored on den Besucher’s device.
  • Generally, the JavaScript SDK will attempt to verwenden a localStorage Cookie for the conditions. If localStorage is not possible, das SDK can verwenden Cookie data as an alternative.
  • Jedes Besucher can only have one Cookie. Adding a second Cookie overwrites the first one.
Methods
Cookie data has a static utility Methode, fromString, that Sie können verwenden to erstellen a Cookie by parsing a Zeichenfolge that enthält gültig Cookie data. Die Methode accepts string as a Parameter and gibt einen initialized Cookie Instanz.

GeolocationData

GeolocationData enthält den Besucher’s geolocation details.
Jedes Besucher can only have one GeolocationData. Adding a second GeolocationData overwrites the first one.
An Objekt Parameter mit der Typ GeolocationInfoType enthält die folgende Felder:

CustomData

CustomData ermöglicht beliebige Typ of data to be easily zugeordnet zu jedes Besucher. It can then be verwendet as a Targeting condition in Segmente or as a filter/breakdown in Experiment reports. Um mehr zu erfahren about benutzerdefiniert data, please refer to this article.
  • Jedes Besucher is allowed only one CustomData for jedes eindeutig index. Adding ein anderes CustomData mit die gleiche index will replace the existing one.
  • The benutzerdefiniert data ‘index’ finden Sie im Benutzerdefiniert Daten dashboard under the “INDEX” column.
  • To prevent das SDK from sending data mit the selected index to Kameleoon-Servern for privacy reasons, aktivieren the option: Verwenden this data only locally for Targeting purposes wenn creating benutzerdefiniert data.
  • Adding a CustomData Instanz erstellt mit a Name wenn das SDK Instanz is not initialized or der Name is not registered, will Ergebnis in die Daten being ignored.

Device

Since JavaScript SDK 4.10.0, Device is automatically detected based on the User-Agent Zeichenfolge. Allerdings Sie können still manually override it falls erforderlich.
Device enthält information about your device.
Jedes Besucher can have only one Device. Adding a second Device overwrites the first one.

OperatingSystem

Since JavaScript SDK 4.10.0, OperatingSystem is automatically detected based on the User-Agent Zeichenfolge. Allerdings Sie können still manually override it falls erforderlich.
OperatingSystem enthält information about the operating system on den Besucher’s device.
Jedes Besucher can only have one OperatingSystem. Adding a second OperatingSystem overwrites the first one.

PageView

Since JavaScript SDK 4.10.0, PageView is automatically detected based on the window.location?.href and document.title. Allerdings Sie können still manually override it falls erforderlich.
PageView enthält information about your web Seite.
Jedes Besucher can have one PageView pro eindeutig URL. Adding a second PageView mit die gleiche URL notifies das SDK that den Besucher re-visited die Seite.
PageViewParametersType pageViewParameters - an Objekt mit Seite view Parameter described below
Sie können find the index or referrer ID in your Kameleoon account. Beachten Sie, dass this index starts at 0, meaning the first acquisition channel you erstellen for a given site wird assigned 0 as its ID, not 1.

UserAgent

UserAgent ermöglicht es Ihnen, store information on den Besucher’s Benutzer-agent. Server-side Experiments are more likely to be affected by bot traffic than clientseitig Experiments. Kameleoon verwendet IAB/ABC International Spiders and Bots Liste to tackle this issue and recognize known bots and spiders. Kameleoon also verwendet UserAgent Feld to filter out bots and andere unwanted traffic that might distort your Konversion metrics. Weitere Details, see our help article on bot filtering. Wenn Sie verwenden internal bots, we suggest that you pass der Wert curl/8.0 of the userAgent to exclude them from our analytics.
Visitor can only have one UserAgent. Adding a second UserAgent overwrites the first one.
Wenn Sie run Kameleoon in an hybrid Modus, your feature Experiments are automatically protected against bot traffic. This protection occurs weil Kameleoon collects den Benutzer-agent automatically on the front-end. Daher you don’t need to pass den Benutzer-agent or beliebige andere Parameter to filter bots and spiders.Wenn Sie verwenden internal bots, we suggest that you pass der Wert curl/8.0 of the userAgent to exclude them from our analytics.

ApplicationVersion

ApplicationVersion repräsentiert the semantic Version Zahl of your Anwendung.
A Besucher can have only one ApplicationVersion. Adding a second Instanz will overwrite the first one.

Returned Types

DataFile

The DataFile enthält das SDK Konfiguration details. It kann extended mit additional information if erforderlich by clients. Wenn Sie need weitere Details, please contact your Customer Success Manager.

FeatureFlag

The FeatureFlag repräsentiert a set of Eigenschaften that define a feature flag itself — zum Beispiel its Variations, Rules, environment Status, and andere related details. It kann extended mit additional information if erforderlich by clients. Wenn Sie need weitere Details, please contact your Customer Success Manager.

Regel

The Rule repräsentiert a set of Eigenschaften that define a Regel itself — zum Beispiel its Variations. It kann extended mit additional information if erforderlich by clients. Wenn Sie need weitere Details, please contact your Customer Success Manager.

Variation

Variation enthält information about the assigned variation to den Besucher (or the Standard variation, wenn kein spezifisch assignment exists).
  • Ensure that your code handles the case wo id or experimentId is null, indicating a Standard variation.
  • The variables map might be leer wenn kein variables are zugeordnet zu the variation.

Variable

Variable enthält information about a variable zugeordnet zu the assigned variation.

Veraltet Methoden

These Methoden are veraltet and wird removed in the next major aktualisieren.

getFeatureFlagVariationKey()

Verwenden Sie getVariation Methode stattdessen
The getFeatureFlagVariationKey() Methode retrieves the variation Schlüssel for einen Besucher identified by a visitorCode. Diese Methode umfasst a Targeting prüfen that identifies the appropriate variation exposed to den Besucher, saves it to storage, and sends a Tracking Anfrage.
Wenn einen Benutzer is not zugeordnet zu a feature flag, das SDK randomly gibt einen variation Schlüssel entsprechend the feature flag Regeln. If den Benutzer has bereits been registered mit the feature flag, das SDK will detect this association and zurückgeben den Benutzer’s vorherig variation Schlüssel Wert. Allerdings if den Benutzer does not meet beliebige of the defined Regeln, das SDK will zurückgeben der Standardwert angegeben in Kameleoon’s feature flag delivery Regeln. It’s important to beachten Sie, dass der Standardwert kann a variation Schlüssel, a boolescher Wert Wert, or ein anderes data Typ, depending on the feature flag’s Konfiguration.
Arguments
Zurückgeben Wert
Exceptions thrown

getVisitorFeatureFlags()

  • 🚫 Doesn’t senden Tracking Daten to Kameleoon
  • 🎯 Events: EventType.Evaluation (for jedes feature flag)
Verwenden Sie getVariations Methode stattdessen.
The getVisitorFeatureFlags() Methode gibt einen Liste of feature flags that target einen Besucher identified by their visitorCode and the feature flags that are aktiv for the angegeben Besucher.
Diese Methode only collects den Besucher’s active feature flags, meaning das Ergebnis excludes alle feature flags for das den Besucher is assigned the off (Standard or control) variation. Wenn you need alle of den Besucher’s feature flags, verwenden getFeatureFlags stattdessen.Zum Beispiel:
For cases wo you need alle of den Besucher’s feature flags, verwenden getFeatureFlags stattdessen:
Arguments
Zurückgeben Wert
Exceptions thrown

getActiveFeatureFlags()

  • 🚫 Doesn’t senden Tracking Daten to Kameleoon
  • 🎯 Events: EventType.Evaluation (for jedes feature flag)
Verwenden Sie getVariations Methode stattdessen.
The getActiveFeatureFlags() Methode gibt einen Map, wo Schlüssel is featurekey and Wert is detailed information about den Besucher’s variation and it’s variables
Diese Methode only collects den Besucher’s active feature flags. This means das Ergebnis excludes alle the feature flags for das den Besucher is assigned to the off (Standard or control) variation. Wenn you need alle of den Besucher’s feature flags to iterate, verwenden getFeatureFlags stattdessen.See the getVisitorFeatureFlags CAUTION section Methode weitere Details.
Arguments
Zurückgeben Wert
Exceptions thrown

getFeatureFlagVariable()

Verwenden Sie getVariation Methode.
The getFeatureFlagVariable() Methode gibt einen variable for einen Besucher identified by a visitorCode. Diese Methode umfasst a Targeting prüfen that identifies the appropriate variation exposed to den Besucher, saves it to storage, and sends a Tracking Anfrage.
Arguments
Parameters Objekt of Typ GetFeatureFlagVariableParamsType containing die folgende Felder:
Zurückgeben Wert
Exceptions thrown

getFeatureFlagVariables()

Verwenden Sie getVariation Methode.
The getFeatureFlagVariables() Methode gibt einen variable for einen Besucher identified by a visitorCode. Diese Methode umfasst a Targeting prüfen that identifies the appropriate variation exposed to den Besucher, saves it to storage, and sends a Tracking Anfrage.
Arguments
Zurückgeben Wert
Exceptions thrown

onConfigurationUpdate()

Verwenden Sie onEvent Methode mit EventType.ConfigurationUpdate stattdessen.
The onConfigurationUpdate() Methode fires a Callback on client Konfiguration aktualisieren.
Diese Methode is applicable only for server-sent Events verwendet in Echtzeit updates.
Arguments
Exceptions thrown

getFeatureFlags()

Verwenden Sie getDataFile() Methode stattdessen.
🚫 Doesn’t senden Tracking Daten to Kameleoon The getFeatureFlags() Methode gibt einen Liste of feature flags stored in der Client Konfiguration.
Zurückgeben Wert
Exceptions thrown