@amplitude/gtm-snippet 2.25.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/amplitude-wrapper.js.ejs +340 -0
- package/lib/amplitude-wrapper.js +343 -0
- package/lib/scripts/analytics-browser-gtm-wrapper.min.js +2 -0
- package/lib/scripts/analytics-browser-gtm-wrapper.min.js.gz +0 -0
- package/lib/scripts/analytics-browser-gtm-wrapper.min.js.map +1 -0
- package/package.json +39 -0
- package/rollup.config.js +3 -0
- package/scripts/build-snippet.js +34 -0
- package/scripts/upload-to-s3.js +61 -0
- package/scripts/version.js +29 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [2.25.4](https://github.com/amplitude/Amplitude-TypeScript/compare/@amplitude/gtm-snippet@2.25.3...@amplitude/gtm-snippet@2.25.4) (2025-10-07)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @amplitude/gtm-snippet
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 2.25.3 (2025-10-06)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @amplitude/gtm-snippet
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Amplitude Analytics
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { version } from '../package.json';
|
|
2
|
+
|
|
3
|
+
/* Amplitude Browser 2.0 SDK begin */
|
|
4
|
+
<%- analyticsBrowserSnippet %>
|
|
5
|
+
|
|
6
|
+
/* Amplitude Browser 2.0 SDK end */
|
|
7
|
+
|
|
8
|
+
/* Amplitude Page View V1 Enrichment Plugin begin */
|
|
9
|
+
var amplitudePageViewV1EnrichmentPlugin=function(e){"use strict";var t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},t.apply(this,arguments)};function n(e,t,n,r){return new(n||(n=Promise))((function(i,o){function u(e){try{l(r.next(e))}catch(e){o(e)}}function a(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,a)}l((r=r.apply(e,t||[])).next())}))}function r(e,t){var n,r,i,o,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(l){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(u=0)),u;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){u.label=a[1];break}if(6===a[0]&&u.label<i[1]){u.label=i[1],i=a;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(a);break}i[2]&&u.ops.pop(),u.trys.pop();continue}a=t.call(e,u)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}}var i=function(){var e=this;return{name:"@amplitude/plugin-page-view-v1-enrichment-browser",type:"enrichment",setup:function(e){return n(this,void 0,void 0,(function(){return r(this,(function(t){return e.loggerProvider.log("Installing @amplitude/plugin-page-view-v1-enrichment-browser."),[2]}))}))},execute:function(i){return n(e,void 0,void 0,(function(){var e,n,o,u,a,l;return r(this,(function(r){return"[Amplitude] Page Viewed"==i.event_type&&(e=i.event_properties||{},n=e["[Amplitude] Page Domain"],o=e["[Amplitude] Page Location"],u=e["[Amplitude] Page Path"],a=e["[Amplitude] Page Title"],l=e["[Amplitude] Page URL"],(i=t(t({},i),{event_type:"Page View",event_properties:t(t({},i.event_properties),{page_domain:null!=n?n:"",page_location:null!=o?o:"",page_path:null!=u?u:"",page_title:null!=a?a:"",page_url:null!=l?l:""})})).event_properties&&(delete i.event_properties["[Amplitude] Page Domain"],delete i.event_properties["[Amplitude] Page Location"],delete i.event_properties["[Amplitude] Page Path"],delete i.event_properties["[Amplitude] Page Title"],delete i.event_properties["[Amplitude] Page URL"])),[2,i]}))}))}}};return e.pageViewV1EnrichmentPlugin=i,e.plugin=i,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
|
|
10
|
+
/* Amplitude Page View V1 Enrichment Plugin end */
|
|
11
|
+
|
|
12
|
+
/* Amplitude User Agent Enrichment Plugin begin */
|
|
13
|
+
var amplitudeUserAgentEnrichmentPlugin=function(i){"use strict";var e=function(){return e=Object.assign||function(i){for(var e,o=1,r=arguments.length;o<r;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(i[n]=e[n]);return i},e.apply(this,arguments)};function o(i,e,o,r){return new(o||(o=Promise))((function(n,a){function t(i){try{b(r.next(i))}catch(i){a(i)}}function s(i){try{b(r.throw(i))}catch(i){a(i)}}function b(i){var e;i.done?n(i.value):(e=i.value,e instanceof o?e:new o((function(i){i(e)}))).then(t,s)}b((r=r.apply(i,e||[])).next())}))}function r(i,e){var o,r,n,a,t={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(b){return function(s){if(o)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(t=0)),t;)try{if(o=1,r&&(n=2&s[0]?r.return:s[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,s[1])).done)return n;switch(r=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return t.label++,{value:s[1],done:!1};case 5:t.label++,r=s[1],s=[0];continue;case 7:s=t.ops.pop(),t.trys.pop();continue;default:if(!(n=t.trys,(n=n.length>0&&n[n.length-1])||6!==s[0]&&2!==s[0])){t=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]<n[3])){t.label=s[1];break}if(6===s[0]&&t.label<n[1]){t.label=n[1],n=s;break}if(n&&t.label<n[2]){t.label=n[2],t.ops.push(s);break}n[2]&&t.ops.pop(),t.trys.pop();continue}s=e.call(i,t)}catch(i){s=[6,i],r=0}finally{o=n=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,b])}}}var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},a={exports:{}};!function(i,e){!function(o,r){var n="function",a="undefined",t="object",s="string",b="model",l="name",w="type",u="vendor",d="version",c="architecture",p="console",m="mobile",f="tablet",h="smarttv",v="wearable",g="embedded",x="Amazon",k="Apple",y="ASUS",_="BlackBerry",T="Browser",S="Chrome",q="Firefox",N="Google",z="Huawei",A="LG",E="Microsoft",O="Motorola",j="Opera",C="Samsung",P="Sharp",U="Sony",M="Xiaomi",R="Zebra",V="Facebook",B=function(i){for(var e={},o=0;o<i.length;o++)e[i[o].toUpperCase()]=i[o];return e},I=function(i,e){return typeof i===s&&-1!==D(e).indexOf(D(i))},D=function(i){return i.toLowerCase()},G=function(i,e){if(typeof i===s)return i=i.replace(/^\s\s*/,""),typeof e===a?i:i.substring(0,350)},W=function(i,e){for(var o,a,s,b,l,w,u=0;u<e.length&&!l;){var d=e[u],c=e[u+1];for(o=a=0;o<d.length&&!l;)if(l=d[o++].exec(i))for(s=0;s<c.length;s++)w=l[++a],typeof(b=c[s])===t&&b.length>0?2===b.length?typeof b[1]==n?this[b[0]]=b[1].call(this,w):this[b[0]]=b[1]:3===b.length?typeof b[1]!==n||b[1].exec&&b[1].test?this[b[0]]=w?w.replace(b[1],b[2]):r:this[b[0]]=w?b[1].call(this,w,b[2]):r:4===b.length&&(this[b[0]]=w?b[3].call(this,w.replace(b[1],b[2])):r):this[b]=w||r;u+=2}},F=function(i,e){for(var o in e)if(typeof e[o]===t&&e[o].length>0){for(var n=0;n<e[o].length;n++)if(I(e[o][n],i))return"?"===o?r:o}else if(I(e[o],i))return"?"===o?r:o;return i},L={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},Z={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[d,[l,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[d,[l,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[l,d],[/opios[\/ ]+([\w\.]+)/i],[d,[l,j+" Mini"]],[/\bopr\/([\w\.]+)/i],[d,[l,j]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i,/(ba?idubrowser)[\/ ]?([\w\.]+)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,/(weibo)__([\d\.]+)/i],[l,d],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[d,[l,"UC"+T]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i],[d,[l,"WeChat(Win) Desktop"]],[/micromessenger\/([\w\.]+)/i],[d,[l,"WeChat"]],[/konqueror\/([\w\.]+)/i],[d,[l,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[d,[l,"IE"]],[/yabrowser\/([\w\.]+)/i],[d,[l,"Yandex"]],[/(avast|avg)\/([\w\.]+)/i],[[l,/(.+)/,"$1 Secure "+T],d],[/\bfocus\/([\w\.]+)/i],[d,[l,q+" Focus"]],[/\bopt\/([\w\.]+)/i],[d,[l,j+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[d,[l,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[d,[l,"Dolphin"]],[/coast\/([\w\.]+)/i],[d,[l,j+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[d,[l,"MIUI "+T]],[/fxios\/([-\w\.]+)/i],[d,[l,q]],[/\bqihu|(qi?ho?o?|360)browser/i],[[l,"360 "+T]],[/(oculus|samsung|sailfish|huawei)browser\/([\w\.]+)/i],[[l,/(.+)/,"$1 "+T],d],[/(comodo_dragon)\/([\w\.]+)/i],[[l,/_/g," "],d],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i],[l,d],[/(metasr)[\/ ]?([\w\.]+)/i,/(lbbrowser)/i,/\[(linkedin)app\]/i],[l],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[l,V],d],[/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(chromium|instagram)[\/ ]([-\w\.]+)/i],[l,d],[/\bgsa\/([\w\.]+) .*safari\//i],[d,[l,"GSA"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[d,[l,S+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[l,S+" WebView"],d],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[d,[l,"Android "+T]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[l,d],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[d,[l,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[d,l],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[l,[d,F,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[l,d],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[l,"Netscape"],d],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[d,[l,q+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i],[l,d],[/(cobalt)\/([\w\.]+)/i],[l,[d,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[c,"amd64"]],[/(ia32(?=;))/i],[[c,D]],[/((?:i[346]|x)86)[;\)]/i],[[c,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[c,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[c,"armhf"]],[/windows (ce|mobile); ppc;/i],[[c,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[c,/ower/,"",D]],[/(sun4\w)[;\)]/i],[[c,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[c,D]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[b,[u,C],[w,f]],[/\b((?:s[cgp]h|gt|sm)-\w+|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[b,[u,C],[w,m]],[/((ipod|iphone)\d+,\d+)/i],[b,[u,k],[w,m]],[/(ipad\d+,\d+)/i],[b,[u,k],[w,f]],[/\((ip(?:hone|od)[\w ]*);/i],[b,[u,k],[w,m]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[b,[u,k],[w,f]],[/(macintosh);/i],[b,[u,k]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[b,[u,z],[w,f]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[b,[u,z],[w,m]],[/\b(poco[\w ]+)(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[b,/_/g," "],[u,M],[w,m]],[/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[b,/_/g," "],[u,M],[w,f]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[b,[u,"OPPO"],[w,m]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[b,[u,"Vivo"],[w,m]],[/\b(rmx[12]\d{3})(?: bui|;|\))/i],[b,[u,"Realme"],[w,m]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[b,[u,O],[w,m]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[b,[u,O],[w,f]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[b,[u,A],[w,f]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[b,[u,A],[w,m]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[b,[u,"Lenovo"],[w,f]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[b,/_/g," "],[u,"Nokia"],[w,m]],[/(pixel c)\b/i],[b,[u,N],[w,f]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[b,[u,N],[w,m]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[b,[u,U],[w,m]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[b,"Xperia Tablet"],[u,U],[w,f]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[b,[u,"OnePlus"],[w,m]],[/(alexa)webm/i,/(kf[a-z]{2}wi)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[b,[u,x],[w,f]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[b,/(.+)/g,"Fire Phone $1"],[u,x],[w,m]],[/(playbook);[-\w\),; ]+(rim)/i],[b,u,[w,f]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[b,[u,_],[w,m]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[b,[u,y],[w,f]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[b,[u,y],[w,m]],[/(nexus 9)/i],[b,[u,"HTC"],[w,f]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic|sony(?!-bra))[-_ ]?([-\w]*)/i],[u,[b,/_/g," "],[w,m]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[b,[u,"Acer"],[w,f]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[b,[u,"Meizu"],[w,m]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[b,[u,P],[w,m]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[u,b,[w,m]],[/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[u,b,[w,f]],[/(surface duo)/i],[b,[u,E],[w,f]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[b,[u,"Fairphone"],[w,m]],[/(u304aa)/i],[b,[u,"AT&T"],[w,m]],[/\bsie-(\w*)/i],[b,[u,"Siemens"],[w,m]],[/\b(rct\w+) b/i],[b,[u,"RCA"],[w,f]],[/\b(venue[\d ]{2,7}) b/i],[b,[u,"Dell"],[w,f]],[/\b(q(?:mv|ta)\w+) b/i],[b,[u,"Verizon"],[w,f]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[b,[u,"Barnes & Noble"],[w,f]],[/\b(tm\d{3}\w+) b/i],[b,[u,"NuVision"],[w,f]],[/\b(k88) b/i],[b,[u,"ZTE"],[w,f]],[/\b(nx\d{3}j) b/i],[b,[u,"ZTE"],[w,m]],[/\b(gen\d{3}) b.+49h/i],[b,[u,"Swiss"],[w,m]],[/\b(zur\d{3}) b/i],[b,[u,"Swiss"],[w,f]],[/\b((zeki)?tb.*\b) b/i],[b,[u,"Zeki"],[w,f]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[u,"Dragon Touch"],b,[w,f]],[/\b(ns-?\w{0,9}) b/i],[b,[u,"Insignia"],[w,f]],[/\b((nxa|next)-?\w{0,9}) b/i],[b,[u,"NextBook"],[w,f]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[u,"Voice"],b,[w,m]],[/\b(lvtel\-)?(v1[12]) b/i],[[u,"LvTel"],b,[w,m]],[/\b(ph-1) /i],[b,[u,"Essential"],[w,m]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[b,[u,"Envizen"],[w,f]],[/\b(trio[-\w\. ]+) b/i],[b,[u,"MachSpeed"],[w,f]],[/\btu_(1491) b/i],[b,[u,"Rotor"],[w,f]],[/(shield[\w ]+) b/i],[b,[u,"Nvidia"],[w,f]],[/(sprint) (\w+)/i],[u,b,[w,m]],[/(kin\.[onetw]{3})/i],[[b,/\./g," "],[u,E],[w,m]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[b,[u,R],[w,f]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[b,[u,R],[w,m]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[u,b,[w,p]],[/droid.+; (shield) bui/i],[b,[u,"Nvidia"],[w,p]],[/(playstation [345portablevi]+)/i],[b,[u,U],[w,p]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[b,[u,E],[w,p]],[/smart-tv.+(samsung)/i],[u,[w,h]],[/hbbtv.+maple;(\d+)/i],[[b,/^/,"SmartTV"],[u,C],[w,h]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[u,A],[w,h]],[/(apple) ?tv/i],[u,[b,k+" TV"],[w,h]],[/crkey/i],[[b,S+"cast"],[u,N],[w,h]],[/droid.+aft(\w)( bui|\))/i],[b,[u,x],[w,h]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[b,[u,P],[w,h]],[/(bravia[\w ]+)( bui|\))/i],[b,[u,U],[w,h]],[/(mitv-\w{5}) bui/i],[b,[u,M],[w,h]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w ]*; *(\w[^;]*);([^;]*)/i],[[u,G],[b,G],[w,h]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[w,h]],[/((pebble))app/i],[u,b,[w,v]],[/droid.+; (glass) \d/i],[b,[u,N],[w,v]],[/droid.+; (wt63?0{2,3})\)/i],[b,[u,R],[w,v]],[/(quest( 2)?)/i],[b,[u,V],[w,v]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[u,[w,g]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i],[b,[w,m]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[b,[w,f]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[w,f]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[w,m]],[/(android[-\w\. ]{0,9});.+buil/i],[b,[u,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[d,[l,"EdgeHTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[d,[l,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i],[l,d],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[d,l]],os:[[/microsoft (windows) (vista|xp)/i],[l,d],[/(windows) nt 6\.2; (arm)/i,/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i,/(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i],[l,[d,F,L]],[/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[l,"Windows"],[d,F,L]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/cfnetwork\/.+darwin/i],[[d,/_/g,"."],[l,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[l,"Mac OS"],[d,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[d,l],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[l,d],[/\(bb(10);/i],[d,[l,_]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[d,[l,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[d,[l,q+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[d,[l,"webOS"]],[/crkey\/([\d\.]+)/i],[d,[l,S+"cast"]],[/(cros) [\w]+ ([\w\.]+\w)/i],[[l,"Chromium OS"],d],[/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[l,d],[/(sunos) ?([\w\.\d]*)/i],[[l,"Solaris"],d],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux)/i,/(unix) ?([\w\.]*)/i],[l,d]]},H=function(i,e){if(typeof i===t&&(e=i,i=r),!(this instanceof H))return new H(i,e).getResult();var n=i||(typeof o!==a&&o.navigator&&o.navigator.userAgent?o.navigator.userAgent:""),p=e?function(i,e){var o={};for(var r in i)e[r]&&e[r].length%2==0?o[r]=e[r].concat(i[r]):o[r]=i[r];return o}(Z,e):Z;return this.getBrowser=function(){var i,e={};return e[l]=r,e[d]=r,W.call(e,n,p.browser),e.major=typeof(i=e.version)===s?i.replace(/[^\d\.]/g,"").split(".")[0]:r,e},this.getCPU=function(){var i={};return i[c]=r,W.call(i,n,p.cpu),i},this.getDevice=function(){var i={};return i[u]=r,i[b]=r,i[w]=r,W.call(i,n,p.device),i},this.getEngine=function(){var i={};return i[l]=r,i[d]=r,W.call(i,n,p.engine),i},this.getOS=function(){var i={};return i[l]=r,i[d]=r,W.call(i,n,p.os),i},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return n},this.setUA=function(i){return n=typeof i===s&&i.length>350?G(i,350):i,this},this.setUA(n),this};H.VERSION="0.7.33",H.BROWSER=B([l,d,"major"]),H.CPU=B([c]),H.DEVICE=B([b,u,w,p,m,h,f,v,g]),H.ENGINE=H.OS=B([l,d]),i.exports&&(e=i.exports=H),e.UAParser=H;var $=typeof o!==a&&(o.jQuery||o.Zepto);if($&&!$.ua){var X=new H;$.ua=X.getResult(),$.ua.get=function(){return X.getUA()},$.ua.set=function(i){X.setUA(i);var e=X.getResult();for(var o in e)$.ua[o]=e[o]}}}("object"==typeof window?window:n)}(a,a.exports);var t=a.exports,s=function(i){var n=this;void 0===i&&(i={});var a,s=i.osName,b=void 0===s||s,l=i.osVersion,w=void 0===l||l,u=i.deviceManufacturer,d=void 0===u||u,c=i.deviceModel,p=void 0===c||c;return{name:"@amplitude/plugin-user-agent-enrichment-browser",type:"enrichment",setup:function(i){return o(this,void 0,void 0,(function(){var e;return r(this,(function(o){return"undefined"!=typeof navigator&&(e=navigator.userAgent),a=new t(e).getResult(),i.loggerProvider.log("Installing @amplitude/plugin-user-agent-enrichment-browser."),[2]}))}))},execute:function(i){return o(n,void 0,void 0,(function(){var o,n,t,s;return r(this,(function(r){return o=a.browser.name,n=a.browser.version,t=a.device.model||a.os.name,s=a.device.vendor,[2,e(e(e(e(e({},i),b&&{os_name:o}),w&&{os_version:n}),d&&{device_manufacturer:s}),p&&{device_model:t})]}))}))}}};return i.plugin=s,i.userAgentEnrichmentPlugin=s,Object.defineProperty(i,"__esModule",{value:!0}),i}({});
|
|
14
|
+
/* Amplitude User Agent Enrichment Plugin end */
|
|
15
|
+
|
|
16
|
+
/* Session Replay Plugin start */
|
|
17
|
+
// plugin-session-replay-browser version: 1.22.15
|
|
18
|
+
<%- pluginSessionReplaySnippet %>
|
|
19
|
+
var sessionReplayPlugin = sessionReplay;
|
|
20
|
+
/* Session Replay Plugin end */
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/* Guides and Surveys Plugin (engagement) start */
|
|
30
|
+
var engagementSnippet=function(){"use strict";(()=>{var x=function(){function t(){}return t.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:U(),platform:"Web",os:void 0,deviceModel:void 0}},t}(),U=function(){return typeof navigator<"u"&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},L=function(){function t(){this.queue=[]}return t.prototype.logEvent=function(e){this.receiver?this.receiver(e):this.queue.length<512&&this.queue.push(e)},t.prototype.setEventReceiver=function(e){this.receiver=e,this.queue.length>0&&(this.queue.forEach(function(n){e(n)}),this.queue=[])},t}(),m=function(){return m=Object.assign||function(e){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},m.apply(this,arguments)};function A(t){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function D(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,s=[],g;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(c){g={error:c}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(g)throw g.error}}return s}var _=function(t,e){var n,r,i=["string","number","boolean","undefined"],s=typeof t,g=typeof e;if(s!==g)return!1;try{for(var c=A(i),d=c.next();!d.done;d=c.next()){var v=d.value;if(v===s)return t===e}}catch(y){n={error:y}}finally{try{d&&!d.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}if(t==null&&e==null)return!0;if(t==null||e==null||t.length!==e.length)return!1;var h=Array.isArray(t),f=Array.isArray(e);if(h!==f)return!1;if(h&&f){for(var o=0;o<t.length;o++)if(!_(t[o],e[o]))return!1}else{var a=Object.keys(t).sort(),u=Object.keys(e).sort();if(!_(a,u))return!1;var l=!0;return Object.keys(t).forEach(function(y){_(t[y],e[y])||(l=!1)}),l}return!0},q="$set",B="$unset",N="$clearAll";Object.entries||(Object.entries=function(t){for(var e=Object.keys(t),n=e.length,r=new Array(n);n--;)r[n]=[e[n],t[e[n]]];return r});var T=function(){function t(){this.identity={userProperties:{}},this.listeners=new Set}return t.prototype.editIdentity=function(){var e=this,n=m({},this.identity.userProperties),r=m(m({},this.identity),{userProperties:n});return{setUserId:function(i){return r.userId=i,this},setDeviceId:function(i){return r.deviceId=i,this},setUserProperties:function(i){return r.userProperties=i,this},setOptOut:function(i){return r.optOut=i,this},updateUserProperties:function(i){var s,g,c,d,v,h,f=r.userProperties||{};try{for(var o=A(Object.entries(i)),a=o.next();!a.done;a=o.next()){var u=D(a.value,2),l=u[0],y=u[1];switch(l){case q:try{for(var I=(c=void 0,A(Object.entries(y))),p=I.next();!p.done;p=I.next()){var C=D(p.value,2),b=C[0],k=C[1];f[b]=k}}catch(S){c={error:S}}finally{try{p&&!p.done&&(d=I.return)&&d.call(I)}finally{if(c)throw c.error}}break;case B:try{for(var P=(v=void 0,A(Object.keys(y))),w=P.next();!w.done;w=P.next()){var b=w.value;delete f[b]}}catch(S){v={error:S}}finally{try{w&&!w.done&&(h=P.return)&&h.call(P)}finally{if(v)throw v.error}}break;case N:f={};break}}}catch(S){s={error:S}}finally{try{a&&!a.done&&(g=o.return)&&g.call(o)}finally{if(s)throw s.error}}return r.userProperties=f,this},commit:function(){return e.setIdentity(r),this}}},t.prototype.getIdentity=function(){return m({},this.identity)},t.prototype.setIdentity=function(e){var n=m({},this.identity);this.identity=m({},e),_(n,this.identity)||this.listeners.forEach(function(r){r(e)})},t.prototype.addIdentityListener=function(e){this.listeners.add(e)},t.prototype.removeIdentityListener=function(e){this.listeners.delete(e)},t}(),E=typeof globalThis<"u"?globalThis:typeof window<"u"?window:self,O=function(){function t(){this.identityStore=new T,this.eventBridge=new L,this.applicationContextProvider=new x}return t.getInstance=function(e){return E.analyticsConnectorInstances||(E.analyticsConnectorInstances={}),E.analyticsConnectorInstances[e]||(E.analyticsConnectorInstances[e]=new t),E.analyticsConnectorInstances[e]},t}();var $=["boot"];var M="$default_instance";function K(t){var i,s,g,c,d,v,h;let e=window.engagement,n={_q:(i=e==null?void 0:e._q)!=null?i:[],_configuration:{apiKey:(g=(s=e==null?void 0:e._configuration)==null?void 0:s.apiKey)!=null?g:"",serverUrl:(c=e==null?void 0:e._configuration)==null?void 0:c.serverUrl,serverZone:(v=(d=e==null?void 0:e._configuration)==null?void 0:d.serverZone)!=null?v:"US",options:{...(h=e==null?void 0:e._configuration)==null?void 0:h.options}},_sentry:void 0,init(f,o){var a,u,l;if(n._configuration.apiKey){console.log("Engagement SDK has already been initialized. Ignoring additional init call.");return}n._configuration={...n._configuration,...o,apiKey:f,options:{...n._configuration.options,...o==null?void 0:o.options}},(u=(a=n._configuration)==null?void 0:a.options)!=null&&u.logger&&n._configuration.options.logger.enable((l=n._configuration.options.logLevel)!=null?l:2),t()},plugin(f){let o=n.init;return{name:"@amplitude/engagement-browser",type:"enrichment",async setup(a,u){var I;let l=(I=a.instanceName)!=null?I:M,y=O.getInstance(l).identityStore;o(a.apiKey,{options:{logLevel:a.logLevel},...f,serverZone:a.serverZone}),await window.engagement.boot({user:()=>{let p=y.getIdentity();return{user_id:u.getUserId(),device_id:u.getDeviceId(),user_properties:p.userProperties,getSessionId:u.getSessionId}},integrations:[{track:p=>{u.track(p)}}]}),y.addIdentityListener(p=>{window.engagement._setUserProperties(p.userProperties)})},async execute(a){return window.engagement.forwardEvent(a),a}}}},r=n;return new Proxy(n,{get:function(f,o){if(o in r)return r[o];if(o!=="then")return o==="gs"?new Proxy({},{get:function(a,u){return function(){let l=Array.from(arguments),y=`${o}.${u}`;l.unshift(y),n._q.push(l)}}}):$.includes(o)?function(){let a=Array.prototype.slice.call(arguments);return new Promise((u,l)=>{a.unshift(o,u,l),n._q.push(a)})}:function(){let a=Array.prototype.slice.call(arguments);a.unshift(o),n._q.push(a)}}})}var Z=()=>{function t(e){for(let n of e){let r=document.createElement("script");r.src=n,r.id="engagement-sdk-bundle";let i=document.querySelector("[nonce]");i&&r.setAttribute("nonce",i.nonce||i.getAttribute("nonce")),document.getElementsByTagName("head")[0].appendChild(r)}}return K(()=>t(["https://cdn.amplitude.com/engagement-browser/prod/index.min.js.gz"]))};window.engagement=Z();})()};
|
|
31
|
+
/* Guides and Surveys Plugin (engagement) end */
|
|
32
|
+
|
|
33
|
+
/* Amplitude Wrapper begin */
|
|
34
|
+
const LOG_PREFIX = '[Amplitude / GTM]';
|
|
35
|
+
|
|
36
|
+
(function(a,p) {
|
|
37
|
+
// If window.amplitudeGTM doesn't exist, return
|
|
38
|
+
const globalAmplitude = a.amplitudeGTM;
|
|
39
|
+
if (!globalAmplitude || typeof globalAmplitude.init !== 'function') return;
|
|
40
|
+
|
|
41
|
+
// Enumerate available events
|
|
42
|
+
var eventEnum = [
|
|
43
|
+
'init',
|
|
44
|
+
'track',
|
|
45
|
+
'identify',
|
|
46
|
+
'setGroup',
|
|
47
|
+
'groupIdentify',
|
|
48
|
+
'revenue',
|
|
49
|
+
'flush',
|
|
50
|
+
'getUserId',
|
|
51
|
+
'setUserId',
|
|
52
|
+
'getSessionId',
|
|
53
|
+
'setSessionId',
|
|
54
|
+
'setDeviceId',
|
|
55
|
+
'getDeviceId',
|
|
56
|
+
'reset',
|
|
57
|
+
'setOptOut',
|
|
58
|
+
'setTransport'
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
var identifyEnum = [
|
|
62
|
+
'add',
|
|
63
|
+
'append',
|
|
64
|
+
'clearAll',
|
|
65
|
+
'prepend',
|
|
66
|
+
'set',
|
|
67
|
+
'setOnce',
|
|
68
|
+
'remove',
|
|
69
|
+
'preInsert',
|
|
70
|
+
'postInsert',
|
|
71
|
+
'unset'
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
/* To work with the identify API, pass an array of identify operations (each an array in itself)
|
|
75
|
+
* with the command and parameters included.
|
|
76
|
+
*
|
|
77
|
+
* window._amplitude('identify', [
|
|
78
|
+
* ['add', 'someUserProp', 1],
|
|
79
|
+
* ['add', 'someOtherUserProp', 2],
|
|
80
|
+
* ['prepend', 'anotherUserProp', 'someValue']
|
|
81
|
+
* ['unset', 'unsetUserProp', 'value is ignored']
|
|
82
|
+
* ['clearAll', 'key is ignored', 'value is ignored']
|
|
83
|
+
* ]);
|
|
84
|
+
*
|
|
85
|
+
*/
|
|
86
|
+
var identify = function(client, args, group) {
|
|
87
|
+
args = args.shift();
|
|
88
|
+
|
|
89
|
+
// Validate identify args
|
|
90
|
+
if (!Array.isArray(args) || args.length === 0) return;
|
|
91
|
+
|
|
92
|
+
var identifyInstance = new globalAmplitude.Identify();
|
|
93
|
+
|
|
94
|
+
// Loop through the commands array and execute each
|
|
95
|
+
args.forEach(function(identifyParams) {
|
|
96
|
+
// If the operation is not in array format, return
|
|
97
|
+
if (!Array.isArray(identifyParams)) return;
|
|
98
|
+
|
|
99
|
+
var cmd = identifyParams.shift();
|
|
100
|
+
|
|
101
|
+
// If not a valid "identify" command, return
|
|
102
|
+
if (identifyEnum.indexOf(cmd) === -1) return;
|
|
103
|
+
|
|
104
|
+
if (cmd === 'unset') {
|
|
105
|
+
identifyInstance.unset(identifyParams[0]);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (cmd === 'clearAll') {
|
|
109
|
+
identifyInstance.clearAll();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
identifyInstance[cmd].apply(identifyInstance, identifyParams);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// If this API is used with groupIdentify, return the Identify object
|
|
116
|
+
if (group === true) return identifyInstance;
|
|
117
|
+
|
|
118
|
+
client.identify(identifyInstance);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/* The groupIdentify API is similar to identify, except you also need to collect
|
|
122
|
+
* the group name and type in addition to the Identify array.
|
|
123
|
+
*
|
|
124
|
+
* window._amplitude(
|
|
125
|
+
* 'groupIdentify',
|
|
126
|
+
* 'groupType',
|
|
127
|
+
* 'groupName',
|
|
128
|
+
* [
|
|
129
|
+
* ['add', 'someGroupUserProp', 1],
|
|
130
|
+
* ['prepend', 'someOtherGroupUserProp', 'someValue']
|
|
131
|
+
* ]
|
|
132
|
+
* );
|
|
133
|
+
*
|
|
134
|
+
*/
|
|
135
|
+
var groupIdentify = function(client, args) {
|
|
136
|
+
// Validate the arguments
|
|
137
|
+
if (args.length < 3) return;
|
|
138
|
+
if (typeof args[0] !== 'string' || typeof args[1] !== 'string') return;
|
|
139
|
+
if (!Array.isArray(args[2]) || args[2].length === 0) return;
|
|
140
|
+
|
|
141
|
+
// Get the Identify instance object
|
|
142
|
+
var groupIdentifyInstance = identify(client, [args[2]], true);
|
|
143
|
+
|
|
144
|
+
client.groupIdentify(args[0], args[1], groupIdentifyInstance);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/* To send revenue, you need to pass an object to the command:
|
|
148
|
+
*
|
|
149
|
+
* {
|
|
150
|
+
* productId: 'product_id', // required
|
|
151
|
+
* price: 10.88, // required
|
|
152
|
+
* quantity: 1,
|
|
153
|
+
* revenueType: 'purchase',
|
|
154
|
+
* eventProperties: {'someKey': 'someValue}
|
|
155
|
+
* }
|
|
156
|
+
*
|
|
157
|
+
*/
|
|
158
|
+
var revenue = function(client, args) {
|
|
159
|
+
args = args.shift();
|
|
160
|
+
// Validate revenue args
|
|
161
|
+
if (!args.price || !args.productId) return;
|
|
162
|
+
|
|
163
|
+
var revenue = new globalAmplitude.Revenue()
|
|
164
|
+
.setProductId(args.productId)
|
|
165
|
+
.setQuantity(args.quantity || 1)
|
|
166
|
+
.setPrice(args.price)
|
|
167
|
+
.setRevenue(args.revenue || (args.price * (args.quantity || 1)));
|
|
168
|
+
if (args.revenueType) {
|
|
169
|
+
revenue.setRevenueType(args.revenueType)
|
|
170
|
+
}
|
|
171
|
+
if (args.eventProperties) {
|
|
172
|
+
revenue.setEventProperties(args.eventProperties)
|
|
173
|
+
}
|
|
174
|
+
if (args.currency) {
|
|
175
|
+
revenue.setCurrency(args.currency);
|
|
176
|
+
}
|
|
177
|
+
if (args.receipt) {
|
|
178
|
+
revenue.setReceipt(args.receipt);
|
|
179
|
+
}
|
|
180
|
+
if (args.receiptSig) {
|
|
181
|
+
revenue.setReceiptSig(args.receiptSig);
|
|
182
|
+
}
|
|
183
|
+
client.revenue(revenue);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
var gtmLibraryPlugin = () => {
|
|
187
|
+
return {
|
|
188
|
+
name: 'gtm-library-enrichment',
|
|
189
|
+
type: 'enrichment',
|
|
190
|
+
setup: async () => undefined,
|
|
191
|
+
execute: async (event) => {
|
|
192
|
+
event['library'] = `amplitude-ts-gtm/${version}`;
|
|
193
|
+
return event;
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
var getRegExp = function(expression) {
|
|
199
|
+
try {
|
|
200
|
+
return new RegExp(expression);
|
|
201
|
+
} catch (e) {
|
|
202
|
+
console.error(`${LOG_PREFIX} - ${e}`);
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
var getValidExp = function (expArray) {
|
|
208
|
+
return expArray?.reduce((acc, item) => {
|
|
209
|
+
var regExp = getRegExp(item);
|
|
210
|
+
if (regExp !== null) {
|
|
211
|
+
acc.push(regExp);
|
|
212
|
+
}
|
|
213
|
+
return acc;
|
|
214
|
+
}, []);
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
var init = function(client, args) {
|
|
219
|
+
const argsLength = args.length;
|
|
220
|
+
const configuration = args[argsLength - 1];
|
|
221
|
+
|
|
222
|
+
if (configuration.autocapture.attribution) {
|
|
223
|
+
const excludeReferrers = [
|
|
224
|
+
...(configuration.autocapture.attribution.excludeReferrersText || []),
|
|
225
|
+
...(getValidExp(configuration.autocapture.attribution.excludeReferrersRegex) || [])
|
|
226
|
+
];
|
|
227
|
+
delete configuration.autocapture.attribution.excludeReferrersText;
|
|
228
|
+
delete configuration.autocapture.attribution.excludeReferrersRegex;
|
|
229
|
+
// if excludeReferrers is empty, use default
|
|
230
|
+
if (excludeReferrers.length !== 0) {
|
|
231
|
+
configuration.autocapture.attribution.excludeReferrers = excludeReferrers;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (configuration.autocapture.elementInteractions) {
|
|
236
|
+
const pageUrlAllowlist = [
|
|
237
|
+
...(configuration.autocapture.elementInteractions.pageUrlAllowlistString || []),
|
|
238
|
+
...(getValidExp(configuration.autocapture.elementInteractions.pageUrlAllowlistRegex) || [])
|
|
239
|
+
];
|
|
240
|
+
delete configuration.autocapture.elementInteractions.pageUrlAllowlistString;
|
|
241
|
+
delete configuration.autocapture.elementInteractions.pageUrlAllowlistRegex;
|
|
242
|
+
// if pageUrlAllowlist is empty, use default
|
|
243
|
+
if (pageUrlAllowlist.length !== 0) {
|
|
244
|
+
configuration.autocapture.elementInteractions.pageUrlAllowlist = pageUrlAllowlist;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
const dataAttributePrefix = [
|
|
249
|
+
...(configuration.autocapture.elementInteractions.dataAttributePrefixString || []),
|
|
250
|
+
...(getValidExp(configuration.autocapture.elementInteractions.dataAttributePrefixRegex) || [])
|
|
251
|
+
]
|
|
252
|
+
delete configuration.autocapture.elementInteractions.dataAttributePrefixString;
|
|
253
|
+
delete configuration.autocapture.elementInteractions.dataAttributePrefixRegex;
|
|
254
|
+
// if dataAttributePrefix is empty, use default
|
|
255
|
+
if (dataAttributePrefix.length !== 0) {
|
|
256
|
+
configuration.autocapture.elementInteractions.dataAttributePrefix = dataAttributePrefix;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (configuration.autocapture.networkTracking) {
|
|
261
|
+
const networkTracking = configuration.autocapture.networkTracking;
|
|
262
|
+
const captureRules = networkTracking.captureRules || [];
|
|
263
|
+
captureRules.forEach((rule) => {
|
|
264
|
+
rule.urls = [
|
|
265
|
+
...(rule.urls || []),
|
|
266
|
+
...(getValidExp(rule.urlsRegex) || [])
|
|
267
|
+
];
|
|
268
|
+
if (rule.urls.length === 0) {
|
|
269
|
+
delete rule.urls;
|
|
270
|
+
}
|
|
271
|
+
delete rule.urlsRegex;
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const userAgentEnrichmentOptions = configuration['userAgentEnrichmentOptions'];
|
|
276
|
+
const pageViewLegacy = configuration['pageViewLegacy'];
|
|
277
|
+
const sessionReplay = configuration['sessionReplay'];
|
|
278
|
+
const guidesSurveys = configuration['guidesSurveys'];
|
|
279
|
+
|
|
280
|
+
if (userAgentEnrichmentOptions) {
|
|
281
|
+
client.add(amplitudeUserAgentEnrichmentPlugin.userAgentEnrichmentPlugin(userAgentEnrichmentOptions));
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (pageViewLegacy) {
|
|
285
|
+
client.add(amplitudePageViewV1EnrichmentPlugin.pageViewV1EnrichmentPlugin())
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if(sessionReplay) {
|
|
289
|
+
client.add(sessionReplayPlugin.plugin());
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
if (guidesSurveys) {
|
|
293
|
+
// Only initiate G/S here, otherwise, we'll auto-install the proxy for users who don't need it
|
|
294
|
+
engagementSnippet();
|
|
295
|
+
client.add(window.engagement.plugin());
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// as plugin order cannot be adjusted, init first then add library plugin to overwrite the library value
|
|
299
|
+
let promise = client.init(...args).promise;
|
|
300
|
+
promise.then(
|
|
301
|
+
() => client.add(gtmLibraryPlugin())
|
|
302
|
+
);
|
|
303
|
+
return promise;
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
// Build the command wrapper logic
|
|
308
|
+
a[p] = a[p] || function() {
|
|
309
|
+
// Build array out of arguments
|
|
310
|
+
var args = [].slice.call(arguments, 0);
|
|
311
|
+
|
|
312
|
+
// Pick the first argument as the instance name
|
|
313
|
+
var name = args.shift();
|
|
314
|
+
var client = !name ? globalAmplitude : globalAmplitude._iq[name];
|
|
315
|
+
if (!client) {
|
|
316
|
+
client = globalAmplitude.createInstance(name);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// Pick the first argument as the command
|
|
320
|
+
var cmd = args.shift();
|
|
321
|
+
|
|
322
|
+
// If cmd is not one of the available ones, return
|
|
323
|
+
if (eventEnum.indexOf(cmd) === -1) return;
|
|
324
|
+
|
|
325
|
+
// Handle Revenue separately
|
|
326
|
+
if (cmd === 'revenue') return revenue(client, args);
|
|
327
|
+
|
|
328
|
+
// Handle Identify separately
|
|
329
|
+
if (cmd === 'identify') return identify(client, args);
|
|
330
|
+
|
|
331
|
+
// Handle GroupIdentify separately
|
|
332
|
+
if (cmd === 'groupIdentify') return groupIdentify(client, args);
|
|
333
|
+
|
|
334
|
+
if (cmd === 'init') return init(client, args);
|
|
335
|
+
|
|
336
|
+
// Otherwise call the method and pass the arguments
|
|
337
|
+
return client[cmd].apply(this, args);
|
|
338
|
+
};
|
|
339
|
+
})(window, '_amplitude')
|
|
340
|
+
/* Amplitude wrapper end */
|