@amplitude/plugin-global-user-properties 1.1.0 → 1.2.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 +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"}
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,0BA+BxC,CAAC"}
@@ -10,12 +10,21 @@ var globalUserPropertiesPlugin = function (options) {
10
10
  type: 'enrichment',
11
11
  /* Note: The promise is because of the interface, not because this has any asynchronous behavior */
12
12
  execute: function (event) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
13
+ var globalUserProperties;
13
14
  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
- }
15
+ if (!(0, helpers_1.isTrackEvent)(event) && !(0, helpers_1.isAmplitudeIdentifyEvent)(event)) {
16
+ return [2 /*return*/, event];
17
+ }
18
+ globalUserProperties = event.user_properties;
19
+ if (options.propertyTransform && globalUserProperties) {
20
+ globalUserProperties = options.propertyTransform(globalUserProperties);
21
+ }
22
+ if (!globalUserProperties) {
23
+ return [2 /*return*/, event];
24
+ }
25
+ event.global_user_properties = globalUserProperties;
26
+ if (!options.shouldKeepOriginalUserProperties) {
27
+ delete event.user_properties;
19
28
  }
20
29
  return [2 /*return*/, event];
21
30
  });
@@ -1 +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"]}
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,iBA+BrE;IA/B+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,CAAC,IAAA,sBAAY,EAAC,KAAK,CAAC,IAAI,CAAC,IAAA,kCAAwB,EAAC,KAAK,CAAC,EAAE;oBAC5D,sBAAO,KAAK,EAAC;iBACd;gBAEG,oBAAoB,GAAG,KAAK,CAAC,eAAe,CAAC;gBACjD,IAAI,OAAO,CAAC,iBAAiB,IAAI,oBAAoB,EAAE;oBACrD,oBAAoB,GAAG,OAAO,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;iBACxE;gBAED,IAAI,CAAC,oBAAoB,EAAE;oBACzB,sBAAO,KAAK,EAAC;iBACd;gBAED,KAAK,CAAC,sBAAsB,GAAG,oBAAoB,CAAC;gBAEpD,IAAI,CAAC,OAAO,CAAC,gCAAgC,EAAE;oBAC7C,OAAO,KAAK,CAAC,eAAe,CAAC;iBAC9B;gBAED,sBAAO,KAAK,EAAC;;aACd;KACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AA/BW,QAAA,0BAA0B,8BA+BrC","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 return event;\n }\n\n let globalUserProperties = event.user_properties;\n if (options.propertyTransform && globalUserProperties) {\n globalUserProperties = options.propertyTransform(globalUserProperties);\n }\n\n if (!globalUserProperties) {\n return event;\n }\n\n event.global_user_properties = globalUserProperties;\n\n if (!options.shouldKeepOriginalUserProperties) {\n delete event.user_properties;\n }\n\n return event;\n },\n };\n\n return plugin;\n};\n"]}
@@ -1,5 +1,16 @@
1
1
  import { EnrichmentPlugin } from '@amplitude/analytics-types';
2
2
  export interface Options {
3
+ /**
4
+ * A configuration to modify the user properties before they are attached as global user properties
5
+ *
6
+ * @param properties The original user properties on the event
7
+ * @returns The modified global user properties. Returning no properties is possible
8
+ */
9
+ propertyTransform?: (properties: {
10
+ [key: string]: any;
11
+ }) => {
12
+ [key: string]: any;
13
+ } | undefined;
3
14
  /**
4
15
  * Whether or not the orignal user_properties field should be kept on the event
5
16
  */
@@ -1 +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"}
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;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,CAAC,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,KAAK;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,GAAG,SAAS,CAAC;IAC/F;;OAEG;IACH,gCAAgC,CAAC,EAAE,OAAO,CAAC;CAC5C;AAED,MAAM,WAAW,0BAA0B;IACzC,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC;CACvC"}
@@ -1 +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"]}
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 * A configuration to modify the user properties before they are attached as global user properties\n *\n * @param properties The original user properties on the event\n * @returns The modified global user properties. Returning no properties is possible\n */\n propertyTransform?: (properties: { [key: string]: any }) => { [key: string]: any } | undefined;\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"]}
@@ -1 +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"}
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,0BA+BxC,CAAC"}
@@ -8,12 +8,21 @@ export var globalUserPropertiesPlugin = function (options) {
8
8
  type: 'enrichment',
9
9
  /* Note: The promise is because of the interface, not because this has any asynchronous behavior */
10
10
  execute: function (event) { return __awaiter(_this, void 0, void 0, function () {
11
+ var globalUserProperties;
11
12
  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
- }
13
+ if (!isTrackEvent(event) && !isAmplitudeIdentifyEvent(event)) {
14
+ return [2 /*return*/, event];
15
+ }
16
+ globalUserProperties = event.user_properties;
17
+ if (options.propertyTransform && globalUserProperties) {
18
+ globalUserProperties = options.propertyTransform(globalUserProperties);
19
+ }
20
+ if (!globalUserProperties) {
21
+ return [2 /*return*/, event];
22
+ }
23
+ event.global_user_properties = globalUserProperties;
24
+ if (!options.shouldKeepOriginalUserProperties) {
25
+ delete event.user_properties;
17
26
  }
18
27
  return [2 /*return*/, event];
19
28
  });
@@ -1 +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"]}
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,iBA+BrE;IA/B+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,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,EAAE;oBAC5D,sBAAO,KAAK,EAAC;iBACd;gBAEG,oBAAoB,GAAG,KAAK,CAAC,eAAe,CAAC;gBACjD,IAAI,OAAO,CAAC,iBAAiB,IAAI,oBAAoB,EAAE;oBACrD,oBAAoB,GAAG,OAAO,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;iBACxE;gBAED,IAAI,CAAC,oBAAoB,EAAE;oBACzB,sBAAO,KAAK,EAAC;iBACd;gBAED,KAAK,CAAC,sBAAsB,GAAG,oBAAoB,CAAC;gBAEpD,IAAI,CAAC,OAAO,CAAC,gCAAgC,EAAE;oBAC7C,OAAO,KAAK,CAAC,eAAe,CAAC;iBAC9B;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 return event;\n }\n\n let globalUserProperties = event.user_properties;\n if (options.propertyTransform && globalUserProperties) {\n globalUserProperties = options.propertyTransform(globalUserProperties);\n }\n\n if (!globalUserProperties) {\n return event;\n }\n\n event.global_user_properties = globalUserProperties;\n\n if (!options.shouldKeepOriginalUserProperties) {\n delete event.user_properties;\n }\n\n return event;\n },\n };\n\n return plugin;\n};\n"]}
@@ -1,5 +1,16 @@
1
1
  import { EnrichmentPlugin } from '@amplitude/analytics-types';
2
2
  export interface Options {
3
+ /**
4
+ * A configuration to modify the user properties before they are attached as global user properties
5
+ *
6
+ * @param properties The original user properties on the event
7
+ * @returns The modified global user properties. Returning no properties is possible
8
+ */
9
+ propertyTransform?: (properties: {
10
+ [key: string]: any;
11
+ }) => {
12
+ [key: string]: any;
13
+ } | undefined;
3
14
  /**
4
15
  * Whether or not the orignal user_properties field should be kept on the event
5
16
  */
@@ -1 +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"}
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;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,CAAC,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,KAAK;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,GAAG,SAAS,CAAC;IAC/F;;OAEG;IACH,gCAAgC,CAAC,EAAE,OAAO,CAAC;CAC5C;AAED,MAAM,WAAW,0BAA0B;IACzC,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAC;CACvC"}
@@ -1 +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"]}
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 * A configuration to modify the user properties before they are attached as global user properties\n *\n * @param properties The original user properties on the event\n * @returns The modified global user properties. Returning no properties is possible\n */\n propertyTransform?: (properties: { [key: string]: any }) => { [key: string]: any } | undefined;\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"]}
@@ -1 +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})}));
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{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(u,a)}l((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:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(l){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(u=0)),u;)try{if(t=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=n.call(e,u)}catch(e){a=[6,e],r=0}finally{t=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}}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)),a=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(){var n;return t(this,(function(t){return function(e){return!u.has(e.event_type)}(o)||function(e){return e.event_type===i.IDENTIFY}(o)?(n=o.user_properties,e.propertyTransform&&n&&(n=e.propertyTransform(n)),n?(o.global_user_properties=n,e.shouldKeepOriginalUserProperties||delete o.user_properties,[2,o]):[2,o]):[2,o]}))}))}}};e.globalUserPropertiesPlugin=a,e.plugin=a,Object.defineProperty(e,"__esModule",{value:!0})}));
Binary file
@@ -1 +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"}
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,0BA+BxC,CAAC"}
@@ -1,5 +1,16 @@
1
1
  import { EnrichmentPlugin } from '@amplitude/analytics-types';
2
2
  export interface Options {
3
+ /**
4
+ * A configuration to modify the user properties before they are attached as global user properties
5
+ *
6
+ * @param properties The original user properties on the event
7
+ * @returns The modified global user properties. Returning no properties is possible
8
+ */
9
+ propertyTransform?: (properties: {
10
+ [key: string]: any;
11
+ }) => {
12
+ [key: string]: any;
13
+ } | undefined;
3
14
  /**
4
15
  * Whether or not the orignal user_properties field should be kept on the event
5
16
  */
@@ -1 +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"}
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;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,CAAC,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,KAAK;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,GAAG,SAAS,CAAC;IAC/F;;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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amplitude/plugin-global-user-properties",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "An event enrichment plugin that adds the experimental global user properties field to events",
5
5
  "author": "Amplitude Inc",
6
6
  "homepage": "https://github.com/amplitude/Amplitude-TypeScript",
@@ -40,7 +40,7 @@
40
40
  "tslib": "^2.4.1"
41
41
  },
42
42
  "devDependencies": {
43
- "@amplitude/analytics-browser": "^2.3.1",
43
+ "@amplitude/analytics-browser": "^2.3.2",
44
44
  "@rollup/plugin-commonjs": "^23.0.4",
45
45
  "@rollup/plugin-node-resolve": "^15.0.1",
46
46
  "@rollup/plugin-typescript": "^10.0.1",
@@ -52,5 +52,5 @@
52
52
  "files": [
53
53
  "lib"
54
54
  ],
55
- "gitHead": "98e7483e397d83cec498d6284efe92f03f0632c2"
55
+ "gitHead": "7c16ef52be4a8fcdb7165db03c51d938a3dd9d64"
56
56
  }