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AAA,GACE,KAAK,QAAQ,SAAU,GACzB,CAIA,MAAA,GACE,GAAI,KAAK,MACP,KAAO,KAAK,MAAM,QAAQ,CACxB,MAAM,EAAQ,KAAK,MAAM,MACzB,KAAK,WAAW,GACb,MAAK,IAAM,EAAM,MAAO,GAC7B,CAEJ,CAEA,OAAA,CAAQ,EAAW,GACjB,GAAI,KAAK,OAAQ,CACf,MAAM,EAAO,CACX,OAAU,KAAK,MACf,aAAgB,KAAK,QAEvB,EAAK,IAAI,KAAe,EAExB,KAAK,aAAa,EACpB,CACF,CAEA,UAAA,CAAW,GACT,IAAI,EAAO,CACT,MAAO,EAAM,KACb,WAAY,EAAM,OAAS,CAAC,GAyB9B,OAvBI,KAAK,SACP,EAAK,WAAW,YAAc,KAAK,QAErC,EAAK,WAAW,MAAQ,KAAK,MAC7B,EAAK,WAAW,WAAa,KAAK,UAClC,EAAK,WAAW,SAAW,KAAK,QAChC,EAAK,WAAW,OAAS,KAAK,MAC9B,EAAK,WAAW,YAAc,KAAK,WACnC,EAAK,WAAW,YAAc,KAAK,WACnC,EAAK,WAAW,UAAY,KAAK,SACjC,EAAK,WAAW,YAAc,KAAK,WAC/B,KAAK,WACP,EAAK,WAAW,SAAW,KAAK,UAE9B,KAAK,QACP,EAAK,WAAW,MAAQ,KAAK,OAE3B,KAAK,YACP,EAAK,WAAW,WAAa,KAAK,WAGpC,EAAO,IAAI,OAAO,KAAK,UAAU,IAAO,SAAS,UAE1C,MAAM,GAAG,gCAAgC,IAClD,CAEA,YAAA,CAAa,GAEX,OADA,EAAO,IAAI,OAAO,KAAK,UAAU,IAAO,SAAS,UAC1C,MAAM,GAAG,iCAAiC,IACnD","file":"/npm/@portify/expo-mixpanel-analytics@0.0.8/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@portify/expo-mixpanel-analytics@0.0.8/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import {Platform, Dimensions} from 'react-native';\nimport Constants from 'expo-constants';\nimport {Buffer} from 'buffer';\n\nconst {width, height} = Dimensions.get('window');\n\nconst MIXPANEL_API_URL = 'https://api.mixpanel.com';\nconst isIosPlatform = Platform.OS === 'ios';\n\nexport default class ExpoMixpanelAnalytics {\n  constructor(token) {\n    this.ready = false;\n    this.queue = [];\n\n    this.token = token;\n    this.userId = null;\n    this.clientId = Constants.deviceId;\n    this.identify(this.clientId);\n\n    Constants.getWebViewUserAgentAsync()\n      .then(userAgent => {\n        this.userAgent = userAgent;\n        this.appName = Constants.manifest.name;\n        this.appId = Constants.manifest.slug;\n        this.appVersion = Constants.manifest.version;\n        this.screenSize = `${width}x${height}`;\n        this.deviceName = Constants.deviceName;\n        if (isIosPlatform) {\n          this.platform = Constants.platform.ios.platform;\n          this.model = Constants.platform.ios.model;\n          this.osVersion = Constants.platform.ios.systemVersion;\n        } else {\n          this.platform = \"android\";\n        }\n\n        this.ready = true;\n        this._flush();\n      });\n  }\n\n  track(name, props) {\n    this.queue.push({\n      name,\n      props\n    });\n    this._flush();\n  }\n\n  identify(userId) {\n    this.userId = userId;\n  }\n\n  reset() {\n    this.identify(this.clientId);\n  }\n\n  people_set(props) {\n    this._people('set', props);\n  }\n\n  people_set_once(props) {\n    this._people('set_once', props);\n  }\n\n  people_unset(props) {\n    this._people('unset', props);\n  }\n\n  people_increment(props) {\n    this._people('add', props);\n  }\n\n  people_append(props) {\n    this._people('append', props);\n  }\n\n  people_union(props) {\n    this._people('union', props);\n  }\n\n  people_delete_user() {\n    this._people('delete', '');\n  }\n\n  // ===========================================================================================\n\n  _flush() {\n    if (this.ready) {\n      while (this.queue.length) {\n        const event = this.queue.pop();\n        this._pushEvent(event)\n          .then(() => event.sent = true);\n      }\n    }\n  }\n\n  _people(operation, props) {\n    if (this.userId) {\n      const data = {\n        \"$token\": this.token,\n        \"$distinct_id\": this.userId\n      };\n      data[`$${operation}`] = props;\n\n      this._pushProfile(data);\n    }\n  }\n\n  _pushEvent(event) {\n    let data = {\n      event: event.name,\n      properties: event.props || {}\n    };\n    if (this.userId) {\n      data.properties.distinct_id = this.userId;\n    }\n    data.properties.token = this.token;\n    data.properties.user_agent = this.userAgent;\n    data.properties.app_name = this.appName;\n    data.properties.app_id = this.appId;\n    data.properties.app_version = this.appVersion;\n    data.properties.screen_size = this.screenSize;\n    data.properties.client_id = this.clientId;\n    data.properties.device_name = this.deviceName;\n    if (this.platform) {\n      data.properties.platform = this.platform;\n    }\n    if (this.model) {\n      data.properties.model = this.model;\n    }\n    if (this.osVersion) {\n      data.properties.os_version = this.osVersion;\n    }\n\n    data = new Buffer(JSON.stringify(data)).toString('base64');\n\n    return fetch(`${MIXPANEL_API_URL}/track/?data=${data}`);\n  }\n\n  _pushProfile(data) {\n    data = new Buffer(JSON.stringify(data)).toString('base64');\n    return fetch(`${MIXPANEL_API_URL}/engage/?data=${data}`);\n  }\n}"]}