react-native-test-adx 0.1.19 → 0.1.20
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/module/AdaxonSdk.js +3 -2
- package/lib/module/sdkVersion.js +1 -1
- package/lib/module/services/logging/AdaxonLogger.js +29 -2
- package/lib/typescript/src/sdkVersion.d.ts +1 -1
- package/lib/typescript/src/services/logging/AdaxonLogger.d.ts +9 -0
- package/lib/typescript/src/types/AdaxonConfig.d.ts +7 -2
- package/package.json +1 -1
package/lib/module/AdaxonSdk.js
CHANGED
|
@@ -7,7 +7,7 @@ import { AdaxonSdkError } from "./errors/AdaxonSdkError.js";
|
|
|
7
7
|
import { detectReactNativePlatform, reactNativeAppInfoReader, reactNativeDeviceReader, reactNativeNetworkInfoReader, reactNativeNetworkStatusReader, reactNativeUrlOpener } from "./platform/reactNative.js";
|
|
8
8
|
import { buildAddToCartProperties, buildPurchaseProperties, normalizeEventValues } from "./services/event/normalizeProperties.js";
|
|
9
9
|
import { AdxEvent } from "./services/event/predefined.js";
|
|
10
|
-
import { AdaxonLogger, logSdkActivity } from "./services/logging/AdaxonLogger.js";
|
|
10
|
+
import { AdaxonLogger, logSdkActivity, resolveAllowRemoteActivityLogging } from "./services/logging/AdaxonLogger.js";
|
|
11
11
|
function openableOfferUrl(url) {
|
|
12
12
|
return url.replace(/[{}]/g, brace => brace === '{' ? '%7B' : '%7D');
|
|
13
13
|
}
|
|
@@ -24,7 +24,8 @@ export class AdaxonSdk {
|
|
|
24
24
|
enabled: Boolean(configuration.activityLogging),
|
|
25
25
|
dsn: configuration.sentryDsn,
|
|
26
26
|
platform,
|
|
27
|
-
testMode: Boolean(configuration.testMode)
|
|
27
|
+
testMode: Boolean(configuration.testMode),
|
|
28
|
+
allowRemoteLogging: resolveAllowRemoteActivityLogging(configuration)
|
|
28
29
|
});
|
|
29
30
|
logSdkActivity({
|
|
30
31
|
eventName: 'sdk.initialize.started',
|
package/lib/module/sdkVersion.js
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
import { SDK_VERSION } from "../../sdkVersion.js";
|
|
4
4
|
import { AdaxonSdkError } from "../../errors/AdaxonSdkError.js";
|
|
5
5
|
import { sanitizeLogMetadata } from "./sanitizeLogMetadata.js";
|
|
6
|
+
/** Remote Sentry uploads (dev/test only unless host explicitly allows). */
|
|
7
|
+
export function resolveAllowRemoteActivityLogging(input) {
|
|
8
|
+
if (!input.activityLogging) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (input.allowRemoteActivityLogging === false) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if (!input.sentryDsn?.trim()) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (input.allowRemoteActivityLogging === true) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return Boolean(input.testMode) || isDevBuild();
|
|
21
|
+
}
|
|
6
22
|
const DEFAULT_LEVEL = 'info';
|
|
7
23
|
|
|
8
24
|
/** Milestones + native dev warn/error → Sentry Message when Logs are off. */
|
|
@@ -137,19 +153,24 @@ class AdaxonLoggerService {
|
|
|
137
153
|
platform = 'web';
|
|
138
154
|
sentryReady = false;
|
|
139
155
|
ownsSentryClient = false;
|
|
156
|
+
remoteLoggingEnabled = false;
|
|
140
157
|
configure(input) {
|
|
141
158
|
this.enabled = Boolean(input.enabled);
|
|
142
159
|
this.platform = input.platform;
|
|
143
160
|
this.sentryReady = false;
|
|
161
|
+
this.remoteLoggingEnabled = Boolean(input.allowRemoteLogging);
|
|
144
162
|
if (!this.enabled) {
|
|
145
163
|
return;
|
|
146
164
|
}
|
|
147
|
-
|
|
148
|
-
|
|
165
|
+
if (this.remoteLoggingEnabled) {
|
|
166
|
+
warnSentryUnavailableOnce(Boolean(input.dsn?.trim()));
|
|
167
|
+
this.ensureSentry(input.dsn, Boolean(input.testMode));
|
|
168
|
+
}
|
|
149
169
|
}
|
|
150
170
|
reset() {
|
|
151
171
|
this.enabled = false;
|
|
152
172
|
this.sentryReady = false;
|
|
173
|
+
this.remoteLoggingEnabled = false;
|
|
153
174
|
this.platform = 'web';
|
|
154
175
|
this.ownsSentryClient = false;
|
|
155
176
|
cachedSentryModule = undefined;
|
|
@@ -167,6 +188,9 @@ class AdaxonLoggerService {
|
|
|
167
188
|
timestamp: new Date().toISOString()
|
|
168
189
|
};
|
|
169
190
|
mirrorToDevConsole(level, input.eventName, sanitizeLogMetadata(baseMetadata));
|
|
191
|
+
if (!this.remoteLoggingEnabled) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
170
194
|
const sentryAttributes = sanitizeLogMetadata({
|
|
171
195
|
...baseMetadata,
|
|
172
196
|
event_name: input.eventName
|
|
@@ -238,6 +262,9 @@ class AdaxonLoggerService {
|
|
|
238
262
|
});
|
|
239
263
|
this.ownsSentryClient = true;
|
|
240
264
|
}
|
|
265
|
+
if (!this.ownsSentryClient) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
241
268
|
for (const [key, value] of [['adaxon_sdk_version', SDK_VERSION], ['adaxon_platform', this.platform]]) {
|
|
242
269
|
sentry.setTag(key, value);
|
|
243
270
|
}
|
|
@@ -13,12 +13,21 @@ export type AdaxonLoggerConfigureInput = {
|
|
|
13
13
|
dsn?: string;
|
|
14
14
|
platform: AdaxonPlatform;
|
|
15
15
|
testMode?: boolean;
|
|
16
|
+
allowRemoteLogging?: boolean;
|
|
16
17
|
};
|
|
18
|
+
/** Remote Sentry uploads (dev/test only unless host explicitly allows). */
|
|
19
|
+
export declare function resolveAllowRemoteActivityLogging(input: {
|
|
20
|
+
activityLogging?: boolean;
|
|
21
|
+
sentryDsn?: string;
|
|
22
|
+
testMode?: boolean;
|
|
23
|
+
allowRemoteActivityLogging?: boolean;
|
|
24
|
+
}): boolean;
|
|
17
25
|
declare class AdaxonLoggerService {
|
|
18
26
|
private enabled;
|
|
19
27
|
private platform;
|
|
20
28
|
private sentryReady;
|
|
21
29
|
private ownsSentryClient;
|
|
30
|
+
private remoteLoggingEnabled;
|
|
22
31
|
configure(input: AdaxonLoggerConfigureInput): void;
|
|
23
32
|
reset(): void;
|
|
24
33
|
logActivity(input: AdaxonActivityLogInput): void;
|
|
@@ -10,10 +10,15 @@ export interface AdaxonSdkConfig {
|
|
|
10
10
|
timeoutMs?: number;
|
|
11
11
|
fetch?: typeof globalThis.fetch;
|
|
12
12
|
testMode?: boolean;
|
|
13
|
-
/** When true,
|
|
13
|
+
/** When true, emits activity diagnostics (local dev console when __DEV__). Default false. */
|
|
14
14
|
activityLogging?: boolean;
|
|
15
|
-
/** Sentry DSN
|
|
15
|
+
/** Sentry DSN for remote activity logging (ignored when allowRemoteActivityLogging is false). */
|
|
16
16
|
sentryDsn?: string;
|
|
17
|
+
/**
|
|
18
|
+
* When true, activity is sent to Sentry (dev/test). When false, Sentry is never initialized.
|
|
19
|
+
* Host apps should set false in production even if activityLogging is on by mistake.
|
|
20
|
+
*/
|
|
21
|
+
allowRemoteActivityLogging?: boolean;
|
|
17
22
|
}
|
|
18
23
|
export type AdaxonInitializationConfiguration = AdaxonSdkConfig;
|
|
19
24
|
export type AdaxonInitializationErrorCode = 'INVALID_CONFIG' | 'UNKNOWN';
|
package/package.json
CHANGED