OMCAnalytics Class Reference

Inherits from OMCServiceProxy : NSObject
Declared in OMCAnalytics.h

Overview

Library interface to the Oracle Mobile Cloud Analytics service.

Device Location Support

By default, the Analytics library captures the device’s location with each Analytics event and session start/end. As a result, the first time the Analytics library records a session start, the library will request authorization to access the device’s location. If the library’s client app has not already requested this authorization, the user will be prompted via a dialog.

[iOS 8 and later] By default, the Analytics library will request “when in use” location authorization. If the client app will be starting or ending Analytics sessions or logging Analytics events in the background and would like the device location to be updated while the app is in the background, this library must be configured to request “always” authorization. (Alternatively, the client app itself can request “always” authorization.) This is configured via the appropriate OMC.plist property.

[iOS 8 and later] The Analytics library requests location updates by calling the method [CLLocationManager startUpdatingLocation], which requires only “when in use” authorization, unless updates are required while the client app is in the background.

Warning: [iOS 8 and later] If the Analytics library is configured to capture location information, the client app’s Info.plist file must include the appropriate entry for prompting the user for location authorization; either NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription. See the documentation for CLLocationManager.

  sessionID

The analytics service’s current session ID. This is nil if there is currently no analytics session.

@property (readonly, nullable) NSUUID *sessionID

Declared In

OMCAnalytics.h

  delegate

The analytics service’s delegate.

@property (weak) id<OMCAnalyticsDelegate> delegate

Declared In

OMCAnalytics.h

  optOut

Determines whether sessions and events are logged. If this flag is set to YES, the following methods will do nothing:

@property BOOL optOut

Discussion

This allows the client application to simply set this flag if the user wants to “opt out” of being tracked via analytics events. The client application code then need not check the user’s preference with every call to the Analytics library.

NB: As the value of this flag is not persisted, its value must be set by the client application every time the application starts. The client must persist the user’s preference as appropriate.

NB: The flush method ignores this flag and will still upload any events generated while this flag was not set. As usual, if there are no events, the flush method does nothing.

Declared In

OMCAnalytics.h

– startSession

Starts an OMC Analytics session. If a session is already in progress, it simply proceeds and a new session is NOT started.

- (void)startSession

Discussion

Does nothing if the optOut flag is set.

Declared In

OMCAnalytics.h

– endSession

Stops the current OMC Analytics session. Does nothing if a session is not in progress.

- (void)endSession

Discussion

Does nothing if the optOut flag is set.

Declared In

OMCAnalytics.h

– logEvent:

Logs an OMC Analytics event with the specified name. If a session is not in progress, starts a session. Copies the specified name before returning.

- (void)logEvent:(NSString *)name

Parameters

name

The event name.

Discussion

Does nothing if the optOut flag is set.

Declared In

OMCAnalytics.h

– logEvent:properties:

Logs an OMC Analytics event with the specified name and properties. If a session is not in progress, starts a session. Copies the specified name and properties before returning.

- (void)logEvent:(NSString *)name properties:(NSDictionary<NSString*,NSString*> *_Nullable)properties

Parameters

name

The event name.

properties

Optional dictionary of arbitrarily named properties for the event.

Discussion

Does nothing if the optOut flag is set.

Warning: Raises an NSInvalidArgumentException if any of the keys in properties is reserved.

Declared In

OMCAnalytics.h

– flush

Uploads all the logged events to the OMC Mobile Analytics REST service.

- (void)flush

Declared In

OMCAnalytics.h

+ reservedEventPropertyNames

Returns a set of the reserved event property names.

+ (NSSet *)reservedEventPropertyNames

Declared In

OMCAnalytics.h

  contextLocationCountry

The analytics service’s context location country. This can be nil.

@property (readonly, nullable) NSString *contextLocationCountry

Declared In

OMCAnalytics.h

  contextLocationRegion

The analytics service’s context location region. This can be nil.

@property (readonly, nullable) NSString *contextLocationRegion

Declared In

OMCAnalytics.h

  contextLocationLocality

The analytics service’s context location locality. This can be nil.

@property (readonly, nullable) NSString *contextLocationLocality

Declared In

OMCAnalytics.h

  contextLocationPostalCode

The analytics service’s context location postal code. This can be nil.

@property (readonly, nullable) NSString *contextLocationPostalCode

Declared In

OMCAnalytics.h

– setContextLocationCountry:region:locality:postalCode:

Set the analytics service’s context location country, region, locality, and/or postal code. Any of these settings can be nil.

- (void)setContextLocationCountry:(nullable NSString *)country region:(nullable NSString *)region locality:(nullable NSString *)locality postalCode:(nullable NSString *)postalCode

Parameters

country

Optional country.

region

Optional region.

locality

Optional locality.

postalCode

Optional postal code.

Declared In

OMCAnalytics.h