@amplitude/analytics-node 0.3.7 → 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.
@@ -1,4 +1,5 @@
1
- export { add, groupIdentify, identify, init, logEvent, remove, revenue, setGroup, setOptOut, track, flush, } from './node-client';
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,aAAa,EACb,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,OAAO,EACP,QAAQ,EACR,SAAS,EACT,KAAK,EACL,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,KAAK,MAAM,4BAA4B,CAAC"}
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
- Object.defineProperty(exports, "add", { enumerable: true, get: function () { return node_client_1.add; } });
5
- Object.defineProperty(exports, "groupIdentify", { enumerable: true, get: function () { return node_client_1.groupIdentify; } });
6
- Object.defineProperty(exports, "identify", { enumerable: true, get: function () { return node_client_1.identify; } });
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; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;AAAA,6CAYuB;AAXrB,kGAAA,GAAG,OAAA;AACH,4GAAA,aAAa,OAAA;AACb,uGAAA,QAAQ,OAAA;AACR,mGAAA,IAAI,OAAA;AACJ,uGAAA,QAAQ,OAAA;AACR,qGAAA,MAAM,OAAA;AACN,sGAAA,OAAO,OAAA;AACP,uGAAA,QAAQ,OAAA;AACR,wGAAA,SAAS,OAAA;AACT,oGAAA,KAAK,OAAA;AACL,oGAAA,KAAK,OAAA;AAEP,4DAA8D;AAArD,yGAAA,OAAO,OAAA;AAAE,0GAAA,QAAQ,OAAA;AAC1B,sDAAoD","sourcesContent":["export {\n add,\n groupIdentify,\n identify,\n init,\n logEvent,\n remove,\n revenue,\n setGroup,\n setOptOut,\n track,\n flush,\n} from './node-client';\nexport { Revenue, Identify } from '@amplitude/analytics-core';\nexport * as Types from '@amplitude/analytics-types';\n"]}
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"]}
@@ -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
- * Initializes the Amplitude SDK with your apiKey and optional configurations.
8
- * This method must be called before any other operations.
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[], eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => 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;AAIrE,qBAAa,aAAc,SAAQ,aAAa,CAAC,UAAU,CAAC;IACpD,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW;CAiBjD;AAID;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,4HAA0C,CAAC;AAE5D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,GAAG,8HAAyC,CAAC;AAE1D;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,6FAA4C,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,KAAK,sTAA2C,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,QAAQ,sTAA8C,CAAC;AAEpE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,QAAQ,uPAA8C,CAAC;AAEpE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa,wSAAmD,CAAC;AAC9E,eAAO,MAAM,QAAQ,+OAA8C,CAAC;AAEpE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,OAAO,qPAA6C,CAAC;AAElE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,2BAAgC,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,2EAA2C,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"}
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.flush = exports.setOptOut = exports.revenue = exports.setGroup = exports.groupIdentify = exports.identify = exports.logEvent = exports.track = exports.remove = exports.add = exports.init = exports.AmplitudeNode = void 0;
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 client = new AmplitudeNode();
43
- /**
44
- * Initializes the Amplitude SDK with your apiKey and optional configurations.
45
- * This method must be called before any other operations.
46
- *
47
- * ```typescript
48
- * await init(API_KEY, USER_ID, options).promise;
49
- * ```
50
- */
51
- exports.init = (0, analytics_core_1.returnWrapper)(client.init.bind(client));
52
- /**
53
- * Adds a new plugin.
54
- *
55
- * ```typescript
56
- * const plugin = {...};
57
- * add(plugin);
58
- *
59
- * // alternatively, this tracking method is awaitable
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;;IAkBA,CAAC;IAjBO,4BAAI,GAAV,UAAW,MAAc,EAAE,OAAqB;;;;;;wBACxC,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,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,AAlBD,CAAmC,8BAAa,GAkB/C;AAlBY,sCAAa;AAoB1B,IAAM,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;AAEnC;;;;;;;GAOG;AACU,QAAA,IAAI,GAAG,IAAA,8BAAa,EAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AAE5D;;;;;;;;;;GA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mplitudeCore, Destination, returnWrapper } from '@amplitude/analytics-core';\nimport { 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 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 // 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\nconst client = new AmplitudeNode();\n\n/**\n * Initializes the Amplitude SDK with your apiKey and optional configurations.\n * This method must be called before any other operations.\n *\n * ```typescript\n * await init(API_KEY, USER_ID, options).promise;\n * ```\n */\nexport const init = returnWrapper(client.init.bind(client));\n\n/**\n * Adds a new plugin.\n *\n * ```typescript\n * const plugin = {...};\n * add(plugin);\n *\n * // alternatively, this tracking method is awaitable\n * await add(plugin).promise;\n * ```\n */\nexport const add = returnWrapper(client.add.bind(client));\n\n/**\n * Removes a plugin.\n *\n * ```typescript\n * remove('myPlugin');\n *\n * // alternatively, this tracking method is awaitable\n * await remove('myPlugin').promise;\n * ```\n */\nexport const remove = returnWrapper(client.remove.bind(client));\n\n/**\n * Tracks user-defined event, with specified type, optional event properties and optional overwrites.\n *\n * ```typescript\n * // event tracking with event type only\n * track('Page Load');\n *\n * // event tracking with event type and additional event properties\n * track('Page Load', { loadTime: 1000 });\n *\n * // event tracking with event type, additional event properties, and overwritten event options\n * track('Page Load', { loadTime: 1000 }, { sessionId: -1 });\n *\n * // alternatively, this tracking method is awaitable\n * const result = await track('Page Load').promise;\n * console.log(result.event); // {...}\n * console.log(result.code); // 200\n * console.log(result.message); // \"Event tracked successfully\"\n * ```\n */\nexport const track = returnWrapper(client.track.bind(client));\n\n/**\n * Alias for track()\n */\nexport const logEvent = returnWrapper(client.logEvent.bind(client));\n\n/**\n * Sends an identify event containing user property operations\n *\n * ```typescript\n * const id = new Identify();\n * id.set('colors', ['rose', 'gold']);\n * identify(id);\n *\n * // alternatively, this tracking method is awaitable\n * const result = await identify(id).promise;\n * console.log(result.event); // {...}\n * console.log(result.code); // 200\n * console.log(result.message); // \"Event tracked successfully\"\n * ```\n */\nexport const identify = returnWrapper(client.identify.bind(client));\n\n/**\n * Sends a group identify event containing group property operations.\n *\n * ```typescript\n * const id = new Identify();\n * id.set('skills', ['js', 'ts']);\n * const groupType = 'org';\n * const groupName = 'engineering';\n * groupIdentify(groupType, groupName, id);\n *\n * // alternatively, this tracking method is awaitable\n * const result = await groupIdentify(groupType, groupName, id).promise;\n * console.log(result.event); // {...}\n * console.log(result.code); // 200\n * console.log(result.message); // \"Event tracked successfully\"\n * ```\n */\nexport const groupIdentify = returnWrapper(client.groupIdentify.bind(client));\nexport const setGroup = returnWrapper(client.setGroup.bind(client));\n\n/**\n * Sends a revenue event containing revenue property operations.\n *\n * ```typescript\n * const rev = new Revenue();\n * rev.setRevenue(100);\n * revenue(rev);\n *\n * // alternatively, this tracking method is awaitable\n * const result = await revenue(rev).promise;\n * console.log(result.event); // {...}\n * console.log(result.code); // 200\n * console.log(result.message); // \"Event tracked successfully\"\n * ```\n */\nexport const revenue = returnWrapper(client.revenue.bind(client));\n\n/**\n * Sets a new optOut config value. This toggles event tracking on/off.\n *\n *```typescript\n * // Stops tracking\n * setOptOut(true);\n *\n * // Starts/resumes tracking\n * setOptOut(false);\n * ```\n */\nexport const setOptOut = client.setOptOut.bind(client);\n\n/**\n * Flush and send all the events which haven't been sent.\n *\n *```typescript\n * // Send all the unsent events\n * flush();\n *\n * // alternatively, this tracking method is awaitable\n * await flush().promise;\n * ```\n */\nexport const flush = returnWrapper(client.flush.bind(client));\n"]}
1
+ {"version":3,"file":"node-client.js","sourceRoot":"","sources":["../../src/node-client.ts"],"names":[],"mappings":";;;AAAA,4DAAsF;AAEtF,6CAA4C;AAC5C,mCAAyC;AAEzC;I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,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"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.3.7";
1
+ export declare const VERSION = "0.4.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,4 +1,4 @@
1
1
  Object.defineProperty(exports, "__esModule", { value: true });
2
2
  exports.VERSION = void 0;
3
- exports.VERSION = '0.3.7';
3
+ exports.VERSION = '0.4.0';
4
4
  //# sourceMappingURL=version.js.map
@@ -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.3.7';\n"]}
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"]}
@@ -1,4 +1,5 @@
1
- export { add, groupIdentify, identify, init, logEvent, remove, revenue, setGroup, setOptOut, track, flush, } from './node-client';
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,aAAa,EACb,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,OAAO,EACP,QAAQ,EACR,SAAS,EACT,KAAK,EACL,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,KAAK,MAAM,4BAA4B,CAAC"}
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
- export { add, groupIdentify, identify, init, logEvent, remove, revenue, setGroup, setOptOut, track, flush, } from './node-client';
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 };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,aAAa,EACb,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,OAAO,EACP,QAAQ,EACR,SAAS,EACT,KAAK,EACL,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;yBACvC,4BAA4B;oBAAvC,KAAK","sourcesContent":["export {\n add,\n groupIdentify,\n identify,\n init,\n logEvent,\n remove,\n revenue,\n setGroup,\n setOptOut,\n track,\n flush,\n} from './node-client';\nexport { Revenue, Identify } from '@amplitude/analytics-core';\nexport * as Types from '@amplitude/analytics-types';\n"]}
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"]}
@@ -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
- * Initializes the Amplitude SDK with your apiKey and optional configurations.
8
- * This method must be called before any other operations.
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[], eventOptions?: import("@amplitude/analytics-types").EventOptions | undefined) => 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;AAIrE,qBAAa,aAAc,SAAQ,aAAa,CAAC,UAAU,CAAC;IACpD,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW;CAiBjD;AAID;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,4HAA0C,CAAC;AAE5D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,GAAG,8HAAyC,CAAC;AAE1D;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,6FAA4C,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,KAAK,sTAA2C,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,QAAQ,sTAA8C,CAAC;AAEpE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,QAAQ,uPAA8C,CAAC;AAEpE;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa,wSAAmD,CAAC;AAC9E,eAAO,MAAM,QAAQ,+OAA8C,CAAC;AAEpE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,OAAO,qPAA6C,CAAC;AAElE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,2BAAgC,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,2EAA2C,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"}
@@ -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 client = new AmplitudeNode();
41
- /**
42
- * Initializes the Amplitude SDK with your apiKey and optional configurations.
43
- * This method must be called before any other operations.
44
- *
45
- * ```typescript
46
- * await init(API_KEY, USER_ID, options).promise;
47
- * ```
48
- */
49
- export var init = returnWrapper(client.init.bind(client));
50
- /**
51
- * Adds a new plugin.
52
- *
53
- * ```typescript
54
- * const plugin = {...};
55
- * add(plugin);
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;;IAkBA,CAAC;IAjBO,4BAAI,GAAV,UAAW,MAAc,EAAE,OAAqB;;;;;;wBACxC,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,2CAA2C;wBAC3C,sEAAsE;wBACtE,IAAI,CAAC,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;wBAC7B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,E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EpE;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,IAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;AAElE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,IAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,IAAM,KAAK,GAAG,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import { AmplitudeCore, Destination, returnWrapper } from '@amplitude/analytics-core';\nimport { 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 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 // 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\nconst client = new AmplitudeNode();\n\n/**\n * Initializes the Amplitude SDK with your apiKey and optional configurations.\n * This method must be called before any other operations.\n *\n * ```typescript\n * await init(API_KEY, USER_ID, options).promise;\n * ```\n */\nexport const init = returnWrapper(client.init.bind(client));\n\n/**\n * Adds a new plugin.\n *\n * ```typescript\n * const plugin = {...};\n * add(plugin);\n *\n * // alternatively, this tracking method is awaitable\n * await add(plugin).promise;\n * ```\n */\nexport const add = returnWrapper(client.add.bind(client));\n\n/**\n * Removes a plugin.\n *\n * ```typescript\n * remove('myPlugin');\n *\n * // alternatively, this tracking method is awaitable\n * await remove('myPlugin').promise;\n * ```\n */\nexport const remove = returnWrapper(client.remove.bind(client));\n\n/**\n * Tracks user-defined event, with specified type, optional event properties and optional overwrites.\n *\n * ```typescript\n * // event tracking with event type only\n * track('Page Load');\n *\n * // event tracking with event type and additional event properties\n * track('Page Load', { loadTime: 1000 });\n *\n * // event tracking with event type, additional event properties, and overwritten event options\n * track('Page Load', { loadTime: 1000 }, { sessionId: -1 });\n *\n * // alternatively, this tracking method is awaitable\n * const result = await track('Page Load').promise;\n * console.log(result.event); // {...}\n * console.log(result.code); // 200\n * console.log(result.message); // \"Event tracked successfully\"\n * ```\n */\nexport const track = returnWrapper(client.track.bind(client));\n\n/**\n * Alias for track()\n */\nexport const logEvent = returnWrapper(client.logEvent.bind(client));\n\n/**\n * Sends an identify event containing user property operations\n *\n * ```typescript\n * const id = new Identify();\n * id.set('colors', ['rose', 'gold']);\n * identify(id);\n *\n * // alternatively, this tracking method is awaitable\n * const result = await identify(id).promise;\n * console.log(result.event); // {...}\n * console.log(result.code); // 200\n * console.log(result.message); // \"Event tracked successfully\"\n * ```\n */\nexport const identify = returnWrapper(client.identify.bind(client));\n\n/**\n * Sends a group identify event containing group property operations.\n *\n * ```typescript\n * const id = new Identify();\n * id.set('skills', ['js', 'ts']);\n * const groupType = 'org';\n * const groupName = 'engineering';\n * groupIdentify(groupType, groupName, id);\n *\n * // alternatively, this tracking method is awaitable\n * const result = await groupIdentify(groupType, groupName, id).promise;\n * console.log(result.event); // {...}\n * console.log(result.code); // 200\n * console.log(result.message); // \"Event tracked successfully\"\n * ```\n */\nexport const groupIdentify = returnWrapper(client.groupIdentify.bind(client));\nexport const setGroup = returnWrapper(client.setGroup.bind(client));\n\n/**\n * Sends a revenue event containing revenue property operations.\n *\n * ```typescript\n * const rev = new Revenue();\n * rev.setRevenue(100);\n * revenue(rev);\n *\n * // alternatively, this tracking method is awaitable\n * const result = await revenue(rev).promise;\n * console.log(result.event); // {...}\n * console.log(result.code); // 200\n * console.log(result.message); // \"Event tracked successfully\"\n * ```\n */\nexport const revenue = returnWrapper(client.revenue.bind(client));\n\n/**\n * Sets a new optOut config value. This toggles event tracking on/off.\n *\n *```typescript\n * // Stops tracking\n * setOptOut(true);\n *\n * // Starts/resumes tracking\n * setOptOut(false);\n * ```\n */\nexport const setOptOut = client.setOptOut.bind(client);\n\n/**\n * Flush and send all the events which haven't been sent.\n *\n *```typescript\n * // Send all the unsent events\n * flush();\n *\n * // alternatively, this tracking method is awaitable\n * await flush().promise;\n * ```\n */\nexport const flush = returnWrapper(client.flush.bind(client));\n"]}
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,EAA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Core, 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"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.3.7";
1
+ export declare const VERSION = "0.4.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,2 +1,2 @@
1
- export var VERSION = '0.3.7';
1
+ export var VERSION = '0.4.0';
2
2
  //# sourceMappingURL=version.js.map
@@ -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.3.7';\n"]}
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.7",
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.7.0",
39
- "@amplitude/analytics-types": "^0.7.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": "d71a39cd63930ee604f0df293767692c09ab54f5"
45
+ "gitHead": "c701a2b7ada6c8817bf28894f4d68cfa5dd0c403"
46
46
  }