@amplitude/analytics-core 2.9.0 → 2.10.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 (37) hide show
  1. package/lib/cjs/core-client.d.ts +36 -4
  2. package/lib/cjs/core-client.d.ts.map +1 -1
  3. package/lib/cjs/core-client.js +89 -2
  4. package/lib/cjs/core-client.js.map +1 -1
  5. package/lib/cjs/identify.d.ts +4 -0
  6. package/lib/cjs/identify.d.ts.map +1 -1
  7. package/lib/cjs/identify.js +16 -1
  8. package/lib/cjs/identify.js.map +1 -1
  9. package/lib/cjs/timeline.d.ts +4 -1
  10. package/lib/cjs/timeline.d.ts.map +1 -1
  11. package/lib/cjs/timeline.js +30 -0
  12. package/lib/cjs/timeline.js.map +1 -1
  13. package/lib/cjs/types/event/event.d.ts +33 -0
  14. package/lib/cjs/types/event/event.d.ts.map +1 -1
  15. package/lib/cjs/types/event/event.js.map +1 -1
  16. package/lib/cjs/types/plugin.d.ts +22 -0
  17. package/lib/cjs/types/plugin.d.ts.map +1 -1
  18. package/lib/cjs/types/plugin.js.map +1 -1
  19. package/lib/esm/core-client.d.ts +36 -4
  20. package/lib/esm/core-client.d.ts.map +1 -1
  21. package/lib/esm/core-client.js +89 -2
  22. package/lib/esm/core-client.js.map +1 -1
  23. package/lib/esm/identify.d.ts +4 -0
  24. package/lib/esm/identify.d.ts.map +1 -1
  25. package/lib/esm/identify.js +15 -0
  26. package/lib/esm/identify.js.map +1 -1
  27. package/lib/esm/timeline.d.ts +4 -1
  28. package/lib/esm/timeline.d.ts.map +1 -1
  29. package/lib/esm/timeline.js +30 -0
  30. package/lib/esm/timeline.js.map +1 -1
  31. package/lib/esm/types/event/event.d.ts +33 -0
  32. package/lib/esm/types/event/event.d.ts.map +1 -1
  33. package/lib/esm/types/event/event.js.map +1 -1
  34. package/lib/esm/types/plugin.d.ts +22 -0
  35. package/lib/esm/types/plugin.d.ts.map +1 -1
  36. package/lib/esm/types/plugin.js.map +1 -1
  37. package/package.json +2 -2
@@ -6,11 +6,33 @@ type PluginTypeBefore = 'before';
6
6
  type PluginTypeEnrichment = 'enrichment';
7
7
  type PluginTypeDestination = 'destination';
8
8
  export type PluginType = PluginTypeBefore | PluginTypeEnrichment | PluginTypeDestination;
9
+ export interface AnalyticsIdentity {
10
+ deviceId?: string;
11
+ userId?: string;
12
+ userProperties?: {
13
+ [key: string]: any;
14
+ };
15
+ }
9
16
  interface PluginBase<T = CoreClient, U = IConfig> {
10
17
  name?: string;
11
18
  type?: PluginType;
12
19
  setup?(config: U, client: T): Promise<void>;
13
20
  teardown?(): Promise<void>;
21
+ /**
22
+ * Called when the identity is changed. This is a **best-effort** API and may not be triggered in all scenarios.
23
+ *
24
+ * Currently supported only in the Browser SDK. Not supported in React Native or Node SDKs.
25
+ *
26
+ * @param identity The changed identity. If a field is missing, it means it has not changed.
27
+ * For example, `{ userId: undefined }` means the userId was explicitly changed to `undefined`,
28
+ * while deviceId and userProperties remain unchanged.
29
+ *
30
+ * Note: `onIdentityChanged()` will be triggered when a user logs in via `setUserId()`.
31
+ * It will not be triggered on subsequent page loads (e.g., when a user reopens the site in a new tab).
32
+ */
33
+ onIdentityChanged?(identity: AnalyticsIdentity): Promise<void>;
34
+ onSessionIdChanged?(sessionId: number): Promise<void>;
35
+ onOptOutChanged?(optOut: boolean): Promise<void>;
14
36
  }
15
37
  export interface BeforePlugin<T = CoreClient, U = IConfig> extends PluginBase<T, U> {
16
38
  type: PluginTypeBefore;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/types/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,KAAK,gBAAgB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AAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/types/plugin.ts"],"names":[],"mappings":"","sourcesContent":["import { Event } from './event/event';\nimport { IConfig } from '../config';\nimport { Result } from './result';\nimport { CoreClient } from '../core-client';\n\ntype PluginTypeBefore = 'before';\ntype PluginTypeEnrichment = 'enrichment';\ntype PluginTypeDestination = 'destination';\nexport type PluginType = PluginTypeBefore | PluginTypeEnrichment | PluginTypeDestination;\n\ninterface PluginBase<T = CoreClient, U = IConfig> {\n name?: string;\n type?: PluginType;\n setup?(config: U, client: T): Promise<void>;\n teardown?(): Promise<void>;\n}\n\nexport interface BeforePlugin<T = CoreClient, U = IConfig> extends PluginBase<T, U> {\n type: PluginTypeBefore;\n execute?(context: Event): Promise<Event | null>;\n}\n\nexport interface EnrichmentPlugin<T = CoreClient, U = IConfig> extends PluginBase<T, U> {\n type?: PluginTypeEnrichment;\n execute?(context: Event): Promise<Event | null>;\n}\n\nexport interface DestinationPlugin<T = CoreClient, U = IConfig> extends PluginBase<T, U> {\n type: PluginTypeDestination;\n execute(context: Event): Promise<Result>;\n flush?(): Promise<void>;\n}\n\nexport type Plugin<T = CoreClient, U = IConfig> = BeforePlugin<T, U> | EnrichmentPlugin<T, U> | DestinationPlugin<T, U>;\n"]}
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/types/plugin.ts"],"names":[],"mappings":"","sourcesContent":["import { Event } from './event/event';\nimport { IConfig } from '../config';\nimport { Result } from './result';\nimport { CoreClient } from '../core-client';\n\ntype PluginTypeBefore = 'before';\ntype PluginTypeEnrichment = 'enrichment';\ntype PluginTypeDestination = 'destination';\nexport type PluginType = PluginTypeBefore | PluginTypeEnrichment | PluginTypeDestination;\n\nexport interface AnalyticsIdentity {\n deviceId?: string;\n userId?: string;\n userProperties?: { [key: string]: any };\n}\n\ninterface PluginBase<T = CoreClient, U = IConfig> {\n name?: string;\n type?: PluginType;\n setup?(config: U, client: T): Promise<void>;\n teardown?(): Promise<void>;\n /**\n * Called when the identity is changed. This is a **best-effort** API and may not be triggered in all scenarios.\n *\n * Currently supported only in the Browser SDK. Not supported in React Native or Node SDKs.\n *\n * @param identity The changed identity. If a field is missing, it means it has not changed.\n * For example, `{ userId: undefined }` means the userId was explicitly changed to `undefined`,\n * while deviceId and userProperties remain unchanged.\n *\n * Note: `onIdentityChanged()` will be triggered when a user logs in via `setUserId()`.\n * It will not be triggered on subsequent page loads (e.g., when a user reopens the site in a new tab).\n */\n onIdentityChanged?(identity: AnalyticsIdentity): Promise<void>;\n onSessionIdChanged?(sessionId: number): Promise<void>;\n onOptOutChanged?(optOut: boolean): Promise<void>;\n}\n\nexport interface BeforePlugin<T = CoreClient, U = IConfig> extends PluginBase<T, U> {\n type: PluginTypeBefore;\n execute?(context: Event): Promise<Event | null>;\n}\n\nexport interface EnrichmentPlugin<T = CoreClient, U = IConfig> extends PluginBase<T, U> {\n type?: PluginTypeEnrichment;\n execute?(context: Event): Promise<Event | null>;\n}\n\nexport interface DestinationPlugin<T = CoreClient, U = IConfig> extends PluginBase<T, U> {\n type: PluginTypeDestination;\n execute(context: Event): Promise<Result>;\n flush?(): Promise<void>;\n}\n\nexport type Plugin<T = CoreClient, U = IConfig> = BeforePlugin<T, U> | EnrichmentPlugin<T, U> | DestinationPlugin<T, U>;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amplitude/analytics-core",
3
- "version": "2.9.0",
3
+ "version": "2.10.0",
4
4
  "description": "",
5
5
  "author": "Amplitude Inc",
6
6
  "homepage": "https://github.com/amplitude/Amplitude-TypeScript",
@@ -40,5 +40,5 @@
40
40
  "files": [
41
41
  "lib"
42
42
  ],
43
- "gitHead": "bed8f4e611b944dab30a9aea4e48022655b0ddb0"
43
+ "gitHead": "a927cc91ccf2b58b71ed800ff269b1d1e80b071f"
44
44
  }