@amplitude/analytics-node 0.3.5 → 0.4.0
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/lib/cjs/index.d.ts +2 -1
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +5 -12
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/node-client.d.ts +4 -133
- package/lib/cjs/node-client.d.ts.map +1 -1
- package/lib/cjs/node-client.js +25 -134
- package/lib/cjs/node-client.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/index.d.ts +2 -1
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js +4 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/node-client.d.ts +4 -133
- package/lib/esm/node-client.d.ts.map +1 -1
- package/lib/esm/node-client.js +23 -133
- package/lib/esm/node-client.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/package.json +4 -4
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { createInstance } from './node-client';
|
|
2
|
+
export declare const add: (plugin: import("@amplitude/analytics-types").Plugin) => import("@amplitude/analytics-types").AmplitudeReturn<void>, groupIdentify: (groupType: string, groupName: string | string[], identify: import("@amplitude/analytics-types").Identify, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, identify: (identify: import("@amplitude/analytics-types").Identify, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, init: (apiKey: string, options?: import("@amplitude/analytics-types").NodeOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<void>, logEvent: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, remove: (pluginName: string) => import("@amplitude/analytics-types").AmplitudeReturn<void>, revenue: (revenue: import("@amplitude/analytics-types").Revenue, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, setGroup: (groupType: string, groupName: string | string[], eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, setOptOut: (optOut: boolean) => void, track: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, flush: () => import("@amplitude/analytics-types").AmplitudeReturn<void>;
|
|
2
3
|
export { Revenue, Identify } from '@amplitude/analytics-core';
|
|
3
4
|
export * as Types from '@amplitude/analytics-types';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,eAAO,MAAQ,GAAG,uHAAE,aAAa,iSAAE,QAAQ,gPAAE,IAAI,0JAAE,QAAQ,+SAAE,MAAM,sFAAE,OAAO,8OAAE,QAAQ,wOAAE,SAAS,6BAAE,KAAK,+SAAE,KAAK,kEACvG,CAAC;AACT,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,KAAK,MAAM,4BAA4B,CAAC"}
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/unbound-method */
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.Types = exports.Identify = exports.Revenue = exports.flush = exports.track = exports.setOptOut = exports.setGroup = exports.revenue = exports.remove = exports.logEvent = exports.init = exports.identify = exports.groupIdentify = exports.add = void 0;
|
|
3
|
+
exports.Types = exports.Identify = exports.Revenue = exports.flush = exports.track = exports.setOptOut = exports.setGroup = exports.revenue = exports.remove = exports.logEvent = exports.init = exports.identify = exports.groupIdentify = exports.add = exports.createInstance = void 0;
|
|
3
4
|
var node_client_1 = require("./node-client");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "init", { enumerable: true, get: function () { return node_client_1.init; } });
|
|
8
|
-
Object.defineProperty(exports, "logEvent", { enumerable: true, get: function () { return node_client_1.logEvent; } });
|
|
9
|
-
Object.defineProperty(exports, "remove", { enumerable: true, get: function () { return node_client_1.remove; } });
|
|
10
|
-
Object.defineProperty(exports, "revenue", { enumerable: true, get: function () { return node_client_1.revenue; } });
|
|
11
|
-
Object.defineProperty(exports, "setGroup", { enumerable: true, get: function () { return node_client_1.setGroup; } });
|
|
12
|
-
Object.defineProperty(exports, "setOptOut", { enumerable: true, get: function () { return node_client_1.setOptOut; } });
|
|
13
|
-
Object.defineProperty(exports, "track", { enumerable: true, get: function () { return node_client_1.track; } });
|
|
14
|
-
Object.defineProperty(exports, "flush", { enumerable: true, get: function () { return node_client_1.flush; } });
|
|
5
|
+
var node_client_2 = require("./node-client");
|
|
6
|
+
Object.defineProperty(exports, "createInstance", { enumerable: true, get: function () { return node_client_2.createInstance; } });
|
|
7
|
+
exports.add = node_client_1.default.add, exports.groupIdentify = node_client_1.default.groupIdentify, exports.identify = node_client_1.default.identify, exports.init = node_client_1.default.init, exports.logEvent = node_client_1.default.logEvent, exports.remove = node_client_1.default.remove, exports.revenue = node_client_1.default.revenue, exports.setGroup = node_client_1.default.setGroup, exports.setOptOut = node_client_1.default.setOptOut, exports.track = node_client_1.default.track, exports.flush = node_client_1.default.flush;
|
|
15
8
|
var analytics_core_1 = require("@amplitude/analytics-core");
|
|
16
9
|
Object.defineProperty(exports, "Revenue", { enumerable: true, get: function () { return analytics_core_1.Revenue; } });
|
|
17
10
|
Object.defineProperty(exports, "Identify", { enumerable: true, get: function () { return analytics_core_1.Identify; } });
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;;;AAEtD,6CAAmC;AACnC,6CAA+C;AAAtC,6GAAA,cAAc,OAAA;AACR,QAAA,GAAG,GAChB,qBAAM,MADY,QAAA,aAAa,GAC/B,qBAAM,gBAD2B,QAAA,QAAQ,GACzC,qBAAM,WADqC,QAAA,IAAI,GAC/C,qBAAM,OAD2C,QAAA,QAAQ,GACzD,qBAAM,WADqD,QAAA,MAAM,GACjE,qBAAM,SAD6D,QAAA,OAAO,GAC1E,qBAAM,UADsE,QAAA,QAAQ,GACpF,qBAAM,WADgF,QAAA,SAAS,GAC/F,qBAAM,YAD2F,QAAA,KAAK,GACtG,qBAAM,QADkG,QAAA,KAAK,GAC7G,qBAAM,OAAC;AACT,4DAA8D;AAArD,yGAAA,OAAO,OAAA;AAAE,0GAAA,QAAQ,OAAA;AAC1B,sDAAoD","sourcesContent":["/* eslint-disable @typescript-eslint/unbound-method */\n\nimport client from './node-client';\nexport { createInstance } from './node-client';\nexport const { add, groupIdentify, identify, init, logEvent, remove, revenue, setGroup, setOptOut, track, flush } =\n client;\nexport { Revenue, Identify } from '@amplitude/analytics-core';\nexport * as Types from '@amplitude/analytics-types';\n"]}
|
package/lib/cjs/node-client.d.ts
CHANGED
|
@@ -1,138 +1,9 @@
|
|
|
1
1
|
import { AmplitudeCore } from '@amplitude/analytics-core';
|
|
2
|
-
import { NodeConfig, NodeOptions } from '@amplitude/analytics-types';
|
|
2
|
+
import { NodeClient, NodeConfig, NodeOptions } from '@amplitude/analytics-types';
|
|
3
3
|
export declare class AmplitudeNode extends AmplitudeCore<NodeConfig> {
|
|
4
4
|
init(apiKey: string, options?: NodeOptions): Promise<void>;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
* ```typescript
|
|
11
|
-
* await init(API_KEY, USER_ID, options).promise;
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
export declare const init: (apiKey: string, options?: NodeOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>;
|
|
15
|
-
/**
|
|
16
|
-
* Adds a new plugin.
|
|
17
|
-
*
|
|
18
|
-
* ```typescript
|
|
19
|
-
* const plugin = {...};
|
|
20
|
-
* add(plugin);
|
|
21
|
-
*
|
|
22
|
-
* // alternatively, this tracking method is awaitable
|
|
23
|
-
* await add(plugin).promise;
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export declare const add: (plugin: import("@amplitude/analytics-types").Plugin) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>;
|
|
27
|
-
/**
|
|
28
|
-
* Removes a plugin.
|
|
29
|
-
*
|
|
30
|
-
* ```typescript
|
|
31
|
-
* remove('myPlugin');
|
|
32
|
-
*
|
|
33
|
-
* // alternatively, this tracking method is awaitable
|
|
34
|
-
* await remove('myPlugin').promise;
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare const remove: (pluginName: string) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>;
|
|
38
|
-
/**
|
|
39
|
-
* Tracks user-defined event, with specified type, optional event properties and optional overwrites.
|
|
40
|
-
*
|
|
41
|
-
* ```typescript
|
|
42
|
-
* // event tracking with event type only
|
|
43
|
-
* track('Page Load');
|
|
44
|
-
*
|
|
45
|
-
* // event tracking with event type and additional event properties
|
|
46
|
-
* track('Page Load', { loadTime: 1000 });
|
|
47
|
-
*
|
|
48
|
-
* // event tracking with event type, additional event properties, and overwritten event options
|
|
49
|
-
* track('Page Load', { loadTime: 1000 }, { sessionId: -1 });
|
|
50
|
-
*
|
|
51
|
-
* // alternatively, this tracking method is awaitable
|
|
52
|
-
* const result = await track('Page Load').promise;
|
|
53
|
-
* console.log(result.event); // {...}
|
|
54
|
-
* console.log(result.code); // 200
|
|
55
|
-
* console.log(result.message); // "Event tracked successfully"
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export declare const track: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<import("@amplitude/analytics-types").Result>>;
|
|
59
|
-
/**
|
|
60
|
-
* Alias for track()
|
|
61
|
-
*/
|
|
62
|
-
export declare const logEvent: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<import("@amplitude/analytics-types").Result>>;
|
|
63
|
-
/**
|
|
64
|
-
* Sends an identify event containing user property operations
|
|
65
|
-
*
|
|
66
|
-
* ```typescript
|
|
67
|
-
* const id = new Identify();
|
|
68
|
-
* id.set('colors', ['rose', 'gold']);
|
|
69
|
-
* identify(id);
|
|
70
|
-
*
|
|
71
|
-
* // alternatively, this tracking method is awaitable
|
|
72
|
-
* const result = await identify(id).promise;
|
|
73
|
-
* console.log(result.event); // {...}
|
|
74
|
-
* console.log(result.code); // 200
|
|
75
|
-
* console.log(result.message); // "Event tracked successfully"
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
export declare const identify: (identify: import("@amplitude/analytics-types").Identify, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<import("@amplitude/analytics-types").Result>>;
|
|
79
|
-
/**
|
|
80
|
-
* Sends a group identify event containing group property operations.
|
|
81
|
-
*
|
|
82
|
-
* ```typescript
|
|
83
|
-
* const id = new Identify();
|
|
84
|
-
* id.set('skills', ['js', 'ts']);
|
|
85
|
-
* const groupType = 'org';
|
|
86
|
-
* const groupName = 'engineering';
|
|
87
|
-
* groupIdentify(groupType, groupName, id);
|
|
88
|
-
*
|
|
89
|
-
* // alternatively, this tracking method is awaitable
|
|
90
|
-
* const result = await groupIdentify(groupType, groupName, id).promise;
|
|
91
|
-
* console.log(result.event); // {...}
|
|
92
|
-
* console.log(result.code); // 200
|
|
93
|
-
* console.log(result.message); // "Event tracked successfully"
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
export declare const groupIdentify: (groupType: string, groupName: string | string[], identify: import("@amplitude/analytics-types").Identify, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<import("@amplitude/analytics-types").Result>>;
|
|
97
|
-
export declare const setGroup: (groupType: string, groupName: string | string[]) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<import("@amplitude/analytics-types").Result>>;
|
|
98
|
-
/**
|
|
99
|
-
* Sends a revenue event containing revenue property operations.
|
|
100
|
-
*
|
|
101
|
-
* ```typescript
|
|
102
|
-
* const rev = new Revenue();
|
|
103
|
-
* rev.setRevenue(100);
|
|
104
|
-
* revenue(rev);
|
|
105
|
-
*
|
|
106
|
-
* // alternatively, this tracking method is awaitable
|
|
107
|
-
* const result = await revenue(rev).promise;
|
|
108
|
-
* console.log(result.event); // {...}
|
|
109
|
-
* console.log(result.code); // 200
|
|
110
|
-
* console.log(result.message); // "Event tracked successfully"
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
export declare const revenue: (revenue: import("@amplitude/analytics-types").Revenue, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<import("@amplitude/analytics-types").Result>>;
|
|
114
|
-
/**
|
|
115
|
-
* Sets a new optOut config value. This toggles event tracking on/off.
|
|
116
|
-
*
|
|
117
|
-
*```typescript
|
|
118
|
-
* // Stops tracking
|
|
119
|
-
* setOptOut(true);
|
|
120
|
-
*
|
|
121
|
-
* // Starts/resumes tracking
|
|
122
|
-
* setOptOut(false);
|
|
123
|
-
* ```
|
|
124
|
-
*/
|
|
125
|
-
export declare const setOptOut: (optOut: boolean) => void;
|
|
126
|
-
/**
|
|
127
|
-
* Flush and send all the events which haven't been sent.
|
|
128
|
-
*
|
|
129
|
-
*```typescript
|
|
130
|
-
* // Send all the unsent events
|
|
131
|
-
* flush();
|
|
132
|
-
*
|
|
133
|
-
* // alternatively, this tracking method is awaitable
|
|
134
|
-
* await flush().promise;
|
|
135
|
-
* ```
|
|
136
|
-
*/
|
|
137
|
-
export declare const flush: () => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>;
|
|
6
|
+
export declare const createInstance: () => NodeClient;
|
|
7
|
+
declare const _default: NodeClient;
|
|
8
|
+
export default _default;
|
|
138
9
|
//# sourceMappingURL=node-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-client.d.ts","sourceRoot":"","sources":["../../src/node-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA8B,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"node-client.d.ts","sourceRoot":"","sources":["../../src/node-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA8B,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAIjF,qBAAa,aAAc,SAAQ,aAAa,CAAC,UAAU,CAAC;IACpD,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW;CAyBjD;AAED,eAAO,MAAM,cAAc,QAAO,UAejC,CAAC;;AAEF,wBAAgC"}
|
package/lib/cjs/node-client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.
|
|
2
|
+
exports.createInstance = exports.AmplitudeNode = void 0;
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
4
|
var analytics_core_1 = require("@amplitude/analytics-core");
|
|
5
5
|
var context_1 = require("./plugins/context");
|
|
@@ -15,6 +15,11 @@ var AmplitudeNode = /** @class */ (function (_super) {
|
|
|
15
15
|
return (0, tslib_1.__generator)(this, function (_a) {
|
|
16
16
|
switch (_a.label) {
|
|
17
17
|
case 0:
|
|
18
|
+
// Step 0: Block concurrent initialization
|
|
19
|
+
if (this.initializing) {
|
|
20
|
+
return [2 /*return*/];
|
|
21
|
+
}
|
|
22
|
+
this.initializing = true;
|
|
18
23
|
nodeOptions = (0, config_1.useNodeConfig)(apiKey, (0, tslib_1.__assign)({}, options));
|
|
19
24
|
return [4 /*yield*/, _super.prototype._init.call(this, nodeOptions)];
|
|
20
25
|
case 1:
|
|
@@ -25,6 +30,7 @@ var AmplitudeNode = /** @class */ (function (_super) {
|
|
|
25
30
|
return [4 /*yield*/, this.add(new analytics_core_1.Destination())];
|
|
26
31
|
case 3:
|
|
27
32
|
_a.sent();
|
|
33
|
+
this.initializing = false;
|
|
28
34
|
// Set timeline ready for processing events
|
|
29
35
|
// Send existing events, which might be collected by track before init
|
|
30
36
|
this.timeline.isReady = true;
|
|
@@ -39,137 +45,22 @@ var AmplitudeNode = /** @class */ (function (_super) {
|
|
|
39
45
|
return AmplitudeNode;
|
|
40
46
|
}(analytics_core_1.AmplitudeCore));
|
|
41
47
|
exports.AmplitudeNode = AmplitudeNode;
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
* await add(plugin).promise;
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
exports.add = (0, analytics_core_1.returnWrapper)(client.add.bind(client));
|
|
64
|
-
/**
|
|
65
|
-
* Removes a plugin.
|
|
66
|
-
*
|
|
67
|
-
* ```typescript
|
|
68
|
-
* remove('myPlugin');
|
|
69
|
-
*
|
|
70
|
-
* // alternatively, this tracking method is awaitable
|
|
71
|
-
* await remove('myPlugin').promise;
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
exports.remove = (0, analytics_core_1.returnWrapper)(client.remove.bind(client));
|
|
75
|
-
/**
|
|
76
|
-
* Tracks user-defined event, with specified type, optional event properties and optional overwrites.
|
|
77
|
-
*
|
|
78
|
-
* ```typescript
|
|
79
|
-
* // event tracking with event type only
|
|
80
|
-
* track('Page Load');
|
|
81
|
-
*
|
|
82
|
-
* // event tracking with event type and additional event properties
|
|
83
|
-
* track('Page Load', { loadTime: 1000 });
|
|
84
|
-
*
|
|
85
|
-
* // event tracking with event type, additional event properties, and overwritten event options
|
|
86
|
-
* track('Page Load', { loadTime: 1000 }, { sessionId: -1 });
|
|
87
|
-
*
|
|
88
|
-
* // alternatively, this tracking method is awaitable
|
|
89
|
-
* const result = await track('Page Load').promise;
|
|
90
|
-
* console.log(result.event); // {...}
|
|
91
|
-
* console.log(result.code); // 200
|
|
92
|
-
* console.log(result.message); // "Event tracked successfully"
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
exports.track = (0, analytics_core_1.returnWrapper)(client.track.bind(client));
|
|
96
|
-
/**
|
|
97
|
-
* Alias for track()
|
|
98
|
-
*/
|
|
99
|
-
exports.logEvent = (0, analytics_core_1.returnWrapper)(client.logEvent.bind(client));
|
|
100
|
-
/**
|
|
101
|
-
* Sends an identify event containing user property operations
|
|
102
|
-
*
|
|
103
|
-
* ```typescript
|
|
104
|
-
* const id = new Identify();
|
|
105
|
-
* id.set('colors', ['rose', 'gold']);
|
|
106
|
-
* identify(id);
|
|
107
|
-
*
|
|
108
|
-
* // alternatively, this tracking method is awaitable
|
|
109
|
-
* const result = await identify(id).promise;
|
|
110
|
-
* console.log(result.event); // {...}
|
|
111
|
-
* console.log(result.code); // 200
|
|
112
|
-
* console.log(result.message); // "Event tracked successfully"
|
|
113
|
-
* ```
|
|
114
|
-
*/
|
|
115
|
-
exports.identify = (0, analytics_core_1.returnWrapper)(client.identify.bind(client));
|
|
116
|
-
/**
|
|
117
|
-
* Sends a group identify event containing group property operations.
|
|
118
|
-
*
|
|
119
|
-
* ```typescript
|
|
120
|
-
* const id = new Identify();
|
|
121
|
-
* id.set('skills', ['js', 'ts']);
|
|
122
|
-
* const groupType = 'org';
|
|
123
|
-
* const groupName = 'engineering';
|
|
124
|
-
* groupIdentify(groupType, groupName, id);
|
|
125
|
-
*
|
|
126
|
-
* // alternatively, this tracking method is awaitable
|
|
127
|
-
* const result = await groupIdentify(groupType, groupName, id).promise;
|
|
128
|
-
* console.log(result.event); // {...}
|
|
129
|
-
* console.log(result.code); // 200
|
|
130
|
-
* console.log(result.message); // "Event tracked successfully"
|
|
131
|
-
* ```
|
|
132
|
-
*/
|
|
133
|
-
exports.groupIdentify = (0, analytics_core_1.returnWrapper)(client.groupIdentify.bind(client));
|
|
134
|
-
exports.setGroup = (0, analytics_core_1.returnWrapper)(client.setGroup.bind(client));
|
|
135
|
-
/**
|
|
136
|
-
* Sends a revenue event containing revenue property operations.
|
|
137
|
-
*
|
|
138
|
-
* ```typescript
|
|
139
|
-
* const rev = new Revenue();
|
|
140
|
-
* rev.setRevenue(100);
|
|
141
|
-
* revenue(rev);
|
|
142
|
-
*
|
|
143
|
-
* // alternatively, this tracking method is awaitable
|
|
144
|
-
* const result = await revenue(rev).promise;
|
|
145
|
-
* console.log(result.event); // {...}
|
|
146
|
-
* console.log(result.code); // 200
|
|
147
|
-
* console.log(result.message); // "Event tracked successfully"
|
|
148
|
-
* ```
|
|
149
|
-
*/
|
|
150
|
-
exports.revenue = (0, analytics_core_1.returnWrapper)(client.revenue.bind(client));
|
|
151
|
-
/**
|
|
152
|
-
* Sets a new optOut config value. This toggles event tracking on/off.
|
|
153
|
-
*
|
|
154
|
-
*```typescript
|
|
155
|
-
* // Stops tracking
|
|
156
|
-
* setOptOut(true);
|
|
157
|
-
*
|
|
158
|
-
* // Starts/resumes tracking
|
|
159
|
-
* setOptOut(false);
|
|
160
|
-
* ```
|
|
161
|
-
*/
|
|
162
|
-
exports.setOptOut = client.setOptOut.bind(client);
|
|
163
|
-
/**
|
|
164
|
-
* Flush and send all the events which haven't been sent.
|
|
165
|
-
*
|
|
166
|
-
*```typescript
|
|
167
|
-
* // Send all the unsent events
|
|
168
|
-
* flush();
|
|
169
|
-
*
|
|
170
|
-
* // alternatively, this tracking method is awaitable
|
|
171
|
-
* await flush().promise;
|
|
172
|
-
* ```
|
|
173
|
-
*/
|
|
174
|
-
exports.flush = (0, analytics_core_1.returnWrapper)(client.flush.bind(client));
|
|
48
|
+
var createInstance = function () {
|
|
49
|
+
var client = new AmplitudeNode();
|
|
50
|
+
return {
|
|
51
|
+
init: (0, analytics_core_1.returnWrapper)(client.init.bind(client)),
|
|
52
|
+
add: (0, analytics_core_1.returnWrapper)(client.add.bind(client)),
|
|
53
|
+
remove: (0, analytics_core_1.returnWrapper)(client.remove.bind(client)),
|
|
54
|
+
track: (0, analytics_core_1.returnWrapper)(client.track.bind(client)),
|
|
55
|
+
logEvent: (0, analytics_core_1.returnWrapper)(client.logEvent.bind(client)),
|
|
56
|
+
identify: (0, analytics_core_1.returnWrapper)(client.identify.bind(client)),
|
|
57
|
+
groupIdentify: (0, analytics_core_1.returnWrapper)(client.groupIdentify.bind(client)),
|
|
58
|
+
setGroup: (0, analytics_core_1.returnWrapper)(client.setGroup.bind(client)),
|
|
59
|
+
revenue: (0, analytics_core_1.returnWrapper)(client.revenue.bind(client)),
|
|
60
|
+
flush: (0, analytics_core_1.returnWrapper)(client.flush.bind(client)),
|
|
61
|
+
setOptOut: client.setOptOut.bind(client),
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
exports.createInstance = createInstance;
|
|
65
|
+
exports.default = (0, exports.createInstance)();
|
|
175
66
|
//# sourceMappingURL=node-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-client.js","sourceRoot":"","sources":["../../src/node-client.ts"],"names":[],"mappings":";;;AAAA,4DAAsF;AAEtF,6CAA4C;AAC5C,mCAAyC;AAEzC;IAAmC,8CAAyB;IAA5D;;
|
|
1
|
+
{"version":3,"file":"node-client.js","sourceRoot":"","sources":["../../src/node-client.ts"],"names":[],"mappings":";;;AAAA,4DAAsF;AAEtF,6CAA4C;AAC5C,mCAAyC;AAEzC;IAAmC,8CAAyB;IAA5D;;IA0BA,CAAC;IAzBO,4BAAI,GAAV,UAAW,MAAc,EAAE,OAAqB;;;;;;wBAC9C,0CAA0C;wBAC1C,IAAI,IAAI,CAAC,YAAY,EAAE;4BACrB,sBAAO;yBACR;wBACD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;wBAEnB,WAAW,GAAG,IAAA,sBAAa,EAAC,MAAM,4BACnC,OAAO,EACV,CAAC;wBAEH,qBAAM,iBAAM,KAAK,YAAC,WAAW,CAAC,EAAA;;wBAA9B,SAA8B,CAAC;wBAE/B,qBAAM,IAAI,CAAC,GAAG,CAAC,IAAI,iBAAO,EAAE,CAAC,EAAA;;wBAA7B,SAA6B,CAAC;wBAC9B,qBAAM,IAAI,CAAC,GAAG,CAAC,IAAI,4BAAW,EAAE,CAAC,EAAA;;wBAAjC,SAAiC,CAAC;wBAElC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;wBAE1B,2CAA2C;wBAC3C,sEAAsE;wBACtE,IAAI,CAAC,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;wBAC7B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;4BACvB,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;yBAChC;;;;;KACF;IACH,oBAAC;AAAD,CAAC,AA1BD,CAAmC,8BAAa,GA0B/C;AA1BY,sCAAa;AA4BnB,IAAM,cAAc,GAAG;IAC5B,IAAM,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;IACnC,OAAO;QACL,IAAI,EAAE,IAAA,8BAAa,EAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7C,GAAG,EAAE,IAAA,8BAAa,EAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,EAAE,IAAA,8BAAa,EAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjD,KAAK,EAAE,IAAA,8BAAa,EAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC/C,QAAQ,EAAE,IAAA,8BAAa,EAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrD,QAAQ,EAAE,IAAA,8BAAa,EAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrD,aAAa,EAAE,IAAA,8BAAa,EAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC/D,QAAQ,EAAE,IAAA,8BAAa,EAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrD,OAAO,EAAE,IAAA,8BAAa,EAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnD,KAAK,EAAE,IAAA,8BAAa,EAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC/C,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;KACzC,CAAC;AACJ,CAAC,CAAC;AAfW,QAAA,cAAc,kBAezB;AAEF,kBAAe,IAAA,sBAAc,GAAE,CAAC","sourcesContent":["import { AmplitudeCore, Destination, returnWrapper } from '@amplitude/analytics-core';\nimport { NodeClient, NodeConfig, NodeOptions } from '@amplitude/analytics-types';\nimport { Context } from './plugins/context';\nimport { useNodeConfig } from './config';\n\nexport class AmplitudeNode extends AmplitudeCore<NodeConfig> {\n async init(apiKey: string, options?: NodeOptions) {\n // Step 0: Block concurrent initialization\n if (this.initializing) {\n return;\n }\n this.initializing = true;\n\n const nodeOptions = useNodeConfig(apiKey, {\n ...options,\n });\n\n await super._init(nodeOptions);\n\n await this.add(new Context());\n await this.add(new Destination());\n\n this.initializing = false;\n\n // Set timeline ready for processing events\n // Send existing events, which might be collected by track before init\n this.timeline.isReady = true;\n if (!this.config.optOut) {\n this.timeline.scheduleApply(0);\n }\n }\n}\n\nexport const createInstance = (): NodeClient => {\n const client = new AmplitudeNode();\n return {\n init: returnWrapper(client.init.bind(client)),\n add: returnWrapper(client.add.bind(client)),\n remove: returnWrapper(client.remove.bind(client)),\n track: returnWrapper(client.track.bind(client)),\n logEvent: returnWrapper(client.logEvent.bind(client)),\n identify: returnWrapper(client.identify.bind(client)),\n groupIdentify: returnWrapper(client.groupIdentify.bind(client)),\n setGroup: returnWrapper(client.setGroup.bind(client)),\n revenue: returnWrapper(client.revenue.bind(client)),\n flush: returnWrapper(client.flush.bind(client)),\n setOptOut: client.setOptOut.bind(client),\n };\n};\n\nexport default createInstance();\n"]}
|
package/lib/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.4.0";
|
|
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,OAAO,CAAC","sourcesContent":["export const VERSION = '0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;AAAa,QAAA,OAAO,GAAG,OAAO,CAAC","sourcesContent":["export const VERSION = '0.4.0';\n"]}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { createInstance } from './node-client';
|
|
2
|
+
export declare const add: (plugin: import("@amplitude/analytics-types").Plugin) => import("@amplitude/analytics-types").AmplitudeReturn<void>, groupIdentify: (groupType: string, groupName: string | string[], identify: import("@amplitude/analytics-types").Identify, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, identify: (identify: import("@amplitude/analytics-types").Identify, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, init: (apiKey: string, options?: import("@amplitude/analytics-types").NodeOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<void>, logEvent: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, remove: (pluginName: string) => import("@amplitude/analytics-types").AmplitudeReturn<void>, revenue: (revenue: import("@amplitude/analytics-types").Revenue, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, setGroup: (groupType: string, groupName: string | string[], eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, setOptOut: (optOut: boolean) => void, track: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<import("@amplitude/analytics-types").Result>, flush: () => import("@amplitude/analytics-types").AmplitudeReturn<void>;
|
|
2
3
|
export { Revenue, Identify } from '@amplitude/analytics-core';
|
|
3
4
|
export * as Types from '@amplitude/analytics-types';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,eAAO,MAAQ,GAAG,uHAAE,aAAa,iSAAE,QAAQ,gPAAE,IAAI,0JAAE,QAAQ,+SAAE,MAAM,sFAAE,OAAO,8OAAE,QAAQ,wOAAE,SAAS,6BAAE,KAAK,+SAAE,KAAK,kEACvG,CAAC;AACT,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,KAAK,MAAM,4BAA4B,CAAC"}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable @typescript-eslint/unbound-method */
|
|
2
|
+
import client from './node-client';
|
|
3
|
+
export { createInstance } from './node-client';
|
|
4
|
+
export var add = client.add, groupIdentify = client.groupIdentify, identify = client.identify, init = client.init, logEvent = client.logEvent, remove = client.remove, revenue = client.revenue, setGroup = client.setGroup, setOptOut = client.setOptOut, track = client.track, flush = client.flush;
|
|
2
5
|
export { Revenue, Identify } from '@amplitude/analytics-core';
|
|
3
6
|
import * as Types_1 from '@amplitude/analytics-types';
|
|
4
7
|
export { Types_1 as Types };
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AAEtD,OAAO,MAAM,MAAM,eAAe,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,MAAM,CAAS,IAAA,GAAG,GAChB,MAAM,IADU,EAAE,aAAa,GAC/B,MAAM,cADyB,EAAE,QAAQ,GACzC,MAAM,SADmC,EAAE,IAAI,GAC/C,MAAM,KADyC,EAAE,QAAQ,GACzD,MAAM,SADmD,EAAE,MAAM,GACjE,MAAM,OAD2D,EAAE,OAAO,GAC1E,MAAM,QADoE,EAAE,QAAQ,GACpF,MAAM,SAD8E,EAAE,SAAS,GAC/F,MAAM,UADyF,EAAE,KAAK,GACtG,MAAM,MADgG,EAAE,KAAK,GAC7G,MAAM,MADuG,CACtG;AACT,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;yBACvC,4BAA4B;oBAAvC,KAAK","sourcesContent":["/* eslint-disable @typescript-eslint/unbound-method */\n\nimport client from './node-client';\nexport { createInstance } from './node-client';\nexport const { add, groupIdentify, identify, init, logEvent, remove, revenue, setGroup, setOptOut, track, flush } =\n client;\nexport { Revenue, Identify } from '@amplitude/analytics-core';\nexport * as Types from '@amplitude/analytics-types';\n"]}
|
package/lib/esm/node-client.d.ts
CHANGED
|
@@ -1,138 +1,9 @@
|
|
|
1
1
|
import { AmplitudeCore } from '@amplitude/analytics-core';
|
|
2
|
-
import { NodeConfig, NodeOptions } from '@amplitude/analytics-types';
|
|
2
|
+
import { NodeClient, NodeConfig, NodeOptions } from '@amplitude/analytics-types';
|
|
3
3
|
export declare class AmplitudeNode extends AmplitudeCore<NodeConfig> {
|
|
4
4
|
init(apiKey: string, options?: NodeOptions): Promise<void>;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
* ```typescript
|
|
11
|
-
* await init(API_KEY, USER_ID, options).promise;
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
export declare const init: (apiKey: string, options?: NodeOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>;
|
|
15
|
-
/**
|
|
16
|
-
* Adds a new plugin.
|
|
17
|
-
*
|
|
18
|
-
* ```typescript
|
|
19
|
-
* const plugin = {...};
|
|
20
|
-
* add(plugin);
|
|
21
|
-
*
|
|
22
|
-
* // alternatively, this tracking method is awaitable
|
|
23
|
-
* await add(plugin).promise;
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export declare const add: (plugin: import("@amplitude/analytics-types").Plugin) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>;
|
|
27
|
-
/**
|
|
28
|
-
* Removes a plugin.
|
|
29
|
-
*
|
|
30
|
-
* ```typescript
|
|
31
|
-
* remove('myPlugin');
|
|
32
|
-
*
|
|
33
|
-
* // alternatively, this tracking method is awaitable
|
|
34
|
-
* await remove('myPlugin').promise;
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare const remove: (pluginName: string) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>;
|
|
38
|
-
/**
|
|
39
|
-
* Tracks user-defined event, with specified type, optional event properties and optional overwrites.
|
|
40
|
-
*
|
|
41
|
-
* ```typescript
|
|
42
|
-
* // event tracking with event type only
|
|
43
|
-
* track('Page Load');
|
|
44
|
-
*
|
|
45
|
-
* // event tracking with event type and additional event properties
|
|
46
|
-
* track('Page Load', { loadTime: 1000 });
|
|
47
|
-
*
|
|
48
|
-
* // event tracking with event type, additional event properties, and overwritten event options
|
|
49
|
-
* track('Page Load', { loadTime: 1000 }, { sessionId: -1 });
|
|
50
|
-
*
|
|
51
|
-
* // alternatively, this tracking method is awaitable
|
|
52
|
-
* const result = await track('Page Load').promise;
|
|
53
|
-
* console.log(result.event); // {...}
|
|
54
|
-
* console.log(result.code); // 200
|
|
55
|
-
* console.log(result.message); // "Event tracked successfully"
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export declare const track: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<import("@amplitude/analytics-types").Result>>;
|
|
59
|
-
/**
|
|
60
|
-
* Alias for track()
|
|
61
|
-
*/
|
|
62
|
-
export declare const logEvent: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<import("@amplitude/analytics-types").Result>>;
|
|
63
|
-
/**
|
|
64
|
-
* Sends an identify event containing user property operations
|
|
65
|
-
*
|
|
66
|
-
* ```typescript
|
|
67
|
-
* const id = new Identify();
|
|
68
|
-
* id.set('colors', ['rose', 'gold']);
|
|
69
|
-
* identify(id);
|
|
70
|
-
*
|
|
71
|
-
* // alternatively, this tracking method is awaitable
|
|
72
|
-
* const result = await identify(id).promise;
|
|
73
|
-
* console.log(result.event); // {...}
|
|
74
|
-
* console.log(result.code); // 200
|
|
75
|
-
* console.log(result.message); // "Event tracked successfully"
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
export declare const identify: (identify: import("@amplitude/analytics-types").Identify, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<import("@amplitude/analytics-types").Result>>;
|
|
79
|
-
/**
|
|
80
|
-
* Sends a group identify event containing group property operations.
|
|
81
|
-
*
|
|
82
|
-
* ```typescript
|
|
83
|
-
* const id = new Identify();
|
|
84
|
-
* id.set('skills', ['js', 'ts']);
|
|
85
|
-
* const groupType = 'org';
|
|
86
|
-
* const groupName = 'engineering';
|
|
87
|
-
* groupIdentify(groupType, groupName, id);
|
|
88
|
-
*
|
|
89
|
-
* // alternatively, this tracking method is awaitable
|
|
90
|
-
* const result = await groupIdentify(groupType, groupName, id).promise;
|
|
91
|
-
* console.log(result.event); // {...}
|
|
92
|
-
* console.log(result.code); // 200
|
|
93
|
-
* console.log(result.message); // "Event tracked successfully"
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
export declare const groupIdentify: (groupType: string, groupName: string | string[], identify: import("@amplitude/analytics-types").Identify, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<import("@amplitude/analytics-types").Result>>;
|
|
97
|
-
export declare const setGroup: (groupType: string, groupName: string | string[]) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<import("@amplitude/analytics-types").Result>>;
|
|
98
|
-
/**
|
|
99
|
-
* Sends a revenue event containing revenue property operations.
|
|
100
|
-
*
|
|
101
|
-
* ```typescript
|
|
102
|
-
* const rev = new Revenue();
|
|
103
|
-
* rev.setRevenue(100);
|
|
104
|
-
* revenue(rev);
|
|
105
|
-
*
|
|
106
|
-
* // alternatively, this tracking method is awaitable
|
|
107
|
-
* const result = await revenue(rev).promise;
|
|
108
|
-
* console.log(result.event); // {...}
|
|
109
|
-
* console.log(result.code); // 200
|
|
110
|
-
* console.log(result.message); // "Event tracked successfully"
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
export declare const revenue: (revenue: import("@amplitude/analytics-types").Revenue, eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Promise<import("@amplitude/analytics-types").Result>>;
|
|
114
|
-
/**
|
|
115
|
-
* Sets a new optOut config value. This toggles event tracking on/off.
|
|
116
|
-
*
|
|
117
|
-
*```typescript
|
|
118
|
-
* // Stops tracking
|
|
119
|
-
* setOptOut(true);
|
|
120
|
-
*
|
|
121
|
-
* // Starts/resumes tracking
|
|
122
|
-
* setOptOut(false);
|
|
123
|
-
* ```
|
|
124
|
-
*/
|
|
125
|
-
export declare const setOptOut: (optOut: boolean) => void;
|
|
126
|
-
/**
|
|
127
|
-
* Flush and send all the events which haven't been sent.
|
|
128
|
-
*
|
|
129
|
-
*```typescript
|
|
130
|
-
* // Send all the unsent events
|
|
131
|
-
* flush();
|
|
132
|
-
*
|
|
133
|
-
* // alternatively, this tracking method is awaitable
|
|
134
|
-
* await flush().promise;
|
|
135
|
-
* ```
|
|
136
|
-
*/
|
|
137
|
-
export declare const flush: () => import("@amplitude/analytics-types").AmplitudeReturn<Promise<void>>;
|
|
6
|
+
export declare const createInstance: () => NodeClient;
|
|
7
|
+
declare const _default: NodeClient;
|
|
8
|
+
export default _default;
|
|
138
9
|
//# sourceMappingURL=node-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-client.d.ts","sourceRoot":"","sources":["../../src/node-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA8B,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"node-client.d.ts","sourceRoot":"","sources":["../../src/node-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA8B,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAIjF,qBAAa,aAAc,SAAQ,aAAa,CAAC,UAAU,CAAC;IACpD,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW;CAyBjD;AAED,eAAO,MAAM,cAAc,QAAO,UAejC,CAAC;;AAEF,wBAAgC"}
|
package/lib/esm/node-client.js
CHANGED
|
@@ -13,6 +13,11 @@ var AmplitudeNode = /** @class */ (function (_super) {
|
|
|
13
13
|
return __generator(this, function (_a) {
|
|
14
14
|
switch (_a.label) {
|
|
15
15
|
case 0:
|
|
16
|
+
// Step 0: Block concurrent initialization
|
|
17
|
+
if (this.initializing) {
|
|
18
|
+
return [2 /*return*/];
|
|
19
|
+
}
|
|
20
|
+
this.initializing = true;
|
|
16
21
|
nodeOptions = useNodeConfig(apiKey, __assign({}, options));
|
|
17
22
|
return [4 /*yield*/, _super.prototype._init.call(this, nodeOptions)];
|
|
18
23
|
case 1:
|
|
@@ -23,6 +28,7 @@ var AmplitudeNode = /** @class */ (function (_super) {
|
|
|
23
28
|
return [4 /*yield*/, this.add(new Destination())];
|
|
24
29
|
case 3:
|
|
25
30
|
_a.sent();
|
|
31
|
+
this.initializing = false;
|
|
26
32
|
// Set timeline ready for processing events
|
|
27
33
|
// Send existing events, which might be collected by track before init
|
|
28
34
|
this.timeline.isReady = true;
|
|
@@ -37,137 +43,21 @@ var AmplitudeNode = /** @class */ (function (_super) {
|
|
|
37
43
|
return AmplitudeNode;
|
|
38
44
|
}(AmplitudeCore));
|
|
39
45
|
export { AmplitudeNode };
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
* // alternatively, this tracking method is awaitable
|
|
58
|
-
* await add(plugin).promise;
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
export var add = returnWrapper(client.add.bind(client));
|
|
62
|
-
/**
|
|
63
|
-
* Removes a plugin.
|
|
64
|
-
*
|
|
65
|
-
* ```typescript
|
|
66
|
-
* remove('myPlugin');
|
|
67
|
-
*
|
|
68
|
-
* // alternatively, this tracking method is awaitable
|
|
69
|
-
* await remove('myPlugin').promise;
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
export var remove = returnWrapper(client.remove.bind(client));
|
|
73
|
-
/**
|
|
74
|
-
* Tracks user-defined event, with specified type, optional event properties and optional overwrites.
|
|
75
|
-
*
|
|
76
|
-
* ```typescript
|
|
77
|
-
* // event tracking with event type only
|
|
78
|
-
* track('Page Load');
|
|
79
|
-
*
|
|
80
|
-
* // event tracking with event type and additional event properties
|
|
81
|
-
* track('Page Load', { loadTime: 1000 });
|
|
82
|
-
*
|
|
83
|
-
* // event tracking with event type, additional event properties, and overwritten event options
|
|
84
|
-
* track('Page Load', { loadTime: 1000 }, { sessionId: -1 });
|
|
85
|
-
*
|
|
86
|
-
* // alternatively, this tracking method is awaitable
|
|
87
|
-
* const result = await track('Page Load').promise;
|
|
88
|
-
* console.log(result.event); // {...}
|
|
89
|
-
* console.log(result.code); // 200
|
|
90
|
-
* console.log(result.message); // "Event tracked successfully"
|
|
91
|
-
* ```
|
|
92
|
-
*/
|
|
93
|
-
export var track = returnWrapper(client.track.bind(client));
|
|
94
|
-
/**
|
|
95
|
-
* Alias for track()
|
|
96
|
-
*/
|
|
97
|
-
export var logEvent = returnWrapper(client.logEvent.bind(client));
|
|
98
|
-
/**
|
|
99
|
-
* Sends an identify event containing user property operations
|
|
100
|
-
*
|
|
101
|
-
* ```typescript
|
|
102
|
-
* const id = new Identify();
|
|
103
|
-
* id.set('colors', ['rose', 'gold']);
|
|
104
|
-
* identify(id);
|
|
105
|
-
*
|
|
106
|
-
* // alternatively, this tracking method is awaitable
|
|
107
|
-
* const result = await identify(id).promise;
|
|
108
|
-
* console.log(result.event); // {...}
|
|
109
|
-
* console.log(result.code); // 200
|
|
110
|
-
* console.log(result.message); // "Event tracked successfully"
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
export var identify = returnWrapper(client.identify.bind(client));
|
|
114
|
-
/**
|
|
115
|
-
* Sends a group identify event containing group property operations.
|
|
116
|
-
*
|
|
117
|
-
* ```typescript
|
|
118
|
-
* const id = new Identify();
|
|
119
|
-
* id.set('skills', ['js', 'ts']);
|
|
120
|
-
* const groupType = 'org';
|
|
121
|
-
* const groupName = 'engineering';
|
|
122
|
-
* groupIdentify(groupType, groupName, id);
|
|
123
|
-
*
|
|
124
|
-
* // alternatively, this tracking method is awaitable
|
|
125
|
-
* const result = await groupIdentify(groupType, groupName, id).promise;
|
|
126
|
-
* console.log(result.event); // {...}
|
|
127
|
-
* console.log(result.code); // 200
|
|
128
|
-
* console.log(result.message); // "Event tracked successfully"
|
|
129
|
-
* ```
|
|
130
|
-
*/
|
|
131
|
-
export var groupIdentify = returnWrapper(client.groupIdentify.bind(client));
|
|
132
|
-
export var setGroup = returnWrapper(client.setGroup.bind(client));
|
|
133
|
-
/**
|
|
134
|
-
* Sends a revenue event containing revenue property operations.
|
|
135
|
-
*
|
|
136
|
-
* ```typescript
|
|
137
|
-
* const rev = new Revenue();
|
|
138
|
-
* rev.setRevenue(100);
|
|
139
|
-
* revenue(rev);
|
|
140
|
-
*
|
|
141
|
-
* // alternatively, this tracking method is awaitable
|
|
142
|
-
* const result = await revenue(rev).promise;
|
|
143
|
-
* console.log(result.event); // {...}
|
|
144
|
-
* console.log(result.code); // 200
|
|
145
|
-
* console.log(result.message); // "Event tracked successfully"
|
|
146
|
-
* ```
|
|
147
|
-
*/
|
|
148
|
-
export var revenue = returnWrapper(client.revenue.bind(client));
|
|
149
|
-
/**
|
|
150
|
-
* Sets a new optOut config value. This toggles event tracking on/off.
|
|
151
|
-
*
|
|
152
|
-
*```typescript
|
|
153
|
-
* // Stops tracking
|
|
154
|
-
* setOptOut(true);
|
|
155
|
-
*
|
|
156
|
-
* // Starts/resumes tracking
|
|
157
|
-
* setOptOut(false);
|
|
158
|
-
* ```
|
|
159
|
-
*/
|
|
160
|
-
export var setOptOut = client.setOptOut.bind(client);
|
|
161
|
-
/**
|
|
162
|
-
* Flush and send all the events which haven't been sent.
|
|
163
|
-
*
|
|
164
|
-
*```typescript
|
|
165
|
-
* // Send all the unsent events
|
|
166
|
-
* flush();
|
|
167
|
-
*
|
|
168
|
-
* // alternatively, this tracking method is awaitable
|
|
169
|
-
* await flush().promise;
|
|
170
|
-
* ```
|
|
171
|
-
*/
|
|
172
|
-
export var flush = returnWrapper(client.flush.bind(client));
|
|
46
|
+
export var createInstance = function () {
|
|
47
|
+
var client = new AmplitudeNode();
|
|
48
|
+
return {
|
|
49
|
+
init: returnWrapper(client.init.bind(client)),
|
|
50
|
+
add: returnWrapper(client.add.bind(client)),
|
|
51
|
+
remove: returnWrapper(client.remove.bind(client)),
|
|
52
|
+
track: returnWrapper(client.track.bind(client)),
|
|
53
|
+
logEvent: returnWrapper(client.logEvent.bind(client)),
|
|
54
|
+
identify: returnWrapper(client.identify.bind(client)),
|
|
55
|
+
groupIdentify: returnWrapper(client.groupIdentify.bind(client)),
|
|
56
|
+
setGroup: returnWrapper(client.setGroup.bind(client)),
|
|
57
|
+
revenue: returnWrapper(client.revenue.bind(client)),
|
|
58
|
+
flush: returnWrapper(client.flush.bind(client)),
|
|
59
|
+
setOptOut: client.setOptOut.bind(client),
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export default createInstance();
|
|
173
63
|
//# sourceMappingURL=node-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-client.js","sourceRoot":"","sources":["../../src/node-client.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAEtF,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;IAAmC,iCAAyB;IAA5D;;
|
|
1
|
+
{"version":3,"file":"node-client.js","sourceRoot":"","sources":["../../src/node-client.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAEtF,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;IAAmC,iCAAyB;IAA5D;;IA0BA,CAAC;IAzBO,4BAAI,GAAV,UAAW,MAAc,EAAE,OAAqB;;;;;;wBAC9C,0CAA0C;wBAC1C,IAAI,IAAI,CAAC,YAAY,EAAE;4BACrB,sBAAO;yBACR;wBACD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;wBAEnB,WAAW,GAAG,aAAa,CAAC,MAAM,eACnC,OAAO,EACV,CAAC;wBAEH,qBAAM,iBAAM,KAAK,YAAC,WAAW,CAAC,EAAA;;wBAA9B,SAA8B,CAAC;wBAE/B,qBAAM,IAAI,CAAC,GAAG,CAAC,IAAI,OAAO,EAAE,CAAC,EAAA;;wBAA7B,SAA6B,CAAC;wBAC9B,qBAAM,IAAI,CAAC,GAAG,CAAC,IAAI,WAAW,EAAE,CAAC,EAAA;;wBAAjC,SAAiC,CAAC;wBAElC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;wBAE1B,2CAA2C;wBAC3C,sEAAsE;wBACtE,IAAI,CAAC,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;wBAC7B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;4BACvB,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;yBAChC;;;;;KACF;IACH,oBAAC;AAAD,CAAC,AA1BD,CAAmC,aAAa,GA0B/C;;AAED,MAAM,CAAC,IAAM,cAAc,GAAG;IAC5B,IAAM,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;IACnC,OAAO;QACL,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7C,GAAG,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjD,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC/C,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrD,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrD,aAAa,EAAE,aAAa,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC/D,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrD,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnD,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC/C,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;KACzC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,EAAE,CAAC","sourcesContent":["import { AmplitudeCore, Destination, returnWrapper } from '@amplitude/analytics-core';\nimport { NodeClient, NodeConfig, NodeOptions } from '@amplitude/analytics-types';\nimport { Context } from './plugins/context';\nimport { useNodeConfig } from './config';\n\nexport class AmplitudeNode extends AmplitudeCore<NodeConfig> {\n async init(apiKey: string, options?: NodeOptions) {\n // Step 0: Block concurrent initialization\n if (this.initializing) {\n return;\n }\n this.initializing = true;\n\n const nodeOptions = useNodeConfig(apiKey, {\n ...options,\n });\n\n await super._init(nodeOptions);\n\n await this.add(new Context());\n await this.add(new Destination());\n\n this.initializing = false;\n\n // Set timeline ready for processing events\n // Send existing events, which might be collected by track before init\n this.timeline.isReady = true;\n if (!this.config.optOut) {\n this.timeline.scheduleApply(0);\n }\n }\n}\n\nexport const createInstance = (): NodeClient => {\n const client = new AmplitudeNode();\n return {\n init: returnWrapper(client.init.bind(client)),\n add: returnWrapper(client.add.bind(client)),\n remove: returnWrapper(client.remove.bind(client)),\n track: returnWrapper(client.track.bind(client)),\n logEvent: returnWrapper(client.logEvent.bind(client)),\n identify: returnWrapper(client.identify.bind(client)),\n groupIdentify: returnWrapper(client.groupIdentify.bind(client)),\n setGroup: returnWrapper(client.setGroup.bind(client)),\n revenue: returnWrapper(client.revenue.bind(client)),\n flush: returnWrapper(client.flush.bind(client)),\n setOptOut: client.setOptOut.bind(client),\n };\n};\n\nexport default createInstance();\n"]}
|
package/lib/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.4.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/lib/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export var VERSION = '0.
|
|
1
|
+
export var VERSION = '0.4.0';
|
|
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,OAAO,CAAC","sourcesContent":["export const VERSION = '0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,OAAO,GAAG,OAAO,CAAC","sourcesContent":["export const VERSION = '0.4.0';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amplitude/analytics-node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Official Amplitude SDK for NodeJS",
|
|
5
5
|
"author": "Amplitude Inc",
|
|
6
6
|
"homepage": "https://github.com/amplitude/Amplitude-TypeScript",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"url": "https://github.com/amplitude/Amplitude-TypeScript/issues"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@amplitude/analytics-core": "^0.
|
|
39
|
-
"@amplitude/analytics-types": "^0.
|
|
38
|
+
"@amplitude/analytics-core": "^0.8.0",
|
|
39
|
+
"@amplitude/analytics-types": "^0.8.0",
|
|
40
40
|
"tslib": "^2.3.1"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"lib"
|
|
44
44
|
],
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "c701a2b7ada6c8817bf28894f4d68cfa5dd0c403"
|
|
46
46
|
}
|