@ninetailed/experience.js 1.0.0-beta.0 → 1.0.0-beta.5
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/index.esm.js +25 -11
- package/index.umd.js +34 -17
- package/lib/Ninetailed.d.ts +4 -1
- package/lib/analytics/get-analytics-plugin.d.ts +3 -2
- package/lib/analytics/utility/apiClient.d.ts +5 -3
- package/package.json +2 -2
package/index.esm.js
CHANGED
|
@@ -3384,10 +3384,12 @@ const fetchWithTimeout = (input, init) => __awaiter(void 0, void 0, void 0, func
|
|
|
3384
3384
|
|
|
3385
3385
|
class NinetailedApiClient {
|
|
3386
3386
|
constructor({
|
|
3387
|
-
|
|
3387
|
+
clientId,
|
|
3388
|
+
environment = 'main',
|
|
3388
3389
|
url = BASE_URL
|
|
3389
3390
|
}) {
|
|
3390
|
-
this.
|
|
3391
|
+
this.clientId = clientId;
|
|
3392
|
+
this.environment = environment;
|
|
3391
3393
|
this.url = url;
|
|
3392
3394
|
}
|
|
3393
3395
|
|
|
@@ -3403,11 +3405,10 @@ class NinetailedApiClient {
|
|
|
3403
3405
|
log('Profile Request Body: ', body);
|
|
3404
3406
|
|
|
3405
3407
|
try {
|
|
3406
|
-
const request = yield fetchWithTimeout(`${this.url}/
|
|
3408
|
+
const request = yield fetchWithTimeout(`${this.url}/v1/organizations/${this.clientId}/environments/${this.environment}/profiles/${anonymousId}/events`, {
|
|
3407
3409
|
method: 'POST',
|
|
3408
3410
|
headers: {
|
|
3409
|
-
'Content-Type': 'application/json'
|
|
3410
|
-
'x-ninetailed-api-key': this.apiKey
|
|
3411
|
+
'Content-Type': 'application/json'
|
|
3411
3412
|
},
|
|
3412
3413
|
body: JSON.stringify(body),
|
|
3413
3414
|
timeout: 8000
|
|
@@ -3439,13 +3440,16 @@ const PLUGIN_NAME = 'ninetailed';
|
|
|
3439
3440
|
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
3440
3441
|
|
|
3441
3442
|
const ninetailedPlugin = ({
|
|
3442
|
-
|
|
3443
|
+
clientId,
|
|
3444
|
+
environment,
|
|
3443
3445
|
url,
|
|
3444
3446
|
profile,
|
|
3445
3447
|
locale
|
|
3446
3448
|
}) => {
|
|
3449
|
+
let isFirstEvent = true;
|
|
3447
3450
|
const apiClient = new NinetailedApiClient({
|
|
3448
|
-
|
|
3451
|
+
clientId,
|
|
3452
|
+
environment,
|
|
3449
3453
|
url
|
|
3450
3454
|
});
|
|
3451
3455
|
let queue = [];
|
|
@@ -3525,7 +3529,13 @@ const ninetailedPlugin = ({
|
|
|
3525
3529
|
|
|
3526
3530
|
const createEvent = (event, instance) => __awaiter(void 0, void 0, void 0, function* () {
|
|
3527
3531
|
queue = unionBy([event], queue, 'messageId');
|
|
3528
|
-
|
|
3532
|
+
|
|
3533
|
+
if (isFirstEvent) {
|
|
3534
|
+
flush(instance);
|
|
3535
|
+
isFirstEvent = false;
|
|
3536
|
+
} else {
|
|
3537
|
+
throttledFlush(instance);
|
|
3538
|
+
}
|
|
3529
3539
|
});
|
|
3530
3540
|
|
|
3531
3541
|
return {
|
|
@@ -3715,12 +3725,15 @@ $({ target: 'Array', proto: true, forced: !STRICT_METHOD || CHROME_BUG }, {
|
|
|
3715
3725
|
});
|
|
3716
3726
|
|
|
3717
3727
|
class Ninetailed {
|
|
3718
|
-
constructor(
|
|
3728
|
+
constructor({
|
|
3729
|
+
clientId,
|
|
3730
|
+
environment
|
|
3731
|
+
}, {
|
|
3719
3732
|
plugins,
|
|
3720
3733
|
url,
|
|
3721
3734
|
profile,
|
|
3722
3735
|
locale
|
|
3723
|
-
}) {
|
|
3736
|
+
} = {}) {
|
|
3724
3737
|
this.page = (data, options) => {
|
|
3725
3738
|
return this.instance.page(data, this.buildOptions(options));
|
|
3726
3739
|
};
|
|
@@ -3763,7 +3776,8 @@ class Ninetailed {
|
|
|
3763
3776
|
this.instance = Analytics({
|
|
3764
3777
|
app: 'ninetailed',
|
|
3765
3778
|
plugins: [ninetailedPlugin({
|
|
3766
|
-
|
|
3779
|
+
clientId,
|
|
3780
|
+
environment,
|
|
3767
3781
|
url,
|
|
3768
3782
|
profile,
|
|
3769
3783
|
locale
|
package/index.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash/get'), require('lodash/throttle'), require('lodash/unionBy'), require('@ninetailed/experience.js-shared'), require('tty'), require('util'), require('os'), require('analytics'), require('lodash/includes'), require('lodash/find')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', 'lodash/get', 'lodash/throttle', 'lodash/unionBy', '@ninetailed/experience.js-shared', 'tty', 'util', 'os', 'analytics', 'lodash/includes', 'lodash/find'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Javascript = {}, global.get$2, global.throttle, global.unionBy, global.experience_jsShared, global.require$$1, global.require$$1$1, global.require$$0, global.Analytics, global.includes, global.find));
|
|
5
5
|
})(this, (function (exports, get$2, throttle, unionBy, experience_jsShared, require$$1, require$$1$1, require$$0, Analytics, includes, find) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -3452,10 +3452,13 @@
|
|
|
3452
3452
|
/** @class */
|
|
3453
3453
|
function () {
|
|
3454
3454
|
function NinetailedApiClient(_a) {
|
|
3455
|
-
var
|
|
3456
|
-
_b = _a.
|
|
3457
|
-
|
|
3458
|
-
|
|
3455
|
+
var clientId = _a.clientId,
|
|
3456
|
+
_b = _a.environment,
|
|
3457
|
+
environment = _b === void 0 ? 'main' : _b,
|
|
3458
|
+
_c = _a.url,
|
|
3459
|
+
url = _c === void 0 ? BASE_URL : _c;
|
|
3460
|
+
this.clientId = clientId;
|
|
3461
|
+
this.environment = environment;
|
|
3459
3462
|
this.url = url;
|
|
3460
3463
|
}
|
|
3461
3464
|
|
|
@@ -3477,11 +3480,10 @@
|
|
|
3477
3480
|
|
|
3478
3481
|
return [4
|
|
3479
3482
|
/*yield*/
|
|
3480
|
-
, fetchWithTimeout("".concat(this.url, "/
|
|
3483
|
+
, fetchWithTimeout("".concat(this.url, "/v1/organizations/").concat(this.clientId, "/environments/").concat(this.environment, "/profiles/").concat(anonymousId, "/events"), {
|
|
3481
3484
|
method: 'POST',
|
|
3482
3485
|
headers: {
|
|
3483
|
-
'Content-Type': 'application/json'
|
|
3484
|
-
'x-ninetailed-api-key': this.apiKey
|
|
3486
|
+
'Content-Type': 'application/json'
|
|
3485
3487
|
},
|
|
3486
3488
|
body: JSON.stringify(body),
|
|
3487
3489
|
timeout: 8000
|
|
@@ -3534,12 +3536,15 @@
|
|
|
3534
3536
|
};
|
|
3535
3537
|
|
|
3536
3538
|
var ninetailedPlugin = function ninetailedPlugin(_a) {
|
|
3537
|
-
var
|
|
3539
|
+
var clientId = _a.clientId,
|
|
3540
|
+
environment = _a.environment,
|
|
3538
3541
|
url = _a.url,
|
|
3539
3542
|
profile = _a.profile,
|
|
3540
3543
|
locale = _a.locale;
|
|
3544
|
+
var isFirstEvent = true;
|
|
3541
3545
|
var apiClient = new NinetailedApiClient({
|
|
3542
|
-
|
|
3546
|
+
clientId: clientId,
|
|
3547
|
+
environment: environment,
|
|
3543
3548
|
url: url
|
|
3544
3549
|
});
|
|
3545
3550
|
var queue = [];
|
|
@@ -3647,7 +3652,14 @@
|
|
|
3647
3652
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
3648
3653
|
return __generator(this, function (_a) {
|
|
3649
3654
|
queue = unionBy__default["default"]([event], queue, 'messageId');
|
|
3650
|
-
|
|
3655
|
+
|
|
3656
|
+
if (isFirstEvent) {
|
|
3657
|
+
flush(instance);
|
|
3658
|
+
isFirstEvent = false;
|
|
3659
|
+
} else {
|
|
3660
|
+
throttledFlush(instance);
|
|
3661
|
+
}
|
|
3662
|
+
|
|
3651
3663
|
return [2
|
|
3652
3664
|
/*return*/
|
|
3653
3665
|
];
|
|
@@ -3920,13 +3932,17 @@
|
|
|
3920
3932
|
var Ninetailed =
|
|
3921
3933
|
/** @class */
|
|
3922
3934
|
function () {
|
|
3923
|
-
function Ninetailed(
|
|
3935
|
+
function Ninetailed(_a, _b) {
|
|
3924
3936
|
var _this = this;
|
|
3925
3937
|
|
|
3926
|
-
var
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3938
|
+
var clientId = _a.clientId,
|
|
3939
|
+
environment = _a.environment;
|
|
3940
|
+
|
|
3941
|
+
var _c = _b === void 0 ? {} : _b,
|
|
3942
|
+
plugins = _c.plugins,
|
|
3943
|
+
url = _c.url,
|
|
3944
|
+
profile = _c.profile,
|
|
3945
|
+
locale = _c.locale;
|
|
3930
3946
|
|
|
3931
3947
|
this.page = function (data, options) {
|
|
3932
3948
|
return _this.instance.page(data, _this.buildOptions(options));
|
|
@@ -3969,7 +3985,8 @@
|
|
|
3969
3985
|
this.instance = Analytics__default["default"]({
|
|
3970
3986
|
app: 'ninetailed',
|
|
3971
3987
|
plugins: [ninetailedPlugin({
|
|
3972
|
-
|
|
3988
|
+
clientId: clientId,
|
|
3989
|
+
environment: environment,
|
|
3973
3990
|
url: url,
|
|
3974
3991
|
profile: profile,
|
|
3975
3992
|
locale: locale
|
package/lib/Ninetailed.d.ts
CHANGED
|
@@ -33,7 +33,10 @@ export declare class Ninetailed implements NinetailedInstance {
|
|
|
33
33
|
private readonly instance;
|
|
34
34
|
private readonly plugins;
|
|
35
35
|
private _profileState;
|
|
36
|
-
constructor(
|
|
36
|
+
constructor({ clientId, environment }: {
|
|
37
|
+
clientId: string;
|
|
38
|
+
environment?: string;
|
|
39
|
+
}, { plugins, url, profile, locale }?: Options);
|
|
37
40
|
page: (data?: PageData, options?: EventFunctionOptions) => Promise<any>;
|
|
38
41
|
track: (event: string, payload?: unknown, options?: EventFunctionOptions) => Promise<any>;
|
|
39
42
|
identify: (uid: string, traits?: Traits, options?: EventFunctionOptions) => Promise<any>;
|
|
@@ -6,7 +6,8 @@ declare global {
|
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
declare type AnalyticsPluginNinetailedConfig = {
|
|
9
|
-
|
|
9
|
+
clientId: string;
|
|
10
|
+
environment?: string;
|
|
10
11
|
url?: string;
|
|
11
12
|
profile?: Profile;
|
|
12
13
|
locale?: Locale;
|
|
@@ -18,5 +19,5 @@ export declare const NINETAILED_TRACKER_EVENTS: {
|
|
|
18
19
|
profile: string;
|
|
19
20
|
};
|
|
20
21
|
export declare const PLUGIN_NAME = "ninetailed";
|
|
21
|
-
export declare const ninetailedPlugin: ({
|
|
22
|
+
export declare const ninetailedPlugin: ({ clientId, environment, url, profile, locale, }: AnalyticsPluginNinetailedConfig) => AnalyticsPlugin;
|
|
22
23
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AudienceSignals, IngestProfileEventsRequestBody, Profile, Session } from '@ninetailed/experience.js-shared';
|
|
2
2
|
declare type NinetailedApiClientOptions = {
|
|
3
|
-
|
|
3
|
+
clientId: string;
|
|
4
|
+
environment: string;
|
|
4
5
|
url?: string;
|
|
5
6
|
};
|
|
6
7
|
declare type ProfileOptions = IngestProfileEventsRequestBody;
|
|
@@ -11,9 +12,10 @@ declare type ProfileResponse = {
|
|
|
11
12
|
sessions: Session[];
|
|
12
13
|
};
|
|
13
14
|
export declare class NinetailedApiClient {
|
|
14
|
-
private readonly
|
|
15
|
+
private readonly clientId;
|
|
16
|
+
private readonly environment;
|
|
15
17
|
private readonly url;
|
|
16
|
-
constructor({
|
|
18
|
+
constructor({ clientId, environment, url, }: NinetailedApiClientOptions);
|
|
17
19
|
profile(options: ProfileOptions): Promise<ProfileResponse>;
|
|
18
20
|
}
|
|
19
21
|
export {};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.5",
|
|
4
4
|
"main": "./index.umd.js",
|
|
5
5
|
"module": "./index.esm.js",
|
|
6
6
|
"typings": "./index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"analytics": "^0.8.0",
|
|
9
|
-
"@ninetailed/experience.js-shared": "1.0.0-beta.
|
|
9
|
+
"@ninetailed/experience.js-shared": "1.0.0-beta.5",
|
|
10
10
|
"uuid": "^8.3.2",
|
|
11
11
|
"ts-toolbelt": "^9.6.0",
|
|
12
12
|
"locale-enum": "^1.1.1",
|