@amplitude/analytics-react-native 1.11.0-video-analytics-5.0 → 1.11.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.
- package/lib/commonjs/amp-capture.js +10 -1
- package/lib/commonjs/amp-capture.js.map +1 -1
- package/lib/commonjs/autocapture/element-interaction.js +22 -0
- package/lib/commonjs/autocapture/element-interaction.js.map +1 -0
- package/lib/commonjs/autocapture/rage-click.js +141 -0
- package/lib/commonjs/autocapture/rage-click.js.map +1 -0
- package/lib/commonjs/config/joined-config.js +1 -0
- package/lib/commonjs/config/joined-config.js.map +1 -1
- package/lib/commonjs/constants.js +2 -1
- package/lib/commonjs/constants.js.map +1 -1
- package/lib/commonjs/plugins/frustration-plugin.js +67 -0
- package/lib/commonjs/plugins/frustration-plugin.js.map +1 -0
- package/lib/commonjs/react-native-client.js +27 -23
- package/lib/commonjs/react-native-client.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/amp-capture.js +10 -1
- package/lib/module/amp-capture.js.map +1 -1
- package/lib/module/autocapture/element-interaction.js +17 -0
- package/lib/module/autocapture/element-interaction.js.map +1 -0
- package/lib/module/autocapture/rage-click.js +133 -0
- package/lib/module/autocapture/rage-click.js.map +1 -0
- package/lib/module/config/joined-config.js +1 -0
- package/lib/module/config/joined-config.js.map +1 -1
- package/lib/module/constants.js +1 -0
- package/lib/module/constants.js.map +1 -1
- package/lib/module/plugins/frustration-plugin.js +59 -0
- package/lib/module/plugins/frustration-plugin.js.map +1 -0
- package/lib/module/react-native-client.js +28 -24
- package/lib/module/react-native-client.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/amp-capture.d.ts +7 -1
- package/lib/typescript/amp-capture.d.ts.map +1 -1
- package/lib/typescript/autocapture/element-interaction.d.ts +7 -0
- package/lib/typescript/autocapture/element-interaction.d.ts.map +1 -0
- package/lib/typescript/autocapture/rage-click.d.ts +30 -0
- package/lib/typescript/autocapture/rage-click.d.ts.map +1 -0
- package/lib/typescript/config/joined-config.d.ts.map +1 -1
- package/lib/typescript/constants.d.ts +1 -0
- package/lib/typescript/constants.d.ts.map +1 -1
- package/lib/typescript/plugins/frustration-plugin.d.ts +17 -0
- package/lib/typescript/plugins/frustration-plugin.d.ts.map +1 -0
- package/lib/typescript/react-native-client.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/lib/typescript/version.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/amp-capture.ts +13 -3
- package/src/autocapture/element-interaction.ts +27 -0
- package/src/autocapture/rage-click.ts +172 -0
- package/src/config/joined-config.ts +1 -0
- package/src/constants.ts +1 -0
- package/src/plugins/frustration-plugin.ts +80 -0
- package/src/react-native-client.ts +19 -14
- package/src/version.ts +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EnrichmentPlugin,
|
|
3
|
+
ReactNativeClient,
|
|
4
|
+
ReactNativeConfig,
|
|
5
|
+
ReactNativeFrustrationInteractionsOptions,
|
|
6
|
+
} from '@amplitude/analytics-core';
|
|
7
|
+
import * as Capture from '../amp-capture';
|
|
8
|
+
import { getElementInteractionEventProperties } from '../autocapture/element-interaction';
|
|
9
|
+
import { createRageClickTracker, getRageClickEventProperties, getRageClickStartTime } from '../autocapture/rage-click';
|
|
10
|
+
import { DEFAULT_ELEMENT_RAGE_CLICKED_EVENT } from '../constants';
|
|
11
|
+
|
|
12
|
+
export const FRUSTRATION_PLUGIN_NAME = '@amplitude/plugin-frustration-react-native';
|
|
13
|
+
|
|
14
|
+
type ReactNativeEnrichmentPlugin = EnrichmentPlugin<ReactNativeClient, ReactNativeConfig>;
|
|
15
|
+
|
|
16
|
+
export interface FrustrationPluginOptions extends ReactNativeFrustrationInteractionsOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Returns the name of the screen currently being viewed so it can be attached to
|
|
19
|
+
* frustration events as `[Amplitude] Screen Name`.
|
|
20
|
+
*/
|
|
21
|
+
getScreenName?: () => string | undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Tracks frustration interactions (currently `[Amplitude] Rage Click`) from presses
|
|
26
|
+
* captured through `ampCapture`.
|
|
27
|
+
*/
|
|
28
|
+
export const frustrationPlugin = (options: FrustrationPluginOptions = {}): ReactNativeEnrichmentPlugin => {
|
|
29
|
+
const name = FRUSTRATION_PLUGIN_NAME;
|
|
30
|
+
const type = 'enrichment';
|
|
31
|
+
|
|
32
|
+
const rageClicksEnabled = options.rageClick !== false;
|
|
33
|
+
|
|
34
|
+
let subscriptions: (() => void)[] = [];
|
|
35
|
+
|
|
36
|
+
const setup: ReactNativeEnrichmentPlugin['setup'] = async (config, amplitude) => {
|
|
37
|
+
if (rageClicksEnabled) {
|
|
38
|
+
const rageClickTracker = createRageClickTracker((clickData) => {
|
|
39
|
+
const time = getRageClickStartTime(clickData);
|
|
40
|
+
const eventProperties = getRageClickEventProperties(clickData);
|
|
41
|
+
amplitude.track(DEFAULT_ELEMENT_RAGE_CLICKED_EVENT, eventProperties, { time });
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
let unregisterRageClickEvent: (() => void) | undefined;
|
|
45
|
+
const captureUnsubscribe = Capture.subscribe((properties, coordinates) => {
|
|
46
|
+
if (properties.action !== 'Press' || !coordinates) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
unregisterRageClickEvent = rageClickTracker.registerClickEvent(
|
|
50
|
+
coordinates,
|
|
51
|
+
getElementInteractionEventProperties(properties, options.getScreenName?.()),
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
subscriptions.push(captureUnsubscribe, () => unregisterRageClickEvent?.());
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* istanbul ignore next */
|
|
59
|
+
config?.loggerProvider?.log(`${name} has been successfully added.`);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const execute: ReactNativeEnrichmentPlugin['execute'] = async (event) => {
|
|
63
|
+
return event;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const teardown = async () => {
|
|
67
|
+
for (const unsubscribe of subscriptions) {
|
|
68
|
+
unsubscribe();
|
|
69
|
+
}
|
|
70
|
+
subscriptions = [];
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
name,
|
|
75
|
+
type,
|
|
76
|
+
setup,
|
|
77
|
+
execute,
|
|
78
|
+
teardown,
|
|
79
|
+
};
|
|
80
|
+
};
|
|
@@ -41,6 +41,7 @@ import { plugin as networkCapturePlugin } from '@amplitude/plugin-network-captur
|
|
|
41
41
|
import { CampaignTracker } from './campaign/campaign-tracker';
|
|
42
42
|
import { Context } from './plugins/context';
|
|
43
43
|
import { networkConnectivityCheckerPlugin } from './plugins/network-connectivity-checker';
|
|
44
|
+
import { frustrationPlugin } from './plugins/frustration-plugin';
|
|
44
45
|
import { ReactNativeDiagnosticsStorage } from './diagnostics/diagnostics-storage';
|
|
45
46
|
import { LIBPREFIX } from './lib-prefix';
|
|
46
47
|
import { VERSION } from './version';
|
|
@@ -50,6 +51,7 @@ import { parseOldCookies } from './cookie-migration';
|
|
|
50
51
|
import { isNative } from './utils/platform';
|
|
51
52
|
import { RemoteConfigCustomStorage } from './remote-config/remote-config-customstorage';
|
|
52
53
|
import * as Capture from './amp-capture';
|
|
54
|
+
import { getElementInteractionEventProperties } from './autocapture/element-interaction';
|
|
53
55
|
import {
|
|
54
56
|
APP_BUILD,
|
|
55
57
|
APP_VERSION,
|
|
@@ -64,11 +66,6 @@ import {
|
|
|
64
66
|
PREVIOUS_BUILD,
|
|
65
67
|
PREVIOUS_VERSION,
|
|
66
68
|
SCREEN_NAME,
|
|
67
|
-
TARGET_ACCESSIBILITY_LABEL,
|
|
68
|
-
TARGET_ACTION,
|
|
69
|
-
TARGET_COMPONENT,
|
|
70
|
-
TARGET_ELEMENT,
|
|
71
|
-
TARGET_TEST_ID,
|
|
72
69
|
} from './constants';
|
|
73
70
|
|
|
74
71
|
/**
|
|
@@ -300,6 +297,7 @@ export class AmplitudeReactNative extends AmplitudeCore implements ReactNativeCl
|
|
|
300
297
|
screenViews: true,
|
|
301
298
|
elementInteractions: true,
|
|
302
299
|
networkTracking: true,
|
|
300
|
+
frustrationInteractions: true,
|
|
303
301
|
};
|
|
304
302
|
} else if (autocaptureConfig && typeof autocaptureConfig === 'object') {
|
|
305
303
|
this.autocapture = autocaptureConfig;
|
|
@@ -342,17 +340,23 @@ export class AmplitudeReactNative extends AmplitudeCore implements ReactNativeCl
|
|
|
342
340
|
await this.add(networkCapturePlugin(getNetworkTrackingConfig(this.config))).promise;
|
|
343
341
|
}
|
|
344
342
|
|
|
343
|
+
const frustrationInteractions = this.autocapture?.frustrationInteractions;
|
|
344
|
+
if (frustrationInteractions) {
|
|
345
|
+
this.config.loggerProvider.debug('Adding frustration interactions plugin');
|
|
346
|
+
await this.add(
|
|
347
|
+
frustrationPlugin({
|
|
348
|
+
...(typeof frustrationInteractions === 'object' ? frustrationInteractions : {}),
|
|
349
|
+
getScreenName: () => this.currentScreenName,
|
|
350
|
+
}),
|
|
351
|
+
).promise;
|
|
352
|
+
}
|
|
353
|
+
|
|
345
354
|
if (this.autocapture?.elementInteractions === true) {
|
|
346
355
|
this.captureUnsubscribe = Capture.subscribe((properties) => {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
[TARGET_COMPONENT]: properties.component,
|
|
352
|
-
[TARGET_ELEMENT]: properties.element,
|
|
353
|
-
[TARGET_TEST_ID]: properties.testID,
|
|
354
|
-
};
|
|
355
|
-
this.track(DEFAULT_ELEMENT_INTERACTED_EVENT, analyticsProps);
|
|
356
|
+
this.track(
|
|
357
|
+
DEFAULT_ELEMENT_INTERACTED_EVENT,
|
|
358
|
+
getElementInteractionEventProperties(properties, this.currentScreenName),
|
|
359
|
+
);
|
|
356
360
|
});
|
|
357
361
|
}
|
|
358
362
|
|
|
@@ -396,6 +400,7 @@ export class AmplitudeReactNative extends AmplitudeCore implements ReactNativeCl
|
|
|
396
400
|
shutdown() {
|
|
397
401
|
this.appStateChangeHandler?.remove();
|
|
398
402
|
this.captureUnsubscribe?.();
|
|
403
|
+
this.timeline.reset(this);
|
|
399
404
|
}
|
|
400
405
|
|
|
401
406
|
async runAttributionStrategy(attributionConfig?: AttributionOptions, isNewSession = false) {
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '1.11.0
|
|
1
|
+
export const VERSION = '1.11.0';
|