Skip to content

Commit

Permalink
source
Browse files Browse the repository at this point in the history
  • Loading branch information
nprudnikov committed Nov 22, 2020
1 parent dea18f4 commit d597789
Show file tree
Hide file tree
Showing 41 changed files with 3,018 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/Intermediate/
/Binaries/
.DS_Store
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Nikolay Prudnikov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
22 changes: 22 additions & 0 deletions PrFirebase.uplugin
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"FileVersion" : 3,

"FriendlyName" : "PrFirebase",
"Version" : 1,
"VersionName" : "0.1",
"CreatedBy" : "Prudnikov Nikolay",
"CreatedByURL" : "https://github.com/nprudnikov",
"EngineVersion" : "4.26.0",
"Description" : "",
"Category" : "Analytics",
"MarketplaceURL" : "",

"Modules" :
[
{
"Name" : "PrFirebase",
"Type" : "Runtime",
"LoadingPhase": "PreLoadingScreen"
}
]
}
22 changes: 22 additions & 0 deletions Source/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
Language: Cpp
BasedOnStyle: LLVM
IndentWidth: 4
TabWidth: 4
UseTab: ForContinuationAndIndentation
Standard: Cpp11
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignEscapedNewlines: Right
AlignTrailingComments: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: InlineOnly
BreakBeforeBraces: Allman
BreakConstructorInitializersBeforeComma: true
ColumnLimit: 0
PointerAlignment: Left
SpacesInAngles: false
---
Language: ObjC
DisableFormat: true
...
45 changes: 45 additions & 0 deletions Source/PrFirebase/Classes/PrFirebaseAuthModule.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#pragma once

#include "PrFirebaseModule.h"

#include "PrFirebaseDefines.h"

#include "PrFirebaseAuthModule.generated.h"

USTRUCT(Blueprintable, BlueprintType)
struct PRFIREBASE_API FPrFirebaseUser
{
GENERATED_BODY();

FPrFirebaseUser(){};

UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString UserName;

UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString Uid;
};

DECLARE_DYNAMIC_DELEGATE_OneParam(FPrFirebaseAuthDelegate, bool, bSuccess);

UCLASS()
class PRFIREBASE_API UPrFirebaseAuthModule : public UPrFirebaseModule
{
GENERATED_BODY()

public:
UFUNCTION(BlueprintCallable, Category = "Firebase|Auth")
virtual void SignInNativePlatform(FPrFirebaseAuthDelegate Delegate) { Firebase_NotImplemented(); }

UFUNCTION(BlueprintCallable, Category = "Firebase|Auth")
virtual void GetUserInfo(FPrFirebaseUser& OutUserInfo) const { Firebase_NotImplemented(); }

UFUNCTION(BlueprintCallable, Category = "Firebase|Auth")
virtual bool IsAuthenticated() const
{
Firebase_NotImplemented();
return false;
}

virtual bool IsAvailable() const final { return WITH_FIREBASE_CRASHLYTICS; }
};
45 changes: 45 additions & 0 deletions Source/PrFirebase/Classes/PrFirebaseCrashlyticsModule.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#pragma once

#include "PrFirebaseModule.h"

#include "PrFirebaseDefines.h"

#include "PrFirebaseCrashlyticsModule.generated.h"

class FOutputDevice;

UCLASS()
class PRFIREBASE_API UPrFirebaseCrashlyticsModule : public UPrFirebaseModule
{
GENERATED_BODY()

public:
UFUNCTION(BlueprintCallable, Category = "Firebase|Crashlytics|Crash")
virtual void Crash() { Firebase_NotImplemented(); }

UFUNCTION(BlueprintCallable, Category = "Firebase|Crashlytics|User")
virtual void SetUserIdentifier(const FString& UserIdentifier) { Firebase_NotImplemented(); }

UFUNCTION(BlueprintCallable, Category = "Firebase|Crashlytics|Log")
virtual void WriteLog(const FString& Log) { Firebase_NotImplemented(); }

UFUNCTION(BlueprintCallable, Category = "Firebase|Crashlytics|Log")
virtual void WriteError(const FString& Log, int32 Code = 0) { Firebase_NotImplemented(); }

UFUNCTION(BlueprintCallable, Category = "Firebase|Crashlytics|Value")
virtual void AddAttribute(const FString& Key, const FString& Value) { Firebase_NotImplemented(); }

virtual bool IsAvailable() const final { return WITH_FIREBASE_CRASHLYTICS; }

protected:
friend class FCrashlyticsOutputDevice;
friend class FCrashlyticsOutputDeviceError;

void CatchEngineLogs();

FString CrashlyticsLogFormat(const TCHAR* V, ELogVerbosity::Type Verbosity, const class FName& Category);

void WriteBlueprintCallstack();

void Log(bool bCritical, const TCHAR* V, ELogVerbosity::Type Verbosity, const class FName& Category);
};
9 changes: 9 additions & 0 deletions Source/PrFirebase/Classes/PrFirebaseDefines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include "CoreMinimal.h"

DEFINE_LOG_CATEGORY_STATIC(LogFirebase, VeryVerbose, All);
DEFINE_LOG_CATEGORY_STATIC(LogCrashlytics, VeryVerbose, All);
DEFINE_LOG_CATEGORY_STATIC(LogPerformance, VeryVerbose, All);

#define Firebase_NotImplemented()
17 changes: 17 additions & 0 deletions Source/PrFirebase/Classes/PrFirebaseLibrary.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include "Kismet/BlueprintFunctionLibrary.h"

#include "PrFirebaseProxy.h"

#include "PrFirebaseLibrary.generated.h"

UCLASS()
class PRFIREBASE_API UPrFirebaseLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()

public:
UFUNCTION(BlueprintCallable, Category = PrFirebase, BlueprintPure)
static UPrFirebaseProxy* GetFirebaseProxy();
};
28 changes: 28 additions & 0 deletions Source/PrFirebase/Classes/PrFirebaseModule.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

#include "PrFirebaseDefines.h"

#include "CoreMinimal.h"

#include "PrFirebaseModule.generated.h"

UCLASS()
class PRFIREBASE_API UPrFirebaseModule : public UObject
{
GENERATED_BODY()

public:
UFUNCTION(BlueprintCallable, Category = "Firebase|Module")
virtual bool IsAvailable() const
{
Firebase_NotImplemented();
return false;
}

protected:
friend class UPrFirebaseProxy;

virtual void PreInitialize_AnyThread() {}
virtual void Initialize_AnyThread() {}
virtual void PostInitialize_AnyThread() {}
};
155 changes: 155 additions & 0 deletions Source/PrFirebase/Classes/PrFirebasePerformanceModule.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
#pragma once

#include "PrFirebaseModule.h"

#include "PrFirebaseDefines.h"

#include "Misc/CoreDelegates.h"

#include "PrFirebasePerformanceModule.generated.h"

class UPrFirebasePerformanceModule;

USTRUCT(Blueprintable, BlueprintType)
struct FPrFirebasePerformanceTrace
{
GENERATED_BODY()

public:
FPrFirebasePerformanceTrace();

FPrFirebasePerformanceTrace(TWeakObjectPtr<UPrFirebasePerformanceModule> PerformanceModule, const FString& Identifier);

FPrFirebasePerformanceTrace(TWeakObjectPtr<UPrFirebasePerformanceModule> PerformanceModule, int32 Index);

void Stop();

void IncrementMetric(const FString& Name, int32 Value);

void SetMetric(const FString& Name, int32 Value);

void SetAttribute(const FString& Name, const FString& Value);

void RemoveAttribute(const FString& Name);

int32 GetTraceIndex() const;

private:
UPROPERTY()
TWeakObjectPtr<UPrFirebasePerformanceModule> Module;

UPROPERTY()
int32 TraceIndex;
};

USTRUCT()
struct FPrFirebasePerformanceScopeTimeTrace
{
GENERATED_BODY()

public:
FPrFirebasePerformanceScopeTimeTrace();

FPrFirebasePerformanceScopeTimeTrace(TWeakObjectPtr<UPrFirebasePerformanceModule> PerformanceModule, const FString& Identifier);

~FPrFirebasePerformanceScopeTimeTrace();

private:
TOptional<FPrFirebasePerformanceTrace> Trace;
};

UCLASS()
class PRFIREBASE_API UPrFirebasePerformanceModule : public UPrFirebaseModule
{
GENERATED_BODY()

public:
UPrFirebasePerformanceModule();

UFUNCTION(BlueprintCallable, Category = "Firebase|Performance|Trace")
void SetAttributeForAllTraces(const FString& Name, const FString& Value);

UFUNCTION(BlueprintCallable, Category = "Firebase|Performance|Trace")
void RemoveAttributeForAllTraces(const FString& Name);

UFUNCTION(BlueprintCallable, Category = "Firebase|Performance|Trace")
void SetMetricForAllTraces(const FString& Name, int32 Value);

int32 StartTraceWithoutWrapper(const FString& Identifier);

void StopTraceWithoutWrapper(int32 TraceIndex);

UFUNCTION(BlueprintCallable, Category = "Firebase|Performance|Trace")
FPrFirebasePerformanceTrace StartTrace(const FString& Identifier);

UFUNCTION(BlueprintCallable, Category = "Firebase|Performance|Trace")
void StopTrace(const FPrFirebasePerformanceTrace& Trace);

UFUNCTION(BlueprintCallable, Category = "Firebase|Performance|Trace")
void IncrementMetric(const FPrFirebasePerformanceTrace& Trace, const FString& Name, int32 Value);

UFUNCTION(BlueprintCallable, Category = "Firebase|Performance|Trace")
void SetMetric(const FPrFirebasePerformanceTrace& Trace, const FString& Name, int32 Value);

UFUNCTION(BlueprintCallable, Category = "Firebase|Performance|Trace")
void SetAttribute(const FPrFirebasePerformanceTrace& Trace, const FString& Name, const FString& Value);

UFUNCTION(BlueprintCallable, Category = "Firebase|Performance|Trace")
void RemoveAttribute(const FPrFirebasePerformanceTrace& Trace, const FString& Name);

UFUNCTION(BlueprintCallable, Category = "Firebase|Performance|Utils")
void AppliactionLaunched();

virtual bool IsAvailable() const final { return WITH_FIREBASE_PERFORMANCE; }

protected:
virtual void InternalStartTrace(int32 TraceIndex, const FString& Identifier) { Firebase_NotImplemented(); }

virtual void InternalStopTrace(int32 TraceIndex) { Firebase_NotImplemented(); }

virtual void InternalIncrementMetric(int32 TraceIndex, const FString& Name, int32 Value) { Firebase_NotImplemented(); }

virtual void InternalSetMetric(int32 TraceIndex, const FString& Name, int32 Value) { Firebase_NotImplemented(); }

virtual void InternalSetAttribute(int32 TraceIndex, const FString& Name, const FString& Value) { Firebase_NotImplemented(); }

virtual void InternalRemoveAttribute(int32 TraceIndex, const FString& Name) { Firebase_NotImplemented(); }

void InternalLaunch_AnyThread();

void SetTemperature(FCoreDelegates::ETemperatureSeverity Temp);

void SetPowerMode(bool bLowPowerMode);

void StartWatch();

private:
int32 LastTraceIndex;

bool bAppliactionLaunched;

bool bAppliactionFirstFrame;

TMap<FString, FString> GlobalAttributes;

TMap<FString, int32> GlobalMetrics;

TSet<int32> ExistingTraceIndices;

TOptional<FPrFirebasePerformanceTrace> AppLaunchTrace;

TOptional<FPrFirebasePerformanceTrace> AvFrameTrace;

TOptional<FDateTime> AvFrameTime;

int64 AvFrameCounter;

void OnAppliactionLaunched();

void OnEndFrame();
};

#define PRF_SCOPE_TIME(_Identifier_) \
FPrFirebasePerformanceScopeTimeTrace _PrFirebasePerformanceScopeTimeTrace_##_TraceName_##__LINE__(GPrFirebasePerformanceModule, #_Identifier_);

extern PRFIREBASE_API TWeakObjectPtr<UPrFirebasePerformanceModule> GPrFirebasePerformanceModule;
Loading

0 comments on commit d597789

Please sign in to comment.