Ver Fonte

meta pixel

xiongzhu há 2 anos atrás
pai
commit
d54bd4e7c6

BIN
android/app/src/main/assets/cdvasset.manifest


+ 1 - 1
android/capacitor.settings.gradle

@@ -63,7 +63,7 @@ include ':capacitor-codepush'
 project(':capacitor-codepush').projectDir = new File('../node_modules/capacitor-codepush/android')
 
 include ':capacitor-facebook'
-project(':capacitor-facebook').projectDir = new File('../node_modules/capacitor-facebook/android')
+project(':capacitor-facebook').projectDir = new File('../../../capacitor/capacitor-facebook/android')
 
 include ':capacitor-plugin-safe-area'
 project(':capacitor-plugin-safe-area').projectDir = new File('../node_modules/capacitor-plugin-safe-area/android')

+ 3 - 1
ios/App/Podfile

@@ -11,6 +11,7 @@ install! 'cocoapods', :disable_input_output_paths => true
 def capacitor_pods
   pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
   pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
+  pod 'CapacitorCommunityBarcodeScanner', :path => '../../node_modules/@capacitor-community/barcode-scanner'
   pod 'CapacitorCommunityHttp', :path => '../../node_modules/@capacitor-community/http'
   pod 'CapacitorCommunityMedia', :path => '../../node_modules/@capacitor-community/media'
   pod 'CapacitorActionSheet', :path => '../../node_modules/@capacitor/action-sheet'
@@ -30,7 +31,8 @@ def capacitor_pods
   pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'
   pod 'AppsflyerCapacitorPlugin', :path => '../../node_modules/appsflyer-capacitor-plugin'
   pod 'CapacitorCodepush', :path => '../../node_modules/capacitor-codepush'
-  pod 'CapacitorFacebook', :path => '../../node_modules/capacitor-facebook'
+  pod 'CapacitorFacebook', :path => '../../../../capacitor/capacitor-facebook'
+  pod 'CapacitorPluginSafeArea', :path => '../../node_modules/capacitor-plugin-safe-area'
   pod 'CordovaPlugins', :path => '../capacitor-cordova-ios-plugins'
 end
 

+ 1 - 1
package.json

@@ -40,7 +40,7 @@
     "appsflyer-capacitor-plugin": "^6.9.2",
     "axios": "^1.2.0",
     "capacitor-codepush": "https://github.com/x1ongzhu/capacitor-codepush.git",
-    "capacitor-facebook": "https://github.com/x1ongzhu/capacitor-facebook.git",
+    "capacitor-facebook": "link:/Users/drew/Projects/capacitor/capacitor-facebook",
     "capacitor-plugin-safe-area": "^1.0.1",
     "cordova-plugin-android-notch": "^1.0.3",
     "date-fns": "^2.29.3",

+ 21 - 1
src/main.js

@@ -198,7 +198,7 @@ const initOpeninstall = () => {
     //     }
     // })
 }
-Facebook.init({ appId: '683776590201632', pixelId: '557748303040652' }).then(() => {
+Facebook.init({ appId: '683776590201632', pixelId: '557748303040652', autoLogEvent: true }).then(() => {
     console.log('FacebookSDK initialized')
 })
 document.addEventListener('deviceready', () => {
@@ -238,3 +238,23 @@ if (useStorage('showConsole', 0).value > new Date().getTime()) {
 if (location.origin.includes('http://192.168')) {
     initEruda()
 }
+
+const initPixel = id => {
+    if (!document.querySelector('#fb_pixel')) {
+        let n = (window.fbq = function () {
+            n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments)
+        })
+        if (!window._fbq) window._fbq = n
+        n.push = n
+        n.loaded = !0
+        n.version = '2.0'
+        n.queue = []
+        let script = document.createElement('script')
+        script.setAttribute('src', 'https://connect.facebook.net/en_US/fbevents.js')
+        document.body.appendChild(script)
+        window.fbq('init', id)
+    }
+}
+if (Capacitor.getPlatform() === 'web') {
+    initPixel('557748303040652')
+}

+ 30 - 1
src/mixins/common.js

@@ -1,5 +1,6 @@
 import { Capacitor } from '@capacitor/core'
 import { AppsFlyer } from 'appsflyer-capacitor-plugin'
+import { Facebook, PixelEventNames } from 'capacitor-facebook'
 export default {
     methods: {
         getImg(imgs = '', type = '', size = 800) {
@@ -50,6 +51,10 @@ export default {
                         af_currency: 'PHP'
                     }
                 })
+            } else {
+                Facebook.logEvent({
+                    name: 'transfer'
+                })
             }
         },
         async logDelegationPurchase(serviceCharge, delegation) {
@@ -64,6 +69,10 @@ export default {
                         af_currency: 'PHP'
                     }
                 })
+            } else {
+                Facebook.logEvent({
+                    name: 'delegation'
+                })
             }
         },
         async logRecharge(amount, orderId) {
@@ -78,6 +87,14 @@ export default {
                         af_currency: 'PHP'
                     }
                 })
+            } else {
+                Facebook.logEvent({
+                    name: PixelEventNames.Purchase,
+                    bundle: {
+                        currency: 'PHP',
+                        value: amount
+                    }
+                })
             }
         },
         async logWithdraw(amount) {
@@ -98,9 +115,13 @@ export default {
                     eventName: 'af_add_payment_info',
                     eventValue: {}
                 })
+            } else {
+                Facebook.logEvent({
+                    name: PixelEventNames.AddPaymentInfo
+                })
             }
         },
-        async logRegitraion(methods = 'username') {
+        async logRegistraion(methods = 'username') {
             if (Capacitor.isNativePlatform()) {
                 AppsFlyer.logEvent({
                     eventName: 'af_complete_registration',
@@ -108,11 +129,19 @@ export default {
                         af_registration_method: methods
                     }
                 })
+            } else {
+                Facebook.logEvent({
+                    name: PixelEventNames.CompleteRegistration
+                })
             }
         },
         async logLogin() {
             if (Capacitor.isNativePlatform()) {
                 AppsFlyer.logEvent({ eventName: 'af_login' })
+            } else {
+                Facebook.logEvent({
+                    name: 'Login'
+                })
             }
         },
         async setAfCuid(cuid) {

+ 13 - 4
src/stores/user.js

@@ -3,6 +3,7 @@ import { defineStore } from 'pinia'
 import { http } from '@/plugins/http'
 import { AppsFlyer } from 'appsflyer-capacitor-plugin'
 import { Capacitor } from '@capacitor/core'
+import { Facebook, PixelEventNames } from 'capacitor-facebook'
 async function setAfCuid(cuid) {
     // if (Capacitor.isNativePlatform()) {
     //     AppsFlyer.setCustomerUserId({ cuid })
@@ -11,9 +12,13 @@ async function setAfCuid(cuid) {
 async function logLogin() {
     if (Capacitor.isNativePlatform()) {
         AppsFlyer.logEvent({ eventName: 'af_login' })
+    } else {
+        Facebook.logEvent({
+            name: 'Login'
+        })
     }
 }
-async function logRegitraion(methods = 'username') {
+async function logRegistraion(methods = 'username') {
     if (Capacitor.isNativePlatform()) {
         AppsFlyer.logEvent({
             eventName: 'af_complete_registration',
@@ -22,6 +27,10 @@ async function logRegitraion(methods = 'username') {
                 af_currency: 'PHP'
             }
         })
+    } else {
+        Facebook.logEvent({
+            name: PixelEventNames.CompleteRegistration
+        })
     }
 }
 export const useUserStore = defineStore('user', () => {
@@ -34,7 +43,7 @@ export const useUserStore = defineStore('user', () => {
                     user.value = res.user
                     setAfCuid(res.user.id)
                     logLogin()
-                    if (res.newRegister) logRegitraion()
+                    if (res.newRegister) logRegistraion()
                     resolve(res)
                 })
                 .catch(e => {
@@ -50,7 +59,7 @@ export const useUserStore = defineStore('user', () => {
                     user.value = res.user
                     setAfCuid(res.user.id)
                     logLogin()
-                    if (res.newRegister) logRegitraion()
+                    if (res.newRegister) logRegistraion()
                     resolve(res)
                 })
                 .catch(e => {
@@ -66,7 +75,7 @@ export const useUserStore = defineStore('user', () => {
                     user.value = res.user
                     setAfCuid(res.user.id)
                     logLogin()
-                    if (res.newRegister) logRegitraion()
+                    if (res.newRegister) logRegistraion()
                     resolve(res)
                 })
                 .catch(e => {

+ 4 - 4
vite.config.js

@@ -56,22 +56,22 @@ export default defineConfig(({ command, mode }) => {
                           display: 'fullscreen',
                           icons: [
                               {
-                                  src: '/icon-192x192.png',
+                                  src: '/h5/icon-192x192.png',
                                   sizes: '192x192',
                                   type: 'image/png'
                               },
                               {
-                                  src: '/icon-256x256.png',
+                                  src: '/h5/icon-256x256.png',
                                   sizes: '256x256',
                                   type: 'image/png'
                               },
                               {
-                                  src: '/icon-384x384.png',
+                                  src: '/h5/icon-384x384.png',
                                   sizes: '384x384',
                                   type: 'image/png'
                               },
                               {
-                                  src: '/icon-512x512.png',
+                                  src: '/h5/icon-512x512.png',
                                   sizes: '512x512',
                                   type: 'image/png'
                               }

+ 3 - 3
yarn.lock

@@ -2366,9 +2366,9 @@ caniuse-lite@^1.0.30001400:
   dependencies:
     code-push "^4.0.2"
 
-"capacitor-facebook@https://github.com/x1ongzhu/capacitor-facebook.git":
-  version "0.0.1"
-  resolved "https://github.com/x1ongzhu/capacitor-facebook.git#be50b2a17f763d055cdb2e470112d9f8bbf33116"
+"capacitor-facebook@link:/Users/drew/Projects/capacitor/capacitor-facebook":
+  version "0.0.0"
+  uid ""
 
 capacitor-plugin-safe-area@^1.0.1:
   version "1.0.1"