_mixpanel_autocapture.pug 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. if user && user.labsProgram && ExposedSettings.mixpanelLabsToken
  2. script(
  3. type='text/javascript'
  4. nonce=scriptNonce
  5. id='mp-loader'
  6. data-mixpanel-token=ExposedSettings.mixpanelLabsToken
  7. ).
  8. window.olLoadMixpanelAutocapture = function () {
  9. ;(function (f, b) {
  10. if (!b.__SV) {
  11. var e, g, i, h
  12. window.mixpanel = b
  13. b._i = []
  14. b.init = function (e, f, c) {
  15. function g(a, d) {
  16. var b = d.split('.')
  17. 2 == b.length && ((a = a[b[0]]), (d = b[1]))
  18. a[d] = function () {
  19. a.push([d].concat(Array.prototype.slice.call(arguments, 0)))
  20. }
  21. }
  22. var a = b
  23. 'undefined' !== typeof c ? (a = b[c] = []) : (c = 'mixpanel')
  24. a.people = a.people || []
  25. a.toString = function (a) {
  26. var d = 'mixpanel'
  27. 'mixpanel' !== c && (d += '.' + c)
  28. a || (d += ' (stub)')
  29. return d
  30. }
  31. a.people.toString = function () {
  32. return a.toString(1) + '.people (stub)'
  33. }
  34. i = 'disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking start_batch_senders people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user people.remove'.split(' ')
  35. for (h = 0; h < i.length; h++) g(a, i[h])
  36. var j = 'set set_once union unset remove delete'.split(' ')
  37. a.get_group = function () {
  38. function b(c) {
  39. d[c] = function () {
  40. call2_args = arguments
  41. call2 = [c].concat(Array.prototype.slice.call(call2_args, 0))
  42. a.push([e, call2])
  43. }
  44. }
  45. for (var d = {}, e = ['get_group'].concat(Array.prototype.slice.call(arguments, 0)), c = 0; c < j.length; c++) b(j[c])
  46. return d
  47. }
  48. b._i.push([e, f, c])
  49. }
  50. b.__SV = 1.2
  51. e = f.createElement('script')
  52. e.type = 'text/javascript'
  53. e.async = !0
  54. e.src = 'undefined' !== typeof MIXPANEL_CUSTOM_LIB_URL ? MIXPANEL_CUSTOM_LIB_URL : 'file:' === f.location.protocol && '//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js'.match(/^\/\//) ? 'https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js' : '//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js'
  55. g = f.getElementsByTagName('script')[0]
  56. g.parentNode.insertBefore(e, g)
  57. }
  58. })(document, window.mixpanel || [])
  59. var mixpanelSettings = document.querySelector('#mp-loader').dataset
  60. var mixpanelToken = mixpanelSettings.mixpanelToken
  61. if (mixpanelToken) {
  62. mixpanel.init(mixpanelToken, {
  63. api_host: 'https://api-eu.mixpanel.com',
  64. autocapture: {
  65. capture_text_content: false,
  66. input: true,
  67. rage_click: true,
  68. dead_click: true,
  69. scroll: true,
  70. submit: true,
  71. click: true,
  72. pageview: 'full-url',
  73. },
  74. })
  75. }
  76. }