NimbusClient
open class NimbusClient:
NimbusClientProtocol
-
Declaration
Swift
required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer)
-
Declaration
Swift
public convenience init(appCtx: AppContext, recordedContext: RecordedContext?, coenrollingFeatureIds: [String], dbpath: String, remoteSettingsConfig: RemoteSettingsConfig?, metricsHandler: MetricsHandler) throws
-
Advances what the event store thinks is now. This, and
record_past_event
are useful for testing.by_seconds
must be positive.Declaration
Swift
open func advanceEventTime(bySeconds: Int64) throws
-
Apply the updated experiments from the last fetch. After calling this, the list of active experiments might change (there might be new experiments, or old experiments might have expired).
Declaration
Swift
open func applyPendingExperiments() throws -> [EnrollmentChangeEvent]
-
Declaration
Swift
open func clearEvents() throws
-
This provides a unified String interpolation library which exposes the application context. It’s first use is in the messaging helper, to add extra parameters to URLs.
Declaration
Swift
open func createStringHelper(additionalContext: JsonObject? = nil) throws -> NimbusStringHelper
-
This provides low level access to the targeting machinery for other uses by the application (e.g. messages) Additional parameters can be added via the optional JSON object. This allows for many JEXL expressions to be run across the same context.
Declaration
Swift
open func createTargetingHelper(additionalContext: JsonObject? = nil) throws -> NimbusTargetingHelper
-
Declaration
Swift
open func dumpStateToLog() throws
-
Fetches the list of experiments from the server. This does not affect the list of active experiments or experiment enrolment. Fetched experiments are not applied until
apply_pending_updates()
is called.Declaration
Swift
open func fetchExperiments() throws
-
Returns a list of experiments this user is enrolled in.
Declaration
Swift
open func getActiveExperiments() throws -> [EnrolledExperiment]
-
Returns a list of experiments for this
app_name
, as specified in theAppContext
. It is not intended to be used to be used for user facing applications.Declaration
Swift
open func getAvailableExperiments() throws -> [AvailableExperiment]
-
Returns the branch allocated for a given slug or id.
Declaration
Swift
open func getExperimentBranch(id: String) throws -> String?
-
Returns a list of experiment branches for a given experiment ID.
Declaration
Swift
open func getExperimentBranches(experimentSlug: String) throws -> [ExperimentBranch]
-
Declaration
Swift
open func getFeatureConfigVariables(featureId: String) throws -> String?
-
Getter and setter for user’s participation in all experiments. Possible values are:
true
: the user will not enroll in new experiments, and opt out of all existing ones.false
: experiments proceed as usual.
Declaration
Swift
open func getGlobalUserParticipation() throws -> Bool
-
Initializes the database and caches enough information so that the non-blocking API functions (eg,
get_experiment_branch()
) can return accurate results rather than throwing a “not initialized” error. It’s not strictly necessary to call this function - any function that wants to use the database will implicitly initialize too - this exists so that the consuming application can have confidence the non-blocking functions will return data instead of returning an error, and will do the minimum amount of work to achieve that.Declaration
Swift
open func initialize() throws
-
Declaration
Swift
open func isFetchEnabled() throws -> Bool
-
Opt in to a specific branch on a specific experiment. Useful for developers to test their app’s interaction with the experiment.
Declaration
Swift
open func optInWithBranch(experimentSlug: String, branch: String) throws -> [EnrollmentChangeEvent]
-
Opt out of a specific experiment.
Declaration
Swift
open func optOut(experimentSlug: String) throws -> [EnrollmentChangeEvent]
-
Records an event for the purposes of behavioral targeting. This function is used to record and persist data used for the behavioral targeting such as “core-active” user targeting.
Declaration
Swift
open func recordEvent(eventId: String, count: Int64 = Int64(1)) throws
-
Records a Glean event that this feature has been exposed. If the feature is not involved in an experiment, then the event is suppressed. If the feature is only involved in a rollout, then the event is suppressed. If the feature is involved in an experiment, then record the experiment slug and branch. If the feature is involved in an experiment and a rollout, then record only the experiment slug and branch. If the slug is specified, then use this as the experiment, and use it to look up the branch. This is useful for coenrolling features.
Declaration
Swift
open func recordFeatureExposure(featureId: String, slug: String?)
-
Records a Glean event that this feature configuration is malformed. Accepts a part_id to give the experiment owner or feature implementer clues where to look. The Glean event will always fire, but the content of that event will vary depending on whether then feature is part of an experiment or rollout or not.
Declaration
Swift
open func recordMalformedFeatureConfig(featureId: String, partId: String)
-
Records an event as if it were in the past. This, and
advance_event_time
are useful for testing.seconds_ago
must be positive.Declaration
Swift
open func recordPastEvent(eventId: String, secondsAgo: Int64, count: Int64 = Int64(1)) throws
-
These are test-only functions and should never be exposed to production users, as they mess with the “statistical requirements” of the SDK. Reset the enrollments and experiments in the database to an empty state.
Declaration
Swift
open func resetEnrollments() throws
-
Reset internal state in response to application-level telemetry reset.
Consumers should call this method when the user resets the telemetry state of the consuming application, such as by opting out of submitting telemetry. It resets the internal state of the Nimbus client to create a clean break between data collected before and after the reset, including:
* clearing any unique identifiers used internally, so they will reset to new random values on next use. * accepting new randomization units, based on application-level ids that may have also changed. * disqualifying this client out of any active experiments, to avoid submitting misleading incomplete data.
Declaration
Swift
open func resetTelemetryIdentifiers() throws -> [EnrollmentChangeEvent]
-
A convenience method for apps to set the experiments from a local source for either testing, or before the first fetch has finished.
Experiments set with this method are not applied until
apply_pending_updates()
is called.Declaration
Swift
open func setExperimentsLocally(experimentsJson: String) throws
-
Toggles the enablement of the fetch. If
false
, then callingfetch_experiments
returns immediately, having not done any fetching from remote settings. This is only useful for QA, and should not be used in production: useset_global_user_participation
instead.Declaration
Swift
open func setFetchEnabled(flag: Bool) throws
-
Declaration
Swift
open func setGlobalUserParticipation(optIn: Bool) throws -> [EnrollmentChangeEvent]