Analytics

The React Native OpenWeb SDK provides analytics tracking capabilities through the OpenWeb.manager.analytics API, enabling developers to monitor user interactions and integrate with business intelligence systems.

The analytics API consists of two key components:

  • Custom BI Data: A customizable property for adding your own metadata to analytics events
    get customBIData(): Record<string, string>
    set customBIData(value: Record<string, string>)
  • Event Handlers: Callback registration for receiving analytics events
    onAnalyticsEvent(handler: OWAnalyticsHandler): () => void

Event Handlers

Register a handler to receive analytics events:

const unsubscribe = OpenWeb.manager.analytics.onAnalyticsEvent((data) => {
  console.log('Analytics event:', data);
  // Send to your analytics platform
});

// Cleanup when no longer needed
unsubscribe();

Custom Data in Analytics Events

The customData field in OWAnalyticsEventData contains your custom business intelligence data that was set via OpenWeb.manager.analytics.customBIData. This allows you to attach application-specific metadata to every analytics event. It's automatically included with every analytics event, allowing you to enrich your analytics with contextual information about the user, session, or application state.

get customBIData(): Record<string, string>
set customBIData(value: Record<string, string>) 
// Set custom business intelligence data
OpenWeb.manager.analytics.customBIData = {
  userId: '12345',
  userTier: 'premium',
  sessionId: 'abc-def-ghi',
  appVersion: '2.1.0'
};

// Custom data is automatically included in all analytics events
OpenWeb.manager.analytics.onAnalyticsEvent((data) => {
  console.log('Event:', data.eventName);
  console.log('Custom Data:', data.customData);
});

Type Definition

OWAnalyticsEventData

interface OWAnalyticsEventData {
  event: OWAnalyticsEvent;           // The specific event with its data
  postId: string;                    // Unique article identifier
  customData?: Record<string, any>;  // Your custom BI data
}

OWAnalyticsEvent

Event Type

Additional Data

FullConversationLoaded

None

FullConversationLoaded

None

FullConversationViewed

None

PreConversationViewed

None

CommentViewed

commentId?: string

CommentShareClicked

commentId?: string

CommentReadMoreClicked

commentId?: string

CommentRankUpButtonClicked

commentId?: string

CommentRankDownButtonClicked

commentId?: string

CommentRankUpUndoButtonClicked**

commentId?: string

CommentRankDownUndoButtonClicked

commentId?: string

CommentMenuClicked

commentId?: string

CommentMenuClosed

commentId?: string

CommentMenuReportClicked

commentId?: string

CommentMenuDeleteClicked

commentId?: string

CommentMenuConfirmDeleteClicked

commentId?: string

CommentMenuEditClicked

commentId?: string

CommentMenuMuteClicked

commentId?: string

PostCommentClicked

None

PostReplyClicked

replyToCommentId?: string

ReplyClicked

replyToCommentId?: string

EditCommentClicked

commentId?: string

EditCommentClicked

None

CommentCreationClosePage

None

CommentCreationClosePage

None

CommentCreationContinueWriting

None

CameraIconClickedOpen

None

CameraIconClickedTakePhoto

None

CameraIconClickedChooseFromGallery

None

CameraIconClickedChooseFromGallery

None

SortByClicked

currentSort?: OWSortOption

SortByClosed

currentSort?: OWSortOption

SortByChanged

previousSort?: OWSortOption
selectedSort?: OWSortOption

LoadMoreComments

paginationOffset?: number

LoadMoreRepliesClicked

commentId?: string

HideMoreRepliesClicked

commentId?: string

HideMoreRepliesClicked

None

UserProfileClicked

None

MyProfileClicked

source?: OWAvatarSource

SignUpToPostClicked

None

LoginPromptClicked

None

CommunityGuidelinesLinkClicked

None

OWSortOption

Defines the sorting order for comments in a conversation.

export const OWSortOptionType = {
  Best: 'BEST',
  Newest: 'NEWEST',
  Oldest: 'OLDEST',
} as const;

export type OWSortOption =
  | { type: typeof OWSortOptionType.Best }
  | { type: typeof OWSortOptionType.Newest }
  | { type: typeof OWSortOptionType.Oldest };

OWAvatarSource

Identifies where a user avatar was clicked from within the app.

export const OWAvatarSource = {
  Comment: 'comment',
  CommentCreation: 'commentCreation',
  CommentCTA: 'commentCTA',
  Notifications: 'notifications',
} as const;

export type OWAvatarSource =
  | { type: typeof OWAvatarSource.Comment }
  | { type: typeof OWAvatarSource.CommentCreation }
  | { type: typeof OWAvatarSource.CommentCTA }
  | { type: typeof OWAvatarSource.Notifications };