@amplitude/analytics-browser 2.11.10 → 2.11.12
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/README.md +1 -1
- package/lib/cjs/lib-prefix.d.ts +2 -0
- package/lib/cjs/lib-prefix.d.ts.map +1 -0
- package/lib/cjs/lib-prefix.js +4 -0
- package/lib/cjs/lib-prefix.js.map +1 -0
- package/lib/cjs/plugins/context.d.ts.map +1 -1
- package/lib/cjs/plugins/context.js +2 -1
- package/lib/cjs/plugins/context.js.map +1 -1
- package/lib/cjs/plugins/form-interaction-tracking.d.ts +1 -0
- package/lib/cjs/plugins/form-interaction-tracking.d.ts.map +1 -1
- package/lib/cjs/plugins/form-interaction-tracking.js +19 -4
- package/lib/cjs/plugins/form-interaction-tracking.js.map +1 -1
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/cjs/version.js.map +1 -1
- package/lib/esm/lib-prefix.d.ts +2 -0
- package/lib/esm/lib-prefix.d.ts.map +1 -0
- package/lib/esm/lib-prefix.js +2 -0
- package/lib/esm/lib-prefix.js.map +1 -0
- package/lib/esm/plugins/context.d.ts.map +1 -1
- package/lib/esm/plugins/context.js +2 -1
- package/lib/esm/plugins/context.js.map +1 -1
- package/lib/esm/plugins/form-interaction-tracking.d.ts +1 -0
- package/lib/esm/plugins/form-interaction-tracking.d.ts.map +1 -1
- package/lib/esm/plugins/form-interaction-tracking.js +17 -3
- package/lib/esm/plugins/form-interaction-tracking.js.map +1 -1
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/esm/version.js.map +1 -1
- package/lib/scripts/amplitude-bookmarklet-snippet-min.js +1 -1
- package/lib/scripts/amplitude-bookmarklet.html +1 -1
- package/lib/scripts/amplitude-gtm-min.js +1 -1
- package/lib/scripts/amplitude-gtm-min.js.gz +0 -0
- package/lib/scripts/amplitude-gtm-min.js.map +1 -1
- package/lib/scripts/amplitude-gtm-snippet-min.js +1 -1
- package/lib/scripts/amplitude-min.js +1 -1
- package/lib/scripts/amplitude-min.js.gz +0 -0
- package/lib/scripts/amplitude-min.js.map +1 -1
- package/lib/scripts/amplitude-min.umd.js +1 -1
- package/lib/scripts/amplitude-min.umd.js.gz +0 -0
- package/lib/scripts/amplitude-snippet-instructions.html +1 -1
- package/lib/scripts/amplitude-snippet-min.js +1 -1
- package/lib/scripts/lib-prefix.d.ts +2 -0
- package/lib/scripts/lib-prefix.d.ts.map +1 -0
- package/lib/scripts/plugins/context.d.ts.map +1 -1
- package/lib/scripts/plugins/form-interaction-tracking.d.ts +1 -0
- package/lib/scripts/plugins/form-interaction-tracking.d.ts.map +1 -1
- package/lib/scripts/version.d.ts +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ This SDK is also available through CDN. Copy the script loader below and paste b
|
|
|
53
53
|
<!-- README_SNIPPET_BLOCK -->
|
|
54
54
|
```html
|
|
55
55
|
<script type="text/javascript">
|
|
56
|
-
!function(){"use strict";!function(e,t){var r=e.amplitude||{_q:[],_iq:{}};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{var n=function(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}},s=function(e,t,r){return function(n){e._q.push({name:t,args:Array.prototype.slice.call(r,0),resolve:n})}},o=function(e,t,r){e._q.push({name:t,args:Array.prototype.slice.call(r,0)})},i=function(e,t,r){e[t]=function(){if(r)return{promise:new Promise(s(e,t,Array.prototype.slice.call(arguments)))};o(e,t,Array.prototype.slice.call(arguments))}},a=function(e){for(var t=0;t<
|
|
56
|
+
!function(){"use strict";!function(e,t){var r=e.amplitude||{_q:[],_iq:{}};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{var n=function(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}},s=function(e,t,r){return function(n){e._q.push({name:t,args:Array.prototype.slice.call(r,0),resolve:n})}},o=function(e,t,r){e._q.push({name:t,args:Array.prototype.slice.call(r,0)})},i=function(e,t,r){e[t]=function(){if(r)return{promise:new Promise(s(e,t,Array.prototype.slice.call(arguments)))};o(e,t,Array.prototype.slice.call(arguments))}},a=function(e){for(var t=0;t<m.length;t++)i(e,m[t],!1);for(var r=0;r<g.length;r++)i(e,g[r],!0)};r.invoked=!0;var c=t.createElement("script");c.type="text/javascript",c.integrity="sha384-Bm7BOHoy1DFPw612QRLusUyH0HvQphY26zMrayc+oFXf7dk1Quc28naRc6IwtpYM",c.crossOrigin="anonymous",c.async=!0,c.src="https://cdn.amplitude.com/libs/analytics-browser-2.11.12-min.js.gz",c.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var u=t.getElementsByTagName("script")[0];u.parentNode.insertBefore(c,u);for(var p=function(){return this._q=[],this},l=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],d=0;d<l.length;d++)n(p,l[d]);r.Identify=p;for(var f=function(){return this._q=[],this},v=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setEventProperties"],y=0;y<v.length;y++)n(f,v[y]);r.Revenue=f;var m=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset","extendSession"],g=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];a(r),r.createInstance=function(e){return r._iq[e]={_q:[]},a(r._iq[e]),r._iq[e]},e.amplitude=r}}(window,document)}();
|
|
57
57
|
|
|
58
58
|
amplitude.init("<YOUR_API_KEY>");
|
|
59
59
|
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lib-prefix.d.ts","sourceRoot":"","sources":["../../src/lib-prefix.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lib-prefix.js","sourceRoot":"","sources":["../../src/lib-prefix.ts"],"names":[],"mappings":";;AAAa,QAAA,SAAS,GAAG,cAAc,CAAC","sourcesContent":["export const LIBPREFIX = 'amplitude-ts';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/plugins/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/plugins/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAQhF,qBAAa,OAAQ,YAAW,YAAY;IAC1C,IAAI,SAAuC;IAC3C,IAAI,WAAqB;IAKzB,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,SAA6B;;IASpC,KAAK,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC;IAM1C,OAAO,CAAC,OAAO,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;CAkC9C"}
|
|
@@ -4,13 +4,14 @@ var tslib_1 = require("tslib");
|
|
|
4
4
|
var analytics_core_1 = require("@amplitude/analytics-core");
|
|
5
5
|
var analytics_client_common_1 = require("@amplitude/analytics-client-common");
|
|
6
6
|
var version_1 = require("../version");
|
|
7
|
+
var lib_prefix_1 = require("../lib-prefix");
|
|
7
8
|
var BROWSER_PLATFORM = 'Web';
|
|
8
9
|
var IP_ADDRESS = '$remote';
|
|
9
10
|
var Context = /** @class */ (function () {
|
|
10
11
|
function Context() {
|
|
11
12
|
this.name = '@amplitude/plugin-context-browser';
|
|
12
13
|
this.type = 'before';
|
|
13
|
-
this.library = "
|
|
14
|
+
this.library = "".concat(lib_prefix_1.LIBPREFIX, "/").concat(version_1.VERSION);
|
|
14
15
|
/* istanbul ignore else */
|
|
15
16
|
if (typeof navigator !== 'undefined') {
|
|
16
17
|
this.userAgent = navigator.userAgent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/plugins/context.ts"],"names":[],"mappings":";;;AACA,4DAAiD;AACjD,8EAAiE;AACjE,sCAAqC;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/plugins/context.ts"],"names":[],"mappings":";;;AACA,4DAAiD;AACjD,8EAAiE;AACjE,sCAAqC;AACrC,4CAA0C;AAE1C,IAAM,gBAAgB,GAAG,KAAK,CAAC;AAC/B,IAAM,UAAU,GAAG,SAAS,CAAC;AAC7B;IAWE;QAVA,SAAI,GAAG,mCAAmC,CAAC;QAC3C,SAAI,GAAG,QAAiB,CAAC;QAOzB,YAAO,GAAG,UAAG,sBAAS,cAAI,iBAAO,CAAE,CAAC;QAGlC,0BAA0B;QAC1B,IAAI,OAAO,SAAS,KAAK,WAAW,EAAE;YACpC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC;SACtC;IACH,CAAC;IAED,uBAAK,GAAL,UAAM,MAAqB;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC;IAEK,yBAAO,GAAb,UAAc,OAAc;;;;;gBACpB,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;gBAC5B,WAAW,GAAG,MAAA,IAAI,CAAC,MAAM,CAAC,WAAW,mCAAI,CAAC,CAAC,CAAC;gBAC5C,WAAW,GAAG,MAAA,OAAO,CAAC,QAAQ,mCAAI,WAAW,GAAG,CAAC,CAAC;gBACxD,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC;gBACtC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;oBACjB,IAAI,CAAC,MAAM,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itude/analytics-types';\nimport { UUID } from '@amplitude/analytics-core';\nimport { getLanguage } from '@amplitude/analytics-client-common';\nimport { VERSION } from '../version';\nimport { LIBPREFIX } from '../lib-prefix';\n\nconst BROWSER_PLATFORM = 'Web';\nconst IP_ADDRESS = '$remote';\nexport class Context implements BeforePlugin {\n name = '@amplitude/plugin-context-browser';\n type = 'before' as const;\n\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig;\n userAgent: string | undefined;\n library = `${LIBPREFIX}/${VERSION}`;\n\n constructor() {\n /* istanbul ignore else */\n if (typeof navigator !== 'undefined') {\n this.userAgent = navigator.userAgent;\n }\n }\n\n setup(config: BrowserConfig): Promise<undefined> {\n this.config = config;\n\n return Promise.resolve(undefined);\n }\n\n async execute(context: Event): Promise<Event> {\n const time = new Date().getTime();\n const lastEventId = this.config.lastEventId ?? -1;\n const nextEventId = context.event_id ?? lastEventId + 1;\n this.config.lastEventId = nextEventId;\n if (!context.time) {\n this.config.lastEventTime = time;\n }\n\n const event: Event = {\n user_id: this.config.userId,\n device_id: this.config.deviceId,\n session_id: this.config.sessionId,\n time,\n ...(this.config.appVersion && { app_version: this.config.appVersion }),\n ...(this.config.trackingOptions.platform && { platform: BROWSER_PLATFORM }),\n ...(this.config.trackingOptions.language && { language: getLanguage() }),\n ...(this.config.trackingOptions.ipAddress && { ip: IP_ADDRESS }),\n insert_id: UUID(),\n partner_id: this.config.partnerId,\n plan: this.config.plan,\n ...(this.config.ingestionMetadata && {\n ingestion_metadata: {\n source_name: this.config.ingestionMetadata.sourceName,\n source_version: this.config.ingestionMetadata.sourceVersion,\n },\n }),\n ...context,\n event_id: nextEventId,\n library: this.library,\n user_agent: this.userAgent,\n };\n return event;\n }\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EnrichmentPlugin } from '@amplitude/analytics-types';
|
|
2
2
|
export declare const formInteractionTracking: () => EnrichmentPlugin;
|
|
3
3
|
export declare const stringOrUndefined: <T>(name: T) => T extends string ? string : undefined;
|
|
4
|
+
export declare const extractFormAction: (form: HTMLFormElement) => string | null;
|
|
4
5
|
//# sourceMappingURL=form-interaction-tracking.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-interaction-tracking.d.ts","sourceRoot":"","sources":["../../../src/plugins/form-interaction-tracking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAiBpF,eAAO,MAAM,uBAAuB,QAAO,
|
|
1
|
+
{"version":3,"file":"form-interaction-tracking.d.ts","sourceRoot":"","sources":["../../../src/plugins/form-interaction-tracking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAiBpF,eAAO,MAAM,uBAAuB,QAAO,gBAqH1C,CAAC;AAEF,eAAO,MAAM,iBAAiB,uDAU7B,CAAC;AAGF,eAAO,MAAM,iBAAiB,SAAU,eAAe,KAAG,MAAM,GAAG,IASlE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var _this = this;
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stringOrUndefined = exports.formInteractionTracking = void 0;
|
|
3
|
+
exports.extractFormAction = exports.stringOrUndefined = exports.formInteractionTracking = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var constants_1 = require("../constants");
|
|
6
6
|
var analytics_client_common_1 = require("@amplitude/analytics-client-common");
|
|
@@ -47,28 +47,30 @@ var formInteractionTracking = function () {
|
|
|
47
47
|
var hasFormChanged = false;
|
|
48
48
|
addEventListener(form, 'change', function () {
|
|
49
49
|
var _a;
|
|
50
|
+
var formDestination = (0, exports.extractFormAction)(form);
|
|
50
51
|
if (!hasFormChanged) {
|
|
51
52
|
amplitude.track(constants_1.DEFAULT_FORM_START_EVENT, (_a = {},
|
|
52
53
|
_a[constants_1.FORM_ID] = (0, exports.stringOrUndefined)(form.id),
|
|
53
54
|
_a[constants_1.FORM_NAME] = (0, exports.stringOrUndefined)(form.name),
|
|
54
|
-
_a[constants_1.FORM_DESTINATION] =
|
|
55
|
+
_a[constants_1.FORM_DESTINATION] = formDestination,
|
|
55
56
|
_a));
|
|
56
57
|
}
|
|
57
58
|
hasFormChanged = true;
|
|
58
59
|
});
|
|
59
60
|
addEventListener(form, 'submit', function () {
|
|
60
61
|
var _a, _b;
|
|
62
|
+
var formDestination = (0, exports.extractFormAction)(form);
|
|
61
63
|
if (!hasFormChanged) {
|
|
62
64
|
amplitude.track(constants_1.DEFAULT_FORM_START_EVENT, (_a = {},
|
|
63
65
|
_a[constants_1.FORM_ID] = (0, exports.stringOrUndefined)(form.id),
|
|
64
66
|
_a[constants_1.FORM_NAME] = (0, exports.stringOrUndefined)(form.name),
|
|
65
|
-
_a[constants_1.FORM_DESTINATION] =
|
|
67
|
+
_a[constants_1.FORM_DESTINATION] = formDestination,
|
|
66
68
|
_a));
|
|
67
69
|
}
|
|
68
70
|
amplitude.track(constants_1.DEFAULT_FORM_SUBMIT_EVENT, (_b = {},
|
|
69
71
|
_b[constants_1.FORM_ID] = (0, exports.stringOrUndefined)(form.id),
|
|
70
72
|
_b[constants_1.FORM_NAME] = (0, exports.stringOrUndefined)(form.name),
|
|
71
|
-
_b[constants_1.FORM_DESTINATION] =
|
|
73
|
+
_b[constants_1.FORM_DESTINATION] = formDestination,
|
|
72
74
|
_b));
|
|
73
75
|
hasFormChanged = false;
|
|
74
76
|
});
|
|
@@ -130,4 +132,17 @@ var stringOrUndefined = function (name) {
|
|
|
130
132
|
return name;
|
|
131
133
|
};
|
|
132
134
|
exports.stringOrUndefined = stringOrUndefined;
|
|
135
|
+
// Extracts the form action attribute, and normalizes it to a valid URL to preserve the previous behavior of accessing the action property directly.
|
|
136
|
+
var extractFormAction = function (form) {
|
|
137
|
+
var formDestination = form.getAttribute('action');
|
|
138
|
+
try {
|
|
139
|
+
// eslint-disable-next-line no-restricted-globals
|
|
140
|
+
formDestination = new URL(encodeURI(formDestination !== null && formDestination !== void 0 ? formDestination : ''), window.location.href).href;
|
|
141
|
+
}
|
|
142
|
+
catch (_a) {
|
|
143
|
+
//
|
|
144
|
+
}
|
|
145
|
+
return formDestination;
|
|
146
|
+
};
|
|
147
|
+
exports.extractFormAction = extractFormAction;
|
|
133
148
|
//# sourceMappingURL=form-interaction-tracking.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-interaction-tracking.js","sourceRoot":"","sources":["../../../src/plugins/form-interaction-tracking.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"form-interaction-tracking.js","sourceRoot":"","sources":["../../../src/plugins/form-interaction-tracking.ts"],"names":[],"mappings":"AAAA,iBA+JA;;;;AA9JA,0CAMsB;AAEtB,8EAAoE;AAQ7D,IAAM,uBAAuB,GAAG;IACrC,IAAI,QAAsC,CAAC;IAC3C,IAAI,cAAc,GAAoB,EAAE,CAAC;IAEzC,IAAM,gBAAgB,GAAG,UAAC,OAAgB,EAAE,IAAyB,EAAE,OAAmB;QACxF,OAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACxC,cAAc,CAAC,IAAI,CAAC;YAClB,OAAO,SAAA;YACP,IAAI,MAAA;YACJ,OAAO,SAAA;SACR,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,IAAM,oBAAoB,GAAG;QAC3B,cAAc,CAAC,OAAO,CAAC,UAAC,EAA0B;gBAAxB,OAAO,aAAA,EAAE,IAAI,UAAA,EAAE,OAAO,aAAA;YAC9C,0BAA0B;YAC1B,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;QACH,cAAc,GAAG,EAAE,CAAC;IACtB,CAAC,CAAC;IAEF,IAAM,IAAI,GAAG,qDAAqD,CAAC;IAC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AULT_FORM_SUBMIT_EVENT,\n FORM_ID,\n FORM_NAME,\n FORM_DESTINATION,\n} from '../constants';\nimport { BrowserConfig } from '../config';\nimport { getGlobalScope } from '@amplitude/analytics-client-common';\n\ninterface EventListener {\n element: Element;\n type: 'change' | 'submit';\n handler: () => void;\n}\n\nexport const formInteractionTracking = (): EnrichmentPlugin => {\n let observer: MutationObserver | undefined;\n let eventListeners: EventListener[] = [];\n\n const addEventListener = (element: Element, type: 'change' | 'submit', handler: () => void) => {\n element.addEventListener(type, handler);\n eventListeners.push({\n element,\n type,\n handler,\n });\n };\n\n const removeClickListeners = () => {\n eventListeners.forEach(({ element, type, handler }) => {\n /* istanbul ignore next */\n element?.removeEventListener(type, handler);\n });\n eventListeners = [];\n };\n\n const name = '@amplitude/plugin-form-interaction-tracking-browser';\n const type = 'enrichment';\n const setup = async (config: BrowserConfig, amplitude: BrowserClient) => {\n // The form interaction plugin observes changes in the dom. For this to work correctly, the observer can only be setup\n // after the body is built. When Amplitud gets initialized in a script tag, the body tag is still unavailable. So register this\n // only after the window is loaded\n /* istanbul ignore next */\n getGlobalScope()?.addEventListener('load', function () {\n /* istanbul ignore if */\n if (!amplitude) {\n // TODO: Add required minimum version of @amplitude/analytics-browser\n config.loggerProvider.warn(\n 'Form interaction tracking requires a later version of @amplitude/analytics-browser. Form interaction events are not tracked.',\n );\n return;\n }\n\n /* istanbul ignore if */\n if (typeof document === 'undefined') {\n return;\n }\n\n const addFormInteractionListener = (form: HTMLFormElement) => {\n let hasFormChanged = false;\n\n addEventListener(form, 'change', () => {\n const formDestination = extractFormAction(form);\n if (!hasFormChanged) {\n amplitude.track(DEFAULT_FORM_START_EVENT, {\n [FORM_ID]: stringOrUndefined(form.id),\n [FORM_NAME]: stringOrUndefined(form.name),\n [FORM_DESTINATION]: formDestination,\n });\n }\n hasFormChanged = true;\n });\n\n addEventListener(form, 'submit', () => {\n const formDestination = extractFormAction(form);\n if (!hasFormChanged) {\n amplitude.track(DEFAULT_FORM_START_EVENT, {\n [FORM_ID]: stringOrUndefined(form.id),\n [FORM_NAME]: stringOrUndefined(form.name),\n [FORM_DESTINATION]: formDestination,\n });\n }\n\n amplitude.track(DEFAULT_FORM_SUBMIT_EVENT, {\n [FORM_ID]: stringOrUndefined(form.id),\n [FORM_NAME]: stringOrUndefined(form.name),\n [FORM_DESTINATION]: formDestination,\n });\n hasFormChanged = false;\n });\n };\n\n // Adds listener to existing anchor tags\n const forms = Array.from(document.getElementsByTagName('form'));\n forms.forEach(addFormInteractionListener);\n\n // Adds listener to anchor tags added after initial load\n /* istanbul ignore else */\n if (typeof MutationObserver !== 'undefined') {\n observer = new MutationObserver((mutations) => {\n mutations.forEach((mutation) => {\n mutation.addedNodes.forEach((node) => {\n if (node.nodeName === 'FORM') {\n addFormInteractionListener(node as HTMLFormElement);\n }\n if ('querySelectorAll' in node && typeof node.querySelectorAll === 'function') {\n Array.from(node.querySelectorAll('form') as HTMLFormElement[]).map(addFormInteractionListener);\n }\n });\n });\n });\n\n observer.observe(document.body, {\n subtree: true,\n childList: true,\n });\n }\n });\n };\n const execute = async (event: Event) => event;\n const teardown = async () => {\n observer?.disconnect();\n removeClickListeners();\n };\n\n return {\n name,\n type,\n setup,\n execute,\n teardown,\n };\n};\n\nexport const stringOrUndefined = <T>(name: T): T extends string ? string : undefined => {\n /* istanbul ignore if */\n if (typeof name !== 'string') {\n // We found instances where the value of `name` is an Element and not a string.\n // Elements may have circular references and would throw an error when passed to `JSON.stringify(...)`.\n // If a non-string value is seen, assume there is no value.\n return undefined as T extends string ? string : undefined;\n }\n\n return name as T extends string ? string : undefined;\n};\n\n// Extracts the form action attribute, and normalizes it to a valid URL to preserve the previous behavior of accessing the action property directly.\nexport const extractFormAction = (form: HTMLFormElement): string | null => {\n let formDestination = form.getAttribute('action');\n try {\n // eslint-disable-next-line no-restricted-globals\n formDestination = new URL(encodeURI(formDestination ?? ''), window.location.href).href;\n } catch {\n //\n }\n return formDestination;\n};\n"]}
|
package/lib/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "2.11.
|
|
1
|
+
export declare const VERSION = "2.11.12";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/cjs/version.js
CHANGED
package/lib/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;AAAa,QAAA,OAAO,GAAG,SAAS,CAAC","sourcesContent":["export const VERSION = '2.11.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;AAAa,QAAA,OAAO,GAAG,SAAS,CAAC","sourcesContent":["export const VERSION = '2.11.12';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lib-prefix.d.ts","sourceRoot":"","sources":["../../src/lib-prefix.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lib-prefix.js","sourceRoot":"","sources":["../../src/lib-prefix.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,SAAS,GAAG,cAAc,CAAC","sourcesContent":["export const LIBPREFIX = 'amplitude-ts';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/plugins/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/plugins/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAQhF,qBAAa,OAAQ,YAAW,YAAY;IAC1C,IAAI,SAAuC;IAC3C,IAAI,WAAqB;IAKzB,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,OAAO,SAA6B;;IASpC,KAAK,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC;IAM1C,OAAO,CAAC,OAAO,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;CAkC9C"}
|
|
@@ -2,13 +2,14 @@ import { __assign, __awaiter, __generator } from "tslib";
|
|
|
2
2
|
import { UUID } from '@amplitude/analytics-core';
|
|
3
3
|
import { getLanguage } from '@amplitude/analytics-client-common';
|
|
4
4
|
import { VERSION } from '../version';
|
|
5
|
+
import { LIBPREFIX } from '../lib-prefix';
|
|
5
6
|
var BROWSER_PLATFORM = 'Web';
|
|
6
7
|
var IP_ADDRESS = '$remote';
|
|
7
8
|
var Context = /** @class */ (function () {
|
|
8
9
|
function Context() {
|
|
9
10
|
this.name = '@amplitude/plugin-context-browser';
|
|
10
11
|
this.type = 'before';
|
|
11
|
-
this.library = "
|
|
12
|
+
this.library = "".concat(LIBPREFIX, "/").concat(VERSION);
|
|
12
13
|
/* istanbul ignore else */
|
|
13
14
|
if (typeof navigator !== 'undefined') {
|
|
14
15
|
this.userAgent = navigator.userAgent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/plugins/context.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/plugins/context.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAA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U,EAAE,CAAC,GACnE,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,QAAQ,IAAI,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC,GACxE,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,QAAQ,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,CAAC,GACrE,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,SAAS,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,KAChE,SAAS,EAAE,IAAI,EAAE,EACjB,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EACjC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,KACnB,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,IAAI;oBACnC,kBAAkB,EAAE;wBAClB,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,UAAU;wBACrD,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,aAAa;qBAC5D;iBACF,CAAC,GACC,OAAO,KACV,QAAQ,EAAE,WAAW,EACrB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,UAAU,EAAE,IAAI,CAAC,SAAS,GAC3B,CAAC;gBACF,sBAAO,KAAK,EAAC;;;KACd;IACH,cAAC;AAAD,CAAC,AA1DD,IA0DC","sourcesContent":["import { BeforePlugin, BrowserConfig, Event } from '@amplitude/analytics-types';\nimport { UUID } from '@amplitude/analytics-core';\nimport { getLanguage } from '@amplitude/analytics-client-common';\nimport { VERSION } from '../version';\nimport { LIBPREFIX } from '../lib-prefix';\n\nconst BROWSER_PLATFORM = 'Web';\nconst IP_ADDRESS = '$remote';\nexport class Context implements BeforePlugin {\n name = '@amplitude/plugin-context-browser';\n type = 'before' as const;\n\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: BrowserConfig;\n userAgent: string | undefined;\n library = `${LIBPREFIX}/${VERSION}`;\n\n constructor() {\n /* istanbul ignore else */\n if (typeof navigator !== 'undefined') {\n this.userAgent = navigator.userAgent;\n }\n }\n\n setup(config: BrowserConfig): Promise<undefined> {\n this.config = config;\n\n return Promise.resolve(undefined);\n }\n\n async execute(context: Event): Promise<Event> {\n const time = new Date().getTime();\n const lastEventId = this.config.lastEventId ?? -1;\n const nextEventId = context.event_id ?? lastEventId + 1;\n this.config.lastEventId = nextEventId;\n if (!context.time) {\n this.config.lastEventTime = time;\n }\n\n const event: Event = {\n user_id: this.config.userId,\n device_id: this.config.deviceId,\n session_id: this.config.sessionId,\n time,\n ...(this.config.appVersion && { app_version: this.config.appVersion }),\n ...(this.config.trackingOptions.platform && { platform: BROWSER_PLATFORM }),\n ...(this.config.trackingOptions.language && { language: getLanguage() }),\n ...(this.config.trackingOptions.ipAddress && { ip: IP_ADDRESS }),\n insert_id: UUID(),\n partner_id: this.config.partnerId,\n plan: this.config.plan,\n ...(this.config.ingestionMetadata && {\n ingestion_metadata: {\n source_name: this.config.ingestionMetadata.sourceName,\n source_version: this.config.ingestionMetadata.sourceVersion,\n },\n }),\n ...context,\n event_id: nextEventId,\n library: this.library,\n user_agent: this.userAgent,\n };\n return event;\n }\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EnrichmentPlugin } from '@amplitude/analytics-types';
|
|
2
2
|
export declare const formInteractionTracking: () => EnrichmentPlugin;
|
|
3
3
|
export declare const stringOrUndefined: <T>(name: T) => T extends string ? string : undefined;
|
|
4
|
+
export declare const extractFormAction: (form: HTMLFormElement) => string | null;
|
|
4
5
|
//# sourceMappingURL=form-interaction-tracking.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-interaction-tracking.d.ts","sourceRoot":"","sources":["../../../src/plugins/form-interaction-tracking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAiBpF,eAAO,MAAM,uBAAuB,QAAO,
|
|
1
|
+
{"version":3,"file":"form-interaction-tracking.d.ts","sourceRoot":"","sources":["../../../src/plugins/form-interaction-tracking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAiBpF,eAAO,MAAM,uBAAuB,QAAO,gBAqH1C,CAAC;AAEF,eAAO,MAAM,iBAAiB,uDAU7B,CAAC;AAGF,eAAO,MAAM,iBAAiB,SAAU,eAAe,KAAG,MAAM,GAAG,IASlE,CAAC"}
|
|
@@ -44,28 +44,30 @@ export var formInteractionTracking = function () {
|
|
|
44
44
|
var hasFormChanged = false;
|
|
45
45
|
addEventListener(form, 'change', function () {
|
|
46
46
|
var _a;
|
|
47
|
+
var formDestination = extractFormAction(form);
|
|
47
48
|
if (!hasFormChanged) {
|
|
48
49
|
amplitude.track(DEFAULT_FORM_START_EVENT, (_a = {},
|
|
49
50
|
_a[FORM_ID] = stringOrUndefined(form.id),
|
|
50
51
|
_a[FORM_NAME] = stringOrUndefined(form.name),
|
|
51
|
-
_a[FORM_DESTINATION] =
|
|
52
|
+
_a[FORM_DESTINATION] = formDestination,
|
|
52
53
|
_a));
|
|
53
54
|
}
|
|
54
55
|
hasFormChanged = true;
|
|
55
56
|
});
|
|
56
57
|
addEventListener(form, 'submit', function () {
|
|
57
58
|
var _a, _b;
|
|
59
|
+
var formDestination = extractFormAction(form);
|
|
58
60
|
if (!hasFormChanged) {
|
|
59
61
|
amplitude.track(DEFAULT_FORM_START_EVENT, (_a = {},
|
|
60
62
|
_a[FORM_ID] = stringOrUndefined(form.id),
|
|
61
63
|
_a[FORM_NAME] = stringOrUndefined(form.name),
|
|
62
|
-
_a[FORM_DESTINATION] =
|
|
64
|
+
_a[FORM_DESTINATION] = formDestination,
|
|
63
65
|
_a));
|
|
64
66
|
}
|
|
65
67
|
amplitude.track(DEFAULT_FORM_SUBMIT_EVENT, (_b = {},
|
|
66
68
|
_b[FORM_ID] = stringOrUndefined(form.id),
|
|
67
69
|
_b[FORM_NAME] = stringOrUndefined(form.name),
|
|
68
|
-
_b[FORM_DESTINATION] =
|
|
70
|
+
_b[FORM_DESTINATION] = formDestination,
|
|
69
71
|
_b));
|
|
70
72
|
hasFormChanged = false;
|
|
71
73
|
});
|
|
@@ -125,4 +127,16 @@ export var stringOrUndefined = function (name) {
|
|
|
125
127
|
}
|
|
126
128
|
return name;
|
|
127
129
|
};
|
|
130
|
+
// Extracts the form action attribute, and normalizes it to a valid URL to preserve the previous behavior of accessing the action property directly.
|
|
131
|
+
export var extractFormAction = function (form) {
|
|
132
|
+
var formDestination = form.getAttribute('action');
|
|
133
|
+
try {
|
|
134
|
+
// eslint-disable-next-line no-restricted-globals
|
|
135
|
+
formDestination = new URL(encodeURI(formDestination !== null && formDestination !== void 0 ? formDestination : ''), window.location.href).href;
|
|
136
|
+
}
|
|
137
|
+
catch (_a) {
|
|
138
|
+
//
|
|
139
|
+
}
|
|
140
|
+
return formDestination;
|
|
141
|
+
};
|
|
128
142
|
//# sourceMappingURL=form-interaction-tracking.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-interaction-tracking.js","sourceRoot":"","sources":["../../../src/plugins/form-interaction-tracking.ts"],"names":[],"mappings":";AACA,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,OAAO,EACP,SAAS,EACT,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAQpE,MAAM,CAAC,IAAM,uBAAuB,GAAG;IACrC,IAAI,QAAsC,CAAC;IAC3C,IAAI,cAAc,GAAoB,EAAE,CAAC;IAEzC,IAAM,gBAAgB,GAAG,UAAC,OAAgB,EAAE,IAAyB,EAAE,OAAmB;QACxF,OAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACxC,cAAc,CAAC,IAAI,CAAC;YAClB,OAAO,SAAA;YACP,IAAI,MAAA;YACJ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P,QAAQ,UAAA;KACT,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,iBAAiB,GAAG,UAAI,IAAO;IAC1C,wBAAwB;IACxB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,+EAA+E;QAC/E,uGAAuG;QACvG,2DAA2D;QAC3D,OAAO,SAAkD,CAAC;KAC3D;IAED,OAAO,IAA6C,CAAC;AACvD,CAAC,CAAC;AAEF,oJAAoJ;AACpJ,MAAM,CAAC,IAAM,iBAAiB,GAAG,UAAC,IAAqB;IACrD,IAAI,eAAe,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAClD,IAAI;QACF,iDAAiD;QACjD,eAAe,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,EAAE,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;KACxF;IAAC,WAAM;QACN,EAAE;KACH;IACD,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC","sourcesContent":["import { BrowserClient, Event, EnrichmentPlugin } from '@amplitude/analytics-types';\nimport {\n DEFAULT_FORM_START_EVENT,\n DEFAULT_FORM_SUBMIT_EVENT,\n FORM_ID,\n FORM_NAME,\n FORM_DESTINATION,\n} from '../constants';\nimport { BrowserConfig } from '../config';\nimport { getGlobalScope } from '@amplitude/analytics-client-common';\n\ninterface EventListener {\n element: Element;\n type: 'change' | 'submit';\n handler: () => void;\n}\n\nexport const formInteractionTracking = (): EnrichmentPlugin => {\n let observer: MutationObserver | undefined;\n let eventListeners: EventListener[] = [];\n\n const addEventListener = (element: Element, type: 'change' | 'submit', handler: () => void) => {\n element.addEventListener(type, handler);\n eventListeners.push({\n element,\n type,\n handler,\n });\n };\n\n const removeClickListeners = () => {\n eventListeners.forEach(({ element, type, handler }) => {\n /* istanbul ignore next */\n element?.removeEventListener(type, handler);\n });\n eventListeners = [];\n };\n\n const name = '@amplitude/plugin-form-interaction-tracking-browser';\n const type = 'enrichment';\n const setup = async (config: BrowserConfig, amplitude: BrowserClient) => {\n // The form interaction plugin observes changes in the dom. For this to work correctly, the observer can only be setup\n // after the body is built. When Amplitud gets initialized in a script tag, the body tag is still unavailable. So register this\n // only after the window is loaded\n /* istanbul ignore next */\n getGlobalScope()?.addEventListener('load', function () {\n /* istanbul ignore if */\n if (!amplitude) {\n // TODO: Add required minimum version of @amplitude/analytics-browser\n config.loggerProvider.warn(\n 'Form interaction tracking requires a later version of @amplitude/analytics-browser. Form interaction events are not tracked.',\n );\n return;\n }\n\n /* istanbul ignore if */\n if (typeof document === 'undefined') {\n return;\n }\n\n const addFormInteractionListener = (form: HTMLFormElement) => {\n let hasFormChanged = false;\n\n addEventListener(form, 'change', () => {\n const formDestination = extractFormAction(form);\n if (!hasFormChanged) {\n amplitude.track(DEFAULT_FORM_START_EVENT, {\n [FORM_ID]: stringOrUndefined(form.id),\n [FORM_NAME]: stringOrUndefined(form.name),\n [FORM_DESTINATION]: formDestination,\n });\n }\n hasFormChanged = true;\n });\n\n addEventListener(form, 'submit', () => {\n const formDestination = extractFormAction(form);\n if (!hasFormChanged) {\n amplitude.track(DEFAULT_FORM_START_EVENT, {\n [FORM_ID]: stringOrUndefined(form.id),\n [FORM_NAME]: stringOrUndefined(form.name),\n [FORM_DESTINATION]: formDestination,\n });\n }\n\n amplitude.track(DEFAULT_FORM_SUBMIT_EVENT, {\n [FORM_ID]: stringOrUndefined(form.id),\n [FORM_NAME]: stringOrUndefined(form.name),\n [FORM_DESTINATION]: formDestination,\n });\n hasFormChanged = false;\n });\n };\n\n // Adds listener to existing anchor tags\n const forms = Array.from(document.getElementsByTagName('form'));\n forms.forEach(addFormInteractionListener);\n\n // Adds listener to anchor tags added after initial load\n /* istanbul ignore else */\n if (typeof MutationObserver !== 'undefined') {\n observer = new MutationObserver((mutations) => {\n mutations.forEach((mutation) => {\n mutation.addedNodes.forEach((node) => {\n if (node.nodeName === 'FORM') {\n addFormInteractionListener(node as HTMLFormElement);\n }\n if ('querySelectorAll' in node && typeof node.querySelectorAll === 'function') {\n Array.from(node.querySelectorAll('form') as HTMLFormElement[]).map(addFormInteractionListener);\n }\n });\n });\n });\n\n observer.observe(document.body, {\n subtree: true,\n childList: true,\n });\n }\n });\n };\n const execute = async (event: Event) => event;\n const teardown = async () => {\n observer?.disconnect();\n removeClickListeners();\n };\n\n return {\n name,\n type,\n setup,\n execute,\n teardown,\n };\n};\n\nexport const stringOrUndefined = <T>(name: T): T extends string ? string : undefined => {\n /* istanbul ignore if */\n if (typeof name !== 'string') {\n // We found instances where the value of `name` is an Element and not a string.\n // Elements may have circular references and would throw an error when passed to `JSON.stringify(...)`.\n // If a non-string value is seen, assume there is no value.\n return undefined as T extends string ? string : undefined;\n }\n\n return name as T extends string ? string : undefined;\n};\n\n// Extracts the form action attribute, and normalizes it to a valid URL to preserve the previous behavior of accessing the action property directly.\nexport const extractFormAction = (form: HTMLFormElement): string | null => {\n let formDestination = form.getAttribute('action');\n try {\n // eslint-disable-next-line no-restricted-globals\n formDestination = new URL(encodeURI(formDestination ?? ''), window.location.href).href;\n } catch {\n //\n }\n return formDestination;\n};\n"]}
|
package/lib/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "2.11.
|
|
1
|
+
export declare const VERSION = "2.11.12";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export var VERSION = '2.11.
|
|
1
|
+
export var VERSION = '2.11.12';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/lib/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,OAAO,GAAG,SAAS,CAAC","sourcesContent":["export const VERSION = '2.11.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,OAAO,GAAG,SAAS,CAAC","sourcesContent":["export const VERSION = '2.11.12';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";!function(e,t){var r=e.amplitude||{_q:[],_iq:{}};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{var n=function(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}},i=function(e,t,r){return function(n){e._q.push({name:t,args:Array.prototype.slice.call(r,0),resolve:n})}},o=function(e,t,r){e[t]=function(){if(r)return{promise:new Promise(i(e,t,Array.prototype.slice.call(arguments)))}}},s=function(e){for(var t=0;t<v.length;t++)o(e,v[t],!1);for(var r=0;r<y.length;r++)o(e,y[r],!0)};r.invoked=!0;var u=t.getElementsByTagName("script")[0],a=t.createElement("script");a.src="https://cdn.amplitude.com/libs/plugin-autocapture-browser-0.9.0-min.js.gz",a.async=!1,u.parentNode.insertBefore(a,u);var c=t.createElement("script");c.type="text/javascript",c.integrity="sha384-
|
|
1
|
+
!function(){"use strict";!function(e,t){var r=e.amplitude||{_q:[],_iq:{}};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{var n=function(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}},i=function(e,t,r){return function(n){e._q.push({name:t,args:Array.prototype.slice.call(r,0),resolve:n})}},o=function(e,t,r){e[t]=function(){if(r)return{promise:new Promise(i(e,t,Array.prototype.slice.call(arguments)))}}},s=function(e){for(var t=0;t<v.length;t++)o(e,v[t],!1);for(var r=0;r<y.length;r++)o(e,y[r],!0)};r.invoked=!0;var u=t.getElementsByTagName("script")[0],a=t.createElement("script");a.src="https://cdn.amplitude.com/libs/plugin-autocapture-browser-0.9.0-min.js.gz",a.async=!1,u.parentNode.insertBefore(a,u);var c=t.createElement("script");c.type="text/javascript",c.integrity="sha384-Bm7BOHoy1DFPw612QRLusUyH0HvQphY26zMrayc+oFXf7dk1Quc28naRc6IwtpYM",c.crossOrigin="anonymous",c.async=!1,c.src="https://cdn.amplitude.com/libs/analytics-browser-2.11.12-min.js.gz",c.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK"),e.amplitude.init("YOUR_API_KEY","YOUR_USER_ID",{instanceName:"amplitude-bookmarklet",serverZone:"YOUR_SERVER_ZONE",ingestionMetadata:{sourceName:"browser-typescript-bookmarklet",sourceVersion:"1.0.0"},optOut:!1}),amplitudeAutocapturePlugin&&litudeAutocapturePlugin.autocapturePlugin&&"function"==typeof amplitudeAutocapturePlugin.autocapturePlugin&&e.amplitude.add(amplitudeAutocapturePlugin.autocapturePlugin()),alert("Amplitude is now tracking events!")},u.parentNode.insertBefore(c,u);for(var p=function(){return this._q=[],this},l=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],d=0;d<l.length;d++)n(p,l[d]);r.Identify=p;for(var m=function(){return this._q=[],this},g=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setEventProperties"],f=0;f<g.length;f++)n(m,g[f]);r.Revenue=m;var v=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset","extendSession"],y=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];s(r),r.createInstance=function(e){return r._iq[e]={_q:[]},s(r._iq[e]),r._iq[e]},e.amplitude=r}}(window,document)}();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
javascript:!function()%7B%22use%20strict%22%3B!function(e%2Ct)%7Bvar%20r%3De.amplitude%7C%7C%7B_q%3A%5B%5D%2C_iq%3A%7B%7D%7D%3Bif(r.invoked)e.console%26%26console.error%26%26console.error(%22Amplitude%20snippet%20has%20been%20loaded.%22)%3Belse%7Bvar%20n%3Dfunction(e%2Ct)%7Be.prototype%5Bt%5D%3Dfunction()%7Breturn%20this._q.push(%7Bname%3At%2Cargs%3AArray.prototype.slice.call(arguments%2C0)%7D)%2Cthis%7D%7D%2Ci%3Dfunction(e%2Ct%2Cr)%7Breturn%20function(n)%7Be._q.push(%7Bname%3At%2Cargs%3AArray.prototype.slice.call(r%2C0)%2Cresolve%3An%7D)%7D%7D%2Co%3Dfunction(e%2Ct%2Cr)%7Be%5Bt%5D%3Dfunction()%7Bif(r)return%7Bpromise%3Anew%20Promise(i(e%2Ct%2CArray.prototype.slice.call(arguments)))%7D%7D%7D%2Cs%3Dfunction(e)%7Bfor(var%20t%3D0%3Bt%3Cv.length%3Bt%2B%2B)o(e%2Cv%5Bt%5D%2C!1)%3Bfor(var%20r%3D0%3Br%3Cy.length%3Br%2B%2B)o(e%2Cy%5Br%5D%2C!0)%7D%3Br.invoked%3D!0%3Bvar%20u%3Dt.getElementsByTagName(%22script%22)%5B0%5D%2Ca%3Dt.createElement(%22script%22)%3Ba.src%3D%22https%3A%2F%2Fcdn.amplitude.com%2Flibs%2Fplugin-autocapture-browser-0.9.0-min.js.gz%22%2Ca.async%3D!1%2Cu.parentNode.insertBefore(a%2Cu)%3Bvar%20c%3Dt.createElement(%22script%22)%3Bc.type%3D%22text%2Fjavascript%22%2Cc.integrity%3D%22sha384-
|
|
1
|
+
javascript:!function()%7B%22use%20strict%22%3B!function(e%2Ct)%7Bvar%20r%3De.amplitude%7C%7C%7B_q%3A%5B%5D%2C_iq%3A%7B%7D%7D%3Bif(r.invoked)e.console%26%26console.error%26%26console.error(%22Amplitude%20snippet%20has%20been%20loaded.%22)%3Belse%7Bvar%20n%3Dfunction(e%2Ct)%7Be.prototype%5Bt%5D%3Dfunction()%7Breturn%20this._q.push(%7Bname%3At%2Cargs%3AArray.prototype.slice.call(arguments%2C0)%7D)%2Cthis%7D%7D%2Ci%3Dfunction(e%2Ct%2Cr)%7Breturn%20function(n)%7Be._q.push(%7Bname%3At%2Cargs%3AArray.prototype.slice.call(r%2C0)%2Cresolve%3An%7D)%7D%7D%2Co%3Dfunction(e%2Ct%2Cr)%7Be%5Bt%5D%3Dfunction()%7Bif(r)return%7Bpromise%3Anew%20Promise(i(e%2Ct%2CArray.prototype.slice.call(arguments)))%7D%7D%7D%2Cs%3Dfunction(e)%7Bfor(var%20t%3D0%3Bt%3Cv.length%3Bt%2B%2B)o(e%2Cv%5Bt%5D%2C!1)%3Bfor(var%20r%3D0%3Br%3Cy.length%3Br%2B%2B)o(e%2Cy%5Br%5D%2C!0)%7D%3Br.invoked%3D!0%3Bvar%20u%3Dt.getElementsByTagName(%22script%22)%5B0%5D%2Ca%3Dt.createElement(%22script%22)%3Ba.src%3D%22https%3A%2F%2Fcdn.amplitude.com%2Flibs%2Fplugin-autocapture-browser-0.9.0-min.js.gz%22%2Ca.async%3D!1%2Cu.parentNode.insertBefore(a%2Cu)%3Bvar%20c%3Dt.createElement(%22script%22)%3Bc.type%3D%22text%2Fjavascript%22%2Cc.integrity%3D%22sha384-Bm7BOHoy1DFPw612QRLusUyH0HvQphY26zMrayc%2BoFXf7dk1Quc28naRc6IwtpYM%22%2Cc.crossOrigin%3D%22anonymous%22%2Cc.async%3D!1%2Cc.src%3D%22https%3A%2F%2Fcdn.amplitude.com%2Flibs%2Fanalytics-browser-2.11.12-min.js.gz%22%2Cc.onload%3Dfunction()%7Be.amplitude.runQueuedFunctions%7C%7Cconsole.log(%22%5BAmplitude%5D%20Error%3A%20could%20not%20load%20SDK%22)%2Ce.amplitude.init(%22YOUR_API_KEY%22%2C%22YOUR_USER_ID%22%2C%7BinstanceName%3A%22amplitude-bookmarklet%22%2CserverZone%3A%22YOUR_SERVER_ZONE%22%2CingestionMetadata%3A%7BsourceName%3A%22browser-typescript-bookmarklet%22%2CsourceVersion%3A%221.0.0%22%7D%2CoptOut%3A!1%7D)%2CamplitudeAutocapturePlugin%26%26amplitudeAutocapturePlugin.autocapturePlugin%26%26%22function%22%3D%3Dtypeof%20amplitudeAutocapturePlugin.autocapturePlugin%26%26e.amplitude.add(amplitudeAutocapturePlugin.autocapturePlugin())%2Calert(%22Amplitude%20is%20now%20tracking%20events!%22)%7D%2Cu.parentNode.insertBefore(c%2Cu)%3Bfor(var%20p%3Dfunction()%7Breturn%20this._q%3D%5B%5D%2Cthis%7D%2Cl%3D%5B%22add%22%2C%22append%22%2C%22clearAll%22%2C%22prepend%22%2C%22set%22%2C%22setOnce%22%2C%22unset%22%2C%22preInsert%22%2C%22postInsert%22%2C%22remove%22%2C%22getUserProperties%22%5D%2Cd%3D0%3Bd%3Cl.length%3Bd%2B%2B)n(p%2Cl%5Bd%5D)%3Br.Identify%3Dp%3Bfor(var%20m%3Dfunction()%7Breturn%20this._q%3D%5B%5D%2Cthis%7D%2Cg%3D%5B%22getEventProperties%22%2C%22setProductId%22%2C%22setQuantity%22%2C%22setPrice%22%2C%22setRevenue%22%2C%22setRevenueType%22%2C%22setEventProperties%22%5D%2Cf%3D0%3Bf%3Cg.length%3Bf%2B%2B)n(m%2Cg%5Bf%5D)%3Br.Revenue%3Dm%3Bvar%20v%3D%5B%22getDeviceId%22%2C%22setDeviceId%22%2C%22getSessionId%22%2C%22setSessionId%22%2C%22getUserId%22%2C%22setUserId%22%2C%22setOptOut%22%2C%22setTransport%22%2C%22reset%22%2C%22extendSession%22%5D%2Cy%3D%5B%22init%22%2C%22add%22%2C%22remove%22%2C%22track%22%2C%22logEvent%22%2C%22identify%22%2C%22groupIdentify%22%2C%22setGroup%22%2C%22revenue%22%2C%22flush%22%5D%3Bs(r)%2Cr.createInstance%3Dfunction(e)%7Breturn%20r._iq%5Be%5D%3D%7B_q%3A%5B%5D%7D%2Cs(r._iq%5Be%5D)%2Cr._iq%5Be%5D%7D%2Ce.amplitude%3Dr%7D%7D(window%2Cdocument)%7D()%3B%0A
|