@amplitude/analytics-browser 0.3.0 → 0.4.1
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/LICENSE +21 -0
- package/README.md +1 -1
- package/lib/cjs/attribution.d.ts +1 -1
- package/lib/cjs/attribution.d.ts.map +1 -1
- package/lib/cjs/attribution.js +5 -17
- package/lib/cjs/attribution.js.map +1 -1
- package/lib/cjs/browser-client.d.ts +96 -81
- package/lib/cjs/browser-client.d.ts.map +1 -1
- package/lib/cjs/browser-client.js +194 -196
- package/lib/cjs/browser-client.js.map +1 -1
- package/lib/cjs/config.d.ts +11 -7
- package/lib/cjs/config.d.ts.map +1 -1
- package/lib/cjs/config.js +33 -34
- package/lib/cjs/config.js.map +1 -1
- package/lib/cjs/cookie-migration/index.d.ts +5 -0
- package/lib/cjs/cookie-migration/index.d.ts.map +1 -0
- package/lib/cjs/cookie-migration/index.js +55 -0
- package/lib/cjs/cookie-migration/index.js.map +1 -0
- package/lib/cjs/plugins/context.js +1 -1
- package/lib/cjs/plugins/context.js.map +1 -1
- package/lib/cjs/session-manager.d.ts +3 -3
- package/lib/cjs/session-manager.d.ts.map +1 -1
- package/lib/cjs/session-manager.js +10 -16
- package/lib/cjs/session-manager.js.map +1 -1
- package/lib/cjs/storage/cookie.d.ts +2 -2
- package/lib/cjs/storage/cookie.d.ts.map +1 -1
- package/lib/cjs/storage/cookie.js +16 -11
- package/lib/cjs/storage/cookie.js.map +1 -1
- package/lib/cjs/storage/local-storage.d.ts +1 -0
- package/lib/cjs/storage/local-storage.d.ts.map +1 -1
- package/lib/cjs/storage/local-storage.js +4 -1
- package/lib/cjs/storage/local-storage.js.map +1 -1
- package/lib/cjs/storage/memory.d.ts +1 -0
- package/lib/cjs/storage/memory.d.ts.map +1 -1
- package/lib/cjs/storage/memory.js +4 -0
- package/lib/cjs/storage/memory.js.map +1 -1
- package/lib/cjs/storage/utm-cookie.js +1 -1
- package/lib/cjs/storage/utm-cookie.js.map +1 -1
- package/lib/cjs/transports/fetch.d.ts +2 -1
- package/lib/cjs/transports/fetch.d.ts.map +1 -1
- package/lib/cjs/transports/fetch.js +5 -3
- package/lib/cjs/transports/fetch.js.map +1 -1
- package/lib/cjs/transports/send-beacon.d.ts +2 -1
- package/lib/cjs/transports/send-beacon.d.ts.map +1 -1
- package/lib/cjs/transports/send-beacon.js +7 -4
- package/lib/cjs/transports/send-beacon.js.map +1 -1
- package/lib/cjs/transports/xhr.d.ts +2 -1
- package/lib/cjs/transports/xhr.d.ts.map +1 -1
- package/lib/cjs/transports/xhr.js +7 -4
- package/lib/cjs/transports/xhr.js.map +1 -1
- package/lib/cjs/utils/snippet-helper.d.ts +1 -0
- package/lib/cjs/utils/snippet-helper.d.ts.map +1 -1
- package/lib/cjs/utils/snippet-helper.js +1 -0
- package/lib/cjs/utils/snippet-helper.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/attribution.d.ts +1 -1
- package/lib/esm/attribution.d.ts.map +1 -1
- package/lib/esm/attribution.js +4 -16
- package/lib/esm/attribution.js.map +1 -1
- package/lib/esm/browser-client.d.ts +96 -81
- package/lib/esm/browser-client.d.ts.map +1 -1
- package/lib/esm/browser-client.js +197 -182
- package/lib/esm/browser-client.js.map +1 -1
- package/lib/esm/config.d.ts +11 -7
- package/lib/esm/config.d.ts.map +1 -1
- package/lib/esm/config.js +28 -29
- package/lib/esm/config.js.map +1 -1
- package/lib/esm/cookie-migration/index.d.ts +5 -0
- package/lib/esm/cookie-migration/index.d.ts.map +1 -0
- package/lib/esm/cookie-migration/index.js +50 -0
- package/lib/esm/cookie-migration/index.js.map +1 -0
- package/lib/esm/plugins/context.js +2 -2
- package/lib/esm/plugins/context.js.map +1 -1
- package/lib/esm/session-manager.d.ts +3 -3
- package/lib/esm/session-manager.d.ts.map +1 -1
- package/lib/esm/session-manager.js +8 -14
- package/lib/esm/session-manager.js.map +1 -1
- package/lib/esm/storage/cookie.d.ts +2 -2
- package/lib/esm/storage/cookie.d.ts.map +1 -1
- package/lib/esm/storage/cookie.js +16 -11
- package/lib/esm/storage/cookie.js.map +1 -1
- package/lib/esm/storage/local-storage.d.ts +1 -0
- package/lib/esm/storage/local-storage.d.ts.map +1 -1
- package/lib/esm/storage/local-storage.js +4 -1
- package/lib/esm/storage/local-storage.js.map +1 -1
- package/lib/esm/storage/memory.d.ts +1 -0
- package/lib/esm/storage/memory.d.ts.map +1 -1
- package/lib/esm/storage/memory.js +4 -0
- package/lib/esm/storage/memory.js.map +1 -1
- package/lib/esm/storage/utm-cookie.js +1 -1
- package/lib/esm/storage/utm-cookie.js.map +1 -1
- package/lib/esm/transports/fetch.d.ts +2 -1
- package/lib/esm/transports/fetch.d.ts.map +1 -1
- package/lib/esm/transports/fetch.js +7 -5
- package/lib/esm/transports/fetch.js.map +1 -1
- package/lib/esm/transports/send-beacon.d.ts +2 -1
- package/lib/esm/transports/send-beacon.d.ts.map +1 -1
- package/lib/esm/transports/send-beacon.js +9 -6
- package/lib/esm/transports/send-beacon.js.map +1 -1
- package/lib/esm/transports/xhr.d.ts +2 -1
- package/lib/esm/transports/xhr.d.ts.map +1 -1
- package/lib/esm/transports/xhr.js +9 -6
- package/lib/esm/transports/xhr.js.map +1 -1
- package/lib/esm/utils/snippet-helper.d.ts +1 -0
- package/lib/esm/utils/snippet-helper.d.ts.map +1 -1
- package/lib/esm/utils/snippet-helper.js +1 -0
- package/lib/esm/utils/snippet-helper.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-min.js +1 -1
- package/lib/scripts/amplitude-min.js.gz +0 -0
- 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/package.json +10 -6
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.
|
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ Alternatively, the package is also distributed through a CDN. Copy and paste the
|
|
|
32
32
|
<!-- README_SNIPPET_BLOCK -->
|
|
33
33
|
```html
|
|
34
34
|
<script type="text/javascript">
|
|
35
|
-
!function(){"use strict";!function(e,t){var r=e.amplitude||{_q:[]};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{r.invoked=!0;var n=t.createElement("script");n.type="text/javascript",n.integrity="sha384-
|
|
35
|
+
!function(){"use strict";!function(e,t){var r=e.amplitude||{_q:[]};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{r.invoked=!0;var n=t.createElement("script");n.type="text/javascript",n.integrity="sha384-uhLfRZptXuAOheWdBzdbLlI4IsiZKZDJU5F0tF0QADF4vMob3RWlNU4DJ9PZV2J4",n.crossOrigin="anonymous",n.async=!0,n.src="https://cdn.amplitude.com/libs/analytics-browser-0.4.1-min.js.gz",n.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var s=t.getElementsByTagName("script")[0];function v(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}}s.parentNode.insertBefore(n,s);for(var o=function(){return this._q=[],this},i=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],a=0;a<i.length;a++)v(o,i[a]);r.Identify=o;for(var u=function(){return this._q=[],this},c=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setEventProperties"],p=0;p<c.length;p++)v(u,c[p]);r.Revenue=u;var d=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport"],l=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue"];function f(e){function t(t,r){e[t]=function(){var n={promise:new Promise((r=>{e._q.push({name:t,args:Array.prototype.slice.call(arguments,0),resolve:r})}))};if(r)return n}}for(var r=0;r<d.length;r++)t(d[r],!1);for(var n=0;n<l.length;n++)t(l[n],!0)}f(r),e.amplitude=r}}(window,document)}();
|
|
36
36
|
|
|
37
37
|
amplitude.init("YOUR_API_KEY_HERE");
|
|
38
38
|
</script>
|
package/lib/cjs/attribution.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BrowserConfig, UTMData } from '@amplitude/analytics-types';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const getAttributions: (config: BrowserConfig) => Record<string, string>;
|
|
3
3
|
export declare const getUtmParam: () => UTMData;
|
|
4
4
|
export declare const getReferrer: () => Record<string, string | undefined>;
|
|
5
5
|
export declare const getGclid: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attribution.d.ts","sourceRoot":"","sources":["../../src/attribution.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"attribution.d.ts","sourceRoot":"","sources":["../../src/attribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAkBpE,eAAO,MAAM,eAAe,WAAY,aAAa,KAAG,OAAO,MAAM,EAAE,MAAM,CAS5E,CAAC;AAEF,eAAO,MAAM,WAAW,QAAO,OAkB9B,CAAC;AAEF,eAAO,MAAM,WAAW,0CAYvB,CAAC;AAEF,eAAO,MAAM,QAAQ;;CAKpB,CAAC;AAEF,eAAO,MAAM,SAAS;;CAKrB,CAAC"}
|
package/lib/cjs/attribution.js
CHANGED
|
@@ -1,26 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.getFbclid = exports.getGclid = exports.getReferrer = exports.getUtmParam = exports.
|
|
2
|
+
exports.getFbclid = exports.getGclid = exports.getReferrer = exports.getUtmParam = exports.getAttributions = void 0;
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
|
-
var analytics_core_1 = require("@amplitude/analytics-core");
|
|
5
4
|
var constants_1 = require("./constants");
|
|
6
5
|
var utm_cookie_1 = require("./storage/utm-cookie");
|
|
7
6
|
var query_params_1 = require("./utils/query-params");
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
var id = new analytics_core_1.Identify();
|
|
14
|
-
Object.entries(attribution).forEach(function (_a) {
|
|
15
|
-
var _b = (0, tslib_1.__read)(_a, 2), key = _b[0], value = _b[1];
|
|
16
|
-
if (value) {
|
|
17
|
-
id.setOnce("initial_".concat(key), value);
|
|
18
|
-
id.set(key, value);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
void (0, analytics_core_1.identify)(undefined, undefined, id);
|
|
7
|
+
var getAttributions = function (config) {
|
|
8
|
+
var attributions = (0, tslib_1.__assign)((0, tslib_1.__assign)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, (config.includeUtm && (0, exports.getUtmParam)())), (config.includeReferrer && (0, exports.getReferrer)())), (config.includeGclid && (0, exports.getGclid)())), (config.includeFbclid && (0, exports.getFbclid)()));
|
|
9
|
+
return attributions;
|
|
22
10
|
};
|
|
23
|
-
exports.
|
|
11
|
+
exports.getAttributions = getAttributions;
|
|
24
12
|
var getUtmParam = function () {
|
|
25
13
|
var params = (0, query_params_1.getQueryParams)();
|
|
26
14
|
var utmStorage = new utm_cookie_1.UTMCookie();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attribution.js","sourceRoot":"","sources":["../../src/attribution.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"attribution.js","sourceRoot":"","sources":["../../src/attribution.ts"],"names":[],"mappings":";;;AACA,yCAaqB;AACrB,mDAAiD;AACjD,qDAAsD;AAE/C,IAAM,eAAe,GAAG,UAAC,MAAqB;IACnD,IAAM,YAAY,+FACb,CAAC,MAAM,CAAC,UAAU,IAAI,IAAA,mBAAW,GAAE,CAAC,GACpC,CAAC,MAAM,CAAC,eAAe,IAAI,IAAA,mBAAW,GAAE,CAAC,GACzC,CAAC,MAAM,CAAC,YAAY,IAAI,IAAA,gBAAQ,GAAE,CAAC,GACnC,CAAC,MAAM,CAAC,aAAa,IAAI,IAAA,iBAAS,GAAE,CAAC,CACzC,CAAC;IAEF,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AATW,QAAA,eAAe,mBAS1B;AAEK,IAAM,WAAW,GAAG;IACzB,IAAM,MAAM,GAAG,IAAA,6BAAc,GAAE,CAAC;IAChC,IAAM,UAAU,GAAG,IAAI,sBAAS,EAAE,CAAC;IACnC,IA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,IAAI,QAAQ,KAAK,SAAS;YAAE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACrD,IAAI,eAAe,KAAK,SAAS;YAAE,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;KAC5E;IAAC,WAAM;QACN,EAAE;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAZW,QAAA,WAAW,eAYtB;AAEK,IAAM,QAAQ,GAAG;;IACtB,IAAM,MAAM,GAAG,IAAA,6BAAc,GAAE,CAAC;IAChC,iCACK,CAAC,MAAM,CAAC,iBAAK,CAAC,cAAM,GAAC,iBAAK,IAAG,MAAM,CAAC,iBAAK,CAAC,KAAE,CAAC,EAChD;AACJ,CAAC,CAAC;AALW,QAAA,QAAQ,YAKnB;AAEK,IAAM,SAAS,GAAG;;IACvB,IAAM,MAAM,GAAG,IAAA,6BAAc,GAAE,CAAC;IAChC,iCACK,CAAC,MAAM,CAAC,kBAAM,CAAC,cAAM,GAAC,kBAAM,IAAG,MAAM,CAAC,kBAAM,CAAC,KAAE,CAAC,EACnD;AACJ,CAAC,CAAC;AALW,QAAA,SAAS,aAKpB","sourcesContent":["import { BrowserConfig, UTMData } from '@amplitude/analytics-types';\nimport {\n UTM_CAMPAIGN,\n UTM_CONTENT,\n UTM_MEDIUM,\n UTM_SOURCE,\n UTM_TERM,\n UTMZ_SOURCE,\n UTMZ_MEDIUM,\n UTMZ_CAMPAIGN,\n UTMZ_TERM,\n UTMZ_CONTENT,\n GCLID,\n FBCLID,\n} from './constants';\nimport { UTMCookie } from './storage/utm-cookie';\nimport { getQueryParams } from './utils/query-params';\n\nexport const getAttributions = (config: BrowserConfig): Record<string, string> => {\n const attributions = {\n ...(config.includeUtm && getUtmParam()),\n ...(config.includeReferrer && getReferrer()),\n ...(config.includeGclid && getGclid()),\n ...(config.includeFbclid && getFbclid()),\n };\n\n return attributions;\n};\n\nexport const getUtmParam = (): UTMData => {\n const params = getQueryParams();\n const utmStorage = new UTMCookie();\n const cookies = (utmStorage.isEnabled() && utmStorage.get('__utmz')) || {};\n\n const utmSource = params[UTM_SOURCE] || cookies[UTMZ_SOURCE];\n const utmMedium = params[UTM_MEDIUM] || cookies[UTMZ_MEDIUM];\n const utmCampaign = params[UTM_CAMPAIGN] || cookies[UTMZ_CAMPAIGN];\n const utmTerm = params[UTM_TERM] || cookies[UTMZ_TERM];\n const utmContent = params[UTM_CONTENT] || cookies[UTMZ_CONTENT];\n\n const data: UTMData = {};\n if (utmSource) data.utm_source = utmSource;\n if (utmMedium) data.utm_medium = utmMedium;\n if (utmCampaign) data.utm_campaign = utmCampaign;\n if (utmTerm) data.utm_term = utmTerm;\n if (utmContent) data.utm_content = utmContent;\n return data;\n};\n\nexport const getReferrer = () => {\n const data: Record<string, string | undefined> = {};\n try {\n const referrer = document.referrer || undefined;\n const referringDomain = referrer?.split('/')[2] ?? undefined;\n\n if (referrer !== undefined) data.referrer = referrer;\n if (referringDomain !== undefined) data.referring_domain = referringDomain;\n } catch {\n //\n }\n return data;\n};\n\nexport const getGclid = () => {\n const params = getQueryParams();\n return {\n ...(params[GCLID] && { [GCLID]: params[GCLID] }),\n };\n};\n\nexport const getFbclid = () => {\n const params = getQueryParams();\n return {\n ...(params[FBCLID] && { [FBCLID]: params[FBCLID] }),\n };\n};\n"]}
|
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AmplitudeCore } from '@amplitude/analytics-core';
|
|
2
|
+
import { BrowserConfig, BrowserOptions, EventOptions, Identify as IIdentify, Result, Revenue as IRevenue, TransportType } from '@amplitude/analytics-types';
|
|
3
|
+
export declare class AmplitudeBrowser extends AmplitudeCore<BrowserConfig> {
|
|
4
|
+
init(apiKey: string, userId?: string, options?: BrowserOptions): Promise<void>;
|
|
5
|
+
getUserId(): string | undefined;
|
|
6
|
+
setUserId(userId: string): void;
|
|
7
|
+
getDeviceId(): string | undefined;
|
|
8
|
+
setDeviceId(deviceId: string): void;
|
|
9
|
+
getSessionId(): number | undefined;
|
|
10
|
+
setSessionId(sessionId: number): void;
|
|
11
|
+
setOptOut(optOut: boolean): void;
|
|
12
|
+
setTransport(transport: TransportType): void;
|
|
13
|
+
identify(identify: IIdentify, eventOptions?: EventOptions): Promise<Result>;
|
|
14
|
+
groupIdentify(groupType: string, groupName: string | string[], identify: IIdentify, eventOptions?: EventOptions): Promise<Result>;
|
|
15
|
+
revenue(revenue: IRevenue, eventOptions?: EventOptions): Promise<Result>;
|
|
16
|
+
trackAttributions(): Promise<Result> | undefined;
|
|
17
|
+
}
|
|
3
18
|
/**
|
|
4
19
|
* Initializes the Amplitude SDK with your apiKey, userId and optional configurations.
|
|
5
20
|
* This method must be called before any other operations.
|
|
@@ -8,7 +23,7 @@ import { AmplitudeReturn, BrowserOptions, EventOptions, Plugin, Result, Transpor
|
|
|
8
23
|
* await init(API_KEY, USER_ID, options).promise;
|
|
9
24
|
* ```
|
|
10
25
|
*/
|
|
11
|
-
export declare const init: (apiKey: string, userId?: string | undefined, options?: BrowserOptions | undefined) => AmplitudeReturn<void>;
|
|
26
|
+
export declare const init: (apiKey: string, userId?: string | undefined, options?: BrowserOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<void>;
|
|
12
27
|
/**
|
|
13
28
|
* Adds a new plugin.
|
|
14
29
|
*
|
|
@@ -17,7 +32,7 @@ export declare const init: (apiKey: string, userId?: string | undefined, options
|
|
|
17
32
|
* amplitude.add(plugin);
|
|
18
33
|
* ```
|
|
19
34
|
*/
|
|
20
|
-
export declare const add: (plugin: Plugin) => AmplitudeReturn<void>;
|
|
35
|
+
export declare const add: (plugin: import("@amplitude/analytics-types").Plugin) => import("@amplitude/analytics-types").AmplitudeReturn<void>;
|
|
21
36
|
/**
|
|
22
37
|
* Removes a plugin.
|
|
23
38
|
*
|
|
@@ -25,7 +40,83 @@ export declare const add: (plugin: Plugin) => AmplitudeReturn<void>;
|
|
|
25
40
|
* amplitude.remove('myPlugin');
|
|
26
41
|
* ```
|
|
27
42
|
*/
|
|
28
|
-
export declare const remove: (pluginName: string) => AmplitudeReturn<void>;
|
|
43
|
+
export declare const remove: (pluginName: string) => import("@amplitude/analytics-types").AmplitudeReturn<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Tracks user-defined event, with specified type, optional event properties and optional overwrites.
|
|
46
|
+
*
|
|
47
|
+
* ```typescript
|
|
48
|
+
* // event tracking with event type only
|
|
49
|
+
* track('Page Load');
|
|
50
|
+
*
|
|
51
|
+
* // event tracking with event type and additional event properties
|
|
52
|
+
* track('Page Load', { loadTime: 1000 });
|
|
53
|
+
*
|
|
54
|
+
* // event tracking with event type, additional event properties, and overwritten event options
|
|
55
|
+
* track('Page Load', { loadTime: 1000 }, { sessionId: -1 });
|
|
56
|
+
*
|
|
57
|
+
* // alternatively, this tracking method is awaitable
|
|
58
|
+
* const result = await track('Page Load').promise;
|
|
59
|
+
* console.log(result.event); // {...}
|
|
60
|
+
* console.log(result.code); // 200
|
|
61
|
+
* console.log(result.message); // "Event tracked successfully"
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare const track: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Result>;
|
|
65
|
+
/**
|
|
66
|
+
* Alias for track()
|
|
67
|
+
*/
|
|
68
|
+
export declare const logEvent: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Result>;
|
|
69
|
+
/**
|
|
70
|
+
* Sends an identify event containing user property operations
|
|
71
|
+
*
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const id = new Identify();
|
|
74
|
+
* id.set('colors', ['rose', 'gold']);
|
|
75
|
+
* identify(id);
|
|
76
|
+
*
|
|
77
|
+
* // alternatively, this tracking method is awaitable
|
|
78
|
+
* const result = await identify(id).promise;
|
|
79
|
+
* console.log(result.event); // {...}
|
|
80
|
+
* console.log(result.code); // 200
|
|
81
|
+
* console.log(result.message); // "Event tracked successfully"
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare const identify: (identify: IIdentify, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Result>;
|
|
85
|
+
/**
|
|
86
|
+
* Sends a group identify event containing group property operations.
|
|
87
|
+
*
|
|
88
|
+
* ```typescript
|
|
89
|
+
* const id = new Identify();
|
|
90
|
+
* id.set('skills', ['js', 'ts']);
|
|
91
|
+
* const groupType = 'org';
|
|
92
|
+
* const groupName = 'engineering';
|
|
93
|
+
* groupIdentify(groupType, groupName, id);
|
|
94
|
+
*
|
|
95
|
+
* // alternatively, this tracking method is awaitable
|
|
96
|
+
* const result = await groupIdentify(groupType, groupName, id).promise;
|
|
97
|
+
* console.log(result.event); // {...}
|
|
98
|
+
* console.log(result.code); // 200
|
|
99
|
+
* console.log(result.message); // "Event tracked successfully"
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare const groupIdentify: (groupType: string, groupName: string | string[], identify: IIdentify, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Result>;
|
|
103
|
+
export declare const setGroup: (groupType: string, groupName: string | string[]) => import("@amplitude/analytics-types").AmplitudeReturn<Result>;
|
|
104
|
+
/**
|
|
105
|
+
* Sends a revenue event containing revenue property operations.
|
|
106
|
+
*
|
|
107
|
+
* ```typescript
|
|
108
|
+
* const rev = new Revenue();
|
|
109
|
+
* rev.setRevenue(100);
|
|
110
|
+
* revenue(rev);
|
|
111
|
+
*
|
|
112
|
+
* // alternatively, this tracking method is awaitable
|
|
113
|
+
* const result = await revenue(rev).promise;
|
|
114
|
+
* console.log(result.event); // {...}
|
|
115
|
+
* console.log(result.code); // 200
|
|
116
|
+
* console.log(result.message); // "Event tracked successfully"
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare const revenue: (revenue: IRevenue, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Result>;
|
|
29
120
|
/**
|
|
30
121
|
* Returns current user ID.
|
|
31
122
|
*
|
|
@@ -104,80 +195,4 @@ export declare const setOptOut: (optOut: boolean) => void;
|
|
|
104
195
|
* ```
|
|
105
196
|
*/
|
|
106
197
|
export declare const setTransport: (transport: TransportType) => void;
|
|
107
|
-
/**
|
|
108
|
-
* Tracks user-defined event, with specified type, optional event properties and optional overwrites.
|
|
109
|
-
*
|
|
110
|
-
* ```typescript
|
|
111
|
-
* // event tracking with event type only
|
|
112
|
-
* track('Page Load');
|
|
113
|
-
*
|
|
114
|
-
* // event tracking with event type and additional event properties
|
|
115
|
-
* track('Page Load', { loadTime: 1000 });
|
|
116
|
-
*
|
|
117
|
-
* // event tracking with event type, additional event properties, and overwritten event options
|
|
118
|
-
* track('Page Load', { loadTime: 1000 }, { sessionId: -1 });
|
|
119
|
-
*
|
|
120
|
-
* // alternatively, this tracking method is awaitable
|
|
121
|
-
* const result = await track('Page Load').promise;
|
|
122
|
-
* console.log(result.event); // {...}
|
|
123
|
-
* console.log(result.code); // 200
|
|
124
|
-
* console.log(result.message); // "Event tracked successfully"
|
|
125
|
-
* ```
|
|
126
|
-
*/
|
|
127
|
-
export declare const track: (eventType: string, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined) => AmplitudeReturn<Result>;
|
|
128
|
-
/**
|
|
129
|
-
* Alis for track()
|
|
130
|
-
*/
|
|
131
|
-
export declare const logEvent: (eventType: string, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined) => AmplitudeReturn<Result>;
|
|
132
|
-
/**
|
|
133
|
-
* Sends an identify event containing user property operations
|
|
134
|
-
*
|
|
135
|
-
* ```typescript
|
|
136
|
-
* const id = new Identify();
|
|
137
|
-
* id.set('colors', ['rose', 'gold']);
|
|
138
|
-
* identify(id);
|
|
139
|
-
*
|
|
140
|
-
* // alternatively, this tracking method is awaitable
|
|
141
|
-
* const result = await identify(id).promise;
|
|
142
|
-
* console.log(result.event); // {...}
|
|
143
|
-
* console.log(result.code); // 200
|
|
144
|
-
* console.log(result.message); // "Event tracked successfully"
|
|
145
|
-
* ```
|
|
146
|
-
*/
|
|
147
|
-
export declare const identify: (identify: Identify, eventOptions?: EventOptions | undefined) => AmplitudeReturn<Result>;
|
|
148
|
-
/**
|
|
149
|
-
* Sends a group identify event containing group property operations.
|
|
150
|
-
*
|
|
151
|
-
* ```typescript
|
|
152
|
-
* const id = new Identify();
|
|
153
|
-
* id.set('skills', ['js', 'ts']);
|
|
154
|
-
* const groupType = 'org';
|
|
155
|
-
* const groupName = 'engineering';
|
|
156
|
-
* groupIdentify(groupType, groupName, id);
|
|
157
|
-
*
|
|
158
|
-
* // alternatively, this tracking method is awaitable
|
|
159
|
-
* const result = await groupIdentify(groupType, groupName, id).promise;
|
|
160
|
-
* console.log(result.event); // {...}
|
|
161
|
-
* console.log(result.code); // 200
|
|
162
|
-
* console.log(result.message); // "Event tracked successfully"
|
|
163
|
-
* ```
|
|
164
|
-
*/
|
|
165
|
-
export declare const groupIdentify: (groupType: string, groupName: string | string[], identify: Identify, eventOptions?: EventOptions | undefined) => AmplitudeReturn<Result>;
|
|
166
|
-
export declare const setGroup: (groupType: string, groupName: string | string[]) => AmplitudeReturn<Result>;
|
|
167
|
-
/**
|
|
168
|
-
* Sends a revenue event containing revenue property operations.
|
|
169
|
-
*
|
|
170
|
-
* ```typescript
|
|
171
|
-
* const rev = new Revenue();
|
|
172
|
-
* rev.setRevenue(100);
|
|
173
|
-
* revenue(rev);
|
|
174
|
-
*
|
|
175
|
-
* // alternatively, this tracking method is awaitable
|
|
176
|
-
* const result = await revenue(rev).promise;
|
|
177
|
-
* console.log(result.event); // {...}
|
|
178
|
-
* console.log(result.code); // 200
|
|
179
|
-
* console.log(result.message); // "Event tracked successfully"
|
|
180
|
-
* ```
|
|
181
|
-
*/
|
|
182
|
-
export declare const revenue: (revenue: Revenue, eventOptions?: EventOptions | undefined) => AmplitudeReturn<Result>;
|
|
183
198
|
//# sourceMappingURL=browser-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-client.d.ts","sourceRoot":"","sources":["../../src/browser-client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"browser-client.d.ts","sourceRoot":"","sources":["../../src/browser-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAiD,MAAM,2BAA2B,CAAC;AACzG,OAAO,EACL,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,IAAI,SAAS,EACrB,MAAM,EACN,OAAO,IAAI,QAAQ,EACnB,aAAa,EACd,MAAM,4BAA4B,CAAC;AAQpC,qBAAa,gBAAiB,SAAQ,aAAa,CAAC,aAAa,CAAC;IAC1D,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc;IAwBpE,SAAS;IAIT,SAAS,CAAC,MAAM,EAAE,MAAM;IAKxB,WAAW;IAIX,WAAW,CAAC,QAAQ,EAAE,MAAM;IAK5B,YAAY;IAIZ,YAAY,CAAC,SAAS,EAAE,MAAM;IAK9B,SAAS,CAAC,MAAM,EAAE,OAAO;IAKzB,YAAY,CAAC,SAAS,EAAE,aAAa;IAIrC,QAAQ,CAAC,QAAQ,EAAE,SAAS,EAAE,YAAY,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;IAS3E,aAAa,CACX,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAC5B,QAAQ,EAAE,SAAS,EACnB,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,MAAM,CAAC;IASlB,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,YAAY;IAStD,iBAAiB;CAclB;AAID;;;;;;;GAOG;AACH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