@amplitude/plugin-global-user-properties 1.1.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.
Files changed (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +66 -0
  3. package/lib/cjs/global-user-properties.d.ts +3 -0
  4. package/lib/cjs/global-user-properties.d.ts.map +1 -0
  5. package/lib/cjs/global-user-properties.js +27 -0
  6. package/lib/cjs/global-user-properties.js.map +1 -0
  7. package/lib/cjs/helpers.d.ts +4 -0
  8. package/lib/cjs/helpers.d.ts.map +1 -0
  9. package/lib/cjs/helpers.js +13 -0
  10. package/lib/cjs/helpers.js.map +1 -0
  11. package/lib/cjs/index.d.ts +4 -0
  12. package/lib/cjs/index.d.ts.map +1 -0
  13. package/lib/cjs/index.js +7 -0
  14. package/lib/cjs/index.js.map +1 -0
  15. package/lib/cjs/typings/global-user-properties.d.ts +11 -0
  16. package/lib/cjs/typings/global-user-properties.d.ts.map +1 -0
  17. package/lib/cjs/typings/global-user-properties.js +2 -0
  18. package/lib/cjs/typings/global-user-properties.js.map +1 -0
  19. package/lib/esm/global-user-properties.d.ts +3 -0
  20. package/lib/esm/global-user-properties.d.ts.map +1 -0
  21. package/lib/esm/global-user-properties.js +24 -0
  22. package/lib/esm/global-user-properties.js.map +1 -0
  23. package/lib/esm/helpers.d.ts +4 -0
  24. package/lib/esm/helpers.d.ts.map +1 -0
  25. package/lib/esm/helpers.js +9 -0
  26. package/lib/esm/helpers.js.map +1 -0
  27. package/lib/esm/index.d.ts +4 -0
  28. package/lib/esm/index.d.ts.map +1 -0
  29. package/lib/esm/index.js +3 -0
  30. package/lib/esm/index.js.map +1 -0
  31. package/lib/esm/typings/global-user-properties.d.ts +11 -0
  32. package/lib/esm/typings/global-user-properties.d.ts.map +1 -0
  33. package/lib/esm/typings/global-user-properties.js +2 -0
  34. package/lib/esm/typings/global-user-properties.js.map +1 -0
  35. package/lib/scripts/amplitude-min.umd.js +1 -0
  36. package/lib/scripts/amplitude-min.umd.js.gz +0 -0
  37. package/lib/scripts/global-user-properties.d.ts +3 -0
  38. package/lib/scripts/global-user-properties.d.ts.map +1 -0
  39. package/lib/scripts/helpers.d.ts +4 -0
  40. package/lib/scripts/helpers.d.ts.map +1 -0
  41. package/lib/scripts/index.d.ts +4 -0
  42. package/lib/scripts/index.d.ts.map +1 -0
  43. package/lib/scripts/typings/global-user-properties.d.ts +11 -0
  44. package/lib/scripts/typings/global-user-properties.d.ts.map +1 -0
  45. package/package.json +56 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Amplitude Analytics
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ <p align="center">
2
+ <a href="https://amplitude.com" target="_blank" align="center">
3
+ <img src="https://static.amplitude.com/lightning/46c85bfd91905de8047f1ee65c7c93d6fa9ee6ea/static/media/amplitude-logo-with-text.4fb9e463.svg" width="280">
4
+ </a>
5
+ <br />
6
+ </p>
7
+
8
+ # @amplitude/plugin-global-user-properties
9
+
10
+ Official SDK plugin for adding global user properties to events
11
+
12
+ ## Installation
13
+
14
+ This package is published on NPM registry and is available to be installed using npm and yarn.
15
+
16
+ ```sh
17
+ # npm
18
+ npm install @amplitude/plugin-global-user-properties
19
+
20
+ # yarn
21
+ yarn add @amplitude/plugin-global-user-properties
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ This plugin works on top of the Amplitude SDK and sends user properties as global user properties, a beta feature for that allows projects to share user properties (i.e. user properties can become "global" across multiple projects).
27
+
28
+ To use this plugin, you need to install `@amplitude/plugin-global-user-properties `v1.0.0` or later.
29
+
30
+ ### 1. Import Amplitude packages
31
+
32
+ * `@amplitude/plugin-global-user-properties`
33
+
34
+ ```typescript
35
+ import * as Amplitude from '@amplitude/analytics-browser'
36
+ import { globalUserPropertiesPlugin } from '@amplitude/plugin-global-user-properties';
37
+ ```
38
+
39
+ ### 2. Instantiate page view plugin
40
+
41
+ The plugin accepts an optional parameter of type `Object` to configure the plugin based on your use case.
42
+
43
+ ```typescript
44
+ const globalUserPropertiesPlugin = globalUserPropertiesPlugin({
45
+ shouldKeepOriginalUserProperties: true,
46
+ });
47
+ ```
48
+
49
+ #### Options
50
+
51
+ |Name|Type|Default|Description|
52
+ |-|-|-|-|
53
+ |`shouldKeepOriginalUserProperties`|`boolean`| `false` | Use this option if you want the user properties to be sent along with the global user properties. Since global user properties do not appear in Data yet, this would allow indirect governance (by observing the same properties as regular user properties). |
54
+
55
+ ### 3. Install plugin to Amplitude SDK
56
+
57
+ ```typescript
58
+ amplitude.add(globalUserPropertiesPlugin);
59
+ ```
60
+
61
+ ### 4. Initialize Amplitude SDK
62
+
63
+ ```typescript
64
+ amplitude.init('API_KEY');
65
+ ```
66
+
@@ -0,0 +1,3 @@
1
+ import { GlobalUserPropertiesPlugin } from './typings/global-user-properties';
2
+ export declare const globalUserPropertiesPlugin: GlobalUserPropertiesPlugin;
3
+ //# sourceMappingURL=global-user-properties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-user-properties.d.ts","sourceRoot":"","sources":["../../src/global-user-properties.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAW,MAAM,kCAAkC,CAAC;AAGvF,eAAO,MAAM,0BAA0B,EAAE,0BAoBxC,CAAC"}
@@ -0,0 +1,27 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.globalUserPropertiesPlugin = void 0;
3
+ var tslib_1 = require("tslib");
4
+ var helpers_1 = require("./helpers");
5
+ var globalUserPropertiesPlugin = function (options) {
6
+ var _this = this;
7
+ if (options === void 0) { options = {}; }
8
+ var plugin = {
9
+ name: '@amplitude/plugin-global-user-properties',
10
+ type: 'enrichment',
11
+ /* Note: The promise is because of the interface, not because this has any asynchronous behavior */
12
+ execute: function (event) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
13
+ return tslib_1.__generator(this, function (_a) {
14
+ if ((0, helpers_1.isTrackEvent)(event) || (0, helpers_1.isAmplitudeIdentifyEvent)(event)) {
15
+ event.global_user_properties = event.user_properties;
16
+ if (!options.shouldKeepOriginalUserProperties) {
17
+ delete event.user_properties;
18
+ }
19
+ }
20
+ return [2 /*return*/, event];
21
+ });
22
+ }); },
23
+ };
24
+ return plugin;
25
+ };
26
+ exports.globalUserPropertiesPlugin = globalUserPropertiesPlugin;
27
+ //# sourceMappingURL=global-user-properties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-user-properties.js","sourceRoot":"","sources":["../../src/global-user-properties.ts"],"names":[],"mappings":";;;AAEA,qCAAmE;AAE5D,IAAM,0BAA0B,GAA+B,UAAU,OAAqB;IAA/B,iBAoBrE;IApB+E,wBAAA,EAAA,YAAqB;IACnG,IAAM,MAAM,GAAqB;QAC/B,IAAI,EAAE,0CAA0C;QAChD,IAAI,EAAE,YAAY;QAElB,mGAAmG;QACnG,OAAO,EAAE,UAAO,KAAY;;gBAC1B,IAAI,IAAA,sBAAY,EAAC,KAAK,CAAC,IAAI,IAAA,kCAAwB,EAAC,KAAK,CAAC,EAAE;oBAC1D,KAAK,CAAC,sBAAsB,GAAG,KAAK,CAAC,eAAe,CAAC;oBAErD,IAAI,CAAC,OAAO,CAAC,gCAAgC,EAAE;wBAC7C,OAAO,KAAK,CAAC,eAAe,CAAC;qBAC9B;iBACF;gBAED,sBAAO,KAAK,EAAC;;aACd;KACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AApBW,QAAA,0BAA0B,8BAoBrC","sourcesContent":["import { EnrichmentPlugin, Event } from '@amplitude/analytics-types';\nimport { GlobalUserPropertiesPlugin, Options } from './typings/global-user-properties';\nimport { isAmplitudeIdentifyEvent, isTrackEvent } from './helpers';\n\nexport const globalUserPropertiesPlugin: GlobalUserPropertiesPlugin = function (options: Options = {}) {\n const plugin: EnrichmentPlugin = {\n name: '@amplitude/plugin-global-user-properties',\n type: 'enrichment',\n\n /* Note: The promise is because of the interface, not because this has any asynchronous behavior */\n execute: async (event: Event): Promise<Event> => {\n if (isTrackEvent(event) || isAmplitudeIdentifyEvent(event)) {\n event.global_user_properties = event.user_properties;\n\n if (!options.shouldKeepOriginalUserProperties) {\n delete event.user_properties;\n }\n }\n\n return event;\n },\n };\n\n return plugin;\n};\n"]}
@@ -0,0 +1,4 @@
1
+ import { Event, TrackEvent, IdentifyEvent } from '@amplitude/analytics-types';
2
+ export declare const isTrackEvent: (event: Event) => event is TrackEvent;
3
+ export declare const isAmplitudeIdentifyEvent: (event: Event) => event is IdentifyEvent;
4
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAoB,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAIhG,eAAO,MAAM,YAAY,UAAW,KAAK,wBAExC,CAAC;AAEF,eAAO,MAAM,wBAAwB,UAAW,KAAK,2BAEpD,CAAC"}
@@ -0,0 +1,13 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.isAmplitudeIdentifyEvent = exports.isTrackEvent = void 0;
3
+ var analytics_types_1 = require("@amplitude/analytics-types");
4
+ var specialAmplitudeEvents = new Set(Object.values(analytics_types_1.SpecialEventType));
5
+ var isTrackEvent = function (event) {
6
+ return !specialAmplitudeEvents.has(event.event_type);
7
+ };
8
+ exports.isTrackEvent = isTrackEvent;
9
+ var isAmplitudeIdentifyEvent = function (event) {
10
+ return event.event_type === analytics_types_1.SpecialEventType.IDENTIFY;
11
+ };
12
+ exports.isAmplitudeIdentifyEvent = isAmplitudeIdentifyEvent;
13
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":";;AAAA,8DAAgG;AAEhG,IAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,kCAAgB,CAAC,CAAC,CAAC;AAEjE,IAAM,YAAY,GAAG,UAAC,KAAY;IACvC,OAAO,CAAC,sBAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,UAA8B,CAAC,CAAC;AAC3E,CAAC,CAAC;AAFW,QAAA,YAAY,gBAEvB;AAEK,IAAM,wBAAwB,GAAG,UAAC,KAAY;IACnD,OAAO,KAAK,CAAC,UAAU,KAAK,kCAAgB,CAAC,QAAQ,CAAC;AACxD,CAAC,CAAC;AAFW,QAAA,wBAAwB,4BAEnC","sourcesContent":["import { Event, TrackEvent, SpecialEventType, IdentifyEvent } from '@amplitude/analytics-types';\n\nconst specialAmplitudeEvents = new Set(Object.values(SpecialEventType));\n\nexport const isTrackEvent = (event: Event): event is TrackEvent => {\n return !specialAmplitudeEvents.has(event.event_type as SpecialEventType);\n};\n\nexport const isAmplitudeIdentifyEvent = (event: Event): event is IdentifyEvent => {\n return event.event_type === SpecialEventType.IDENTIFY;\n};\n"]}
@@ -0,0 +1,4 @@
1
+ export { globalUserPropertiesPlugin } from './global-user-properties';
2
+ export { globalUserPropertiesPlugin as plugin } from './global-user-properties';
3
+ export { GlobalUserPropertiesPlugin, Options } from './typings/global-user-properties';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,0BAA0B,IAAI,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,0BAA0B,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC"}
@@ -0,0 +1,7 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.plugin = exports.globalUserPropertiesPlugin = void 0;
3
+ var global_user_properties_1 = require("./global-user-properties");
4
+ Object.defineProperty(exports, "globalUserPropertiesPlugin", { enumerable: true, get: function () { return global_user_properties_1.globalUserPropertiesPlugin; } });
5
+ var global_user_properties_2 = require("./global-user-properties");
6
+ Object.defineProperty(exports, "plugin", { enumerable: true, get: function () { return global_user_properties_2.globalUserPropertiesPlugin; } });
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;AAAA,mEAAsE;AAA7D,oIAAA,0BAA0B,OAAA;AACnC,mEAAgF;AAAvE,gHAAA,0BAA0B,OAAU","sourcesContent":["export { globalUserPropertiesPlugin } from './global-user-properties';\nexport { globalUserPropertiesPlugin as plugin } from './global-user-properties';\nexport { GlobalUserPropertiesPlugin, Options } from './typings/global-user-properties';\n"]}
@@ -0,0 +1,11 @@
1
+ import { EnrichmentPlugin } from '@amplitude/analytics-types';
2
+ export interface Options {
3
+ /**
4
+ * Whether or not the orignal user_properties field should be kept on the event
5
+ */
6
+ shouldKeepOriginalUserProperties?: boolean;
7
+ }
8
+ export interface GlobalUserPropertiesPlugin {
9
+ (options?: Options): EnrichmentPlugin;
10
+ }
11
+ //# sourceMappingURL=global-user-properties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-user-properties.d.ts","sourceRoot":"","sources":["../../../src/typings/global-user-properties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,gCAAgC,CAAC,EAAE,OAAO,CAAC;CAC5C;AAED,MAAM,WAAW,0BAA0B;IACzC,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC;CACvC"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ //# sourceMappingURL=global-user-properties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-user-properties.js","sourceRoot":"","sources":["../../../src/typings/global-user-properties.ts"],"names":[],"mappings":"","sourcesContent":["import { EnrichmentPlugin } from '@amplitude/analytics-types';\n\nexport interface Options {\n /**\n * Whether or not the orignal user_properties field should be kept on the event\n */\n shouldKeepOriginalUserProperties?: boolean;\n}\n\nexport interface GlobalUserPropertiesPlugin {\n (options?: Options): EnrichmentPlugin;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { GlobalUserPropertiesPlugin } from './typings/global-user-properties';
2
+ export declare const globalUserPropertiesPlugin: GlobalUserPropertiesPlugin;
3
+ //# sourceMappingURL=global-user-properties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-user-properties.d.ts","sourceRoot":"","sources":["../../src/global-user-properties.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAW,MAAM,kCAAkC,CAAC;AAGvF,eAAO,MAAM,0BAA0B,EAAE,0BAoBxC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { __awaiter, __generator } from "tslib";
2
+ import { isAmplitudeIdentifyEvent, isTrackEvent } from './helpers';
3
+ export var globalUserPropertiesPlugin = function (options) {
4
+ var _this = this;
5
+ if (options === void 0) { options = {}; }
6
+ var plugin = {
7
+ name: '@amplitude/plugin-global-user-properties',
8
+ type: 'enrichment',
9
+ /* Note: The promise is because of the interface, not because this has any asynchronous behavior */
10
+ execute: function (event) { return __awaiter(_this, void 0, void 0, function () {
11
+ return __generator(this, function (_a) {
12
+ if (isTrackEvent(event) || isAmplitudeIdentifyEvent(event)) {
13
+ event.global_user_properties = event.user_properties;
14
+ if (!options.shouldKeepOriginalUserProperties) {
15
+ delete event.user_properties;
16
+ }
17
+ }
18
+ return [2 /*return*/, event];
19
+ });
20
+ }); },
21
+ };
22
+ return plugin;
23
+ };
24
+ //# sourceMappingURL=global-user-properties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-user-properties.js","sourceRoot":"","sources":["../../src/global-user-properties.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEnE,MAAM,CAAC,IAAM,0BAA0B,GAA+B,UAAU,OAAqB;IAA/B,iBAoBrE;IApB+E,wBAAA,EAAA,YAAqB;IACnG,IAAM,MAAM,GAAqB;QAC/B,IAAI,EAAE,0CAA0C;QAChD,IAAI,EAAE,YAAY;QAElB,mGAAmG;QACnG,OAAO,EAAE,UAAO,KAAY;;gBAC1B,IAAI,YAAY,CAAC,KAAK,CAAC,IAAI,wBAAwB,CAAC,KAAK,CAAC,EAAE;oBAC1D,KAAK,CAAC,sBAAsB,GAAG,KAAK,CAAC,eAAe,CAAC;oBAErD,IAAI,CAAC,OAAO,CAAC,gCAAgC,EAAE;wBAC7C,OAAO,KAAK,CAAC,eAAe,CAAC;qBAC9B;iBACF;gBAED,sBAAO,KAAK,EAAC;;aACd;KACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import { EnrichmentPlugin, Event } from '@amplitude/analytics-types';\nimport { GlobalUserPropertiesPlugin, Options } from './typings/global-user-properties';\nimport { isAmplitudeIdentifyEvent, isTrackEvent } from './helpers';\n\nexport const globalUserPropertiesPlugin: GlobalUserPropertiesPlugin = function (options: Options = {}) {\n const plugin: EnrichmentPlugin = {\n name: '@amplitude/plugin-global-user-properties',\n type: 'enrichment',\n\n /* Note: The promise is because of the interface, not because this has any asynchronous behavior */\n execute: async (event: Event): Promise<Event> => {\n if (isTrackEvent(event) || isAmplitudeIdentifyEvent(event)) {\n event.global_user_properties = event.user_properties;\n\n if (!options.shouldKeepOriginalUserProperties) {\n delete event.user_properties;\n }\n }\n\n return event;\n },\n };\n\n return plugin;\n};\n"]}
@@ -0,0 +1,4 @@
1
+ import { Event, TrackEvent, IdentifyEvent } from '@amplitude/analytics-types';
2
+ export declare const isTrackEvent: (event: Event) => event is TrackEvent;
3
+ export declare const isAmplitudeIdentifyEvent: (event: Event) => event is IdentifyEvent;
4
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAoB,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAIhG,eAAO,MAAM,YAAY,UAAW,KAAK,wBAExC,CAAC;AAEF,eAAO,MAAM,wBAAwB,UAAW,KAAK,2BAEpD,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { SpecialEventType } from '@amplitude/analytics-types';
2
+ var specialAmplitudeEvents = new Set(Object.values(SpecialEventType));
3
+ export var isTrackEvent = function (event) {
4
+ return !specialAmplitudeEvents.has(event.event_type);
5
+ };
6
+ export var isAmplitudeIdentifyEvent = function (event) {
7
+ return event.event_type === SpecialEventType.IDENTIFY;
8
+ };
9
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,gBAAgB,EAAiB,MAAM,4BAA4B,CAAC;AAEhG,IAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAExE,MAAM,CAAC,IAAM,YAAY,GAAG,UAAC,KAAY;IACvC,OAAO,CAAC,sBAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,UAA8B,CAAC,CAAC;AAC3E,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,wBAAwB,GAAG,UAAC,KAAY;IACnD,OAAO,KAAK,CAAC,UAAU,KAAK,gBAAgB,CAAC,QAAQ,CAAC;AACxD,CAAC,CAAC","sourcesContent":["import { Event, TrackEvent, SpecialEventType, IdentifyEvent } from '@amplitude/analytics-types';\n\nconst specialAmplitudeEvents = new Set(Object.values(SpecialEventType));\n\nexport const isTrackEvent = (event: Event): event is TrackEvent => {\n return !specialAmplitudeEvents.has(event.event_type as SpecialEventType);\n};\n\nexport const isAmplitudeIdentifyEvent = (event: Event): event is IdentifyEvent => {\n return event.event_type === SpecialEventType.IDENTIFY;\n};\n"]}
@@ -0,0 +1,4 @@
1
+ export { globalUserPropertiesPlugin } from './global-user-properties';
2
+ export { globalUserPropertiesPlugin as plugin } from './global-user-properties';
3
+ export { GlobalUserPropertiesPlugin, Options } from './typings/global-user-properties';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,0BAA0B,IAAI,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,0BAA0B,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { globalUserPropertiesPlugin } from './global-user-properties';
2
+ export { globalUserPropertiesPlugin as plugin } from './global-user-properties';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,0BAA0B,IAAI,MAAM,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["export { globalUserPropertiesPlugin } from './global-user-properties';\nexport { globalUserPropertiesPlugin as plugin } from './global-user-properties';\nexport { GlobalUserPropertiesPlugin, Options } from './typings/global-user-properties';\n"]}
@@ -0,0 +1,11 @@
1
+ import { EnrichmentPlugin } from '@amplitude/analytics-types';
2
+ export interface Options {
3
+ /**
4
+ * Whether or not the orignal user_properties field should be kept on the event
5
+ */
6
+ shouldKeepOriginalUserProperties?: boolean;
7
+ }
8
+ export interface GlobalUserPropertiesPlugin {
9
+ (options?: Options): EnrichmentPlugin;
10
+ }
11
+ //# sourceMappingURL=global-user-properties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-user-properties.d.ts","sourceRoot":"","sources":["../../../src/typings/global-user-properties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,gCAAgC,CAAC,EAAE,OAAO,CAAC;CAC5C;AAED,MAAM,WAAW,0BAA0B;IACzC,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC;CACvC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=global-user-properties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-user-properties.js","sourceRoot":"","sources":["../../../src/typings/global-user-properties.ts"],"names":[],"mappings":"","sourcesContent":["import { EnrichmentPlugin } from '@amplitude/analytics-types';\n\nexport interface Options {\n /**\n * Whether or not the orignal user_properties field should be kept on the event\n */\n shouldKeepOriginalUserProperties?: boolean;\n}\n\nexport interface GlobalUserPropertiesPlugin {\n (options?: Options): EnrichmentPlugin;\n}\n"]}
@@ -0,0 +1 @@
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).amplitude={})}(this,(function(e){"use strict";function n(e,n,t,r){return new(t||(t=Promise))((function(o,i){function u(e){try{a(r.next(e))}catch(e){i(e)}}function l(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(u,l)}a((r=r.apply(e,n||[])).next())}))}function t(e,n){var t,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(a){return function(l){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(u=0)),u;)try{if(t=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return u.label++,{value:l[1],done:!1};case 5:u.label++,r=l[1],l=[0];continue;case 7:l=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==l[0]&&2!==l[0])){u=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){u.label=l[1];break}if(6===l[0]&&u.label<o[1]){u.label=o[1],o=l;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(l);break}o[2]&&u.ops.pop(),u.trys.pop();continue}l=n.call(e,u)}catch(e){l=[6,e],r=0}finally{t=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,a])}}}var r,o,i;!function(e){e.SET="$set",e.SET_ONCE="$setOnce",e.ADD="$add",e.APPEND="$append",e.PREPEND="$prepend",e.REMOVE="$remove",e.PREINSERT="$preInsert",e.POSTINSERT="$postInsert",e.UNSET="$unset",e.CLEAR_ALL="$clearAll"}(r||(r={})),function(e){e.REVENUE_PRODUCT_ID="$productId",e.REVENUE_QUANTITY="$quantity",e.REVENUE_PRICE="$price",e.REVENUE_TYPE="$revenueType",e.REVENUE="$revenue"}(o||(o={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(i||(i={}));var u=new Set(Object.values(i)),l=function(e){var r=this;return void 0===e&&(e={}),{name:"@amplitude/plugin-global-user-properties",type:"enrichment",execute:function(o){return n(r,void 0,void 0,(function(){return t(this,(function(n){return(function(e){return!u.has(e.event_type)}(o)||function(e){return e.event_type===i.IDENTIFY}(o))&&(o.global_user_properties=o.user_properties,e.shouldKeepOriginalUserProperties||delete o.user_properties),[2,o]}))}))}}};e.globalUserPropertiesPlugin=l,e.plugin=l,Object.defineProperty(e,"__esModule",{value:!0})}));
@@ -0,0 +1,3 @@
1
+ import { GlobalUserPropertiesPlugin } from './typings/global-user-properties';
2
+ export declare const globalUserPropertiesPlugin: GlobalUserPropertiesPlugin;
3
+ //# sourceMappingURL=global-user-properties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-user-properties.d.ts","sourceRoot":"","sources":["../../src/global-user-properties.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAW,MAAM,kCAAkC,CAAC;AAGvF,eAAO,MAAM,0BAA0B,EAAE,0BAoBxC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Event, TrackEvent, IdentifyEvent } from '@amplitude/analytics-types';
2
+ export declare const isTrackEvent: (event: Event) => event is TrackEvent;
3
+ export declare const isAmplitudeIdentifyEvent: (event: Event) => event is IdentifyEvent;
4
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAoB,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAIhG,eAAO,MAAM,YAAY,UAAW,KAAK,wBAExC,CAAC;AAEF,eAAO,MAAM,wBAAwB,UAAW,KAAK,2BAEpD,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { globalUserPropertiesPlugin } from './global-user-properties';
2
+ export { globalUserPropertiesPlugin as plugin } from './global-user-properties';
3
+ export { GlobalUserPropertiesPlugin, Options } from './typings/global-user-properties';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,0BAA0B,IAAI,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,0BAA0B,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { EnrichmentPlugin } from '@amplitude/analytics-types';
2
+ export interface Options {
3
+ /**
4
+ * Whether or not the orignal user_properties field should be kept on the event
5
+ */
6
+ shouldKeepOriginalUserProperties?: boolean;
7
+ }
8
+ export interface GlobalUserPropertiesPlugin {
9
+ (options?: Options): EnrichmentPlugin;
10
+ }
11
+ //# sourceMappingURL=global-user-properties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-user-properties.d.ts","sourceRoot":"","sources":["../../../src/typings/global-user-properties.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,MAAM,WAAW,OAAO;IACtB;;OAEG;IACH,gCAAgC,CAAC,EAAE,OAAO,CAAC;CAC5C;AAED,MAAM,WAAW,0BAA0B;IACzC,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC;CACvC"}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@amplitude/plugin-global-user-properties",
3
+ "version": "1.1.0",
4
+ "description": "An event enrichment plugin that adds the experimental global user properties field to events",
5
+ "author": "Amplitude Inc",
6
+ "homepage": "https://github.com/amplitude/Amplitude-TypeScript",
7
+ "license": "MIT",
8
+ "main": "lib/cjs/index.js",
9
+ "module": "lib/esm/index.js",
10
+ "types": "lib/esm/index.d.ts",
11
+ "sideEffects": false,
12
+ "publishConfig": {
13
+ "access": "public",
14
+ "tag": "latest"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/amplitude/Amplitude-TypeScript.git"
19
+ },
20
+ "scripts": {
21
+ "build": "yarn bundle && yarn build:es5 && yarn build:esm",
22
+ "bundle": "rollup --config rollup.config.js",
23
+ "build:es5": "tsc -p ./tsconfig.es5.json",
24
+ "build:esm": "tsc -p ./tsconfig.esm.json",
25
+ "clean": "rimraf node_modules lib coverage",
26
+ "fix": "yarn fix:eslint & yarn fix:prettier",
27
+ "fix:eslint": "eslint '{src,test}/**/*.ts' --fix",
28
+ "fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
29
+ "lint": "yarn lint:eslint & yarn lint:prettier",
30
+ "lint:eslint": "eslint '{src,test}/**/*.ts'",
31
+ "lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
32
+ "test": "jest",
33
+ "typecheck": "tsc -p ./tsconfig.json"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/amplitude/Amplitude-TypeScript/issues"
37
+ },
38
+ "dependencies": {
39
+ "@amplitude/analytics-types": "^2.2.0",
40
+ "tslib": "^2.4.1"
41
+ },
42
+ "devDependencies": {
43
+ "@amplitude/analytics-browser": "^2.3.1",
44
+ "@rollup/plugin-commonjs": "^23.0.4",
45
+ "@rollup/plugin-node-resolve": "^15.0.1",
46
+ "@rollup/plugin-typescript": "^10.0.1",
47
+ "rollup": "^2.79.1",
48
+ "rollup-plugin-execute": "^1.1.1",
49
+ "rollup-plugin-gzip": "^3.1.0",
50
+ "rollup-plugin-terser": "^7.0.2"
51
+ },
52
+ "files": [
53
+ "lib"
54
+ ],
55
+ "gitHead": "98e7483e397d83cec498d6284efe92f03f0632c2"
56
+ }