@amplitude/analytics-browser
Advanced tools
Comparing version 0.7.0 to 0.7.1
@@ -27,3 +27,3 @@ import { AmplitudeCore } from '@amplitude/analytics-core'; | ||
*/ | ||
export declare const init: (apiKey: string, userId?: string | undefined, options?: (BrowserOptions & AdditionalBrowserOptions) | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<void>; | ||
export declare const init: (apiKey: string, userId?: string | undefined, options?: (BrowserOptions & AdditionalBrowserOptions) | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>; | ||
/** | ||
@@ -37,3 +37,3 @@ * Adds a new plugin. | ||
*/ | ||
export declare const add: (plugin: import("@amplitude/analytics-types").Plugin) => import("@amplitude/analytics-types").AmplitudeReturn<void>; | ||
export declare const add: (plugin: import("@amplitude/analytics-types").Plugin) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>; | ||
/** | ||
@@ -46,3 +46,3 @@ * Removes a plugin. | ||
*/ | ||
export declare const remove: (pluginName: string) => import("@amplitude/analytics-types").AmplitudeReturn<void>; | ||
export declare const remove: (pluginName: string) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>; | ||
/** | ||
@@ -68,7 +68,7 @@ * Tracks user-defined event, with specified type, optional event properties and optional overwrites. | ||
*/ | ||
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>; | ||
export declare const track: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
/** | ||
* Alias for track() | ||
*/ | ||
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>; | ||
export declare const logEvent: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
/** | ||
@@ -89,3 +89,3 @@ * Sends an identify event containing user property operations | ||
*/ | ||
export declare const identify: (identify: IIdentify, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Result>; | ||
export declare const identify: (identify: IIdentify, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
/** | ||
@@ -108,4 +108,4 @@ * Sends a group identify event containing group property operations. | ||
*/ | ||
export declare const groupIdentify: (groupType: string, groupName: string | string[], identify: IIdentify, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Result>; | ||
export declare const setGroup: (groupType: string, groupName: string | string[]) => import("@amplitude/analytics-types").AmplitudeReturn<Result>; | ||
export declare const groupIdentify: (groupType: string, groupName: string | string[], identify: IIdentify, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
export declare const setGroup: (groupType: string, groupName: string | string[]) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
/** | ||
@@ -126,3 +126,3 @@ * Sends a revenue event containing revenue property operations. | ||
*/ | ||
export declare const revenue: (revenue: IRevenue, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Result>; | ||
export declare const revenue: (revenue: IRevenue, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
/** | ||
@@ -227,3 +227,3 @@ * Returns current user ID. | ||
*/ | ||
export declare const flush: () => import("@amplitude/analytics-types").AmplitudeReturn<void>; | ||
export declare const flush: () => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>; | ||
//# sourceMappingURL=browser-client.d.ts.map |
@@ -90,2 +90,3 @@ import { Event, BrowserOptions, BrowserConfig as IBrowserConfig, Storage, TrackingOptions, TransportType, UserSession, SessionManager as ISessionManager } from '@amplitude/analytics-types'; | ||
export declare const createTransport: (transport?: TransportType | undefined) => FetchTransport | XHRTransport | SendBeaconTransport; | ||
export declare const getTopLevelDomain: (url?: string | undefined) => Promise<string>; | ||
//# sourceMappingURL=config.d.ts.map |
var _this = this; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createTransport = exports.createDeviceId = exports.createEventsStorage = exports.createFlexibleStorage = exports.createCookieStorage = exports.useBrowserConfig = exports.BrowserConfig = exports.getDefaultConfig = void 0; | ||
exports.getTopLevelDomain = exports.createTransport = exports.createDeviceId = exports.createEventsStorage = exports.createFlexibleStorage = exports.createCookieStorage = exports.useBrowserConfig = exports.BrowserConfig = exports.getDefaultConfig = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -126,29 +126,38 @@ var analytics_types_1 = require("@amplitude/analytics-types"); | ||
var useBrowserConfig = function (apiKey, userId, options) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () { | ||
var defaultConfig, cookieStorage, cookieName, cookies, queryParams, sessionManager, _a, _b, _c; | ||
var _d; | ||
var _e, _f, _g, _h; | ||
return (0, tslib_1.__generator)(this, function (_j) { | ||
switch (_j.label) { | ||
var defaultConfig, domain, _a, cookieStorage, cookieName, cookies, queryParams, sessionManager, _b, _c, _d; | ||
var _e; | ||
var _f, _g, _h, _j, _k; | ||
return (0, tslib_1.__generator)(this, function (_l) { | ||
switch (_l.label) { | ||
case 0: | ||
defaultConfig = (0, exports.getDefaultConfig)(); | ||
return [4 /*yield*/, (0, exports.createCookieStorage)(options)]; | ||
case 1: | ||
cookieStorage = _j.sent(); | ||
if (!((_f = options === null || options === void 0 ? void 0 : options.domain) !== null && _f !== void 0)) return [3 /*break*/, 1]; | ||
_a = _f; | ||
return [3 /*break*/, 3]; | ||
case 1: return [4 /*yield*/, (0, exports.getTopLevelDomain)()]; | ||
case 2: | ||
_a = (_l.sent()); | ||
_l.label = 3; | ||
case 3: | ||
domain = _a; | ||
return [4 /*yield*/, (0, exports.createCookieStorage)((0, tslib_1.__assign)((0, tslib_1.__assign)({}, options), { domain: domain }))]; | ||
case 4: | ||
cookieStorage = _l.sent(); | ||
cookieName = (0, cookie_name_1.getCookieName)(apiKey); | ||
return [4 /*yield*/, cookieStorage.get(cookieName)]; | ||
case 2: | ||
cookies = _j.sent(); | ||
case 5: | ||
cookies = _l.sent(); | ||
queryParams = (0, query_params_1.getQueryParams)(); | ||
return [4 /*yield*/, new session_manager_1.SessionManager(cookieStorage, apiKey).load()]; | ||
case 3: | ||
sessionManager = _j.sent(); | ||
_a = BrowserConfig.bind; | ||
_b = [void 0, apiKey, userId !== null && userId !== void 0 ? userId : cookies === null || cookies === void 0 ? void 0 : cookies.userId]; | ||
_c = [(0, tslib_1.__assign)({}, options)]; | ||
_d = { cookieStorage: cookieStorage, sessionManager: sessionManager, deviceId: (0, exports.createDeviceId)(cookies === null || cookies === void 0 ? void 0 : cookies.deviceId, options === null || options === void 0 ? void 0 : options.deviceId, queryParams.deviceId), optOut: (_e = options === null || options === void 0 ? void 0 : options.optOut) !== null && _e !== void 0 ? _e : Boolean(cookies === null || cookies === void 0 ? void 0 : cookies.optOut) }; | ||
case 6: | ||
sessionManager = _l.sent(); | ||
_b = BrowserConfig.bind; | ||
_c = [void 0, apiKey, userId !== null && userId !== void 0 ? userId : cookies === null || cookies === void 0 ? void 0 : cookies.userId]; | ||
_d = [(0, tslib_1.__assign)({}, options)]; | ||
_e = { cookieStorage: cookieStorage, sessionManager: sessionManager, deviceId: (0, exports.createDeviceId)(cookies === null || cookies === void 0 ? void 0 : cookies.deviceId, options === null || options === void 0 ? void 0 : options.deviceId, queryParams.deviceId), domain: domain, optOut: (_g = options === null || options === void 0 ? void 0 : options.optOut) !== null && _g !== void 0 ? _g : Boolean(cookies === null || cookies === void 0 ? void 0 : cookies.optOut) }; | ||
return [4 /*yield*/, cookieStorage.get(cookieName)]; | ||
case 4: | ||
_d.sessionId = (_g = (_f = (_j.sent())) === null || _f === void 0 ? void 0 : _f.sessionId) !== null && _g !== void 0 ? _g : options === null || options === void 0 ? void 0 : options.sessionId; | ||
case 7: | ||
_e.sessionId = (_j = (_h = (_l.sent())) === null || _h === void 0 ? void 0 : _h.sessionId) !== null && _j !== void 0 ? _j : options === null || options === void 0 ? void 0 : options.sessionId; | ||
return [4 /*yield*/, (0, exports.createEventsStorage)(options)]; | ||
case 5: return [2 /*return*/, new (_a.apply(BrowserConfig, _b.concat([tslib_1.__assign.apply(void 0, _c.concat([(_d.storageProvider = _j.sent(), _d.trackingOptions = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, defaultConfig.trackingOptions), options === null || options === void 0 ? void 0 : options.trackingOptions), _d.transportProvider = (_h = options === null || options === void 0 ? void 0 : options.transportProvider) !== null && _h !== void 0 ? _h : (0, exports.createTransport)(options === null || options === void 0 ? void 0 : options.transport), _d)]))])))()]; | ||
case 8: return [2 /*return*/, new (_b.apply(BrowserConfig, _c.concat([tslib_1.__assign.apply(void 0, _d.concat([(_e.storageProvider = _l.sent(), _e.trackingOptions = (0, tslib_1.__assign)((0, tslib_1.__assign)({}, defaultConfig.trackingOptions), options === null || options === void 0 ? void 0 : options.trackingOptions), _e.transportProvider = (_k = options === null || options === void 0 ? void 0 : options.transportProvider) !== null && _k !== void 0 ? _k : (0, exports.createTransport)(options === null || options === void 0 ? void 0 : options.transport), _e)]))])))()]; | ||
} | ||
@@ -254,2 +263,44 @@ }); | ||
exports.createTransport = createTransport; | ||
var getTopLevelDomain = function (url) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () { | ||
var host, parts, levels, storageKey, i, i, domain, options, storage, value; | ||
return (0, tslib_1.__generator)(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, new cookie_1.CookieStorage().isEnabled()]; | ||
case 1: | ||
if (!(_a.sent()) || (!url && typeof location === 'undefined')) { | ||
return [2 /*return*/, '']; | ||
} | ||
host = url !== null && url !== void 0 ? url : location.hostname; | ||
parts = host.split('.'); | ||
levels = []; | ||
storageKey = 'AMP_TLDTEST'; | ||
for (i = parts.length - 2; i >= 0; --i) { | ||
levels.push(parts.slice(i).join('.')); | ||
} | ||
i = 0; | ||
_a.label = 2; | ||
case 2: | ||
if (!(i < levels.length)) return [3 /*break*/, 7]; | ||
domain = levels[i]; | ||
options = { domain: '.' + domain }; | ||
storage = new cookie_1.CookieStorage(options); | ||
return [4 /*yield*/, storage.set(storageKey, 1)]; | ||
case 3: | ||
_a.sent(); | ||
return [4 /*yield*/, storage.get(storageKey)]; | ||
case 4: | ||
value = _a.sent(); | ||
if (!value) return [3 /*break*/, 6]; | ||
return [4 /*yield*/, storage.remove(storageKey)]; | ||
case 5: | ||
_a.sent(); | ||
return [2 /*return*/, '.' + domain]; | ||
case 6: | ||
i++; | ||
return [3 /*break*/, 2]; | ||
case 7: return [2 /*return*/, '']; | ||
} | ||
}); | ||
}); }; | ||
exports.getTopLevelDomain = getTopLevelDomain; | ||
//# sourceMappingURL=config.js.map |
@@ -56,6 +56,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
try { | ||
try { | ||
value = decodeURIComponent(atob(value)); | ||
} | ||
catch (_b) { | ||
// value not encoded | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return | ||
return [2 /*return*/, JSON.parse(value)]; | ||
} | ||
catch (_b) { | ||
catch (_c) { | ||
/* istanbul ignore next */ | ||
@@ -96,3 +102,3 @@ return [2 /*return*/, undefined]; | ||
} | ||
str = "".concat(key, "=").concat(JSON.stringify(value)); | ||
str = "".concat(key, "=").concat(btoa(encodeURIComponent(JSON.stringify(value)))); | ||
if (expireDate) { | ||
@@ -99,0 +105,0 @@ str += "; expires=".concat(expireDate.toUTCString()); |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.7.0"; | ||
export declare const VERSION = "0.7.1"; | ||
//# sourceMappingURL=version.d.ts.map |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.VERSION = void 0; | ||
exports.VERSION = '0.7.0'; | ||
exports.VERSION = '0.7.1'; | ||
//# sourceMappingURL=version.js.map |
@@ -27,3 +27,3 @@ import { AmplitudeCore } from '@amplitude/analytics-core'; | ||
*/ | ||
export declare const init: (apiKey: string, userId?: string | undefined, options?: (BrowserOptions & AdditionalBrowserOptions) | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<void>; | ||
export declare const init: (apiKey: string, userId?: string | undefined, options?: (BrowserOptions & AdditionalBrowserOptions) | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>; | ||
/** | ||
@@ -37,3 +37,3 @@ * Adds a new plugin. | ||
*/ | ||
export declare const add: (plugin: import("@amplitude/analytics-types").Plugin) => import("@amplitude/analytics-types").AmplitudeReturn<void>; | ||
export declare const add: (plugin: import("@amplitude/analytics-types").Plugin) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>; | ||
/** | ||
@@ -46,3 +46,3 @@ * Removes a plugin. | ||
*/ | ||
export declare const remove: (pluginName: string) => import("@amplitude/analytics-types").AmplitudeReturn<void>; | ||
export declare const remove: (pluginName: string) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>; | ||
/** | ||
@@ -68,7 +68,7 @@ * Tracks user-defined event, with specified type, optional event properties and optional overwrites. | ||
*/ | ||
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>; | ||
export declare const track: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
/** | ||
* Alias for track() | ||
*/ | ||
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>; | ||
export declare const logEvent: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
/** | ||
@@ -89,3 +89,3 @@ * Sends an identify event containing user property operations | ||
*/ | ||
export declare const identify: (identify: IIdentify, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Result>; | ||
export declare const identify: (identify: IIdentify, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
/** | ||
@@ -108,4 +108,4 @@ * Sends a group identify event containing group property operations. | ||
*/ | ||
export declare const groupIdentify: (groupType: string, groupName: string | string[], identify: IIdentify, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Result>; | ||
export declare const setGroup: (groupType: string, groupName: string | string[]) => import("@amplitude/analytics-types").AmplitudeReturn<Result>; | ||
export declare const groupIdentify: (groupType: string, groupName: string | string[], identify: IIdentify, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
export declare const setGroup: (groupType: string, groupName: string | string[]) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
/** | ||
@@ -126,3 +126,3 @@ * Sends a revenue event containing revenue property operations. | ||
*/ | ||
export declare const revenue: (revenue: IRevenue, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Result>; | ||
export declare const revenue: (revenue: IRevenue, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<Result>>; | ||
/** | ||
@@ -227,3 +227,3 @@ * Returns current user ID. | ||
*/ | ||
export declare const flush: () => import("@amplitude/analytics-types").AmplitudeReturn<void>; | ||
export declare const flush: () => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>; | ||
//# sourceMappingURL=browser-client.d.ts.map |
@@ -90,2 +90,3 @@ import { Event, BrowserOptions, BrowserConfig as IBrowserConfig, Storage, TrackingOptions, TransportType, UserSession, SessionManager as ISessionManager } from '@amplitude/analytics-types'; | ||
export declare const createTransport: (transport?: TransportType | undefined) => FetchTransport | XHRTransport | SendBeaconTransport; | ||
export declare const getTopLevelDomain: (url?: string | undefined) => Promise<string>; | ||
//# sourceMappingURL=config.d.ts.map |
@@ -122,29 +122,38 @@ import { __assign, __awaiter, __extends, __generator } from "tslib"; | ||
export var useBrowserConfig = function (apiKey, userId, options) { return __awaiter(void 0, void 0, void 0, function () { | ||
var defaultConfig, cookieStorage, cookieName, cookies, queryParams, sessionManager, _a, _b, _c; | ||
var _d; | ||
var _e, _f, _g, _h; | ||
return __generator(this, function (_j) { | ||
switch (_j.label) { | ||
var defaultConfig, domain, _a, cookieStorage, cookieName, cookies, queryParams, sessionManager, _b, _c, _d; | ||
var _e; | ||
var _f, _g, _h, _j, _k; | ||
return __generator(this, function (_l) { | ||
switch (_l.label) { | ||
case 0: | ||
defaultConfig = getDefaultConfig(); | ||
return [4 /*yield*/, createCookieStorage(options)]; | ||
case 1: | ||
cookieStorage = _j.sent(); | ||
if (!((_f = options === null || options === void 0 ? void 0 : options.domain) !== null && _f !== void 0)) return [3 /*break*/, 1]; | ||
_a = _f; | ||
return [3 /*break*/, 3]; | ||
case 1: return [4 /*yield*/, getTopLevelDomain()]; | ||
case 2: | ||
_a = (_l.sent()); | ||
_l.label = 3; | ||
case 3: | ||
domain = _a; | ||
return [4 /*yield*/, createCookieStorage(__assign(__assign({}, options), { domain: domain }))]; | ||
case 4: | ||
cookieStorage = _l.sent(); | ||
cookieName = getCookieName(apiKey); | ||
return [4 /*yield*/, cookieStorage.get(cookieName)]; | ||
case 2: | ||
cookies = _j.sent(); | ||
case 5: | ||
cookies = _l.sent(); | ||
queryParams = getQueryParams(); | ||
return [4 /*yield*/, new SessionManager(cookieStorage, apiKey).load()]; | ||
case 3: | ||
sessionManager = _j.sent(); | ||
_a = BrowserConfig.bind; | ||
_b = [void 0, apiKey, userId !== null && userId !== void 0 ? userId : cookies === null || cookies === void 0 ? void 0 : cookies.userId]; | ||
_c = [__assign({}, options)]; | ||
_d = { cookieStorage: cookieStorage, sessionManager: sessionManager, deviceId: createDeviceId(cookies === null || cookies === void 0 ? void 0 : cookies.deviceId, options === null || options === void 0 ? void 0 : options.deviceId, queryParams.deviceId), optOut: (_e = options === null || options === void 0 ? void 0 : options.optOut) !== null && _e !== void 0 ? _e : Boolean(cookies === null || cookies === void 0 ? void 0 : cookies.optOut) }; | ||
case 6: | ||
sessionManager = _l.sent(); | ||
_b = BrowserConfig.bind; | ||
_c = [void 0, apiKey, userId !== null && userId !== void 0 ? userId : cookies === null || cookies === void 0 ? void 0 : cookies.userId]; | ||
_d = [__assign({}, options)]; | ||
_e = { cookieStorage: cookieStorage, sessionManager: sessionManager, deviceId: createDeviceId(cookies === null || cookies === void 0 ? void 0 : cookies.deviceId, options === null || options === void 0 ? void 0 : options.deviceId, queryParams.deviceId), domain: domain, optOut: (_g = options === null || options === void 0 ? void 0 : options.optOut) !== null && _g !== void 0 ? _g : Boolean(cookies === null || cookies === void 0 ? void 0 : cookies.optOut) }; | ||
return [4 /*yield*/, cookieStorage.get(cookieName)]; | ||
case 4: | ||
_d.sessionId = (_g = (_f = (_j.sent())) === null || _f === void 0 ? void 0 : _f.sessionId) !== null && _g !== void 0 ? _g : options === null || options === void 0 ? void 0 : options.sessionId; | ||
case 7: | ||
_e.sessionId = (_j = (_h = (_l.sent())) === null || _h === void 0 ? void 0 : _h.sessionId) !== null && _j !== void 0 ? _j : options === null || options === void 0 ? void 0 : options.sessionId; | ||
return [4 /*yield*/, createEventsStorage(options)]; | ||
case 5: return [2 /*return*/, new (_a.apply(BrowserConfig, _b.concat([__assign.apply(void 0, _c.concat([(_d.storageProvider = _j.sent(), _d.trackingOptions = __assign(__assign({}, defaultConfig.trackingOptions), options === null || options === void 0 ? void 0 : options.trackingOptions), _d.transportProvider = (_h = options === null || options === void 0 ? void 0 : options.transportProvider) !== null && _h !== void 0 ? _h : createTransport(options === null || options === void 0 ? void 0 : options.transport), _d)]))])))()]; | ||
case 8: return [2 /*return*/, new (_b.apply(BrowserConfig, _c.concat([__assign.apply(void 0, _d.concat([(_e.storageProvider = _l.sent(), _e.trackingOptions = __assign(__assign({}, defaultConfig.trackingOptions), options === null || options === void 0 ? void 0 : options.trackingOptions), _e.transportProvider = (_k = options === null || options === void 0 ? void 0 : options.transportProvider) !== null && _k !== void 0 ? _k : createTransport(options === null || options === void 0 ? void 0 : options.transport), _e)]))])))()]; | ||
} | ||
@@ -244,2 +253,43 @@ }); | ||
}; | ||
export var getTopLevelDomain = function (url) { return __awaiter(void 0, void 0, void 0, function () { | ||
var host, parts, levels, storageKey, i, i, domain, options, storage, value; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, new CookieStorage().isEnabled()]; | ||
case 1: | ||
if (!(_a.sent()) || (!url && typeof location === 'undefined')) { | ||
return [2 /*return*/, '']; | ||
} | ||
host = url !== null && url !== void 0 ? url : location.hostname; | ||
parts = host.split('.'); | ||
levels = []; | ||
storageKey = 'AMP_TLDTEST'; | ||
for (i = parts.length - 2; i >= 0; --i) { | ||
levels.push(parts.slice(i).join('.')); | ||
} | ||
i = 0; | ||
_a.label = 2; | ||
case 2: | ||
if (!(i < levels.length)) return [3 /*break*/, 7]; | ||
domain = levels[i]; | ||
options = { domain: '.' + domain }; | ||
storage = new CookieStorage(options); | ||
return [4 /*yield*/, storage.set(storageKey, 1)]; | ||
case 3: | ||
_a.sent(); | ||
return [4 /*yield*/, storage.get(storageKey)]; | ||
case 4: | ||
value = _a.sent(); | ||
if (!value) return [3 /*break*/, 6]; | ||
return [4 /*yield*/, storage.remove(storageKey)]; | ||
case 5: | ||
_a.sent(); | ||
return [2 /*return*/, '.' + domain]; | ||
case 6: | ||
i++; | ||
return [3 /*break*/, 2]; | ||
case 7: return [2 /*return*/, '']; | ||
} | ||
}); | ||
}); }; | ||
//# sourceMappingURL=config.js.map |
@@ -54,6 +54,12 @@ import { __assign, __awaiter, __generator } from "tslib"; | ||
try { | ||
try { | ||
value = decodeURIComponent(atob(value)); | ||
} | ||
catch (_b) { | ||
// value not encoded | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return | ||
return [2 /*return*/, JSON.parse(value)]; | ||
} | ||
catch (_b) { | ||
catch (_c) { | ||
/* istanbul ignore next */ | ||
@@ -94,3 +100,3 @@ return [2 /*return*/, undefined]; | ||
} | ||
str = "".concat(key, "=").concat(JSON.stringify(value)); | ||
str = "".concat(key, "=").concat(btoa(encodeURIComponent(JSON.stringify(value)))); | ||
if (expireDate) { | ||
@@ -97,0 +103,0 @@ str += "; expires=".concat(expireDate.toUTCString()); |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.7.0"; | ||
export declare const VERSION = "0.7.1"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export var VERSION = '0.7.0'; | ||
export var VERSION = '0.7.1'; | ||
//# sourceMappingURL=version.js.map |
@@ -1,1 +0,1 @@ | ||
!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-4cI8KmvK50Np4vrOodfx8p0b15oVvHpnhj9jrlCLpvzxkXaIoJu7qoeud6+iIDSv",n.crossOrigin="anonymous",n.async=!0,n.src="https://cdn.amplitude.com/libs/analytics-browser-0.7.0-min.js.gz",n.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var o=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}}o.parentNode.insertBefore(n,o);for(var s=function(){return this._q=[],this},i=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],a=0;a<i.length;a++)v(s,i[a]);r.Identify=s;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","regenerateDeviceId","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)}(); | ||
!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-ho3E5748vpodII9SJqQ/FgprUBt08iMcOKD4TUuwdTaDKbj2ajIskx7tJkEr790c",n.crossOrigin="anonymous",n.async=!0,n.src="https://cdn.amplitude.com/libs/analytics-browser-0.7.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 c=function(){return this._q=[],this},u=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setEventProperties"],p=0;p<u.length;p++)v(c,u[p]);r.Revenue=c;var d=["getDeviceId","setDeviceId","regenerateDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport"],l=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue"];function g(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)}g(r),e.amplitude=r}}(window,document)}(); |
{ | ||
"name": "@amplitude/analytics-browser", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"description": "Official Amplitude SDK for Web", | ||
@@ -43,4 +43,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@amplitude/analytics-core": "^0.6.0", | ||
"@amplitude/analytics-types": "^0.5.0", | ||
"@amplitude/analytics-core": "^0.6.1", | ||
"@amplitude/analytics-types": "^0.5.1", | ||
"@amplitude/ua-parser-js": "^0.7.31", | ||
@@ -64,3 +64,3 @@ "tslib": "^2.3.1" | ||
], | ||
"gitHead": "84a7c2295d7a3720fe3b77c57e8f779c4879e57f" | ||
"gitHead": "c71d676eb4eabebad93561771e1f4d2a6dde8ea9" | ||
} |
@@ -35,3 +35,3 @@ <p align="center"> | ||
<script type="text/javascript"> | ||
!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-4cI8KmvK50Np4vrOodfx8p0b15oVvHpnhj9jrlCLpvzxkXaIoJu7qoeud6+iIDSv",n.crossOrigin="anonymous",n.async=!0,n.src="https://cdn.amplitude.com/libs/analytics-browser-0.7.0-min.js.gz",n.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var o=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}}o.parentNode.insertBefore(n,o);for(var s=function(){return this._q=[],this},i=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],a=0;a<i.length;a++)v(s,i[a]);r.Identify=s;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","regenerateDeviceId","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)}(); | ||
!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-ho3E5748vpodII9SJqQ/FgprUBt08iMcOKD4TUuwdTaDKbj2ajIskx7tJkEr790c",n.crossOrigin="anonymous",n.async=!0,n.src="https://cdn.amplitude.com/libs/analytics-browser-0.7.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 c=function(){return this._q=[],this},u=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setEventProperties"],p=0;p<u.length;p++)v(c,u[p]);r.Revenue=c;var d=["getDeviceId","setDeviceId","regenerateDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport"],l=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue"];function g(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)}g(r),e.amplitude=r}}(window,document)}(); | ||
@@ -38,0 +38,0 @@ amplitude.init("YOUR_API_KEY_HERE"); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
558430
4753