Firebase-Google Analaytics Desktop 버전 연동을 위해서 JavaScript SDK( JS-SDk ) 관련 코드 추가
This commit is contained in:
37
backup/firebase-jssdk/fb-ga.js
Normal file
37
backup/firebase-jssdk/fb-ga.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// Import the functions you need from the SDKs you need
|
||||||
|
import { initializeApp } from './firebase-app.js';
|
||||||
|
import { getAnalytics, logEvent } from './firebase-analytics.js';
|
||||||
|
|
||||||
|
// TODO: Add SDKs for Firebase products that you want to use
|
||||||
|
// https://firebase.google.com/docs/web/setup#available-libraries
|
||||||
|
|
||||||
|
// Your web app's Firebase configuration
|
||||||
|
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
|
||||||
|
const firebaseConfig = {
|
||||||
|
apiKey: "{{.FBA_apiKey}}",
|
||||||
|
authDomain: "{{.FBA_authDomain}}",
|
||||||
|
databaseURL: "{{.FBA_databaseURL}}",
|
||||||
|
projectId: "{{.FBA_projectId}}",
|
||||||
|
storageBucket: "{{.FBA_storageBucket}}",
|
||||||
|
messagingSenderId: "{{.FBA_messagingSenderId}}",
|
||||||
|
appId: "{{.FBA_appId}}",
|
||||||
|
measurementId: "{{.FBA_measurementId}}"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Initialize Firebase
|
||||||
|
const app = initializeApp(firebaseConfig);
|
||||||
|
const analytics = getAnalytics(app);
|
||||||
|
|
||||||
|
// LogEvent('DESKTOP_TEST8');
|
||||||
|
|
||||||
|
export function LogEvent(args){
|
||||||
|
|
||||||
|
if ( arguments.length == 1) {
|
||||||
|
logEvent(analytics, arguments[0]);
|
||||||
|
} else {
|
||||||
|
logEvent(analytics, arguments[0], arguments[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
1
backup/firebase-jssdk/fb-ga.min.js
vendored
Normal file
1
backup/firebase-jssdk/fb-ga.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2376
backup/firebase-jssdk/fb-ga.rollup.js
Normal file
2376
backup/firebase-jssdk/fb-ga.rollup.js
Normal file
File diff suppressed because one or more lines are too long
3
backup/firebase-jssdk/firebase-analytics.js
Normal file
3
backup/firebase-jssdk/firebase-analytics.js
Normal file
File diff suppressed because one or more lines are too long
2522
backup/firebase-jssdk/firebase-app.js
Normal file
2522
backup/firebase-jssdk/firebase-app.js
Normal file
File diff suppressed because it is too large
Load Diff
537
backup/firebase-jssdk/js.js
Normal file
537
backup/firebase-jssdk/js.js
Normal file
File diff suppressed because one or more lines are too long
3
backup/firebase-jssdk/original/firebase-analytics.js
Normal file
3
backup/firebase-jssdk/original/firebase-analytics.js
Normal file
File diff suppressed because one or more lines are too long
2522
backup/firebase-jssdk/original/firebase-app.js
Normal file
2522
backup/firebase-jssdk/original/firebase-app.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -28,6 +28,15 @@
|
|||||||
|
|
||||||
"firebase_admin_sdk_credentialfile": "",
|
"firebase_admin_sdk_credentialfile": "",
|
||||||
|
|
||||||
|
"firebase_google_analytics_jssdk_apikey": "",
|
||||||
|
"firebase_google_analytics_jssdk_authdomain": "",
|
||||||
|
"firebase_google_analytics_jssdk_databaseurl": "",
|
||||||
|
"firebase_google_analytics_jssdk_projectid": "",
|
||||||
|
"firebase_google_analytics_jssdk_storagebucket": "",
|
||||||
|
"firebase_google_analytics_jssdk_messagingsenderid": "",
|
||||||
|
"firebase_google_analytics_jssdk_apiid": "",
|
||||||
|
"firebase_google_analytics_jssdk_measurementid": "",
|
||||||
|
|
||||||
"maingate_global_admins" : [
|
"maingate_global_admins" : [
|
||||||
"mountain@action2quare.com"
|
"mountain@action2quare.com"
|
||||||
]
|
]
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
"text/template"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
@ -95,6 +96,18 @@ type maingateConfig struct {
|
|||||||
FirebaseAdminSDKCredentialFile string `json:"firebase_admin_sdk_credentialfile"`
|
FirebaseAdminSDKCredentialFile string `json:"firebase_admin_sdk_credentialfile"`
|
||||||
SteamAppId string `json:"steam_app_id"`
|
SteamAppId string `json:"steam_app_id"`
|
||||||
SteamPublisherAuthKey string `json:"steam_publisher_authkey"`
|
SteamPublisherAuthKey string `json:"steam_publisher_authkey"`
|
||||||
|
Firebase_Google_Analytics_JS_SDK_Config
|
||||||
|
}
|
||||||
|
|
||||||
|
type Firebase_Google_Analytics_JS_SDK_Config struct {
|
||||||
|
FGA_apiKey string `json:"firebase_google_analytics_jssdk_apikey"`
|
||||||
|
FGA_authDomain string `json:"firebase_google_analytics_jssdk_authdomain"`
|
||||||
|
FGA_databaseURL string `json:"firebase_google_analytics_jssdk_databaseurl"`
|
||||||
|
FGA_projectId string `json:"firebase_google_analytics_jssdk_projectid"`
|
||||||
|
FGA_storageBucket string `json:"firebase_google_analytics_jssdk_storagebucket"`
|
||||||
|
FGA_messagingSenderId string `json:"firebase_google_analytics_jssdk_messagingsenderid"`
|
||||||
|
FGA_appId string `json:"firebase_google_analytics_jssdk_apiid"`
|
||||||
|
FGA_measurementId string `json:"ffirebase_google_analytics_jssdk_measurementid"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type globalAdmins struct {
|
type globalAdmins struct {
|
||||||
@ -495,6 +508,14 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMu
|
|||||||
serveMux.Handle(pattern, http.StripPrefix(pattern, staticfs))
|
serveMux.Handle(pattern, http.StripPrefix(pattern, staticfs))
|
||||||
logger.Println("maingate static registered :", pattern)
|
logger.Println("maingate static registered :", pattern)
|
||||||
|
|
||||||
|
fbafs := http.FileServer(http.Dir("fba"))
|
||||||
|
pattern = gocommon.MakeHttpHandlerPattern(prefix, "fba", "/")
|
||||||
|
serveMux.Handle(pattern, http.StripPrefix(pattern, fbafs))
|
||||||
|
logger.Println("google_analytics static registered :", pattern)
|
||||||
|
|
||||||
|
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "fba", "fb-ga.min.js"), mg.google_analytics_js)
|
||||||
|
logger.Println("google_analytics.js static registered :", pattern)
|
||||||
|
|
||||||
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "request_login_url", AuthPlatformGoogle), mg.platform_google_get_login_url)
|
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "request_login_url", AuthPlatformGoogle), mg.platform_google_get_login_url)
|
||||||
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "authorize", AuthPlatformGoogle), mg.platform_google_authorize)
|
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "authorize", AuthPlatformGoogle), mg.platform_google_authorize)
|
||||||
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "authorize_result", AuthPlatformGoogle), mg.platform_google_authorize_result)
|
serveMux.HandleFunc(gocommon.MakeHttpHandlerPattern(prefix, "authorize_result", AuthPlatformGoogle), mg.platform_google_authorize_result)
|
||||||
@ -848,3 +869,31 @@ func JWTparseCode(keyurl string, code string) (string, string, string) {
|
|||||||
//--- nonce 체크 필요하다.
|
//--- nonce 체크 필요하다.
|
||||||
return claims["sub"].(string), email, nonce
|
return claims["sub"].(string), email, nonce
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (mg *Maingate) google_analytics_html(w http.ResponseWriter, r *http.Request) {
|
||||||
|
parsedTemplate, _ := template.ParseFiles("template/track-event.html")
|
||||||
|
err := parsedTemplate.Execute(w, nil)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("Error executing template :", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mg *Maingate) google_analytics_js(w http.ResponseWriter, r *http.Request) {
|
||||||
|
fgaconfig := Firebase_Google_Analytics_JS_SDK_Config{
|
||||||
|
FGA_apiKey: mg.FGA_apiKey,
|
||||||
|
FGA_authDomain: mg.FGA_authDomain,
|
||||||
|
FGA_databaseURL: mg.FGA_databaseURL,
|
||||||
|
FGA_projectId: mg.FGA_projectId,
|
||||||
|
FGA_storageBucket: mg.FGA_storageBucket,
|
||||||
|
FGA_messagingSenderId: mg.FGA_messagingSenderId,
|
||||||
|
FGA_appId: mg.FGA_appId,
|
||||||
|
FGA_measurementId: mg.FGA_measurementId,
|
||||||
|
}
|
||||||
|
parsedTemplate, _ := template.ParseFiles("template/fb-ga.min.js")
|
||||||
|
err := parsedTemplate.Execute(w, fgaconfig)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("Error executing template :", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
11
fba/track-event.html
Normal file
11
fba/track-event.html
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<script type="text/javascript" src="./fb-ga.min.js">
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
<!-- <body> -->
|
||||||
|
<!-- <body onload="window.FBA.TrackLogEvent('DESKTOP-TEST');"> -->
|
||||||
|
<!-- <script type="cjs" src="./fb-ga.rollup.js"> -->
|
||||||
1
template/fb-ga.min.js
vendored
Normal file
1
template/fb-ga.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user