@amplitude/analytics-browser 0.2.4 → 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.
Files changed (101) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +8 -22
  3. package/lib/cjs/attribution.d.ts +1 -1
  4. package/lib/cjs/attribution.d.ts.map +1 -1
  5. package/lib/cjs/attribution.js +5 -17
  6. package/lib/cjs/attribution.js.map +1 -1
  7. package/lib/cjs/browser-client.d.ts +96 -81
  8. package/lib/cjs/browser-client.d.ts.map +1 -1
  9. package/lib/cjs/browser-client.js +194 -196
  10. package/lib/cjs/browser-client.js.map +1 -1
  11. package/lib/cjs/config.d.ts +11 -7
  12. package/lib/cjs/config.d.ts.map +1 -1
  13. package/lib/cjs/config.js +33 -34
  14. package/lib/cjs/config.js.map +1 -1
  15. package/lib/cjs/cookie-migration/index.d.ts +5 -0
  16. package/lib/cjs/cookie-migration/index.d.ts.map +1 -0
  17. package/lib/cjs/cookie-migration/index.js +55 -0
  18. package/lib/cjs/cookie-migration/index.js.map +1 -0
  19. package/lib/cjs/plugins/context.js +1 -1
  20. package/lib/cjs/plugins/context.js.map +1 -1
  21. package/lib/cjs/session-manager.d.ts +3 -3
  22. package/lib/cjs/session-manager.d.ts.map +1 -1
  23. package/lib/cjs/session-manager.js +10 -16
  24. package/lib/cjs/session-manager.js.map +1 -1
  25. package/lib/cjs/storage/cookie.d.ts +2 -2
  26. package/lib/cjs/storage/cookie.d.ts.map +1 -1
  27. package/lib/cjs/storage/cookie.js +16 -11
  28. package/lib/cjs/storage/cookie.js.map +1 -1
  29. package/lib/cjs/storage/local-storage.d.ts +1 -0
  30. package/lib/cjs/storage/local-storage.d.ts.map +1 -1
  31. package/lib/cjs/storage/local-storage.js +4 -1
  32. package/lib/cjs/storage/local-storage.js.map +1 -1
  33. package/lib/cjs/storage/memory.d.ts +1 -0
  34. package/lib/cjs/storage/memory.d.ts.map +1 -1
  35. package/lib/cjs/storage/memory.js +4 -0
  36. package/lib/cjs/storage/memory.js.map +1 -1
  37. package/lib/cjs/storage/utm-cookie.js +1 -1
  38. package/lib/cjs/storage/utm-cookie.js.map +1 -1
  39. package/lib/cjs/transports/fetch.d.ts.map +1 -1
  40. package/lib/cjs/transports/fetch.js +0 -2
  41. package/lib/cjs/transports/fetch.js.map +1 -1
  42. package/lib/cjs/utils/snippet-helper.d.ts +1 -0
  43. package/lib/cjs/utils/snippet-helper.d.ts.map +1 -1
  44. package/lib/cjs/utils/snippet-helper.js +1 -0
  45. package/lib/cjs/utils/snippet-helper.js.map +1 -1
  46. package/lib/cjs/version.d.ts +1 -1
  47. package/lib/cjs/version.js +1 -1
  48. package/lib/cjs/version.js.map +1 -1
  49. package/lib/esm/attribution.d.ts +1 -1
  50. package/lib/esm/attribution.d.ts.map +1 -1
  51. package/lib/esm/attribution.js +4 -16
  52. package/lib/esm/attribution.js.map +1 -1
  53. package/lib/esm/browser-client.d.ts +96 -81
  54. package/lib/esm/browser-client.d.ts.map +1 -1
  55. package/lib/esm/browser-client.js +197 -182
  56. package/lib/esm/browser-client.js.map +1 -1
  57. package/lib/esm/config.d.ts +11 -7
  58. package/lib/esm/config.d.ts.map +1 -1
  59. package/lib/esm/config.js +28 -29
  60. package/lib/esm/config.js.map +1 -1
  61. package/lib/esm/cookie-migration/index.d.ts +5 -0
  62. package/lib/esm/cookie-migration/index.d.ts.map +1 -0
  63. package/lib/esm/cookie-migration/index.js +50 -0
  64. package/lib/esm/cookie-migration/index.js.map +1 -0
  65. package/lib/esm/plugins/context.js +2 -2
  66. package/lib/esm/plugins/context.js.map +1 -1
  67. package/lib/esm/session-manager.d.ts +3 -3
  68. package/lib/esm/session-manager.d.ts.map +1 -1
  69. package/lib/esm/session-manager.js +8 -14
  70. package/lib/esm/session-manager.js.map +1 -1
  71. package/lib/esm/storage/cookie.d.ts +2 -2
  72. package/lib/esm/storage/cookie.d.ts.map +1 -1
  73. package/lib/esm/storage/cookie.js +16 -11
  74. package/lib/esm/storage/cookie.js.map +1 -1
  75. package/lib/esm/storage/local-storage.d.ts +1 -0
  76. package/lib/esm/storage/local-storage.d.ts.map +1 -1
  77. package/lib/esm/storage/local-storage.js +4 -1
  78. package/lib/esm/storage/local-storage.js.map +1 -1
  79. package/lib/esm/storage/memory.d.ts +1 -0
  80. package/lib/esm/storage/memory.d.ts.map +1 -1
  81. package/lib/esm/storage/memory.js +4 -0
  82. package/lib/esm/storage/memory.js.map +1 -1
  83. package/lib/esm/storage/utm-cookie.js +1 -1
  84. package/lib/esm/storage/utm-cookie.js.map +1 -1
  85. package/lib/esm/transports/fetch.d.ts.map +1 -1
  86. package/lib/esm/transports/fetch.js +0 -2
  87. package/lib/esm/transports/fetch.js.map +1 -1
  88. package/lib/esm/utils/snippet-helper.d.ts +1 -0
  89. package/lib/esm/utils/snippet-helper.d.ts.map +1 -1
  90. package/lib/esm/utils/snippet-helper.js +1 -0
  91. package/lib/esm/utils/snippet-helper.js.map +1 -1
  92. package/lib/esm/version.d.ts +1 -1
  93. package/lib/esm/version.js +1 -1
  94. package/lib/esm/version.js.map +1 -1
  95. package/lib/scripts/amplitude-min.js +1 -1
  96. package/lib/scripts/amplitude-min.js.gz +0 -0
  97. package/lib/scripts/amplitude-min.umd.js +1 -1
  98. package/lib/scripts/amplitude-min.umd.js.gz +0 -0
  99. package/lib/scripts/amplitude-snippet-instructions.html +5 -0
  100. package/lib/scripts/amplitude-snippet-min.js +1 -0
  101. package/package.json +13 -9
@@ -26,12 +26,10 @@ var FetchTransport = /** @class */ (function () {
26
26
  return [4 /*yield*/, fetch(serverUrl, options)];
27
27
  case 1:
28
28
  response = _a.sent();
29
- if (!response.ok) return [3 /*break*/, 3];
30
29
  return [4 /*yield*/, response.json()];
31
30
  case 2:
32
31
  responsePayload = _a.sent();
33
32
  return [2 /*return*/, (0, analytics_core_1.buildResponse)(responsePayload)];
34
- case 3: throw new Error('Server did not return a response');
35
33
  }
36
34
  });
37
35
  });
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/transports/fetch.ts"],"names":[],"mappings":";;;AAAA,4DAA0D;AAG1D;IAAA;IAsBA,CAAC;IArBO,6BAAI,GAAV,UAAW,SAAiB,EAAE,OAAgB;;;;;;wBAC5C,wBAAwB;wBACxB,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;4BAChC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;yBACpD;wBACK,OAAO,GAAgB;4BAC3B,OAAO,EAAE;gCACP,cAAc,EAAE,kBAAkB;gCAClC,MAAM,EAAE,KAAK;6BACd;4BACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;4BAC7B,MAAM,EAAE,MAAM;yBACf,CAAC;wBACe,qBAAM,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,EAAA;;wBAA1C,QAAQ,GAAG,SAA+B;6BAC5C,QAAQ,CAAC,EAAE,EAAX,wBAAW;wBAEgC,qBAAM,QAAQ,CAAC,IAAI,EAAE,EAAA;;wBAA5D,eAAe,GAAwB,SAAqB;wBAClE,sBAAO,IAAA,8BAAa,EAAC,eAAe,CAAC,EAAC;4BAExC,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;;;;KACrD;IACH,qBAAC;AAAD,CAAC,AAtBD,IAsBC;AAtBY,wCAAc","sourcesContent":["import { buildResponse } from '@amplitude/analytics-core';\nimport { Payload, Response, Transport } from '@amplitude/analytics-types';\n\nexport class FetchTransport implements Transport {\n async send(serverUrl: string, payload: Payload): Promise<Response | null> {\n /* istanbul ignore if */\n if (typeof fetch === 'undefined') {\n throw new Error('FetchTransport is not supported');\n }\n const options: RequestInit = {\n headers: {\n 'Content-Type': 'application/json',\n Accept: '*/*',\n },\n body: JSON.stringify(payload),\n method: 'POST',\n };\n const response = await fetch(serverUrl, options);\n if (response.ok) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const responsePayload: Record<string, any> = await response.json();\n return buildResponse(responsePayload);\n }\n throw new Error('Server did not return a response');\n }\n}\n"]}
1
+ {"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/transports/fetch.ts"],"names":[],"mappings":";;;AAAA,4DAA0D;AAG1D;IAAA;IAmBA,CAAC;IAlBO,6BAAI,GAAV,UAAW,SAAiB,EAAE,OAAgB;;;;;;wBAC5C,wBAAwB;wBACxB,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;4BAChC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;yBACpD;wBACK,OAAO,GAAgB;4BAC3B,OAAO,EAAE;gCACP,cAAc,EAAE,kBAAkB;gCAClC,MAAM,EAAE,KAAK;6BACd;4BACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;4BAC7B,MAAM,EAAE,MAAM;yBACf,CAAC;wBACe,qBAAM,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,EAAA;;wBAA1C,QAAQ,GAAG,SAA+B;wBAEH,qBAAM,QAAQ,CAAC,IAAI,EAAE,EAAA;;wBAA5D,eAAe,GAAwB,SAAqB;wBAClE,sBAAO,IAAA,8BAAa,EAAC,eAAe,CAAC,EAAC;;;;KACvC;IACH,qBAAC;AAAD,CAAC,AAnBD,IAmBC;AAnBY,wCAAc","sourcesContent":["import { buildResponse } from '@amplitude/analytics-core';\nimport { Payload, Response, Transport } from '@amplitude/analytics-types';\n\nexport class FetchTransport implements Transport {\n async send(serverUrl: string, payload: Payload): Promise<Response | null> {\n /* istanbul ignore if */\n if (typeof fetch === 'undefined') {\n throw new Error('FetchTransport is not supported');\n }\n const options: RequestInit = {\n headers: {\n 'Content-Type': 'application/json',\n Accept: '*/*',\n },\n body: JSON.stringify(payload),\n method: 'POST',\n };\n const response = await fetch(serverUrl, options);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const responsePayload: Record<string, any> = await response.json();\n return buildResponse(responsePayload);\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { InstanceProxy, QueueProxy } from '@amplitude/analytics-types';
2
2
  /**
3
3
  * Applies the proxied functions on the proxied amplitude snippet to an instance of the real object.
4
+ * @ignore
4
5
  */
5
6
  export declare const runQueuedFunctions: (instance: object, queue: QueueProxy) => void;
6
7
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"snippet-helper.d.ts","sourceRoot":"","sources":["../../../src/utils/snippet-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,aAAa,EAAE,UAAU,EAAU,MAAM,4BAA4B,CAAC;AAEhG;;GAEG;AACH,eAAO,MAAM,kBAAkB,aAAc,MAAM,4BAElD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,8BAA8B,0CAY1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,aAAc,OAAO,8BAGhD,CAAC"}
1
+ {"version":3,"file":"snippet-helper.d.ts","sourceRoot":"","sources":["../../../src/utils/snippet-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,aAAa,EAAE,UAAU,EAAU,MAAM,4BAA4B,CAAC;AAEhG;;;GAGG;AACH,eAAO,MAAM,kBAAkB,aAAc,MAAM,4BAElD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,8BAA8B,0CAY1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,aAAc,OAAO,8BAGhD,CAAC"}
@@ -2,6 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
2
2
  exports.isInstanceProxy = exports.convertProxyObjectToRealObject = exports.runQueuedFunctions = void 0;
3
3
  /**
4
4
  * Applies the proxied functions on the proxied amplitude snippet to an instance of the real object.
5
+ * @ignore
5
6
  */
6
7
  var runQueuedFunctions = function (instance, queue) {
7
8
  (0, exports.convertProxyObjectToRealObject)(instance, queue);
@@ -1 +1 @@
1
- {"version":3,"file":"snippet-helper.js","sourceRoot":"","sources":["../../../src/utils/snippet-helper.ts"],"names":[],"mappings":";;AAEA;;GAEG;AACI,IAAM,kBAAkB,GAAG,UAAC,QAAgB,EAAE,KAAiB;IACpE,IAAA,sCAA8B,EAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AAClD,CAAC,CAAC;AAFW,QAAA,kBAAkB,sBAE7B;AAEF;;;GAGG;AACI,IAAM,8BAA8B,GAAG,UAAI,QAAW,EAAE,KAAiB;IAC9E,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC/B,IAAA,KAA0B,KAAK,CAAC,CAAC,CAAC,EAAhC,MAAI,UAAA,EAAE,IAAI,UAAA,EAAE,OAAO,aAAa,CAAC;QACzC,IAAM,EAAE,GAAG,QAAQ,IAAI,QAAQ,CAAC,MAAe,CAAC,CAAC;QACjD,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE;YAC5B,IAAM,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAA4B,CAAC;YACnE,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;gBACjC,OAAO,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,CAAC,CAAC;aAC1B;SACF;KACF;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAZW,QAAA,8BAA8B,kCAYzC;AAEF;;GAEG;AACI,IAAM,eAAe,GAAG,UAAC,QAAiB;IAC/C,IAAM,aAAa,GAAG,QAAyB,CAAC;IAChD,OAAO,aAAa,IAAI,aAAa,CAAC,EAAE,KAAK,SAAS,CAAC;AACzD,CAAC,CAAC;AAHW,QAAA,eAAe,mBAG1B","sourcesContent":["import { AmplitudeReturn, InstanceProxy, QueueProxy, Result } from '@amplitude/analytics-types';\n\n/**\n * Applies the proxied functions on the proxied amplitude snippet to an instance of the real object.\n */\nexport const runQueuedFunctions = (instance: object, queue: QueueProxy) => {\n convertProxyObjectToRealObject(instance, queue);\n};\n\n/**\n * Applies the proxied functions on the proxied object to an instance of the real object.\n * Used to convert proxied Identify and Revenue objects.\n */\nexport const convertProxyObjectToRealObject = <T>(instance: T, queue: QueueProxy): T => {\n for (let i = 0; i < queue.length; i++) {\n const { name, args, resolve } = queue[i];\n const fn = instance && instance[name as keyof T];\n if (typeof fn === 'function') {\n const result = fn.apply(instance, args) as AmplitudeReturn<Result>;\n if (typeof resolve === 'function') {\n resolve(result?.promise);\n }\n }\n }\n return instance;\n};\n\n/**\n * Check if the param is snippet proxy\n */\nexport const isInstanceProxy = (instance: unknown): instance is InstanceProxy => {\n const instanceProxy = instance as InstanceProxy;\n return instanceProxy && instanceProxy._q !== undefined;\n};\n"]}
1
+ {"version":3,"file":"snippet-helper.js","sourceRoot":"","sources":["../../../src/utils/snippet-helper.ts"],"names":[],"mappings":";;AAEA;;;GAGG;AACI,IAAM,kBAAkB,GAAG,UAAC,QAAgB,EAAE,KAAiB;IACpE,IAAA,sCAA8B,EAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;AAClD,CAAC,CAAC;AAFW,QAAA,kBAAkB,sBAE7B;AAEF;;;GAGG;AACI,IAAM,8BAA8B,GAAG,UAAI,QAAW,EAAE,KAAiB;IAC9E,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC/B,IAAA,KAA0B,KAAK,CAAC,CAAC,CAAC,EAAhC,MAAI,UAAA,EAAE,IAAI,UAAA,EAAE,OAAO,aAAa,CAAC;QACzC,IAAM,EAAE,GAAG,QAAQ,IAAI,QAAQ,CAAC,MAAe,CAAC,CAAC;QACjD,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE;YAC5B,IAAM,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAA4B,CAAC;YACnE,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;gBACjC,OAAO,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,CAAC,CAAC;aAC1B;SACF;KACF;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAZW,QAAA,8BAA8B,kCAYzC;AAEF;;GAEG;AACI,IAAM,eAAe,GAAG,UAAC,QAAiB;IAC/C,IAAM,aAAa,GAAG,QAAyB,CAAC;IAChD,OAAO,aAAa,IAAI,aAAa,CAAC,EAAE,KAAK,SAAS,CAAC;AACzD,CAAC,CAAC;AAHW,QAAA,eAAe,mBAG1B","sourcesContent":["import { AmplitudeReturn, InstanceProxy, QueueProxy, Result } from '@amplitude/analytics-types';\n\n/**\n * Applies the proxied functions on the proxied amplitude snippet to an instance of the real object.\n * @ignore\n */\nexport const runQueuedFunctions = (instance: object, queue: QueueProxy) => {\n convertProxyObjectToRealObject(instance, queue);\n};\n\n/**\n * Applies the proxied functions on the proxied object to an instance of the real object.\n * Used to convert proxied Identify and Revenue objects.\n */\nexport const convertProxyObjectToRealObject = <T>(instance: T, queue: QueueProxy): T => {\n for (let i = 0; i < queue.length; i++) {\n const { name, args, resolve } = queue[i];\n const fn = instance && instance[name as keyof T];\n if (typeof fn === 'function') {\n const result = fn.apply(instance, args) as AmplitudeReturn<Result>;\n if (typeof resolve === 'function') {\n resolve(result?.promise);\n }\n }\n }\n return instance;\n};\n\n/**\n * Check if the param is snippet proxy\n */\nexport const isInstanceProxy = (instance: unknown): instance is InstanceProxy => {\n const instanceProxy = instance as InstanceProxy;\n return instanceProxy && instanceProxy._q !== undefined;\n};\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.2.4";
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.2.4';
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.2.4';\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,5 +1,5 @@
1
1
  import { BrowserConfig, UTMData } from '@amplitude/analytics-types';
2
- export declare const trackAttributions: (config: BrowserConfig) => void;
2
+ export declare const getAttributions: (config: BrowserConfig) => Record<string, string>;
3
3
  export declare const getUtmParam: () => UTMData;
4
4
  export declare const getReferrer: () => Record<string, string | undefined>;
5
5
  export declare const getGclid: () => {
@@ -1 +1 @@
1
- {"version":3,"file":"attribution.d.ts","sourceRoot":"","sources":["../../src/attribution.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAkBpE,eAAO,MAAM,iBAAiB,WAAY,aAAa,SAoBtD,CAAC;AAEF,eAAO,MAAM,WAAW,QAAO,OAkB9B,CAAC;AAEF,eAAO,MAAM,WAAW,0CAYvB,CAAC;AAEF,eAAO,MAAM,QAAQ;;CAKpB,CAAC;AAEF,eAAO,MAAM,SAAS;;CAKrB,CAAC"}
1
+ {"version":3,"file":"attribution.d.ts","sourceRoot":"","sources":["../../src/attribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAkBpE,eAAO,MAAM,eAAe,WAAY,aAAa,KAAG,OAAO,MAAM,EAAE,MAAM,CAS5E,CAAC;AAEF,eAAO,MAAM,WAAW,QAAO,OAkB9B,CAAC;AAEF,eAAO,MAAM,WAAW,0CAYvB,CAAC;AAEF,eAAO,MAAM,QAAQ;;CAKpB,CAAC;AAEF,eAAO,MAAM,SAAS;;CAKrB,CAAC"}
@@ -1,22 +1,10 @@
1
- import { __assign, __read } from "tslib";
2
- import { Identify, identify } from '@amplitude/analytics-core';
1
+ import { __assign } from "tslib";
3
2
  import { UTM_CAMPAIGN, UTM_CONTENT, UTM_MEDIUM, UTM_SOURCE, UTM_TERM, UTMZ_SOURCE, UTMZ_MEDIUM, UTMZ_CAMPAIGN, UTMZ_TERM, UTMZ_CONTENT, GCLID, FBCLID, } from './constants';
4
3
  import { UTMCookie } from './storage/utm-cookie';
5
4
  import { getQueryParams } from './utils/query-params';
6
- export var trackAttributions = function (config) {
7
- var attribution = __assign(__assign(__assign(__assign({}, (config.includeUtm && getUtmParam())), (config.includeReferrer && getReferrer())), (config.includeGclid && getGclid())), (config.includeFbclid && getFbclid()));
8
- if (Object.keys(attribution).length === 0) {
9
- return;
10
- }
11
- var id = new Identify();
12
- Object.entries(attribution).forEach(function (_a) {
13
- var _b = __read(_a, 2), key = _b[0], value = _b[1];
14
- if (value) {
15
- id.setOnce("initial_".concat(key), value);
16
- id.set(key, value);
17
- }
18
- });
19
- void identify(undefined, undefined, id);
5
+ export var getAttributions = function (config) {
6
+ var attributions = __assign(__assign(__assign(__assign({}, (config.includeUtm && getUtmParam())), (config.includeReferrer && getReferrer())), (config.includeGclid && getGclid())), (config.includeFbclid && getFbclid()));
7
+ return attributions;
20
8
  };
21
9
  export var getUtmParam = function () {
22
10
  var params = getQueryParams();
@@ -1 +1 @@
1
- {"version":3,"file":"attribution.js","sourceRoot":"","sources":["../../src/attribution.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EACL,YAAY,EACZ,WAAW,EACX,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,WAAW,EACX,aAAa,EACb,SAAS,EACT,YAAY,EACZ,KAAK,EACL,MAAM,GACP,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,CAAC,IAAM,iBAAiB,GAAG,UAAC,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AM,CAAC,KAAK,CAAC,cAAM,GAAC,KAAK,IAAG,MAAM,CAAC,KAAK,CAAC,KAAE,CAAC,EAChD;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,SAAS,GAAG;;IACvB,IAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,oBACK,CAAC,MAAM,CAAC,MAAM,CAAC,cAAM,GAAC,MAAM,IAAG,MAAM,CAAC,MAAM,CAAC,KAAE,CAAC,EACnD;AACJ,CAAC,CAAC","sourcesContent":["import { Identify, identify } from '@amplitude/analytics-core';\nimport { BrowserConfig, UTMData } from '@amplitude/analytics-types';\nimport {\n UTM_CAMPAIGN,\n UTM_CONTENT,\n UTM_MEDIUM,\n UTM_SOURCE,\n UTM_TERM,\n UTMZ_SOURCE,\n UTMZ_MEDIUM,\n UTMZ_CAMPAIGN,\n UTMZ_TERM,\n UTMZ_CONTENT,\n GCLID,\n FBCLID,\n} from './constants';\nimport { UTMCookie } from './storage/utm-cookie';\nimport { getQueryParams } from './utils/query-params';\n\nexport const trackAttributions = (config: BrowserConfig) => {\n const attribution = {\n ...(config.includeUtm && getUtmParam()),\n ...(config.includeReferrer && getReferrer()),\n ...(config.includeGclid && getGclid()),\n ...(config.includeFbclid && getFbclid()),\n };\n\n if (Object.keys(attribution).length === 0) {\n return;\n }\n\n const id = new Identify();\n Object.entries(attribution).forEach(([key, value]: [string, string]) => {\n if (value) {\n id.setOnce(`initial_${key}`, value);\n id.set(key, value);\n }\n });\n void identify(undefined, undefined, id);\n};\n\nexport const getUtmParam = (): UTMData => {\n const params = getQueryParams();\n const utmStorage = new UTMCookie();\n const cookies = (utmStorage.isEnabled() && utmStorage.get('__utmz')) || {};\n\n const utmSource = params[UTM_SOURCE] || cookies[UTMZ_SOURCE];\n const utmMedium = params[UTM_MEDIUM] || cookies[UTMZ_MEDIUM];\n const utmCampaign = params[UTM_CAMPAIGN] || cookies[UTMZ_CAMPAIGN];\n const utmTerm = params[UTM_TERM] || cookies[UTMZ_TERM];\n const utmContent = params[UTM_CONTENT] || cookies[UTMZ_CONTENT];\n\n const data: UTMData = {};\n if (utmSource) data.utm_source = utmSource;\n if (utmMedium) data.utm_medium = utmMedium;\n if (utmCampaign) data.utm_campaign = utmCampaign;\n if (utmTerm) data.utm_term = utmTerm;\n if (utmContent) data.utm_content = utmContent;\n return data;\n};\n\nexport const getReferrer = () => {\n const data: Record<string, string | undefined> = {};\n try {\n const referrer = document.referrer || undefined;\n const referringDomain = referrer?.split('/')[2] ?? undefined;\n\n if (referrer !== undefined) data.referrer = referrer;\n if (referringDomain !== undefined) data.referring_domain = referringDomain;\n } catch {\n //\n }\n return data;\n};\n\nexport const getGclid = () => {\n const params = getQueryParams();\n return {\n ...(params[GCLID] && { [GCLID]: params[GCLID] }),\n };\n};\n\nexport const getFbclid = () => {\n const params = getQueryParams();\n return {\n ...(params[FBCLID] && { [FBCLID]: params[FBCLID] }),\n };\n};\n"]}
1
+ {"version":3,"file":"attribution.js","sourceRoot":"","sources":["../../src/attribution.ts"],"names":[],"mappings":";AACA,OAAO,EACL,YAAY,EACZ,WAAW,EACX,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,WAAW,EACX,aAAa,EACb,SAAS,EACT,YAAY,EACZ,KAAK,EACL,MAAM,GACP,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,MAAM,CAAC,IAAM,eAAe,GAAG,UAAC,MAAqB;IACnD,IAAM,YAAY,2CACb,CAAC,MAAM,CAAC,UAAU,IAAI,WAAW,EAAE,CAAC,GACpC,CAAC,MAAM,CAAC,eAAe,IAAI,WAAW,EAAE,CAAC,GACzC,CAAC,MAAM,CAAC,YAAY,IAAI,QAAQ,EAAE,CAAC,GACnC,CAAC,MAAM,CAAC,aAAa,IAAI,SAAS,EAAE,CAAC,CACzC,CAAC;IAEF,OAAO,YAAY,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AChD,IAAM,eAAe,GAAG,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,mCAAI,SAAS,CAAC;QAE7D,IAAI,QAAQ,KAAK,SAAS;YAAE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACrD,IAAI,eAAe,KAAK,SAAS;YAAE,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;KAC5E;IAAC,WAAM;QACN,EAAE;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,QAAQ,GAAG;;IACtB,IAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,oBACK,CAAC,MAAM,CAAC,KAAK,CAAC,cAAM,GAAC,KAAK,IAAG,MAAM,CAAC,KAAK,CAAC,KAAE,CAAC,EAChD;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,SAAS,GAAG;;IACvB,IAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,oBACK,CAAC,MAAM,CAAC,MAAM,CAAC,cAAM,GAAC,MAAM,IAAG,MAAM,CAAC,MAAM,CAAC,KAAE,CAAC,EACnD;AACJ,CAAC,CAAC","sourcesContent":["import { BrowserConfig, UTMData } from '@amplitude/analytics-types';\nimport {\n UTM_CAMPAIGN,\n UTM_CONTENT,\n UTM_MEDIUM,\n UTM_SOURCE,\n UTM_TERM,\n UTMZ_SOURCE,\n UTMZ_MEDIUM,\n UTMZ_CAMPAIGN,\n UTMZ_TERM,\n UTMZ_CONTENT,\n GCLID,\n FBCLID,\n} from './constants';\nimport { UTMCookie } from './storage/utm-cookie';\nimport { getQueryParams } from './utils/query-params';\n\nexport const getAttributions = (config: BrowserConfig): Record<string, string> => {\n const attributions = {\n ...(config.includeUtm && getUtmParam()),\n ...(config.includeReferrer && getReferrer()),\n ...(config.includeGclid && getGclid()),\n ...(config.includeFbclid && getFbclid()),\n };\n\n return attributions;\n};\n\nexport const getUtmParam = (): UTMData => {\n const params = getQueryParams();\n const utmStorage = new UTMCookie();\n const cookies = (utmStorage.isEnabled() && utmStorage.get('__utmz')) || {};\n\n const utmSource = params[UTM_SOURCE] || cookies[UTMZ_SOURCE];\n const utmMedium = params[UTM_MEDIUM] || cookies[UTMZ_MEDIUM];\n const utmCampaign = params[UTM_CAMPAIGN] || cookies[UTMZ_CAMPAIGN];\n const utmTerm = params[UTM_TERM] || cookies[UTMZ_TERM];\n const utmContent = params[UTM_CONTENT] || cookies[UTMZ_CONTENT];\n\n const data: UTMData = {};\n if (utmSource) data.utm_source = utmSource;\n if (utmMedium) data.utm_medium = utmMedium;\n if (utmCampaign) data.utm_campaign = utmCampaign;\n if (utmTerm) data.utm_term = utmTerm;\n if (utmContent) data.utm_content = utmContent;\n return data;\n};\n\nexport const getReferrer = () => {\n const data: Record<string, string | undefined> = {};\n try {\n const referrer = document.referrer || undefined;\n const referringDomain = referrer?.split('/')[2] ?? undefined;\n\n if (referrer !== undefined) data.referrer = referrer;\n if (referringDomain !== undefined) data.referring_domain = referringDomain;\n } catch {\n //\n }\n return data;\n};\n\nexport const getGclid = () => {\n const params = getQueryParams();\n return {\n ...(params[GCLID] && { [GCLID]: params[GCLID] }),\n };\n};\n\nexport const getFbclid = () => {\n const params = getQueryParams();\n return {\n ...(params[FBCLID] && { [FBCLID]: params[FBCLID] }),\n };\n};\n"]}
@@ -1,5 +1,20 @@
1
- import { Identify, Revenue } from '@amplitude/analytics-core';
2
- import { AmplitudeReturn, BrowserOptions, EventOptions, Plugin, Result, TransportType } from '@amplitude/analytics-types';
1
+ import { AmplitudeCore } from '@amplitude/analytics-core';
2
+ import { BrowserConfig, BrowserOptions, EventOptions, Identify as IIdentify, Result, Revenue as IRevenue, TransportType } from '@amplitude/analytics-types';
3
+ export declare class AmplitudeBrowser extends AmplitudeCore<BrowserConfig> {
4
+ init(apiKey: string, userId?: string, options?: BrowserOptions): Promise<void>;
5
+ getUserId(): string | undefined;
6
+ setUserId(userId: string): void;
7
+ getDeviceId(): string | undefined;
8
+ setDeviceId(deviceId: string): void;
9
+ getSessionId(): number | undefined;
10
+ setSessionId(sessionId: number): void;
11
+ setOptOut(optOut: boolean): void;
12
+ setTransport(transport: TransportType): void;
13
+ identify(identify: IIdentify, eventOptions?: EventOptions): Promise<Result>;
14
+ groupIdentify(groupType: string, groupName: string | string[], identify: IIdentify, eventOptions?: EventOptions): Promise<Result>;
15
+ revenue(revenue: IRevenue, eventOptions?: EventOptions): Promise<Result>;
16
+ trackAttributions(): Promise<Result> | undefined;
17
+ }
3
18
  /**
4
19
  * Initializes the Amplitude SDK with your apiKey, userId and optional configurations.
5
20
  * This method must be called before any other operations.
@@ -8,7 +23,7 @@ import { AmplitudeReturn, BrowserOptions, EventOptions, Plugin, Result, Transpor
8
23
  * await init(API_KEY, USER_ID, options).promise;
9
24
  * ```
10
25
  */
11
- export declare const init: (apiKey: string, userId?: string | undefined, options?: BrowserOptions | undefined) => AmplitudeReturn<void>;
26
+ export declare const init: (apiKey: string, userId?: string | undefined, options?: BrowserOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<void>;
12
27
  /**
13
28
  * Adds a new plugin.
14
29
  *
@@ -17,7 +32,7 @@ export declare const init: (apiKey: string, userId?: string | undefined, options
17
32
  * amplitude.add(plugin);
18
33
  * ```
19
34
  */
20
- export declare const add: (plugin: Plugin) => AmplitudeReturn<void>;
35
+ export declare const add: (plugin: import("@amplitude/analytics-types").Plugin) => import("@amplitude/analytics-types").AmplitudeReturn<void>;
21
36
  /**
22
37
  * Removes a plugin.
23
38
  *
@@ -25,7 +40,83 @@ export declare const add: (plugin: Plugin) => AmplitudeReturn<void>;
25
40
  * amplitude.remove('myPlugin');
26
41
  * ```
27
42
  */
28
- export declare const remove: (pluginName: string) => AmplitudeReturn<void>;
43
+ export declare const remove: (pluginName: string) => import("@amplitude/analytics-types").AmplitudeReturn<void>;
44
+ /**
45
+ * Tracks user-defined event, with specified type, optional event properties and optional overwrites.
46
+ *
47
+ * ```typescript
48
+ * // event tracking with event type only
49
+ * track('Page Load');
50
+ *
51
+ * // event tracking with event type and additional event properties
52
+ * track('Page Load', { loadTime: 1000 });
53
+ *
54
+ * // event tracking with event type, additional event properties, and overwritten event options
55
+ * track('Page Load', { loadTime: 1000 }, { sessionId: -1 });
56
+ *
57
+ * // alternatively, this tracking method is awaitable
58
+ * const result = await track('Page Load').promise;
59
+ * console.log(result.event); // {...}
60
+ * console.log(result.code); // 200
61
+ * console.log(result.message); // "Event tracked successfully"
62
+ * ```
63
+ */
64
+ export declare const track: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Result>;
65
+ /**
66
+ * Alias for track()
67
+ */
68
+ export declare const logEvent: (eventInput: string | import("@amplitude/analytics-types").BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Result>;
69
+ /**
70
+ * Sends an identify event containing user property operations
71
+ *
72
+ * ```typescript
73
+ * const id = new Identify();
74
+ * id.set('colors', ['rose', 'gold']);
75
+ * identify(id);
76
+ *
77
+ * // alternatively, this tracking method is awaitable
78
+ * const result = await identify(id).promise;
79
+ * console.log(result.event); // {...}
80
+ * console.log(result.code); // 200
81
+ * console.log(result.message); // "Event tracked successfully"
82
+ * ```
83
+ */
84
+ export declare const identify: (identify: IIdentify, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Result>;
85
+ /**
86
+ * Sends a group identify event containing group property operations.
87
+ *
88
+ * ```typescript
89
+ * const id = new Identify();
90
+ * id.set('skills', ['js', 'ts']);
91
+ * const groupType = 'org';
92
+ * const groupName = 'engineering';
93
+ * groupIdentify(groupType, groupName, id);
94
+ *
95
+ * // alternatively, this tracking method is awaitable
96
+ * const result = await groupIdentify(groupType, groupName, id).promise;
97
+ * console.log(result.event); // {...}
98
+ * console.log(result.code); // 200
99
+ * console.log(result.message); // "Event tracked successfully"
100
+ * ```
101
+ */
102
+ export declare const groupIdentify: (groupType: string, groupName: string | string[], identify: IIdentify, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Result>;
103
+ export declare const setGroup: (groupType: string, groupName: string | string[]) => import("@amplitude/analytics-types").AmplitudeReturn<Result>;
104
+ /**
105
+ * Sends a revenue event containing revenue property operations.
106
+ *
107
+ * ```typescript
108
+ * const rev = new Revenue();
109
+ * rev.setRevenue(100);
110
+ * revenue(rev);
111
+ *
112
+ * // alternatively, this tracking method is awaitable
113
+ * const result = await revenue(rev).promise;
114
+ * console.log(result.event); // {...}
115
+ * console.log(result.code); // 200
116
+ * console.log(result.message); // "Event tracked successfully"
117
+ * ```
118
+ */
119
+ export declare const revenue: (revenue: IRevenue, eventOptions?: EventOptions | undefined) => import("@amplitude/analytics-types").AmplitudeReturn<Result>;
29
120
  /**
30
121
  * Returns current user ID.
31
122
  *
@@ -104,80 +195,4 @@ export declare const setOptOut: (optOut: boolean) => void;
104
195
  * ```
105
196
  */
106
197
  export declare const setTransport: (transport: TransportType) => void;
107
- /**
108
- * Tracks user-defined event, with specified type, optional event properties and optional overwrites.
109
- *
110
- * ```typescript
111
- * // event tracking with event type only
112
- * track('Page Load');
113
- *
114
- * // event tracking with event type and additional event properties
115
- * track('Page Load', { loadTime: 1000 });
116
- *
117
- * // event tracking with event type, additional event properties, and overwritten event options
118
- * track('Page Load', { loadTime: 1000 }, { sessionId: -1 });
119
- *
120
- * // alternatively, this tracking method is awaitable
121
- * const result = await track('Page Load').promise;
122
- * console.log(result.event); // {...}
123
- * console.log(result.code); // 200
124
- * console.log(result.message); // "Event tracked successfully"
125
- * ```
126
- */
127
- export declare const track: (eventType: string, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined) => AmplitudeReturn<Result>;
128
- /**
129
- * Alis for track()
130
- */
131
- export declare const logEvent: (eventType: string, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined) => AmplitudeReturn<Result>;
132
- /**
133
- * Sends an identify event containing user property operations
134
- *
135
- * ```typescript
136
- * const id = new Identify();
137
- * id.set('colors', ['rose', 'gold']);
138
- * identify(id);
139
- *
140
- * // alternatively, this tracking method is awaitable
141
- * const result = await identify(id).promise;
142
- * console.log(result.event); // {...}
143
- * console.log(result.code); // 200
144
- * console.log(result.message); // "Event tracked successfully"
145
- * ```
146
- */
147
- export declare const identify: (identify: Identify, eventOptions?: EventOptions | undefined) => AmplitudeReturn<Result>;
148
- /**
149
- * Sends a group identify event containing group property operations.
150
- *
151
- * ```typescript
152
- * const id = new Identify();
153
- * id.set('skills', ['js', 'ts']);
154
- * const groupType = 'org';
155
- * const groupName = 'engineering';
156
- * groupIdentify(groupType, groupName, id);
157
- *
158
- * // alternatively, this tracking method is awaitable
159
- * const result = await groupIdentify(groupType, groupName, id).promise;
160
- * console.log(result.event); // {...}
161
- * console.log(result.code); // 200
162
- * console.log(result.message); // "Event tracked successfully"
163
- * ```
164
- */
165
- export declare const groupIdentify: (groupType: string, groupName: string | string[], identify: Identify, eventOptions?: EventOptions | undefined) => AmplitudeReturn<Result>;
166
- export declare const setGroup: (groupType: string, groupName: string | string[]) => AmplitudeReturn<Result>;
167
- /**
168
- * Sends a revenue event containing revenue property operations.
169
- *
170
- * ```typescript
171
- * const rev = new Revenue();
172
- * rev.setRevenue(100);
173
- * revenue(rev);
174
- *
175
- * // alternatively, this tracking method is awaitable
176
- * const result = await revenue(rev).promise;
177
- * console.log(result.event); // {...}
178
- * console.log(result.code); // 200
179
- * console.log(result.message); // "Event tracked successfully"
180
- * ```
181
- */
182
- export declare const revenue: (revenue: Revenue, eventOptions?: EventOptions | undefined) => AmplitudeReturn<Result>;
183
198
  //# sourceMappingURL=browser-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser-client.d.ts","sourceRoot":"","sources":["../../src/browser-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,QAAQ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