Skip to content

Commit

Permalink
chore: add ios session replay to react-native example app
Browse files Browse the repository at this point in the history
  • Loading branch information
curtisliu committed Oct 8, 2024
1 parent 13c5d12 commit edd8a0e
Show file tree
Hide file tree
Showing 12 changed files with 1,722 additions and 53 deletions.
12 changes: 1 addition & 11 deletions examples/react-native/example/ios/.xcode.env
Original file line number Diff line number Diff line change
@@ -1,11 +1 @@
# This `.xcode.env` file is versioned and is used to source the environment
# used when running script phases inside Xcode.
# To customize your local environment, you can create an `.xcode.env.local`
# file that is not versioned.

# NODE_BINARY variable contains the PATH to the node executable.
#
# Customize the NODE_BINARY variable here.
# For example, to use nvm with brew, add the following line
# . "$(brew --prefix nvm)/nvm.sh" --no-use
export NODE_BINARY=$(command -v node)
export NODE_BINARY=/Users/curtis/.nvm/versions/node/v18.20.4/bin/node
56 changes: 56 additions & 0 deletions examples/react-native/example/ios/ConsoleLogger.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// ConsoleLogger.swift
//
//
// Created by Marvin Liu on 10/28/22.
//

import Foundation
import os.log
import AmplitudeSessionReplay


@objc(AMPLogLevel)
public enum LogLevelEnum: Int {
case OFF
case ERROR
case WARN
case LOG
case DEBUG
}

public class ConsoleLogger: AmplitudeSessionReplay.Logger {
public typealias LogLevel = LogLevelEnum

public var logLevel: Int
private var logger: OSLog

public init(logLevel: Int = LogLevelEnum.OFF.rawValue) {
self.logLevel = logLevel
self.logger = OSLog(subsystem: "Amplitude", category: "Logging")
}

public func error(message: String) {
if logLevel >= LogLevel.ERROR.rawValue {
os_log("Error: %@", log: logger, type: .error, message)
}
}

public func warn(message: String) {
if logLevel >= LogLevel.WARN.rawValue {
os_log("Warn: %@", log: logger, type: .default, message)
}
}

public func log(message: String) {
if logLevel >= LogLevel.LOG.rawValue {
os_log("Log: %@", log: logger, type: .info, message)
}
}

public func debug(message: String) {
if logLevel >= LogLevel.DEBUG.rawValue {
os_log("Debug: %@", log: logger, type: .debug, message)
}
}
}
2 changes: 2 additions & 0 deletions examples/react-native/example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ target 'example' do
:app_path => "#{Pod::Config.instance.installation_root}/.."
)

pod 'AmplitudeSessionReplay', :git => 'https://github.com/amplitude/AmplitudeSessionReplay-iOS.git'

target 'exampleTests' do
inherit! :complete
# Pods for testing
Expand Down
Loading

0 comments on commit edd8a0e

Please sign in to comment.